playbook_ui 14.2.1 → 14.3.0.pre.alpha.revert3654PBNTR479removeextraspacingfromradiochildren3734

Sign up to get free protection for your applications and to get access to all the features.
Files changed (102) hide show
  1. checksums.yaml +4 -4
  2. data/app/pb_kits/playbook/pb_avatar_action_button/_avatar_action_button.scss +3 -3
  3. data/app/pb_kits/playbook/pb_badge/_badge.scss +2 -2
  4. data/app/pb_kits/playbook/pb_bread_crumbs/_bread_crumbs.scss +1 -1
  5. data/app/pb_kits/playbook/pb_button/_button.scss +1 -1
  6. data/app/pb_kits/playbook/pb_button_toolbar/_button_toolbar_mixins.scss +2 -2
  7. data/app/pb_kits/playbook/pb_circle_icon_button/_circle_icon_button.scss +1 -1
  8. data/app/pb_kits/playbook/pb_circle_icon_button/_circle_icon_button.tsx +3 -0
  9. data/app/pb_kits/playbook/pb_circle_icon_button/circle_icon_button.html.erb +1 -1
  10. data/app/pb_kits/playbook/pb_circle_icon_button/circle_icon_button.rb +2 -0
  11. data/app/pb_kits/playbook/pb_circle_icon_button/circle_icon_button.test.js +15 -0
  12. data/app/pb_kits/playbook/pb_circle_icon_button/docs/_circle_icon_button_loading.html.erb +29 -0
  13. data/app/pb_kits/playbook/pb_circle_icon_button/docs/_circle_icon_button_loading.jsx +43 -0
  14. data/app/pb_kits/playbook/pb_circle_icon_button/docs/example.yml +2 -0
  15. data/app/pb_kits/playbook/pb_circle_icon_button/docs/index.js +1 -0
  16. data/app/pb_kits/playbook/pb_collapsible/child_kits/CollapsibleIcon.tsx +30 -24
  17. data/app/pb_kits/playbook/pb_collapsible/collapsible_main.html.erb +11 -7
  18. data/app/pb_kits/playbook/pb_collapsible/collapsible_main.rb +2 -0
  19. data/app/pb_kits/playbook/pb_collapsible/docs/_collapsible_no_icon.html.erb +10 -0
  20. data/app/pb_kits/playbook/pb_collapsible/docs/_collapsible_no_icon.jsx +21 -0
  21. data/app/pb_kits/playbook/pb_collapsible/docs/example.yml +2 -0
  22. data/app/pb_kits/playbook/pb_collapsible/docs/index.js +2 -1
  23. data/app/pb_kits/playbook/pb_date_picker/sass_partials/_input_styles.scss +1 -1
  24. data/app/pb_kits/playbook/pb_date_picker/sass_partials/_overrides.scss +2 -2
  25. data/app/pb_kits/playbook/pb_date_range_inline/_date_range_inline.scss +4 -4
  26. data/app/pb_kits/playbook/pb_date_time_stacked/_date_time_stacked.scss +4 -4
  27. data/app/pb_kits/playbook/pb_dialog/dialog.html.erb +4 -1
  28. data/app/pb_kits/playbook/pb_dialog/dialog.rb +3 -0
  29. data/app/pb_kits/playbook/pb_dialog/dialogHelper.js +21 -0
  30. data/app/pb_kits/playbook/pb_dialog/dialog_footer.html.erb +4 -2
  31. data/app/pb_kits/playbook/pb_dialog/dialog_footer.rb +10 -1
  32. data/app/pb_kits/playbook/pb_dialog/docs/_dialog_loading.html.erb +13 -0
  33. data/app/pb_kits/playbook/pb_dialog/docs/_dialog_loading.md +3 -0
  34. data/app/pb_kits/playbook/pb_dialog/docs/example.yml +1 -0
  35. data/app/pb_kits/playbook/pb_dropdown/_dropdown.scss +1 -1
  36. data/app/pb_kits/playbook/pb_form_pill/_form_pill.scss +2 -2
  37. data/app/pb_kits/playbook/pb_hashtag/_hashtag.tsx +16 -2
  38. data/app/pb_kits/playbook/pb_hashtag/docs/_hashtag_link.html.erb +1 -1
  39. data/app/pb_kits/playbook/pb_hashtag/docs/_hashtag_link.jsx +1 -1
  40. data/app/pb_kits/playbook/pb_hashtag/docs/_hashtag_link.md +1 -1
  41. data/app/pb_kits/playbook/pb_hashtag/hashtag.html.erb +1 -1
  42. data/app/pb_kits/playbook/pb_hashtag/hashtag.rb +9 -2
  43. data/app/pb_kits/playbook/pb_home_address_street/_home_address_street.tsx +16 -0
  44. data/app/pb_kits/playbook/pb_home_address_street/city_emphasis.html.erb +1 -0
  45. data/app/pb_kits/playbook/pb_home_address_street/city_emphasis.rb +11 -0
  46. data/app/pb_kits/playbook/pb_home_address_street/docs/_home_address_street_link.html.erb +1 -1
  47. data/app/pb_kits/playbook/pb_home_address_street/docs/_home_address_street_link.jsx +1 -1
  48. data/app/pb_kits/playbook/pb_home_address_street/docs/_home_address_street_link.md +1 -1
  49. data/app/pb_kits/playbook/pb_home_address_street/home_address_street.rb +13 -0
  50. data/app/pb_kits/playbook/pb_home_address_street/home_adress_street.test.js +2 -2
  51. data/app/pb_kits/playbook/pb_home_address_street/street_emphasis.html.erb +2 -1
  52. data/app/pb_kits/playbook/pb_home_address_street/street_emphasis.rb +11 -0
  53. data/app/pb_kits/playbook/pb_icon/icon.rb +8 -0
  54. data/app/pb_kits/playbook/pb_icon_circle/_icon_circle.scss +1 -1
  55. data/app/pb_kits/playbook/pb_label_value/_label_value.scss +1 -1
  56. data/app/pb_kits/playbook/pb_message/_message_mixins.scss +1 -1
  57. data/app/pb_kits/playbook/pb_multiple_users/_multiple_users.scss +1 -1
  58. data/app/pb_kits/playbook/pb_nav/docs/_collapsible_nav_no_icon.html.erb +24 -0
  59. data/app/pb_kits/playbook/pb_nav/docs/_collapsible_nav_no_icon.jsx +88 -0
  60. data/app/pb_kits/playbook/pb_nav/docs/_collapsible_nav_no_icon_rails.md +1 -0
  61. data/app/pb_kits/playbook/pb_nav/docs/_collapsible_nav_no_icon_react.md +1 -0
  62. data/app/pb_kits/playbook/pb_nav/docs/example.yml +2 -0
  63. data/app/pb_kits/playbook/pb_nav/docs/index.js +4 -3
  64. data/app/pb_kits/playbook/pb_pagination/_pagination.scss +3 -1
  65. data/app/pb_kits/playbook/pb_passphrase/_passphrase.scss +3 -3
  66. data/app/pb_kits/playbook/pb_phone_number_input/_phone_number_input.scss +2 -2
  67. data/app/pb_kits/playbook/pb_phone_number_input/intlTelInput.scss +1290 -0
  68. data/app/pb_kits/playbook/pb_pill/_pill.scss +2 -2
  69. data/app/pb_kits/playbook/pb_progress_simple/_progress_simple.scss +2 -2
  70. data/app/pb_kits/playbook/pb_radio/_radio.tsx +100 -50
  71. data/app/pb_kits/playbook/pb_radio/docs/_radio_children.jsx +56 -0
  72. data/app/pb_kits/playbook/pb_radio/docs/example.yml +1 -0
  73. data/app/pb_kits/playbook/pb_radio/docs/index.js +1 -0
  74. data/app/pb_kits/playbook/pb_rich_text_editor/_previewer_mixin.scss +49 -13
  75. data/app/pb_kits/playbook/pb_rich_text_editor/_rich_text_editor.scss +2 -14
  76. data/app/pb_kits/playbook/pb_rich_text_editor/_tiptap_styles.scss +23 -23
  77. data/app/pb_kits/playbook/pb_rich_text_editor/_trix_styles.scss +19 -27
  78. data/app/pb_kits/playbook/pb_rich_text_editor/docs/_rich_text_editor_preview.html.erb +21 -11
  79. data/app/pb_kits/playbook/pb_select/_select.scss +1 -1
  80. data/app/pb_kits/playbook/pb_selectable_card/_selectable_card.scss +3 -3
  81. data/app/pb_kits/playbook/pb_star_rating/docs/_star_rating_default_value.html.erb +1 -0
  82. data/app/pb_kits/playbook/pb_star_rating/docs/example.yml +1 -0
  83. data/app/pb_kits/playbook/pb_star_rating/index.js +11 -1
  84. data/app/pb_kits/playbook/pb_star_rating/star_rating.rb +3 -1
  85. data/app/pb_kits/playbook/pb_text_input/_text_input.scss +1 -1
  86. data/app/pb_kits/playbook/pb_textarea/_textarea.scss +1 -1
  87. data/app/pb_kits/playbook/pb_time_range_inline/_time_range_inline.scss +4 -4
  88. data/app/pb_kits/playbook/pb_timeline/_timeline.scss +2 -2
  89. data/app/pb_kits/playbook/pb_timestamp/docs/_timestamp_elapsed.html.erb +2 -2
  90. data/app/pb_kits/playbook/pb_timestamp/timestamp.rb +46 -2
  91. data/app/pb_kits/playbook/pb_toggle/_toggle.scss +3 -3
  92. data/dist/chunks/{_typeahead-Cq7RLPBA.js → _typeahead-BWUFVlae.js} +3 -3
  93. data/dist/chunks/{_weekday_stacked-Cykj5kLZ.js → _weekday_stacked-DpRkKl3_.js} +2 -2
  94. data/dist/chunks/{lib-DErGXNy3.js → lib-D9uVVKnh.js} +1 -1
  95. data/dist/chunks/{pb_form_validation-BC6kh7Hu.js → pb_form_validation-u2wnZ3oe.js} +1 -1
  96. data/dist/chunks/vendor.js +1 -1
  97. data/dist/playbook-doc.js +1 -1
  98. data/dist/playbook-rails-react-bindings.js +1 -1
  99. data/dist/playbook-rails.js +1 -1
  100. data/dist/playbook.css +1 -1
  101. data/lib/playbook/version.rb +2 -2
  102. metadata +22 -9
@@ -1,7 +1,7 @@
1
1
 
2
2
  <%= pb_rails("rich_text_editor", props: { id: "content-preview-editor" }) %>
3
3
  <div id="card-obfuscation" style="display:none">
4
- <%= pb_rails("card", props: { margin_top: "md" }) do %>
4
+ <%= pb_rails("card", props: { margin_top: "md", max_width: "md", padding: "sm" }) do %>
5
5
  <div id="content-preview" class="trix-content">
6
6
  </div>
7
7
  <% end %>
@@ -11,15 +11,25 @@
11
11
  <% end %>
12
12
 
13
13
  <script>
14
- // Button event handler
15
- const button = document.getElementById('preview-button');
16
- button.addEventListener('click', function() {
17
- const content = document.getElementById('content-preview-editor');
18
- const previewArea = document.getElementById('content-preview');
19
- const cardDiv = document.getElementById('card-obfuscation');
14
+ document.addEventListener('DOMContentLoaded', () => {
15
+ function handleButtonClick() {
16
+ const editorContainer = [...document.querySelectorAll('[data-react-props]')]
17
+ .find(element => element.getAttribute('data-react-props')?.includes('"id":"content-preview-editor"'))
20
18
 
21
- previewArea.innerHTML = content.value;
22
- cardDiv.classList.add('mt_md');
23
- cardDiv.style.display = 'block';
24
- });
19
+ const editorElement = editorContainer?.querySelector('trix-editor')
20
+ const inputId = editorElement?.getAttribute('input')
21
+ const inputElement = inputId && document.getElementById(inputId)
22
+
23
+ const editorContent = inputElement?.value || ''
24
+ const previewArea = document.getElementById('content-preview')
25
+ const cardDiv = document.getElementById('card-obfuscation')
26
+
27
+ if (previewArea && cardDiv) {
28
+ previewArea.innerHTML = editorContent
29
+ cardDiv.style.display = 'block'
30
+ }
31
+ }
32
+
33
+ document.getElementById('preview-button')?.addEventListener('click', handleButtonClick)
34
+ })
25
35
  </script>
@@ -81,7 +81,7 @@
81
81
  display: block;
82
82
  &.error {
83
83
  [class*=pb_body_kit] {
84
- margin-top: calc($space_xs / 2);
84
+ margin-top: $space_xs / 2;
85
85
  }
86
86
  > select:first-child {
87
87
  border-color: $error;
@@ -43,7 +43,7 @@ $pb_selectable_card_border: 2px;
43
43
  align-items: center;
44
44
  height: $pb_selectable_card_indicator_size;
45
45
  width: $pb_selectable_card_indicator_size;
46
- border-radius: calc($pb_selectable_card_indicator_size/2) + calc($pb_selectable_card_border/2);
46
+ border-radius: $pb_selectable_card_indicator_size/2 + $pb_selectable_card_border/2;
47
47
  border-width: $pb_selectable_card_border;
48
48
  border-style: solid;
49
49
  border-color: $white;
@@ -52,8 +52,8 @@ $pb_selectable_card_border: 2px;
52
52
  font-size: $font_smaller;
53
53
  text-align: center;
54
54
  position: absolute;
55
- top: -(calc($pb_selectable_card_indicator_size/2));
56
- right: -(calc($pb_selectable_card_indicator_size/2));
55
+ top: -($pb_selectable_card_indicator_size/2);
56
+ right: -($pb_selectable_card_indicator_size/2);
57
57
  opacity: 0;
58
58
  }
59
59
  }
@@ -0,0 +1 @@
1
+ <%= pb_rails("star_rating", props: { default_value: "2", padding_bottom: "xs", variant: "interactive" }) %>
@@ -7,6 +7,7 @@ examples:
7
7
  - star_rating_number_config: Number Config
8
8
  - star_rating_size_options: Size Options
9
9
  - star_rating_interactive: Interactive
10
+ - star_rating_default_value: Default Value
10
11
 
11
12
  react:
12
13
  - star_rating_default: Default
@@ -12,6 +12,7 @@ export default class PbStarRating extends PbEnhancedElement {
12
12
  connect() {
13
13
  this.addEventListeners()
14
14
  this.handleFormReset()
15
+ this.setDefaultValue()
15
16
  }
16
17
 
17
18
  addEventListeners() {
@@ -128,7 +129,7 @@ export default class PbStarRating extends PbEnhancedElement {
128
129
  const form = this.element.closest("form")
129
130
  if (form) {
130
131
  form.addEventListener("reset", () => {
131
- this.updateHiddenInputValue("")
132
+ this.element.querySelector(STAR_RATING_INPUT_DATA_SELECTOR)?.setAttribute("value","")
132
133
  this.resetStarRatingValues()
133
134
  })
134
135
  }
@@ -153,4 +154,13 @@ export default class PbStarRating extends PbEnhancedElement {
153
154
  }
154
155
  }
155
156
  }
157
+
158
+ setDefaultValue() {
159
+ const hiddenInput = this.element.querySelector(STAR_RATING_INPUT_DATA_SELECTOR)
160
+ const defaultValue = hiddenInput.value
161
+
162
+ if (defaultValue) {
163
+ this.updateStarColors(defaultValue)
164
+ }
165
+ }
156
166
  }
@@ -34,6 +34,7 @@ module Playbook
34
34
  default: false
35
35
  prop :input_options, type: Playbook::Props::HashProp,
36
36
  default: {}
37
+ prop :default_value
37
38
 
38
39
  def one_decimal_rating
39
40
  rating.to_f.round(1)
@@ -120,7 +121,8 @@ module Playbook
120
121
  data: { "pb-star-rating-input": true },
121
122
  name: name,
122
123
  required: required,
123
- style: "display: none"
124
+ style: "display: none",
125
+ value: default_value || ""
124
126
  )
125
127
  end
126
128
  end
@@ -101,7 +101,7 @@
101
101
  &.error {
102
102
  .text_input_wrapper {
103
103
  [class*="pb_body_kit"] {
104
- margin-top: calc($space_xs / 2);
104
+ margin-top: $space_xs / 2;
105
105
  }
106
106
  input,
107
107
  .text_input {
@@ -60,7 +60,7 @@
60
60
 
61
61
  &.error {
62
62
  [class*=pb_body_kit] {
63
- margin-top: calc($space_xs / 2);
63
+ margin-top: $space_xs / 2;
64
64
  }
65
65
  textarea {
66
66
  border-color: $error;
@@ -22,14 +22,14 @@
22
22
  display: flex;
23
23
  align-items: center;
24
24
  [class*=pb_time_range_inline_arrow] {
25
- margin-left: calc($space_xs/2);
26
- margin-right: calc($space_xs/2);
25
+ margin-left: $space_xs/2;
26
+ margin-right: $space_xs/2;
27
27
  }
28
28
  [class*=pb_time_range_inline_timezone] {
29
- margin-left: calc($space_xs/2);
29
+ margin-left: $space_xs/2;
30
30
  }
31
31
  [class*=pb_time_range_inline_icon] {
32
- margin-right: calc($space_xs/2);
32
+ margin-right: $space_xs/2;
33
33
  }
34
34
  }
35
35
  }
@@ -4,9 +4,9 @@
4
4
  @import "../tokens/typography";
5
5
 
6
6
  $connector_width: 2px;
7
- $icon_margin: calc($space_xs/2);
7
+ $icon_margin: $space_xs/2;
8
8
  $icon_height: 28px;
9
- $height_from_top: calc($icon_height/2) - calc($connector_width/2);
9
+ $height_from_top: $icon_height/2 - $connector_width/2;
10
10
 
11
11
  @mixin pb_timeline_line_solid($width, $height, $margin) {
12
12
  width: $width;
@@ -8,7 +8,7 @@
8
8
  <br>
9
9
 
10
10
  <%= pb_rails("timestamp", props: {
11
- timestamp: DateTime.now,
11
+ timestamp: DateTime.now - 3.months,
12
12
  variant: "elapsed",
13
13
  show_user: false
14
14
  }) %>
@@ -16,7 +16,7 @@
16
16
  <br>
17
17
 
18
18
  <%= pb_rails("timestamp", props: {
19
- timestamp: DateTime.now,
19
+ timestamp: DateTime.now - 320.days,
20
20
  variant: "elapsed",
21
21
  show_user: false,
22
22
  hide_updated: true
@@ -27,6 +27,18 @@ module Playbook
27
27
  values: %w[default elapsed updated],
28
28
  default: "default"
29
29
 
30
+ # Variables to use with pb_time_ago method
31
+ SECS_FORTY_FIVE = 45
32
+ SECS_PER_MIN = 60
33
+ SECS_PER_HOUR = 60 * SECS_PER_MIN # 3,600 seconds
34
+ SECS_PER_DAY = 24 * SECS_PER_HOUR # 86,400 seconds
35
+ SECS_PER_WEEK = 7 * SECS_PER_DAY # 604,800 seconds
36
+ SECS_PER_26 = 26 * SECS_PER_DAY # 26 days = 2,246,400 seconds
37
+ SECS_PER_MONTH = 4 * SECS_PER_WEEK # 2,419,200 seconds
38
+ SECS_PER_YEAR = 12 * SECS_PER_MONTH # 29,030,400 seconds
39
+ SECS_PER_320 = 320 * SECS_PER_DAY # 320 days = 27,648,000 seconds
40
+ SECS_PER_CENT = 100 * SECS_PER_YEAR # 3,153,600,000 seconds
41
+
30
42
  def classname
31
43
  generate_classname("pb_timestamp_kit", variant_class, align)
32
44
  end
@@ -73,12 +85,44 @@ module Playbook
73
85
 
74
86
  def format_elapsed_string
75
87
  user_string = show_user ? " by #{text}" : ""
76
- datetime_string = " #{time_ago_in_words(pb_date_time.convert_to_timestamp)} ago"
88
+ datetime_string = " #{pb_time_ago(pb_date_time.convert_to_timestamp)} ago"
89
+ datetime_string[1] = hide_updated ? datetime_string[1].upcase : datetime_string[1]
77
90
  updated_string = hide_updated ? "" : "Last updated"
78
-
79
91
  "#{updated_string}#{user_string}#{datetime_string}"
80
92
  end
81
93
 
94
+ def pb_time_ago(value)
95
+ time_ago = DateTime.now.to_i - value.to_i
96
+ case time_ago
97
+ when (0...SECS_FORTY_FIVE)
98
+ "a few seconds"
99
+ when (SECS_FORTY_FIVE...SECS_PER_MIN)
100
+ "a minute"
101
+ when (SECS_PER_MIN...SECS_PER_HOUR)
102
+ time = time_ago / SECS_PER_MIN
103
+ time == 1 ? "a minute" : "#{time_ago / SECS_PER_MIN} minutes"
104
+ when (SECS_PER_HOUR...SECS_PER_DAY)
105
+ time = time_ago / SECS_PER_HOUR
106
+ time == 1 ? "an hour" : "#{time_ago / SECS_PER_HOUR} hours"
107
+ when (SECS_PER_DAY...SECS_PER_WEEK)
108
+ time = time_ago / SECS_PER_DAY
109
+ time == 1 ? "a day" : "#{time_ago / SECS_PER_DAY} days"
110
+ when (SECS_PER_WEEK...SECS_PER_26)
111
+ time = time_ago / SECS_PER_WEEK
112
+ time == 1 ? "a week" : "#{time_ago / SECS_PER_WEEK} weeks"
113
+ when (SECS_PER_26...SECS_PER_MONTH)
114
+ "a month"
115
+ when (SECS_PER_MONTH...SECS_PER_320)
116
+ time = time_ago / SECS_PER_MONTH
117
+ time == 1 ? "a month" : "#{time_ago / SECS_PER_MONTH} months"
118
+ when (SECS_PER_320...SECS_PER_YEAR)
119
+ "a year"
120
+ when (SECS_PER_YEAR...SECS_PER_CENT)
121
+ time = time_ago / SECS_PER_YEAR
122
+ time == 1 ? "a year" : "#{time_ago / SECS_PER_YEAR} years"
123
+ end
124
+ end
125
+
82
126
  def datetime_or_text
83
127
  timestamp ? format_datetime_string : text
84
128
  end
@@ -8,7 +8,7 @@ $transition: .2s ease-in-out;
8
8
  [class^=pb_toggle_kit] {
9
9
  position: relative;
10
10
  $width: 44px;
11
- $height: calc($width / 2);
11
+ $height: $width / 2;
12
12
  $border_success: 3px solid $color_checkbox_success;
13
13
  $border_default: 3px solid $color_checkbox_default;
14
14
 
@@ -27,7 +27,7 @@ $transition: .2s ease-in-out;
27
27
  &:after {
28
28
  transition: $transition;
29
29
  content: "";
30
- width: calc($width / 2) - 4px;
30
+ width: $width / 2 - 4px;
31
31
  height: $height - 4px;
32
32
  background-color: $color_checkbox_default;
33
33
  border-radius: 50%;
@@ -68,7 +68,7 @@ $transition: .2s ease-in-out;
68
68
  background-color: $color_checkbox_success;
69
69
 
70
70
  &:after {
71
- left: calc($width / 2) + 2px;
71
+ left: $width / 2 + 2px;
72
72
  background-color: $white;
73
73
  }
74
74
  }