playbook_ui 14.14.0.pre.rc.5 → 14.15.0.pre.alpha.PBNTR617addgriddisplayglobalprop6700

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 (206) hide show
  1. checksums.yaml +4 -4
  2. data/app/pb_kits/playbook/pb_advanced_table/Components/RegularTableView.tsx +127 -0
  3. data/app/pb_kits/playbook/pb_advanced_table/Components/TableActionBar.tsx +55 -0
  4. data/app/pb_kits/playbook/pb_advanced_table/Components/TablePagination.tsx +33 -0
  5. data/app/pb_kits/playbook/pb_advanced_table/Components/VirtualizedTableView.tsx +275 -0
  6. data/app/pb_kits/playbook/pb_advanced_table/Context/AdvancedTableContext.tsx +143 -3
  7. data/app/pb_kits/playbook/pb_advanced_table/Hooks/useTableActions.ts +66 -0
  8. data/app/pb_kits/playbook/pb_advanced_table/Hooks/useTableState.ts +195 -0
  9. data/app/pb_kits/playbook/pb_advanced_table/SubKits/TableBody.tsx +45 -99
  10. data/app/pb_kits/playbook/pb_advanced_table/Utilities/CellRendererUtils.tsx +73 -0
  11. data/app/pb_kits/playbook/pb_advanced_table/Utilities/RowUtils.ts +52 -0
  12. data/app/pb_kits/playbook/pb_advanced_table/Utilities/TableContainerStyles.ts +80 -0
  13. data/app/pb_kits/playbook/pb_advanced_table/_advanced_table.scss +133 -7
  14. data/app/pb_kits/playbook/pb_advanced_table/_advanced_table.tsx +153 -298
  15. data/app/pb_kits/playbook/pb_advanced_table/advanced_table.rb +8 -1
  16. data/app/pb_kits/playbook/pb_advanced_table/docs/_advanced_table_column_headers_custom_cell.jsx +75 -0
  17. data/app/pb_kits/playbook/pb_advanced_table/docs/_advanced_table_infinite_scroll.jsx +50 -0
  18. data/app/pb_kits/playbook/pb_advanced_table/docs/_advanced_table_inline_editing.jsx +102 -0
  19. data/app/pb_kits/playbook/pb_advanced_table/docs/_advanced_table_inline_editing.md +4 -0
  20. data/app/pb_kits/playbook/pb_advanced_table/docs/_advanced_table_table_props.html.erb +1 -1
  21. data/app/pb_kits/playbook/pb_advanced_table/docs/_advanced_table_table_props_rails.md +3 -1
  22. data/app/pb_kits/playbook/pb_advanced_table/docs/_advanced_table_table_props_react.md +1 -1
  23. data/app/pb_kits/playbook/pb_advanced_table/docs/_advanced_table_table_props_sticky_header.html.erb +33 -0
  24. data/app/pb_kits/playbook/pb_advanced_table/docs/_advanced_table_table_props_sticky_header_rails.md +3 -0
  25. data/app/pb_kits/playbook/pb_advanced_table/docs/advanced_table_mock_data_infinite_scroll.json +152002 -0
  26. data/app/pb_kits/playbook/pb_advanced_table/docs/example.yml +4 -1
  27. data/app/pb_kits/playbook/pb_advanced_table/docs/index.js +3 -1
  28. data/app/pb_kits/playbook/pb_card/_card.tsx +2 -1
  29. data/app/pb_kits/playbook/pb_checkbox/_checkbox.tsx +17 -8
  30. data/app/pb_kits/playbook/pb_checkbox/checkbox.test.js +16 -0
  31. data/app/pb_kits/playbook/pb_checkbox/docs/_checkbox_react_hook.jsx +69 -0
  32. data/app/pb_kits/playbook/pb_checkbox/docs/_checkbox_react_hook.md +1 -0
  33. data/app/pb_kits/playbook/pb_checkbox/docs/example.yml +2 -1
  34. data/app/pb_kits/playbook/pb_checkbox/docs/index.js +1 -0
  35. data/app/pb_kits/playbook/pb_currency/_currency.tsx +46 -31
  36. data/app/pb_kits/playbook/pb_currency/currency.html.erb +15 -8
  37. data/app/pb_kits/playbook/pb_currency/currency.rb +17 -2
  38. data/app/pb_kits/playbook/pb_currency/docs/_currency_null_display.html.erb +22 -0
  39. data/app/pb_kits/playbook/pb_currency/docs/_currency_null_display.jsx +34 -0
  40. data/app/pb_kits/playbook/pb_currency/docs/_currency_null_display_rails.md +1 -0
  41. data/app/pb_kits/playbook/pb_currency/docs/_currency_null_display_react.md +1 -0
  42. data/app/pb_kits/playbook/pb_currency/docs/example.yml +2 -0
  43. data/app/pb_kits/playbook/pb_currency/docs/index.js +2 -1
  44. data/app/pb_kits/playbook/pb_date_picker/date_picker.html.erb +4 -1
  45. data/app/pb_kits/playbook/pb_date_picker/date_picker.rb +2 -0
  46. data/app/pb_kits/playbook/pb_date_picker/docs/_date_picker_hooks.md +3 -1
  47. data/app/pb_kits/playbook/pb_date_picker/docs/_date_picker_on_change.html.erb +39 -0
  48. data/app/pb_kits/playbook/pb_date_picker/docs/_date_picker_on_close.html.erb +39 -0
  49. data/app/pb_kits/playbook/pb_date_picker/docs/example.yml +2 -0
  50. data/app/pb_kits/playbook/pb_date_picker/index.ts +38 -0
  51. data/app/pb_kits/playbook/pb_dialog/dialog.html.erb +5 -6
  52. data/app/pb_kits/playbook/pb_dialog/dialogHelper.js +2 -0
  53. data/app/pb_kits/playbook/pb_dialog/index.js +75 -0
  54. data/app/pb_kits/playbook/pb_drawer/_drawer.scss +43 -3
  55. data/app/pb_kits/playbook/pb_drawer/docs/_drawer_behavior.html.erb +8 -0
  56. data/app/pb_kits/playbook/pb_drawer/docs/_drawer_borders.html.erb +33 -0
  57. data/app/pb_kits/playbook/pb_drawer/docs/_drawer_borders.jsx +3 -3
  58. data/app/pb_kits/playbook/pb_drawer/docs/_drawer_breakpoints.html.erb +0 -0
  59. data/app/pb_kits/playbook/pb_drawer/docs/_drawer_breakpoints.jsx +20 -37
  60. data/app/pb_kits/playbook/pb_drawer/docs/_drawer_default.html.erb +20 -1
  61. data/app/pb_kits/playbook/pb_drawer/docs/_drawer_menu.html.erb +24 -0
  62. data/app/pb_kits/playbook/pb_drawer/docs/_drawer_menu.jsx +6 -6
  63. data/app/pb_kits/playbook/pb_drawer/docs/_drawer_overlay.html.erb +21 -0
  64. data/app/pb_kits/playbook/pb_drawer/docs/_drawer_overlay.jsx +1 -0
  65. data/app/pb_kits/playbook/pb_drawer/docs/_drawer_overlay.md +1 -0
  66. data/app/pb_kits/playbook/pb_drawer/docs/_drawer_sizes.html.erb +49 -0
  67. data/app/pb_kits/playbook/pb_drawer/docs/example.yml +6 -0
  68. data/app/pb_kits/playbook/pb_drawer/drawer.html.erb +20 -12
  69. data/app/pb_kits/playbook/pb_drawer/drawer.rb +49 -1
  70. data/app/pb_kits/playbook/pb_drawer/index.js +257 -0
  71. data/app/pb_kits/playbook/pb_filter/Filter/CurrentFilters.tsx +5 -4
  72. data/app/pb_kits/playbook/pb_filter/Filter/FilterSingle.tsx +2 -2
  73. data/app/pb_kits/playbook/pb_form/docs/_form_form_with.html.erb +2 -1
  74. data/app/pb_kits/playbook/pb_form/docs/_form_form_with_validate.html.erb +4 -3
  75. data/app/pb_kits/playbook/pb_form_pill/_form_pill.scss +9 -2
  76. data/app/pb_kits/playbook/pb_form_pill/_form_pill.tsx +4 -0
  77. data/app/pb_kits/playbook/pb_form_pill/docs/_form_pill_wrapped.html.erb +40 -0
  78. data/app/pb_kits/playbook/pb_form_pill/docs/_form_pill_wrapped.jsx +50 -0
  79. data/app/pb_kits/playbook/pb_form_pill/docs/_form_pill_wrapped.md +3 -0
  80. data/app/pb_kits/playbook/pb_form_pill/docs/example.yml +2 -0
  81. data/app/pb_kits/playbook/pb_form_pill/docs/index.js +1 -0
  82. data/app/pb_kits/playbook/pb_form_pill/form_pill.rb +7 -1
  83. data/app/pb_kits/playbook/pb_icon_button/_icon_button.tsx +71 -0
  84. data/app/pb_kits/playbook/pb_icon_button/docs/_icon_button_default.jsx +17 -0
  85. data/app/pb_kits/playbook/pb_icon_button/docs/_icon_button_sizes.jsx +61 -0
  86. data/app/pb_kits/playbook/pb_icon_button/docs/example.yml +4 -0
  87. data/app/pb_kits/playbook/pb_icon_button/docs/index.js +2 -0
  88. data/app/pb_kits/playbook/pb_icon_button/icon_button.html.erb +1 -1
  89. data/app/pb_kits/playbook/pb_icon_button/icon_button.test.jsx +39 -0
  90. data/app/pb_kits/playbook/pb_multi_level_select/_multi_level_select.scss +7 -0
  91. data/app/pb_kits/playbook/pb_multi_level_select/_multi_level_select.tsx +45 -8
  92. data/app/pb_kits/playbook/pb_multi_level_select/docs/_multi_level_select_disabled.html.erb +72 -0
  93. data/app/pb_kits/playbook/pb_multi_level_select/docs/_multi_level_select_disabled.jsx +91 -0
  94. data/app/pb_kits/playbook/pb_multi_level_select/docs/_multi_level_select_react_hook.jsx +91 -0
  95. data/app/pb_kits/playbook/pb_multi_level_select/docs/_multi_level_select_react_hook.md +1 -0
  96. data/app/pb_kits/playbook/pb_multi_level_select/docs/example.yml +3 -1
  97. data/app/pb_kits/playbook/pb_multi_level_select/docs/index.js +2 -0
  98. data/app/pb_kits/playbook/pb_multi_level_select/multi_level_select.rb +7 -1
  99. data/app/pb_kits/playbook/pb_overlay/_overlay.scss +13 -0
  100. data/app/pb_kits/playbook/pb_overlay/_overlay.tsx +11 -1
  101. data/app/pb_kits/playbook/pb_overlay/docs/_overlay_hide_scroll_bar.html.erb +11 -0
  102. data/app/pb_kits/playbook/pb_overlay/docs/_overlay_hide_scroll_bar.jsx +37 -0
  103. data/app/pb_kits/playbook/pb_overlay/docs/_overlay_hide_scroll_bar_rails.md +1 -0
  104. data/app/pb_kits/playbook/pb_overlay/docs/_overlay_hide_scroll_bar_react.md +1 -0
  105. data/app/pb_kits/playbook/pb_overlay/docs/_overlay_vertical_dynamic_multi_directional.html.erb +11 -0
  106. data/app/pb_kits/playbook/pb_overlay/docs/_overlay_vertical_dynamic_multi_directional.jsx +37 -0
  107. data/app/pb_kits/playbook/pb_overlay/docs/_overlay_vertical_dynamic_multi_directional.md +1 -0
  108. data/app/pb_kits/playbook/pb_overlay/docs/_overlay_vertical_dynamic_multi_directional_react.md +1 -0
  109. data/app/pb_kits/playbook/pb_overlay/docs/example.yml +4 -0
  110. data/app/pb_kits/playbook/pb_overlay/docs/index.js +2 -0
  111. data/app/pb_kits/playbook/pb_overlay/index.js +61 -0
  112. data/app/pb_kits/playbook/pb_overlay/overlay.html.erb +5 -3
  113. data/app/pb_kits/playbook/pb_overlay/overlay.rb +16 -1
  114. data/app/pb_kits/playbook/pb_overlay/overlay.test.jsx +12 -0
  115. data/app/pb_kits/playbook/pb_overlay/subcomponents/_overlay_token.tsx +48 -10
  116. data/app/pb_kits/playbook/pb_phone_number_input/_phone_number_input.tsx +6 -0
  117. data/app/pb_kits/playbook/pb_phone_number_input/docs/_phone_number_input_default.html.erb +1 -1
  118. data/app/pb_kits/playbook/pb_phone_number_input/docs/_phone_number_input_hidden_inputs.html.erb +5 -0
  119. data/app/pb_kits/playbook/pb_phone_number_input/docs/_phone_number_input_hidden_inputs.md +1 -0
  120. data/app/pb_kits/playbook/pb_phone_number_input/docs/example.yml +3 -1
  121. data/app/pb_kits/playbook/pb_phone_number_input/phone_number_input.rb +3 -0
  122. data/app/pb_kits/playbook/pb_popover/_popover.tsx +2 -2
  123. data/app/pb_kits/playbook/pb_popover/popover.test.js +1 -1
  124. data/app/pb_kits/playbook/pb_progress_pills/progress_pills.html.erb +1 -6
  125. data/app/pb_kits/playbook/pb_progress_simple/progress_simple.html.erb +1 -5
  126. data/app/pb_kits/playbook/pb_progress_step/progress_step.html.erb +1 -5
  127. data/app/pb_kits/playbook/pb_progress_step/progress_step_item.html.erb +3 -7
  128. data/app/pb_kits/playbook/pb_radio/_radio.tsx +85 -74
  129. data/app/pb_kits/playbook/pb_radio/docs/_radio_react_hook.jsx +60 -0
  130. data/app/pb_kits/playbook/pb_radio/docs/_radio_react_hook.md +1 -0
  131. data/app/pb_kits/playbook/pb_radio/docs/example.yml +2 -1
  132. data/app/pb_kits/playbook/pb_radio/docs/index.js +1 -0
  133. data/app/pb_kits/playbook/pb_radio/radio.html.erb +6 -11
  134. data/app/pb_kits/playbook/pb_radio/radio.test.js +16 -0
  135. data/app/pb_kits/playbook/pb_select/docs/_select_react_hook.jsx +58 -0
  136. data/app/pb_kits/playbook/pb_select/docs/_select_react_hook.md +1 -0
  137. data/app/pb_kits/playbook/pb_select/docs/example.yml +1 -0
  138. data/app/pb_kits/playbook/pb_select/docs/index.js +1 -0
  139. data/app/pb_kits/playbook/pb_select/index.js +38 -0
  140. data/app/pb_kits/playbook/pb_select/select.html.erb +3 -5
  141. data/app/pb_kits/playbook/pb_select/select.rb +8 -0
  142. data/app/pb_kits/playbook/pb_selectable_card/selectable_card.html.erb +1 -5
  143. data/app/pb_kits/playbook/pb_selectable_card_icon/selectable_card_icon.html.erb +1 -4
  144. data/app/pb_kits/playbook/pb_selectable_icon/selectable_icon.html.erb +1 -5
  145. data/app/pb_kits/playbook/pb_text_input/inputMask.ts +2 -3
  146. data/app/pb_kits/playbook/pb_timeline/_timeline.scss +2 -2
  147. data/app/pb_kits/playbook/pb_title/_title.scss +32 -0
  148. data/app/pb_kits/playbook/pb_title/_title.tsx +10 -1
  149. data/app/pb_kits/playbook/pb_title/docs/_title_default.html.erb +1 -2
  150. data/app/pb_kits/playbook/pb_title/docs/_title_default.jsx +1 -1
  151. data/app/pb_kits/playbook/pb_title/docs/_title_display_size.html.erb +7 -0
  152. data/app/pb_kits/playbook/pb_title/docs/_title_display_size.jsx +54 -0
  153. data/app/pb_kits/playbook/pb_title/docs/_title_display_size.md +1 -0
  154. data/app/pb_kits/playbook/pb_title/docs/example.yml +2 -0
  155. data/app/pb_kits/playbook/pb_title/docs/index.js +1 -0
  156. data/app/pb_kits/playbook/pb_title/title.rb +10 -1
  157. data/app/pb_kits/playbook/pb_tooltip/_tooltip.scss +0 -3
  158. data/app/pb_kits/playbook/pb_tooltip/_tooltip.tsx +25 -0
  159. data/app/pb_kits/playbook/pb_tooltip/docs/_tooltip_delay_rails.html.erb +39 -0
  160. data/app/pb_kits/playbook/pb_tooltip/docs/_tooltip_delay_rails.md +3 -0
  161. data/app/pb_kits/playbook/pb_tooltip/docs/_tooltip_icon_rails.html.erb +22 -0
  162. data/app/pb_kits/playbook/pb_tooltip/docs/_tooltip_interaction.html.erb +26 -0
  163. data/app/pb_kits/playbook/pb_tooltip/docs/_tooltip_sizing.jsx +69 -0
  164. data/app/pb_kits/playbook/pb_tooltip/docs/_tooltip_sizing.md +3 -0
  165. data/app/pb_kits/playbook/pb_tooltip/docs/example.yml +4 -1
  166. data/app/pb_kits/playbook/pb_tooltip/docs/index.js +1 -0
  167. data/app/pb_kits/playbook/pb_tooltip/floating_ui.js +282 -0
  168. data/app/pb_kits/playbook/pb_tooltip/index.js +2 -2
  169. data/app/pb_kits/playbook/pb_tooltip/tooltip.rb +10 -2
  170. data/app/pb_kits/playbook/pb_typeahead/_typeahead.tsx +51 -5
  171. data/app/pb_kits/playbook/pb_typeahead/components/MultiValue.tsx +5 -1
  172. data/app/pb_kits/playbook/pb_typeahead/docs/_typeahead_dynamic_options.html.erb +45 -0
  173. data/app/pb_kits/playbook/pb_typeahead/docs/_typeahead_dynamic_options.md +5 -0
  174. data/app/pb_kits/playbook/pb_typeahead/docs/_typeahead_dynamic_options_pure_rails.html.erb +33 -0
  175. data/app/pb_kits/playbook/pb_typeahead/docs/_typeahead_dynamic_options_pure_rails.md +3 -0
  176. data/app/pb_kits/playbook/pb_typeahead/docs/_typeahead_react_hook.jsx +66 -0
  177. data/app/pb_kits/playbook/pb_typeahead/docs/_typeahead_react_hook.md +1 -0
  178. data/app/pb_kits/playbook/pb_typeahead/docs/_typeahead_with_pills_async_custom_options.jsx +1 -1
  179. data/app/pb_kits/playbook/pb_typeahead/docs/_typeahead_with_pills_async_users.jsx +1 -1
  180. data/app/pb_kits/playbook/pb_typeahead/docs/example.yml +3 -0
  181. data/app/pb_kits/playbook/pb_typeahead/docs/index.js +1 -0
  182. data/app/pb_kits/playbook/pb_typeahead/index.ts +61 -8
  183. data/app/pb_kits/playbook/pb_typeahead/typeahead.rb +17 -2
  184. data/app/pb_kits/playbook/tokens/_display.scss +3 -1
  185. data/app/pb_kits/playbook/utilities/_display.scss +6 -1
  186. data/app/pb_kits/playbook/utilities/object.test.js +99 -0
  187. data/app/pb_kits/playbook/utilities/object.ts +29 -1
  188. data/app/pb_kits/playbook/utilities/test/globalProps/display.test.js +1 -1
  189. data/dist/chunks/_typeahead-B8f4HM8I.js +36 -0
  190. data/dist/chunks/_weekday_stacked-BVO5G6au.js +45 -0
  191. data/dist/chunks/{lib-D3us1bGD.js → lib-5OzNgeeu.js} +2 -2
  192. data/dist/chunks/{pb_form_validation-BpihMSOQ.js → pb_form_validation-DGhKbZtO.js} +1 -1
  193. data/dist/chunks/vendor.js +1 -1
  194. data/dist/menu.yml +4 -4
  195. data/dist/playbook-doc.js +1 -1
  196. data/dist/playbook-rails-react-bindings.js +1 -1
  197. data/dist/playbook-rails.js +1 -1
  198. data/dist/playbook.css +1 -1
  199. data/lib/playbook/display.rb +2 -2
  200. data/lib/playbook/forms/builder/time_zone_select_field.rb +19 -0
  201. data/lib/playbook/forms/builder.rb +1 -0
  202. data/lib/playbook/version.rb +2 -2
  203. metadata +86 -7
  204. data/app/pb_kits/playbook/pb_tooltip/docs/_tooltip_icon.erb +0 -10
  205. data/dist/chunks/_typeahead-CAIQfP7X.js +0 -36
  206. data/dist/chunks/_weekday_stacked-DstwbGUv.js +0 -45
@@ -1,6 +1,4 @@
1
- /*eslint-disable react/no-multi-comp */
2
-
3
- import React, { forwardRef, useRef } from 'react'
1
+ import React, { useRef, forwardRef } from 'react'
4
2
  import Body from '../pb_body/_body'
5
3
  import Flex from '../pb_flex/_flex'
6
4
  import classnames from 'classnames'
@@ -10,7 +8,7 @@ import { globalProps, GlobalProps } from '../utilities/globalProps'
10
8
  type RadioProps = {
11
9
  aria?: { [key: string]: string },
12
10
  alignment?: string,
13
- checked?: boolean,
11
+ checked?: boolean, // removed default assignment here
14
12
  children?: React.ReactChild[] | React.ReactChild,
15
13
  customChildren?: boolean,
16
14
  className?: string,
@@ -24,10 +22,10 @@ type RadioProps = {
24
22
  name?: string,
25
23
  value?: string,
26
24
  text?: string,
27
- onChange: (event: React.FormEvent<HTMLInputElement> | null) => void,
25
+ onChange?: (event: React.FormEvent<HTMLInputElement> | null) => void,
28
26
  } & GlobalProps
29
27
 
30
- const Radio = ({
28
+ const Radio = forwardRef<HTMLInputElement, RadioProps>(({
31
29
  aria = {},
32
30
  alignment,
33
31
  children,
@@ -43,110 +41,123 @@ const Radio = ({
43
41
  name = 'radio_name',
44
42
  text = 'Radio Text',
45
43
  value = 'radio_text',
44
+ checked,
46
45
  onChange = () => { void 0 },
47
46
  ...props
48
- }: RadioProps, ref: any) => {
49
- const radioRef = useRef(null);
47
+ }, ref) => {
48
+ const internalRef = useRef<HTMLInputElement>(null)
49
+ const setRefs = (el: HTMLInputElement) => {
50
+ internalRef.current = el
51
+ if (typeof ref === 'function') {
52
+ ref(el)
53
+ } else if (ref) {
54
+ (ref as React.MutableRefObject<HTMLInputElement | null>).current = el
55
+ }
56
+ }
57
+
58
+ const ariaProps = buildAriaProps(aria)
59
+ const dataProps = buildDataProps(data)
60
+ const htmlProps = buildHtmlProps(htmlOptions)
50
61
 
51
- const ariaProps = buildAriaProps(aria);
52
- const dataProps = buildDataProps(data);
53
- const htmlProps = buildHtmlProps(htmlOptions);
54
62
  const classes = classnames(
55
63
  buildCss('pb_radio_kit', alignment),
56
64
  dark ? 'dark' : null,
57
65
  error ? 'error' : null,
58
66
  globalProps(props),
59
67
  className
60
- );
68
+ )
61
69
 
62
70
  const classesCustom = classnames(
63
71
  dark ? 'dark' : null,
64
72
  error ? 'error' : null,
65
73
  globalProps(props),
66
74
  className
67
- );
75
+ )
76
+
77
+ const checkedProps = checked !== undefined ? { checked } : {}
68
78
 
69
- const displayRadio = (props: RadioProps & any) => {
70
- if (children && customChildren == false)
71
- return (children)
79
+ const displayRadio = (inputProps: any) => {
80
+ if (children && customChildren === false)
81
+ return children
72
82
  else
73
- return (
74
- <input
75
- disabled={disabled}
76
- id={id}
77
- name={name}
78
- onChange={onChange}
79
- ref={ref}
80
- text={text}
81
- type="radio"
82
- value={value}
83
- {...props}
84
- />
85
- )}
83
+ return (
84
+ <input
85
+ {...checkedProps}
86
+ disabled={disabled}
87
+ id={id}
88
+ name={name}
89
+ onChange={onChange}
90
+ ref={setRefs}
91
+ type="radio"
92
+ value={value}
93
+ {...inputProps}
94
+ />
95
+ )
96
+ }
86
97
 
87
98
  const handleContainerClick = (event: React.MouseEvent<HTMLDivElement, MouseEvent> | undefined) => {
88
99
  if (event) {
89
- const target = event.target as HTMLElement;
100
+ const target = event.target as HTMLElement
90
101
  if (
91
102
  target.id === 'pb-radio-children-wrapper' ||
92
103
  target.closest('#pb-radio-children-wrapper')
93
104
  ) {
94
- radioRef.current?.click();
105
+ internalRef.current?.click()
95
106
  }
96
107
  }
97
- };
108
+ }
98
109
 
99
- return (
100
- customChildren ? (
101
- <Flex
102
- {...ariaProps}
103
- {...dataProps}
104
- {...htmlProps}
105
- align='center'
106
- className={classesCustom}
107
- cursor='pointer'
108
- htmlFor={id}
109
- htmlOptions={{
110
- onClick: ((event: React.MouseEvent<HTMLDivElement, MouseEvent>) => {
111
- handleContainerClick(event);
112
- }) as unknown as () => void
113
- }}
114
- id="radio-container"
115
- >
116
- <label className={buildCss('pb_radio_kit', alignment)}>
110
+ return customChildren ? (
111
+ <Flex
112
+ {...ariaProps}
113
+ {...dataProps}
114
+ {...htmlProps}
115
+ align="center"
116
+ className={classesCustom}
117
+ cursor="pointer"
118
+ htmlFor={id}
119
+ htmlOptions={{
120
+ onClick: ((event: React.MouseEvent<HTMLDivElement, MouseEvent>) => {
121
+ handleContainerClick(event)
122
+ }) as unknown as () => void
123
+ }}
124
+ id="radio-container"
125
+ >
126
+ <label className={buildCss('pb_radio_kit', alignment)}>
117
127
  <input
128
+ {...checkedProps}
118
129
  disabled={disabled}
119
130
  id={id}
120
131
  name={name}
121
132
  onChange={onChange}
122
- ref={radioRef}
133
+ ref={setRefs}
123
134
  type="radio"
124
135
  value={value}
125
136
  {...props}
126
137
  />
127
- <span className="pb_radio_button" />
128
- </label>
129
- <div id="pb-radio-children-wrapper"> {children} </div>
130
- </Flex>
131
- ) : (
132
- <label
133
- {...ariaProps}
134
- {...dataProps}
135
- {...htmlProps}
136
- className={classes}
137
- htmlFor={id}
138
- >
139
- <>{displayRadio(props)}</>
140
138
  <span className="pb_radio_button" />
141
- <Body
142
- dark={dark}
143
- status={error ? 'negative' : null}
144
- text={label}
145
- variant={null}
146
- />
147
139
  </label>
148
- )
149
- );
150
- };
140
+ <div id="pb-radio-children-wrapper"> {children} </div>
141
+ </Flex>
142
+ ) : (
143
+ <label
144
+ {...ariaProps}
145
+ {...dataProps}
146
+ {...htmlProps}
147
+ className={classes}
148
+ htmlFor={id}
149
+ >
150
+ {displayRadio(props)}
151
+ <span className="pb_radio_button" />
152
+ <Body
153
+ dark={dark}
154
+ status={error ? 'negative' : null}
155
+ text={label}
156
+ variant={null}
157
+ />
158
+ </label>
159
+ )
160
+ })
151
161
 
152
- export default forwardRef(Radio);
162
+ Radio.displayName = "Radio"
163
+ export default Radio
@@ -0,0 +1,60 @@
1
+ import React from "react"
2
+ import { useForm } from "react-hook-form"
3
+ import { Radio, Flex, Body } from "playbook-ui"
4
+
5
+ const RadioReactHook = () => {
6
+ const { register, watch } = useForm({
7
+ defaultValues: {
8
+ size: "Small",
9
+ },
10
+ })
11
+
12
+ const selectedSize = watch("size", "Small")
13
+
14
+ return (
15
+ <Flex orientation="row">
16
+ <Flex
17
+ align="start"
18
+ orientation="column"
19
+ paddingRight="lg"
20
+ >
21
+ <Radio
22
+ alignment="left"
23
+ label="Small"
24
+ marginBottom='sm'
25
+ name="size"
26
+ value="Small"
27
+ {...register("size")}
28
+ />
29
+ <br />
30
+ <Radio
31
+ alignment="left"
32
+ label="Medium"
33
+ marginBottom='sm'
34
+ name="size"
35
+ value="Medium"
36
+ {...register("size")}
37
+ />
38
+ <br />
39
+ <Radio
40
+ alignment="left"
41
+ label="Large"
42
+ marginBottom='sm'
43
+ name="size"
44
+ value="Large"
45
+ {...register("size")}
46
+ />
47
+ </Flex>
48
+ <Flex
49
+ align="start"
50
+ orientation="column"
51
+ >
52
+ <Body
53
+ text={`Selected Size: ${selectedSize}`}
54
+ />
55
+ </Flex>
56
+ </Flex>
57
+ )
58
+ }
59
+
60
+ export default RadioReactHook
@@ -0,0 +1 @@
1
+ You can pass react hook props to the radio kit.
@@ -16,6 +16,7 @@ examples:
16
16
  - radio_alignment: Alignment
17
17
  - radio_disabled: Disabled
18
18
  - radio_custom_children: Custom Children
19
+ - radio_react_hook: React Hook Form
19
20
 
20
21
  swift:
21
22
  - radio_default_swift: Default
@@ -26,4 +27,4 @@ examples:
26
27
  - radio_spacing_swift: Spacing
27
28
  - radio_padding_swift: Padding
28
29
  - radio_subtitle_swift: Subtitle
29
- - radio_props_swift: ""
30
+ - radio_props_swift: ""
@@ -4,3 +4,4 @@ export { default as RadioError } from './_radio_error.jsx'
4
4
  export { default as RadioAlignment } from './_radio_alignment.jsx'
5
5
  export { default as RadioDisabled } from './_radio_disabled.jsx'
6
6
  export { default as RadioCustomChildren } from './_radio_custom_children.jsx'
7
+ export { default as RadioReactHook } from './_radio_react_hook.jsx'
@@ -7,26 +7,21 @@
7
7
  data: object.data,
8
8
  **combined_html_options
9
9
  }) do %>
10
- <%= content_tag(:label,
10
+ <%= pb_content_tag(:label,
11
11
  'data-pb-radio-children': 'true',
12
12
  checked: object.checked,
13
- class: object.classname,
14
- id: object.id,
15
- value: object.value) do %>
13
+ value: object.value
14
+ ) do %>
16
15
  <%= input %>
17
16
  <span class="pb_radio_button"></span>
18
17
  <% end %>
19
18
  <div data-pb-radio-children-wrapper="true"> <%= content %> </div>
20
19
  <% end %>
21
20
  <% else %>
22
- <%= content_tag(:label,
23
- aria: object.aria,
21
+ <%= pb_content_tag(:label,
24
22
  checked: object.checked,
25
- class: object.classname,
26
- data: object.data,
27
- id: object.id,
28
23
  value: object.value,
29
- **combined_html_options) do %>
24
+ ) do %>
30
25
 
31
26
  <% if content.present? %>
32
27
  <%= content %>
@@ -37,4 +32,4 @@
37
32
  <span class="pb_radio_button"></span>
38
33
  <%= pb_rails("body", props: { status: object.body_status, text: object.text, dark: object.dark }) %>
39
34
  <% end %>
40
- <% end %>
35
+ <% end %>
@@ -86,3 +86,19 @@ test('has disabled attribute', () => {
86
86
  expect(input).toHaveAttribute('disabled')
87
87
  })
88
88
 
89
+
90
+ test('has ref in the input element', () => {
91
+ const ref = React.createRef()
92
+ render(
93
+ <Radio
94
+ data={{ testid: testId }}
95
+ name="Radio-name"
96
+ ref={ref}
97
+ text="Radio"
98
+ value="radio value"
99
+ />
100
+ )
101
+
102
+ expect(ref.current).not.toBeNull()
103
+ expect(ref.current?.tagName).toBe('INPUT')
104
+ })
@@ -0,0 +1,58 @@
1
+ import React, { useState } from "react"
2
+ import { useForm } from "react-hook-form"
3
+ import { Button, Body, Select } from "playbook-ui"
4
+
5
+ const SelectReactHook = (props) => {
6
+ const { register, handleSubmit, formState: { errors } } = useForm({
7
+ defaultValues: {
8
+ food: '',
9
+ },
10
+ })
11
+
12
+ const [submittedData, setSubmittedData] = useState({
13
+ food: '',
14
+ })
15
+
16
+ const onSubmit = (data) => {
17
+ setSubmittedData(data)
18
+ }
19
+
20
+ const options = [
21
+ {
22
+ value: 1,
23
+ text: 'Burgers',
24
+ },
25
+ {
26
+ value: 2,
27
+ text: 'Pizza',
28
+ },
29
+ {
30
+ value: 3,
31
+ text: 'Tacos',
32
+ },
33
+ ]
34
+
35
+ return (
36
+ <>
37
+ <form onSubmit={handleSubmit(onSubmit)}>
38
+ <Select
39
+ {...props}
40
+ {...register("food", { required: true })}
41
+ error={errors.food ? "Please select a food." : null}
42
+ label="Favorite Food"
43
+ options={options}
44
+ />
45
+ <br />
46
+ <Button htmlType="submit"
47
+ marginTop="sm"
48
+ text="Submit"
49
+ />
50
+ </form>
51
+ <Body padding="xs"
52
+ text={`Food: ${submittedData.food}`}
53
+ />
54
+ </>
55
+ )
56
+ }
57
+
58
+ export default SelectReactHook
@@ -0,0 +1 @@
1
+ You can pass react-hook-form props to a select kit. You can use `register` which will make the value available for both the form validation and submission.
@@ -30,6 +30,7 @@ examples:
30
30
  - select_inline_show_arrow: Select Inline (Always Show Arrow)
31
31
  - select_inline_compact: Select Inline Compact
32
32
  - select_multiple: Select Multiple
33
+ - select_react_hook: React Hook
33
34
 
34
35
  swift:
35
36
  - select_default_swift: Default
@@ -10,3 +10,4 @@ export { default as SelectInline } from './_select_inline.jsx'
10
10
  export { default as SelectInlineShowArrow } from './_select_inline_show_arrow.jsx'
11
11
  export { default as SelectInlineCompact } from './_select_inline_compact.jsx'
12
12
  export { default as SelectMultiple } from './_select_multiple.jsx'
13
+ export { default as SelectReactHook } from './_select_react_hook.jsx'
@@ -0,0 +1,38 @@
1
+ import PbEnhancedElement from "../pb_enhanced_element";
2
+
3
+ const SELECT_WRAPPER_SELECTOR = "[data-pb-select]";
4
+ const SELECT_VALIDATION_MESSAGE_CLASS = ".pb_body_kit_negative";
5
+
6
+ export default class PbSelect extends PbEnhancedElement {
7
+ static get selector() {
8
+ return SELECT_WRAPPER_SELECTOR;
9
+ }
10
+
11
+ connect() {
12
+ this.setValidationMessage();
13
+ }
14
+
15
+ setValidationMessage() {
16
+ const validationMessage = this.element.dataset?.validationMessage;
17
+
18
+ if (validationMessage) {
19
+ const selectElement = this.element.querySelector("select");
20
+ const setErrorTextContent = (text, timeout) => {
21
+ setTimeout(() => {
22
+ const errorMessageElement = this.element.querySelector(SELECT_VALIDATION_MESSAGE_CLASS);
23
+ if (errorMessageElement) {
24
+ errorMessageElement.textContent = text;
25
+ } else {
26
+ setErrorTextContent(text, 100);
27
+ }
28
+ }, timeout);
29
+ };
30
+
31
+ selectElement.addEventListener("change", (e) => {
32
+ if (!e.target.checkValidity()) {
33
+ setErrorTextContent(validationMessage, 300);
34
+ }
35
+ });
36
+ }
37
+ }
38
+ }
@@ -1,8 +1,6 @@
1
- <%= content_tag(:div,
2
- aria: object.aria,
3
- data: object.data,
4
- class: object.classnames,
5
- **combined_html_options) do %>
1
+ <%= pb_content_tag(:div,
2
+ id: nil,
3
+ class: object.classnames ) do %>
6
4
  <% if object.label %>
7
5
  <label class="pb_select_kit_label" for="<%= object.name %>">
8
6
  <%= pb_rails("caption", props: { text: object.label, dark: object.dark }) %>
@@ -21,6 +21,7 @@ module Playbook
21
21
  prop :options, type: Playbook::Props::HashArray, required: false, default: []
22
22
  prop :show_arrow, type: Playbook::Props::Boolean, default: false
23
23
  prop :required, type: Playbook::Props::Boolean, default: false
24
+ prop :validation_message, type: Playbook::Props::String, default: ""
24
25
 
25
26
  def classnames
26
27
  classname + inline_class + compact_class + show_arrow_class
@@ -88,6 +89,13 @@ module Playbook
88
89
  "app/pb_kits/playbook/utilities/icons/angle-down.svg"
89
90
  end
90
91
 
92
+ def data_attributes
93
+ data = attributes[:data] || {}
94
+ data.merge!("data-pb-select" => true)
95
+ data.merge!("data-validation-message" => validation_message) if validation_message.present?
96
+ data
97
+ end
98
+
91
99
  private
92
100
 
93
101
  def error_class
@@ -1,8 +1,4 @@
1
- <%= content_tag(:div,
2
- id: object.id,
3
- data: object.data,
4
- class: object.classname,
5
- **combined_html_options) do %>
1
+ <%= pb_content_tag do %>
6
2
 
7
3
  <% if object.multi %>
8
4
  <%= check_box_tag(object.name, object.value, object.checked, object.additional_input_options) %>
@@ -1,7 +1,4 @@
1
- <%= content_tag(:div,
2
- data: object.data,
3
- class: object.classname,
4
- **combined_html_options) do %>
1
+ <%= pb_content_tag do %>
5
2
 
6
3
  <%= pb_rails("selectable_card", props: {
7
4
  input_id: object.input_id,
@@ -1,8 +1,4 @@
1
- <%= content_tag(:div,
2
- id: object.id,
3
- data: object.data,
4
- class: object.classname,
5
- **combined_html_options) do %>
1
+ <%= pb_content_tag do %>
6
2
 
7
3
  <% if object.inputs == "disabled" %>
8
4
 
@@ -17,7 +17,7 @@ const formatCurrencyDefaultValue = (value: string): string => {
17
17
 
18
18
  // Parse the numeric value as a float to handle decimals
19
19
  const dollars = parseFloat(numericValue)
20
- if (isNaN(dollars) || dollars === 0) return ''
20
+ if (isNaN(dollars)) return ''
21
21
 
22
22
  // Format as currency
23
23
  return new Intl.NumberFormat('en-US', {
@@ -30,10 +30,9 @@ const formatCurrencyDefaultValue = (value: string): string => {
30
30
  const formatCurrency = (value: string): string => {
31
31
  const numericValue = value.replace(/[^0-9]/g, '').slice(0, 15)
32
32
 
33
- if (!numericValue) return ''
33
+ if (!numericValue || numericValue === "00") return ''
34
34
 
35
35
  const dollars = parseFloat((parseInt(numericValue) / 100).toFixed(2))
36
- if (dollars === 0) return ''
37
36
 
38
37
  return new Intl.NumberFormat('en-US', {
39
38
  style: 'currency',
@@ -243,7 +243,7 @@ $gap_lg: $height_from_top + $space_lg;
243
243
  }
244
244
  [class=pb_timeline_item_left_block] {
245
245
  margin-bottom: $space_lg;
246
- width: $space_lg;
246
+ min-width: $space_lg;
247
247
  }
248
248
  [class=pb_timeline_item_right_block] {
249
249
  @include flex_wrapper(column);
@@ -263,7 +263,7 @@ $gap_lg: $height_from_top + $space_lg;
263
263
  }
264
264
  [class=pb_timeline_item_left_block] {
265
265
  margin-bottom: $space_lg;
266
- width: $space_lg;
266
+ min-width: $space_lg;
267
267
  }
268
268
  [class=pb_timeline_item_right_block] {
269
269
  @include flex_wrapper(column);
@@ -31,6 +31,38 @@
31
31
  @include pb_title_thin;
32
32
  }
33
33
 
34
+ &[class*=_display] {
35
+ font-size: clamp(24px, calc(1.25vw + 5.3vw), 128px);
36
+ }
37
+
38
+ &[class*=_dynamic] {
39
+ &[class*=_xs] {
40
+ font-size: min(2vw, 80vw / 16);
41
+ }
42
+
43
+ &[class*=_sm] {
44
+ font-size: min(2.5vw, 96vw / 16);
45
+ }
46
+
47
+ &[class*=_md] {
48
+ font-size: min(4vw, 160vw / 16);
49
+ }
50
+
51
+ &[class*=_lg] {
52
+ font-size: min(5vw, 192vw / 16);
53
+ }
54
+
55
+ &[class*=_xl] {
56
+ font-size: min(6vw, 224vw / 16);
57
+ }
58
+
59
+ &[class*=_xxl] {
60
+ font-size: min(8vw, 256vw / 16);
61
+ }
62
+ }
63
+
64
+
65
+
34
66
  @each $size, $size_value in $breakpoints_grid {
35
67
  @for $title_size_value from 1 through 4 {
36
68
  $min_size: map-get($size_value, "min");
@@ -3,7 +3,7 @@ import classnames from 'classnames'
3
3
  import { buildAriaProps, buildCss, buildDataProps, buildHtmlProps } from '../utilities/props'
4
4
  import { deprecatedProps, GlobalProps, globalProps } from '../utilities/globalProps'
5
5
 
6
- type SizeType = 1 | 2 | 3 | 4 | "1" | "2" | "3" | "4"
6
+ type SizeType = 1 | 2 | 3 | 4 | "1" | "2" | "3" | "4" | "display"
7
7
  type SizeResponsiveType = {[key: string]: SizeType}
8
8
 
9
9
  type TitleProps = {
@@ -16,6 +16,7 @@ type TitleProps = {
16
16
  htmlOptions?: {[key: string]: string | number | boolean | (() => void)},
17
17
  id?: string,
18
18
  size?: SizeType | SizeResponsiveType,
19
+ displaySize?: null | "xs" | "sm" | "md" | "lg" | "xl" | "xxl",
19
20
  tag?: "h1" | "h2" | "h3" | "h4" | "h5" | "h6" | "div" | "span",
20
21
  text?: string,
21
22
  variant?: null | "link",
@@ -32,6 +33,7 @@ const Title = (props: TitleProps): React.ReactElement => {
32
33
  htmlOptions = {},
33
34
  id,
34
35
  size = 3,
36
+ displaySize = null,
35
37
  bold = true,
36
38
  tag = 'h3',
37
39
  text,
@@ -56,9 +58,16 @@ const Title = (props: TitleProps): React.ReactElement => {
56
58
  return css.trim()
57
59
  }
58
60
 
61
+ const buildDisplaySize = () => {
62
+ if (displaySize) {
63
+ return `pb_title_kit_dynamic_${displaySize}`
64
+ }
65
+ }
66
+
59
67
  const classes = classnames(
60
68
  buildCss('pb_title_kit', isSizeNumberOrString ? `size_${size}` : "", variant, color, getBold),
61
69
  globalProps(props),
70
+ buildDisplaySize(),
62
71
  buildResponsiveSizeCss(),
63
72
  className
64
73
  )