playbook_ui 17.2.0.pre.rc.2 → 18.0.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 (129) hide show
  1. checksums.yaml +4 -4
  2. data/app/pb_kits/playbook/pb_advanced_table/kit.schema.json +8 -2
  3. data/app/pb_kits/playbook/pb_background/kit.schema.json +16 -4
  4. data/app/pb_kits/playbook/pb_card/kit.schema.json +4 -1
  5. data/app/pb_kits/playbook/pb_date_picker/docs/_date_picker_time.jsx +14 -18
  6. data/app/pb_kits/playbook/pb_date_picker/docs/_date_picker_time.md +3 -1
  7. data/app/pb_kits/playbook/pb_date_picker/kit.schema.json +4 -1
  8. data/app/pb_kits/playbook/pb_dropdown/kit.schema.json +8 -2
  9. data/app/pb_kits/playbook/pb_file_upload/kit.schema.json +4 -1
  10. data/app/pb_kits/playbook/pb_filter/kit.schema.json +4 -1
  11. data/app/pb_kits/playbook/pb_home_address_street/kit.schema.json +4 -1
  12. data/app/pb_kits/playbook/pb_icon/kit.schema.json +8 -2
  13. data/app/pb_kits/playbook/pb_layout/docs/_playground.json +1 -4
  14. data/app/pb_kits/playbook/pb_message/kit.schema.json +4 -1
  15. data/app/pb_kits/playbook/pb_multi_level_select/_multi_level_select.tsx +31 -1
  16. data/app/pb_kits/playbook/pb_multi_level_select/docs/_multi_level_select_format_selected_display.jsx +191 -0
  17. data/app/pb_kits/playbook/pb_multi_level_select/docs/_multi_level_select_format_selected_display.md +1 -0
  18. data/app/pb_kits/playbook/pb_multi_level_select/docs/_playground.json +31 -2
  19. data/app/pb_kits/playbook/pb_multi_level_select/docs/_playground.overrides.json +31 -2
  20. data/app/pb_kits/playbook/pb_multi_level_select/docs/example.yml +1 -0
  21. data/app/pb_kits/playbook/pb_multi_level_select/docs/index.js +1 -0
  22. data/app/pb_kits/playbook/pb_multi_level_select/kit.schema.json +14 -2
  23. data/app/pb_kits/playbook/pb_multi_level_select/multi_level_select.test.jsx +39 -1
  24. data/app/pb_kits/playbook/pb_overlay/kit.schema.json +4 -1
  25. data/app/pb_kits/playbook/pb_pagination/pagination.html.erb +1 -1
  26. data/app/pb_kits/playbook/pb_progress_step/kit.schema.json +8 -2
  27. data/app/pb_kits/playbook/pb_radio/kit.schema.json +4 -1
  28. data/app/pb_kits/playbook/pb_rich_text_editor/TipTap/ToolbarDropdown.tsx +9 -2
  29. data/app/pb_kits/playbook/pb_rich_text_editor/TipTap/listSelection.ts +59 -0
  30. data/app/pb_kits/playbook/pb_rich_text_editor/TipTap/markdownPaste.ts +100 -0
  31. data/app/pb_kits/playbook/pb_rich_text_editor/_rich_text_editor.tsx +31 -0
  32. data/app/pb_kits/playbook/pb_rich_text_editor/docs/_playground.json +5 -1
  33. data/app/pb_kits/playbook/pb_rich_text_editor/docs/_playground.overrides.json +4 -1
  34. data/app/pb_kits/playbook/pb_rich_text_editor/docs/_rich_text_editor_advanced_markdown_support.jsx +31 -0
  35. data/app/pb_kits/playbook/pb_rich_text_editor/docs/_rich_text_editor_advanced_markdown_support.md +5 -0
  36. data/app/pb_kits/playbook/pb_rich_text_editor/docs/_rich_text_editor_rails_markdown_support.html.erb +9 -0
  37. data/app/pb_kits/playbook/pb_rich_text_editor/docs/_rich_text_editor_rails_markdown_support.md +5 -0
  38. data/app/pb_kits/playbook/pb_rich_text_editor/docs/example.yml +2 -2
  39. data/app/pb_kits/playbook/pb_rich_text_editor/docs/index.js +1 -0
  40. data/app/pb_kits/playbook/pb_rich_text_editor/kit.schema.json +11 -0
  41. data/app/pb_kits/playbook/pb_rich_text_editor/rich_text_editor.html.erb +2 -2
  42. data/app/pb_kits/playbook/pb_rich_text_editor/rich_text_editor.rb +1 -0
  43. data/app/pb_kits/playbook/pb_rich_text_editor/rich_text_editor_advanced.test.js +241 -1
  44. data/app/pb_kits/playbook/pb_rich_text_editor/rich_text_editor_rails.js +109 -0
  45. data/app/pb_kits/playbook/pb_selectable_card_icon/kit.schema.json +4 -1
  46. data/app/pb_kits/playbook/pb_selectable_icon/kit.schema.json +4 -1
  47. data/app/pb_kits/playbook/pb_skeleton_loading/kit.schema.json +8 -2
  48. data/app/pb_kits/playbook/pb_source/kit.schema.json +4 -1
  49. data/app/pb_kits/playbook/pb_stat_change/kit.schema.json +4 -1
  50. data/app/pb_kits/playbook/pb_stat_value/kit.schema.json +4 -1
  51. data/app/pb_kits/playbook/pb_table/_table.tsx +9 -0
  52. data/app/pb_kits/playbook/pb_table/docs/_playground.json +29 -1
  53. data/app/pb_kits/playbook/pb_table/docs/_playground.overrides.json +23 -0
  54. data/app/pb_kits/playbook/pb_table/docs/_sections.yml +2 -1
  55. data/app/pb_kits/playbook/pb_table/docs/_table_action_middle.html.erb +38 -32
  56. data/app/pb_kits/playbook/pb_table/docs/_table_action_middle.jsx +35 -35
  57. data/app/pb_kits/playbook/pb_table/docs/_table_as_wrapper.html.erb +34 -0
  58. data/app/pb_kits/playbook/pb_table/docs/_table_as_wrapper.jsx +46 -0
  59. data/app/pb_kits/playbook/pb_table/docs/_table_as_wrapper.md +2 -0
  60. data/app/pb_kits/playbook/pb_table/docs/_table_colspan.html.erb +32 -0
  61. data/app/pb_kits/playbook/pb_table/docs/_table_colspan.jsx +52 -0
  62. data/app/pb_kits/playbook/pb_table/docs/_table_colspan.md +5 -0
  63. data/app/pb_kits/playbook/pb_table/docs/_table_container.html.erb +32 -32
  64. data/app/pb_kits/playbook/pb_table/docs/_table_container.jsx +32 -32
  65. data/app/pb_kits/playbook/pb_table/docs/_table_contrast_border.html.erb +64 -64
  66. data/app/pb_kits/playbook/pb_table/docs/_table_contrast_border.jsx +64 -65
  67. data/app/pb_kits/playbook/pb_table/docs/_table_data_table.html.erb +32 -32
  68. data/app/pb_kits/playbook/pb_table/docs/_table_data_table.jsx +32 -32
  69. data/app/pb_kits/playbook/pb_table/docs/_table_disable_hover.html.erb +33 -33
  70. data/app/pb_kits/playbook/pb_table/docs/_table_disable_hover.jsx +32 -32
  71. data/app/pb_kits/playbook/pb_table/docs/_table_header.html.erb +8 -8
  72. data/app/pb_kits/playbook/pb_table/docs/_table_icon_buttons.html.erb +35 -35
  73. data/app/pb_kits/playbook/pb_table/docs/_table_icon_buttons.jsx +37 -37
  74. data/app/pb_kits/playbook/pb_table/docs/_table_lg.html.erb +33 -33
  75. data/app/pb_kits/playbook/pb_table/docs/_table_lg.jsx +32 -32
  76. data/app/pb_kits/playbook/pb_table/docs/_table_md.html.erb +32 -32
  77. data/app/pb_kits/playbook/pb_table/docs/_table_md.jsx +32 -32
  78. data/app/pb_kits/playbook/pb_table/docs/_table_multiline.html.erb +54 -33
  79. data/app/pb_kits/playbook/pb_table/docs/_table_multiline.jsx +38 -38
  80. data/app/pb_kits/playbook/pb_table/docs/_table_one_action.html.erb +38 -32
  81. data/app/pb_kits/playbook/pb_table/docs/_table_one_action.jsx +35 -35
  82. data/app/pb_kits/playbook/pb_table/docs/_table_outer_padding.html.erb +38 -32
  83. data/app/pb_kits/playbook/pb_table/docs/_table_outer_padding.jsx +35 -41
  84. data/app/pb_kits/playbook/pb_table/docs/_table_responsive_table.html.erb +72 -74
  85. data/app/pb_kits/playbook/pb_table/docs/_table_responsive_table.jsx +72 -72
  86. data/app/pb_kits/playbook/pb_table/docs/_table_side_highlight.html.erb +99 -99
  87. data/app/pb_kits/playbook/pb_table/docs/_table_side_highlight.jsx +93 -93
  88. data/app/pb_kits/playbook/pb_table/docs/_table_single_line.html.erb +53 -46
  89. data/app/pb_kits/playbook/pb_table/docs/_table_single_line.jsx +38 -38
  90. data/app/pb_kits/playbook/pb_table/docs/_table_sm.html.erb +33 -33
  91. data/app/pb_kits/playbook/pb_table/docs/_table_sm.jsx +32 -32
  92. data/app/pb_kits/playbook/pb_table/docs/_table_sticky.html.erb +89 -82
  93. data/app/pb_kits/playbook/pb_table/docs/_table_sticky.jsx +82 -81
  94. data/app/pb_kits/playbook/pb_table/docs/_table_sticky.md +3 -3
  95. data/app/pb_kits/playbook/pb_table/docs/_table_sticky_columns.html.erb +73 -72
  96. data/app/pb_kits/playbook/pb_table/docs/_table_sticky_columns.jsx +72 -72
  97. data/app/pb_kits/playbook/pb_table/docs/_table_sticky_left_columns.html.erb +72 -75
  98. data/app/pb_kits/playbook/pb_table/docs/_table_sticky_left_columns.jsx +73 -73
  99. data/app/pb_kits/playbook/pb_table/docs/_table_sticky_right_columns.html.erb +72 -72
  100. data/app/pb_kits/playbook/pb_table/docs/_table_sticky_right_columns.jsx +73 -73
  101. data/app/pb_kits/playbook/pb_table/docs/_table_two_actions.html.erb +41 -41
  102. data/app/pb_kits/playbook/pb_table/docs/_table_two_actions.jsx +37 -37
  103. data/app/pb_kits/playbook/pb_table/docs/_table_two_plus_actions.html.erb +44 -32
  104. data/app/pb_kits/playbook/pb_table/docs/_table_two_plus_actions.jsx +57 -54
  105. data/app/pb_kits/playbook/pb_table/docs/_table_vertical_border.html.erb +32 -32
  106. data/app/pb_kits/playbook/pb_table/docs/_table_vertical_border.jsx +32 -32
  107. data/app/pb_kits/playbook/pb_table/docs/_table_with_background_kit.html.erb +64 -62
  108. data/app/pb_kits/playbook/pb_table/docs/_table_with_background_kit.jsx +69 -79
  109. data/app/pb_kits/playbook/pb_table/docs/_table_with_filter_variant_rails.md +1 -1
  110. data/app/pb_kits/playbook/pb_table/docs/_table_with_filter_variant_react.md +1 -1
  111. data/app/pb_kits/playbook/pb_table/docs/_table_with_header_style_borderless.html.erb +32 -32
  112. data/app/pb_kits/playbook/pb_table/docs/_table_with_header_style_borderless.jsx +32 -32
  113. data/app/pb_kits/playbook/pb_table/docs/example.yml +5 -1
  114. data/app/pb_kits/playbook/pb_table/docs/index.js +3 -1
  115. data/app/pb_kits/playbook/pb_table/kit.schema.json +6 -0
  116. data/app/pb_kits/playbook/pb_table/subcomponents/_table_cell.tsx +6 -1
  117. data/app/pb_kits/playbook/pb_table/subcomponents/_table_header.tsx +6 -1
  118. data/app/pb_kits/playbook/pb_table/table.test.js +62 -0
  119. data/app/pb_kits/playbook/pb_table/table_cell.html.erb +1 -1
  120. data/app/pb_kits/playbook/pb_table/table_cell.rb +1 -0
  121. data/app/pb_kits/playbook/pb_text_input/kit.schema.json +4 -1
  122. data/app/pb_kits/playbook/pb_timeline/kit.schema.json +4 -1
  123. data/app/pb_kits/playbook/pb_user_badge/user_badge.rb +1 -5
  124. data/dist/chunks/{_table-SGw4kUye.js → _table-CUU7TisO.js} +1 -1
  125. data/dist/chunks/vendor.js +2 -2
  126. data/lib/playbook/changelog_generator.rb +204 -23
  127. data/lib/playbook/engine.rb +0 -2
  128. data/lib/playbook/version.rb +1 -1
  129. metadata +27 -13
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 672b9baf425e982f8d59fe03e71b4211cd715c2975de0f0c3a30895201d6b780
4
- data.tar.gz: ed5012fd921338fdcc088c046e07e0a44f54b11f61e9921309958307b324fdfa
3
+ metadata.gz: 1ba21582839d4a05178fc1ea74ca0ad1b8ca652238e4119192fe4c461dcbb9ae
4
+ data.tar.gz: 453a53b804b46fb84aaa6d9efd1bf1f316b7525633a57134da3d3f4b6b8c46dd
5
5
  SHA512:
6
- metadata.gz: 8291cbace8ba3b7abebdf73b25d577d4a464fc49b1c8de677c1e990b42409a90e3b59a1b76f11312a7443c45ddb18bae51e481e501e602bfc3c735aa8ff98422
7
- data.tar.gz: e1277c1934e5ecd79e9740070ca25dee5966f39916501d5cd257055bb96aaade4fa9d5ed924badab1a53666e725caaaef2644a6ec55393d1f06032cf5b250b6f
6
+ metadata.gz: 02f76fdc192859f041aa853a8f155c01248c0bf849a00484409ed5154f99dc4f92bb9829bf24da859c5c38bc532108724eda2dcbe1f11edd1ff527eaa89e1826
7
+ data.tar.gz: 8fa85b1670735641741175e82792867fc72459c5ac1040a5117314a66d2a3ce874c83b017fd4342b56d1d80c5c03c90a23c75629ba15cb74c05240696a2cf6fb
@@ -8,7 +8,10 @@
8
8
  ],
9
9
  "props": {
10
10
  "actions": {
11
- "type": "React.ReactNode[] | React.ReactNode",
11
+ "type": {
12
+ "react": "React.ReactNode[] | React.ReactNode",
13
+ "rails": "array"
14
+ },
12
15
  "platforms": [
13
16
  "react",
14
17
  "rails"
@@ -115,7 +118,10 @@
115
118
  "default": false
116
119
  },
117
120
  "loading": {
118
- "type": "boolean | string",
121
+ "type": {
122
+ "react": "boolean | string",
123
+ "rails": "boolean"
124
+ },
119
125
  "platforms": [
120
126
  "react",
121
127
  "rails"
@@ -14,7 +14,10 @@
14
14
  ]
15
15
  },
16
16
  "backgroundColor": {
17
- "type": "enum",
17
+ "type": {
18
+ "react": "ResponsiveProp<BackgroundColors> | BackgroundColors",
19
+ "rails": "enum"
20
+ },
18
21
  "platforms": [
19
22
  "react",
20
23
  "rails"
@@ -85,7 +88,10 @@
85
88
  "default": "light"
86
89
  },
87
90
  "backgroundSize": {
88
- "type": "enum",
91
+ "type": {
92
+ "react": "ResponsiveProp<BackgroundSizes> | BackgroundSizes",
93
+ "rails": "enum"
94
+ },
89
95
  "platforms": [
90
96
  "react",
91
97
  "rails"
@@ -98,7 +104,10 @@
98
104
  "default": "cover"
99
105
  },
100
106
  "backgroundPosition": {
101
- "type": "ResponsiveProp<string> | string",
107
+ "type": {
108
+ "react": "ResponsiveProp<string> | string",
109
+ "rails": "string"
110
+ },
102
111
  "platforms": [
103
112
  "react",
104
113
  "rails"
@@ -106,7 +115,10 @@
106
115
  "default": null
107
116
  },
108
117
  "backgroundRepeat": {
109
- "type": "enum",
118
+ "type": {
119
+ "react": "ResponsiveProp<BackgroundRepeat> | BackgroundRepeat",
120
+ "rails": "enum"
121
+ },
110
122
  "platforms": [
111
123
  "react",
112
124
  "rails"
@@ -8,7 +8,10 @@
8
8
  ],
9
9
  "props": {
10
10
  "background": {
11
- "type": "enum",
11
+ "type": {
12
+ "react": "BackgroundColors | ProductColors | \"none\"",
13
+ "rails": "enum"
14
+ },
12
15
  "platforms": [
13
16
  "react",
14
17
  "rails"
@@ -1,5 +1,5 @@
1
1
  /* eslint-disable react/no-multi-comp */
2
- import React, { useMemo, useState } from 'react'
2
+ import React, { useState } from 'react'
3
3
 
4
4
  import DatePicker from '../_date_picker'
5
5
  import Body from '../../pb_body/_body'
@@ -11,26 +11,22 @@ DEFAULT_DATE.setMinutes(0)
11
11
  const DatePickerTime = (props) => {
12
12
  const [selectedDateTime, setSelectedDateTime] = useState(DEFAULT_DATE)
13
13
 
14
- const refExample = React.createRef()
15
-
16
- const handleOnInputChanged = (dateTime) => {
17
- setSelectedDateTime(dateTime)
14
+ const handleOnClose = (selectedDates) => {
15
+ setSelectedDateTime(selectedDates[0])
18
16
  }
19
17
 
20
18
  return (
21
- <div ref={refExample}>
22
- <Body marginBottom="md">{selectedDateTime.toString()}</Body>
23
- {useMemo(() => (
24
- <DatePicker
25
- closeOnSelect={false}
26
- defaultDate={DEFAULT_DATE}
27
- enableTime
28
- onChange={handleOnInputChanged}
29
- pickerId="date-picker-time"
30
- showTimezone
31
- {...props}
32
- />
33
- ), [props])}
19
+ <div>
20
+ <Body marginBottom="md">{selectedDateTime ? selectedDateTime.toString() : ''}</Body>
21
+ <DatePicker
22
+ defaultDate={DEFAULT_DATE}
23
+ enableTime
24
+ initializeOnce
25
+ onClose={handleOnClose}
26
+ pickerId="date-picker-time"
27
+ showTimezone
28
+ {...props}
29
+ />
34
30
  </div>
35
31
  )
36
32
  }
@@ -1 +1,3 @@
1
- To select time as well, you should pass the `enableTime` boolean prop. You can also enable timezone display by passing `showTimezone`.
1
+ To select time as well, you should pass the `enableTime` / `enable_time` boolean prop. You can also enable timezone display by passing `showTimezone` / `show_timezone`.
2
+
3
+ Use `onClose` when the calendar should stay open while the user picks both a date and a time. It fires once, after the user clicks outside to close the calendar, instead of on every selection the way `onChange` does. For React, pair the handler with `initializeOnce` so storing the value in state does not re-initialize the picker and reset the input back to `defaultDate`.
@@ -189,7 +189,10 @@
189
189
  "default": "Select Date"
190
190
  },
191
191
  "positionElement": {
192
- "type": "HTMLElement | null",
192
+ "type": {
193
+ "react": "HTMLElement | null",
194
+ "rails": "string"
195
+ },
193
196
  "platforms": [
194
197
  "react",
195
198
  "rails"
@@ -53,7 +53,10 @@
53
53
  "default": false
54
54
  },
55
55
  "customQuickPickDates": {
56
- "type": "CustomQuickPickDates",
56
+ "type": {
57
+ "react": "CustomQuickPickDates",
58
+ "rails": "GenericObject"
59
+ },
57
60
  "platforms": [
58
61
  "react",
59
62
  "rails"
@@ -122,7 +125,10 @@
122
125
  ]
123
126
  },
124
127
  "options": {
125
- "type": "GenericObject",
128
+ "type": {
129
+ "react": "GenericObject",
130
+ "rails": "array"
131
+ },
126
132
  "platforms": [
127
133
  "react",
128
134
  "rails"
@@ -8,7 +8,10 @@
8
8
  ],
9
9
  "props": {
10
10
  "accept": {
11
- "type": "GenericObject",
11
+ "type": {
12
+ "react": "GenericObject",
13
+ "rails": "string"
14
+ },
12
15
  "platforms": [
13
16
  "react",
14
17
  "rails"
@@ -22,7 +22,10 @@
22
22
  ]
23
23
  },
24
24
  "filters": {
25
- "type": "GenericObject",
25
+ "type": {
26
+ "react": "GenericObject",
27
+ "rails": "array"
28
+ },
26
29
  "platforms": [
27
30
  "react",
28
31
  "rails"
@@ -58,7 +58,10 @@
58
58
  "default": "street"
59
59
  },
60
60
  "homeId": {
61
- "type": "string",
61
+ "type": {
62
+ "react": "string",
63
+ "rails": "number"
64
+ },
62
65
  "platforms": [
63
66
  "react",
64
67
  "rails"
@@ -8,7 +8,10 @@
8
8
  ],
9
9
  "props": {
10
10
  "border": {
11
- "type": "enum",
11
+ "type": {
12
+ "react": "boolean | BorderPropValue",
13
+ "rails": "enum"
14
+ },
12
15
  "platforms": [
13
16
  "react",
14
17
  "rails"
@@ -34,7 +37,10 @@
34
37
  ]
35
38
  },
36
39
  "customIcon": {
37
- "type": "GenericObject",
40
+ "type": {
41
+ "react": "GenericObject",
42
+ "rails": "string"
43
+ },
38
44
  "platforms": [
39
45
  "react",
40
46
  "rails"
@@ -6,10 +6,7 @@
6
6
  "full": false,
7
7
  "position": "left",
8
8
  "responsive": false,
9
- "size": {
10
- "react": "sm",
11
- "rails": "md"
12
- },
9
+ "size": "sm",
13
10
  "variant": "light",
14
11
  "transparent": false,
15
12
  "layout": "sidebar"
@@ -78,7 +78,10 @@
78
78
  "default": "America/New_York"
79
79
  },
80
80
  "alignTimestamp": {
81
- "type": "enum",
81
+ "type": {
82
+ "react": "string",
83
+ "rails": "enum"
84
+ },
82
85
  "platforms": [
83
86
  "react",
84
87
  "rails"
@@ -49,12 +49,19 @@ interface MultiLevelSelectComponent extends React.ForwardRefExoticComponent<
49
49
  Options: typeof MultiLevelSelectOptions;
50
50
  }
51
51
 
52
+ type MultiLevelSelectItem = { [key: string]: any };
53
+ type SelectedDisplayContext = {
54
+ ancestors: MultiLevelSelectItem[];
55
+ path: MultiLevelSelectItem[];
56
+ };
57
+
52
58
  type MultiLevelSelectProps = {
53
59
  aria?: { [key: string]: string };
54
60
  className?: string;
55
61
  data?: { [key: string]: string };
56
62
  disabled?: boolean;
57
63
  error?: string;
64
+ formatSelectedDisplay?: (item: MultiLevelSelectItem, context: SelectedDisplayContext) => string;
58
65
  htmlOptions?: { [key: string]: string | number | boolean | (() => void) };
59
66
  id?: string;
60
67
  inputDisplay?: "pills" | "none";
@@ -105,6 +112,7 @@ const MultiLevelSelect = forwardRef<HTMLInputElement, MultiLevelSelectProps>(
105
112
  data = {},
106
113
  disabled = false,
107
114
  error,
115
+ formatSelectedDisplay,
108
116
  htmlOptions = {},
109
117
  id,
110
118
  inputDisplay = "pills",
@@ -175,6 +183,26 @@ const MultiLevelSelect = forwardRef<HTMLInputElement, MultiLevelSelectProps>(
175
183
  item: [],
176
184
  });
177
185
 
186
+ const getSelectedDisplay = (
187
+ item: MultiLevelSelectItem,
188
+ data: MultiLevelSelectItem[],
189
+ ) => {
190
+ const ancestors: MultiLevelSelectItem[] = [];
191
+ let parentId = item.parent_id;
192
+
193
+ while (parentId) {
194
+ const parent = filterFormattedDataById(data, parentId)[0];
195
+ if (!parent) break;
196
+
197
+ ancestors.unshift(parent);
198
+ parentId = parent.parent_id;
199
+ }
200
+
201
+ return formatSelectedDisplay
202
+ ? formatSelectedDisplay(item, { ancestors, path: [...ancestors, item] })
203
+ : item.label;
204
+ };
205
+
178
206
  const arrowDownElementId = `arrow_down_${id}`;
179
207
  const arrowUpElementId = `arrow_up_${id}`;
180
208
  // Control id for label htmlFor: use suffix to avoid conflict with outer div's id
@@ -771,7 +799,9 @@ const MultiLevelSelect = forwardRef<HTMLInputElement, MultiLevelSelectProps>(
771
799
  : placeholderText
772
800
  }
773
801
  required={required}
774
- value={singleSelectedItem.value || filterItem}
802
+ value={singleSelectedItem.item.length
803
+ ? getSelectedDisplay(singleSelectedItem.item[0], formattedData)
804
+ : singleSelectedItem.value || filterItem}
775
805
  />
776
806
  </div>
777
807
 
@@ -0,0 +1,191 @@
1
+ import React from "react";
2
+ import MultiLevelSelect from "../_multi_level_select";
3
+
4
+ const treeData = [
5
+ {
6
+ label: "HQ",
7
+ value: "hQ",
8
+ id: "hq1",
9
+ },
10
+ {
11
+ label: "Philadelphia",
12
+ value: "philadelphia",
13
+ id: "phl1",
14
+ expanded: true,
15
+ children: [
16
+ {
17
+ label: "Marketing & Sales PHL",
18
+ value: "marketingAndSalesPhl",
19
+ id: "marketingPHL1",
20
+ },
21
+ {
22
+ label: "Installation Office PHL",
23
+ value: "installationOfficePhl",
24
+ id: "installationPHL1",
25
+ },
26
+ {
27
+ label: "Warehouse PHL",
28
+ value: "warehousePhl",
29
+ id: "warehousePHL1",
30
+ },
31
+ ]
32
+ },
33
+ {
34
+ label: "New Jersey",
35
+ value: "newJersey",
36
+ id: "nj1",
37
+ children: [
38
+ {
39
+ label: "New Jersey",
40
+ value: "newJersey",
41
+ id: "nj11",
42
+ children: [
43
+ {
44
+ label: "Marketing & Sales NJ",
45
+ value: "marketingAndSalesNj",
46
+ id: "marketingNJ1",
47
+ },
48
+ {
49
+ label: "Installation Office NJ",
50
+ value: "installationOfficeNj",
51
+ id: "installationNJ1",
52
+ },
53
+ {
54
+ label: "Warehouse NJ",
55
+ value: "warehouseNj",
56
+ id: "warehouseNJ1",
57
+ },
58
+ ],
59
+ },
60
+ {
61
+ label: "Princeton",
62
+ value: "princeton",
63
+ id: "princeton1",
64
+ children: [
65
+ {
66
+ label: "Marketing & Sales Princeton",
67
+ value: "marketingAndSalesPrinceton",
68
+ id: "marketingPR1",
69
+ },
70
+ {
71
+ label: "Installation Office Princeton",
72
+ value: "installationOfficePrinceton",
73
+ id: "installationPR1",
74
+ },
75
+ {
76
+ label: "Warehouse Princeton",
77
+ value: "warehousePrinceton",
78
+ id: "warehousePR1",
79
+ },
80
+ ]
81
+ },
82
+ ]
83
+ },
84
+ ];
85
+
86
+ const treeData2 = [
87
+ {
88
+ label: "HQ",
89
+ value: "hQ",
90
+ id: "hq2",
91
+ },
92
+ {
93
+ label: "Philadelphia",
94
+ value: "philadelphia",
95
+ id: "phl2",
96
+ expanded: true,
97
+ children: [
98
+ {
99
+ label: "Marketing & Sales PHL",
100
+ value: "marketingAndSalesPhl",
101
+ id: "marketingPHL2",
102
+ },
103
+ {
104
+ label: "Installation Office PHL",
105
+ value: "installationOfficePhl",
106
+ id: "installationPHL2",
107
+ },
108
+ {
109
+ label: "Warehouse PHL",
110
+ value: "warehousePhl",
111
+ id: "warehousePHL2",
112
+ },
113
+ ]
114
+ },
115
+ {
116
+ label: "New Jersey",
117
+ value: "newJersey",
118
+ id: "nj2",
119
+ children: [
120
+ {
121
+ label: "New Jersey",
122
+ value: "newJersey",
123
+ id: "nj22",
124
+ children: [
125
+ {
126
+ label: "Marketing & Sales NJ",
127
+ value: "marketingAndSalesNj",
128
+ id: "marketingNJ2",
129
+ },
130
+ {
131
+ label: "Installation Office NJ",
132
+ value: "installationOfficeNj",
133
+ id: "installationNJ2",
134
+ },
135
+ {
136
+ label: "Warehouse NJ",
137
+ value: "warehouseNj",
138
+ id: "warehouseNJ2",
139
+ },
140
+ ],
141
+ },
142
+ {
143
+ label: "Princeton",
144
+ value: "princeton",
145
+ id: "princeton2",
146
+ children: [
147
+ {
148
+ label: "Marketing & Sales Princeton",
149
+ value: "marketingAndSalesPrinceton",
150
+ id: "marketingPR2",
151
+ },
152
+ {
153
+ label: "Installation Office Princeton",
154
+ value: "installationOfficePrinceton",
155
+ id: "installationPR2",
156
+ },
157
+ {
158
+ label: "Warehouse Princeton",
159
+ value: "warehousePrinceton",
160
+ id: "warehousePR2",
161
+ },
162
+ ]
163
+ },
164
+ ]
165
+ },
166
+ ];
167
+
168
+ const MultiLevelSelectFormatSelectedDisplay = (props) => (
169
+ <>
170
+ <MultiLevelSelect
171
+ formatSelectedDisplay={(_, { path }) =>
172
+ path.map(({ label }) => label).join(" / ")
173
+ }
174
+ treeData={treeData}
175
+ variant="single"
176
+ {...props}
177
+ />
178
+ <br />
179
+ <MultiLevelSelect
180
+ formatSelectedDisplay={(item, { ancestors }) => {
181
+ const parent = ancestors[ancestors.length - 1];
182
+ return parent ? `${item.label} (${parent.label})` : item.label;
183
+ }}
184
+ treeData={treeData2}
185
+ variant="single"
186
+ {...props}
187
+ />
188
+ </>
189
+ );
190
+
191
+ export default MultiLevelSelectFormatSelectedDisplay;
@@ -0,0 +1 @@
1
+ Use `formatSelectedDisplay` to customize the string shown in the input after a single-select option is chosen. The formatter receives the selected item and a context object containing `ancestors` (ordered from the root through the immediate parent) and `path` (the ancestors plus the selected item). This changes only the displayed string; selection callbacks and form values remain unchanged.
@@ -31,7 +31,8 @@
31
31
  "name",
32
32
  "placeholder",
33
33
  "selectedIds",
34
- "inputName"
34
+ "inputName",
35
+ "formatSelectedDisplay"
35
36
  ]
36
37
  },
37
38
  {
@@ -48,7 +49,8 @@
48
49
  "props": [
49
50
  "inputDisplay",
50
51
  "variant",
51
- "wrapped"
52
+ "wrapped",
53
+ "pillColor"
52
54
  ]
53
55
  },
54
56
  {
@@ -92,6 +94,20 @@
92
94
  "onSelect": "(selectedNode) => console.log('Selected Node', selectedNode)"
93
95
  }
94
96
  },
97
+ {
98
+ "name": "Custom Single Select Display",
99
+ "structureMode": "standard",
100
+ "props": {
101
+ "variant": "single",
102
+ "label": "Pick one team",
103
+ "placeholder": "Choose...",
104
+ "selectedIds": [
105
+ "initiative1"
106
+ ],
107
+ "formatSelectedDisplay": "(_, { path }) => path.map(({ label }) => label).join(' / ')",
108
+ "onSelect": "(selectedNode) => console.log('Selected Node', selectedNode)"
109
+ }
110
+ },
95
111
  {
96
112
  "name": "Selected IDs",
97
113
  "structureMode": "standard",
@@ -246,6 +262,11 @@
246
262
  }
247
263
  ],
248
264
  "conditionals": {
265
+ "formatSelectedDisplay": {
266
+ "requires": {
267
+ "variant": "single"
268
+ }
269
+ },
249
270
  "requiredIndicator": {
250
271
  "requires": "label"
251
272
  }
@@ -266,6 +287,11 @@
266
287
  "message": "Single Select uses radios and should receive at most one selectedIds value because only one node can be selected.",
267
288
  "type": "info"
268
289
  },
290
+ "custom_single_select_display": {
291
+ "presetName": "Custom Single Select Display",
292
+ "message": "formatSelectedDisplay receives the selected item plus ancestors and path context, and must return the string shown in the single-select input. Edit the function in Content to choose which hierarchy details to display.",
293
+ "type": "info"
294
+ },
269
295
  "selected_ids": {
270
296
  "presetName": "Selected IDs",
271
297
  "message": "selectedIds checks matching treeData node ids on load. In multi mode, multiple ids can be passed.",
@@ -319,6 +345,9 @@
319
345
  "editable": false,
320
346
  "default": ""
321
347
  },
348
+ "editableFunctionProps": [
349
+ "formatSelectedDisplay"
350
+ ],
322
351
  "customProps": {
323
352
  "treeData": {
324
353
  "type": "array",
@@ -16,6 +16,9 @@
16
16
  "editable": false,
17
17
  "default": ""
18
18
  },
19
+ "editableFunctionProps": [
20
+ "formatSelectedDisplay"
21
+ ],
19
22
  "customProps": {
20
23
  "treeData": {
21
24
  "type": "array",
@@ -135,7 +138,8 @@
135
138
  "name",
136
139
  "placeholder",
137
140
  "selectedIds",
138
- "inputName"
141
+ "inputName",
142
+ "formatSelectedDisplay"
139
143
  ]
140
144
  },
141
145
  {
@@ -152,7 +156,8 @@
152
156
  "props": [
153
157
  "inputDisplay",
154
158
  "variant",
155
- "wrapped"
159
+ "wrapped",
160
+ "pillColor"
156
161
  ]
157
162
  },
158
163
  {
@@ -196,6 +201,20 @@
196
201
  "onSelect": "(selectedNode) => console.log('Selected Node', selectedNode)"
197
202
  }
198
203
  },
204
+ {
205
+ "name": "Custom Single Select Display",
206
+ "structureMode": "standard",
207
+ "props": {
208
+ "variant": "single",
209
+ "label": "Pick one team",
210
+ "placeholder": "Choose...",
211
+ "selectedIds": [
212
+ "initiative1"
213
+ ],
214
+ "formatSelectedDisplay": "(_, { path }) => path.map(({ label }) => label).join(' / ')",
215
+ "onSelect": "(selectedNode) => console.log('Selected Node', selectedNode)"
216
+ }
217
+ },
199
218
  {
200
219
  "name": "Selected IDs",
201
220
  "structureMode": "standard",
@@ -350,6 +369,11 @@
350
369
  }
351
370
  ],
352
371
  "conditionals": {
372
+ "formatSelectedDisplay": {
373
+ "requires": {
374
+ "variant": "single"
375
+ }
376
+ },
353
377
  "requiredIndicator": {
354
378
  "requires": "label"
355
379
  }
@@ -370,6 +394,11 @@
370
394
  "message": "Single Select uses radios and should receive at most one selectedIds value because only one node can be selected.",
371
395
  "type": "info"
372
396
  },
397
+ "custom_single_select_display": {
398
+ "presetName": "Custom Single Select Display",
399
+ "message": "formatSelectedDisplay receives the selected item plus ancestors and path context, and must return the string shown in the single-select input. Edit the function in Content to choose which hierarchy details to display.",
400
+ "type": "info"
401
+ },
373
402
  "selected_ids": {
374
403
  "presetName": "Selected IDs",
375
404
  "message": "selectedIds checks matching treeData node ids on load. In multi mode, multiple ids can be passed.",