playbook_ui 13.31.0.pre.alpha.PLAY10863204 → 13.31.0.pre.alpha.play1262iconstyles3171

Sign up to get free protection for your applications and to get access to all the features.
Files changed (77) hide show
  1. checksums.yaml +4 -4
  2. data/app/pb_kits/playbook/pb_background/background.html.erb +11 -2
  3. data/app/pb_kits/playbook/pb_body/body.html.erb +6 -1
  4. data/app/pb_kits/playbook/pb_bread_crumbs/bread_crumb_item.html.erb +6 -1
  5. data/app/pb_kits/playbook/pb_bread_crumbs/bread_crumbs.html.erb +6 -1
  6. data/app/pb_kits/playbook/pb_caption/caption.html.erb +6 -1
  7. data/app/pb_kits/playbook/pb_card/card.html.erb +7 -1
  8. data/app/pb_kits/playbook/pb_collapsible/__snapshots__/collapsible.test.js.snap +1 -1
  9. data/app/pb_kits/playbook/pb_date_year_stacked/docs/_date_year_stacked_default.jsx +1 -4
  10. data/app/pb_kits/playbook/pb_detail/detail.html.erb +6 -1
  11. data/app/pb_kits/playbook/pb_dialog/dialog.html.erb +6 -1
  12. data/app/pb_kits/playbook/pb_dialog/dialog_body.html.erb +6 -1
  13. data/app/pb_kits/playbook/pb_dialog/dialog_footer.html.erb +5 -2
  14. data/app/pb_kits/playbook/pb_dialog/dialog_header.html.erb +6 -1
  15. data/app/pb_kits/playbook/pb_draggable/context/index.tsx +1 -15
  16. data/app/pb_kits/playbook/pb_draggable/context/types.ts +0 -5
  17. data/app/pb_kits/playbook/pb_draggable/docs/_draggable_default.jsx +19 -14
  18. data/app/pb_kits/playbook/pb_draggable/docs/_draggable_default.md +3 -5
  19. data/app/pb_kits/playbook/pb_draggable/docs/_draggable_with_cards.md +3 -7
  20. data/app/pb_kits/playbook/pb_draggable/docs/_draggable_with_list.md +5 -3
  21. data/app/pb_kits/playbook/pb_draggable/docs/_draggable_with_selectable_list.md +5 -3
  22. data/app/pb_kits/playbook/pb_dropdown/dropdown.html.erb +1 -3
  23. data/app/pb_kits/playbook/pb_dropdown/dropdown.rb +0 -2
  24. data/app/pb_kits/playbook/pb_dropdown/index.js +4 -33
  25. data/app/pb_kits/playbook/pb_flex/flex.html.erb +5 -1
  26. data/app/pb_kits/playbook/pb_form/docs/_form_form_with_validate.html.erb +0 -9
  27. data/app/pb_kits/playbook/pb_hashtag/hashtag.html.erb +6 -1
  28. data/app/pb_kits/playbook/pb_highlight/highlight.html.erb +5 -1
  29. data/app/pb_kits/playbook/pb_home_address_street/home_address_street.html.erb +5 -1
  30. data/app/pb_kits/playbook/pb_icon/_icon.scss +223 -1
  31. data/app/pb_kits/playbook/pb_icon/_icon.tsx +99 -7
  32. data/app/pb_kits/playbook/pb_icon/icon.rb +22 -16
  33. data/app/pb_kits/playbook/pb_nav/_nav_item.test.js +2 -2
  34. data/app/pb_kits/playbook/pb_rich_text_editor/_rich_text_editor.tsx +23 -8
  35. data/app/pb_kits/playbook/pb_table/_table.tsx +1 -1
  36. data/app/pb_kits/playbook/pb_table/index.ts +4 -4
  37. data/app/pb_kits/playbook/pb_table/subcomponents/_table_body.tsx +1 -1
  38. data/app/pb_kits/playbook/pb_table/subcomponents/_table_cell.tsx +1 -1
  39. data/app/pb_kits/playbook/pb_table/subcomponents/_table_head.tsx +1 -1
  40. data/app/pb_kits/playbook/pb_table/subcomponents/_table_header.tsx +1 -1
  41. data/app/pb_kits/playbook/pb_table/subcomponents/_table_row.tsx +1 -1
  42. data/app/pb_kits/playbook/pb_table/table.test.js +0 -2
  43. data/app/pb_kits/playbook/pb_text_input/_text_input.tsx +1 -1
  44. data/app/pb_kits/playbook/pb_text_input/docs/_text_input_default.jsx +1 -1
  45. data/app/pb_kits/playbook/pb_textarea/_textarea.tsx +27 -45
  46. data/app/pb_kits/playbook/pb_textarea/index.tsx +3 -3
  47. data/app/pb_kits/playbook/pb_time/_time.tsx +3 -3
  48. data/app/pb_kits/playbook/pb_time_range_inline/_time_range_inline.tsx +1 -1
  49. data/app/pb_kits/playbook/pb_timeline/_item.tsx +1 -1
  50. data/app/pb_kits/playbook/pb_timeline/_timeline.tsx +1 -1
  51. data/app/pb_kits/playbook/pb_title_detail/_title_detail.tsx +10 -10
  52. data/app/pb_kits/playbook/pb_toggle/_toggle.tsx +1 -1
  53. data/app/pb_kits/playbook/pb_tooltip/_tooltip.tsx +2 -2
  54. data/app/pb_kits/playbook/pb_treemap_chart/_treemap_chart.tsx +2 -1
  55. data/app/pb_kits/playbook/pb_treemap_chart/treemapChart.test.js +0 -2
  56. data/app/pb_kits/playbook/pb_typeahead/_typeahead.tsx +3 -3
  57. data/app/pb_kits/playbook/pb_typeahead/components/ClearIndicator.tsx +4 -4
  58. data/app/pb_kits/playbook/pb_typeahead/components/Control.tsx +7 -11
  59. data/app/pb_kits/playbook/pb_typeahead/components/IndicatorsContainer.tsx +3 -8
  60. data/app/pb_kits/playbook/pb_typeahead/components/MenuList.tsx +1 -6
  61. data/app/pb_kits/playbook/pb_typeahead/components/MultiValue.tsx +19 -18
  62. data/app/pb_kits/playbook/pb_typeahead/components/Option.tsx +6 -6
  63. data/app/pb_kits/playbook/pb_typeahead/components/Placeholder.tsx +6 -6
  64. data/app/pb_kits/playbook/pb_typeahead/components/ValueContainer.tsx +3 -3
  65. data/app/pb_kits/playbook/pb_typeahead/docs/_typeahead_custom_menu_list.jsx +0 -2
  66. data/app/pb_kits/playbook/pb_typeahead/docs/_typeahead_with_pills_async.jsx +2 -2
  67. data/app/pb_kits/playbook/pb_typeahead/index.ts +31 -31
  68. data/app/pb_kits/playbook/pb_user/_user.tsx +1 -1
  69. data/app/pb_kits/playbook/pb_user_badge/_user_badge.tsx +6 -6
  70. data/app/pb_kits/playbook/pb_user_badge/badges/million-dollar.tsx +235 -236
  71. data/app/pb_kits/playbook/pb_user_badge/badges/veteran.tsx +1 -1
  72. data/app/pb_kits/playbook/pb_walkthrough/_walkthrough.tsx +63 -68
  73. data/app/pb_kits/playbook/pb_weekday_stacked/_weekday_stacked.tsx +2 -2
  74. data/dist/menu.yml +472 -566
  75. data/dist/playbook-rails.js +6 -6
  76. data/lib/playbook/version.rb +1 -1
  77. metadata +2 -2
@@ -1,4 +1,3 @@
1
- // Rails custom icon styles
2
1
  svg.pb_custom_icon {
3
2
  width: 1em;
4
3
  fill: currentColor;
@@ -10,3 +9,226 @@ svg.pb_custom_icon {
10
9
  .pb_icon_kit_emoji {
11
10
  font-family: monospace;
12
11
  }
12
+
13
+ $rotate-list: (90, 180, 270);
14
+ $flip-list: (
15
+ "horizontal": (-1, 1),
16
+ "vertical": (1, -1),
17
+ "both": (-1, -1)
18
+ );
19
+
20
+ @keyframes pb_icon_spin {
21
+ 0% {
22
+ -webkit-transform: rotate(0);
23
+ transform: rotate(0);
24
+ }
25
+ 100% {
26
+ -webkit-transform: rotate(360deg);
27
+ transform: rotate(360deg);
28
+ }
29
+ };
30
+
31
+ svg {
32
+ &.pb_icon_kit,
33
+ &.pb_custom_icon{
34
+ @each $r in $rotate-list {
35
+ &.rotate_#{$r} {
36
+ transform: rotate(#{$r}deg);
37
+ }
38
+ }
39
+ @each $f, $v in $flip-list {
40
+ &.flip_#{$f} {
41
+ transform: scale($v);
42
+ }
43
+ }
44
+ &.svg-inline--fa {
45
+ height: 1em;
46
+ overflow: visible;
47
+ vertical-align: -.125em
48
+ }
49
+ &.svg_inverse {
50
+ color: #fff;
51
+ }
52
+ &.svg_border {
53
+ border-color: #eee;
54
+ border-radius: .1em;
55
+ border-style: solid;
56
+ border-width: .08em;
57
+ padding: .2em .25em .15em;
58
+ }
59
+ &.svg_fw {
60
+ text-align: center;
61
+ width: 1.25em
62
+ }
63
+ &.svg_li {
64
+ left: calc(2em * -1);
65
+ position: absolute;
66
+ text-align: center;
67
+ width: 2em;
68
+ line-height: inherit
69
+ }
70
+ &.pull_left {
71
+ float: left;
72
+ margin-right: .3em;
73
+ }
74
+
75
+ &.pull_right {
76
+ float: right;
77
+ margin-left: .3em;
78
+ }
79
+ &.pulse {
80
+ animation-name: pb_icon_spin;
81
+ animation-direction: normal;
82
+ animation-duration: 1s;
83
+ animation-iteration-count: infinite;
84
+ animation-timing-function: steps(8);
85
+ }
86
+ &.spin {
87
+ animation-name: pb_icon_spin;
88
+ animation-delay: 0s;
89
+ animation-direction: normal;
90
+ animation-duration: 2s;
91
+ animation-iteration-count: infinite;
92
+ animation-timing-function: linear;
93
+ }
94
+
95
+ &.svg_xs {
96
+ font-size: 0.75em
97
+ }
98
+
99
+ &.svg_sm {
100
+ font-size: 0.875em
101
+ }
102
+
103
+ &.svg_lg {
104
+ font-size: 1.25em
105
+ }
106
+
107
+ &.svg_1x {
108
+ font-size: 1em
109
+ }
110
+
111
+ &.svg_2x {
112
+ font-size: 2em
113
+ }
114
+
115
+ &.svg_3x {
116
+ font-size: 3em
117
+ }
118
+
119
+ &.svg_4x {
120
+ font-size: 4em
121
+ }
122
+
123
+ &.svg_5x {
124
+ font-size: 5em
125
+ }
126
+
127
+ &.svg_6x {
128
+ font-size: 6em
129
+ }
130
+
131
+ &.svg_7x {
132
+ font-size: 7em
133
+ }
134
+
135
+ &.svg_8x {
136
+ font-size: 8em
137
+ }
138
+
139
+ &.svg_9x {
140
+ font-size: 9em
141
+ }
142
+
143
+ &.svg_10x {
144
+ font-size: 10em
145
+ }
146
+ &.fa-xs {
147
+ font-size: .75em;
148
+ line-height: .0833333337em;
149
+ vertical-align: .125em
150
+ }
151
+ &.fa-sm {
152
+ font-size: .875em;
153
+ line-height: .0714285718em;
154
+ vertical-align: .0535714295em
155
+ }
156
+ &.fa-lg {
157
+ font-size: 1.25em;
158
+ line-height: .05em;
159
+ vertical-align: -.075em
160
+ }
161
+ &.fa-pull-left {
162
+ float: left;
163
+ margin-right: var(--fa-pull-margin, .3em)
164
+ }
165
+
166
+ &.fa-pull-right {
167
+ float: right;
168
+ margin-left: var(--fa-pull-margin, .3em)
169
+ }
170
+ &.fa-li {
171
+ left: calc(var(--fa-li-width, 2em) * -1);
172
+ position: absolute;
173
+ text-align: center;
174
+ width: var(--fa-li-width, 2em);
175
+ line-height: inherit
176
+ }
177
+ &.svg-inline--fa.fa-li {
178
+ width: var(--fa-li-width, 2em);
179
+ top: .25em
180
+ }
181
+ &.svg-inline--fa.fa-fw {
182
+ width: var(--fa-fw-width, 1.25em)
183
+ }
184
+ &.fa-fw {
185
+ text-align: center;
186
+ width: 1.25em
187
+ }
188
+ &.fa-layers {
189
+ display: inline-block;
190
+ height: 1em;
191
+ position: relative;
192
+ text-align: center;
193
+ vertical-align: -.125em;
194
+ width: 1em
195
+ }
196
+ &.fa-2x {
197
+ font-size: 2em
198
+ }
199
+ &.fa-3x {
200
+ font-size: 3em
201
+ }
202
+ &.fa-flip {
203
+ -webkit-animation-name: fa-flip;
204
+ animation-name: fa-flip;
205
+ -webkit-animation-delay: 0s;
206
+ animation-delay: 0s;
207
+ -webkit-animation-direction: normal;
208
+ animation-direction: normal;
209
+ -webkit-animation-duration: 1s;
210
+ animation-duration: 1s;
211
+ -webkit-animation-iteration-count: infinite;
212
+ animation-iteration-count: infinite;
213
+ -webkit-animation-timing-function: ease-in-out;
214
+ animation-timing-function: ease-in-out;
215
+ }
216
+ &.fa-spin {
217
+ -webkit-animation-name: fa-spin;
218
+ animation-name: fa-spin;
219
+ -webkit-animation-delay: 0s;
220
+ animation-delay: 0s;
221
+ -webkit-animation-direction: normal;
222
+ animation-direction: normal;
223
+ -webkit-animation-duration: 2s;
224
+ animation-duration: 2s;
225
+ -webkit-animation-iteration-count: infinite;
226
+ animation-iteration-count: infinite;
227
+ -webkit-animation-timing-function: linear;
228
+ animation-timing-function: linear;
229
+ }
230
+ &.fa-pulse {
231
+ animation: fa-spin 1s infinite linear;
232
+ }
233
+ }
234
+ }
@@ -55,10 +55,74 @@ const aliases: AliasesJson = aliasesJson;
55
55
 
56
56
 
57
57
  const flipMap = {
58
- horizontal: 'fa-flip-horizontal',
59
- vertical: 'fa-flip-vertical',
60
- both: 'fa-flip-horizontal fa-flip-vertical',
61
- none: ""
58
+ fa: {
59
+ horizontal: 'fa-flip-horizontal',
60
+ vertical: 'fa-flip-vertical',
61
+ both: 'fa-flip-horizontal fa-flip-vertical',
62
+ none: ''
63
+ },
64
+ svg: {
65
+ horizontal: 'flip_horizontal',
66
+ vertical: 'flip_vertical',
67
+ both: 'flip_horizontal flip_vertical',
68
+ none: ''
69
+ }
70
+ }
71
+ const pulseMap = {
72
+ fa: 'fa-pulse',
73
+ svg: 'pulse'
74
+ }
75
+ const spinMap = {
76
+ fa: 'fa-spin',
77
+ svg: 'spin'
78
+ }
79
+ const rotateMap = {
80
+ fa: {
81
+ 90: 'fa-rotate-90',
82
+ 180: 'fa-rotate-180',
83
+ 270: 'fa-rotate-270'
84
+ },
85
+ svg: {
86
+ 90: 'rotate_90',
87
+ 180: 'rotate_180',
88
+ 270: 'rotate_270'
89
+ }
90
+ }
91
+
92
+ const sizeMap = {
93
+ fa: {
94
+ "lg": "fa-lg",
95
+ "xs": "fa-xs",
96
+ "sm": "fa-sm",
97
+ "1x": "fa-1x",
98
+ "2x": "fa-2x",
99
+ "3x": "fa-3x",
100
+ "4x": "fa-4x",
101
+ "5x": "fa-5x",
102
+ "6x": "fa-6x",
103
+ "7x": "fa-7x",
104
+ "8x": "fa-8x",
105
+ "9x": "fa-9x",
106
+ "10x": "fa-10x",
107
+ "": ""
108
+ },
109
+ svg: {
110
+ "lg": "svg_lg",
111
+ "xs": "svg_xs",
112
+ "sm": "svg_sm",
113
+ "1x": "svg_1x",
114
+ "2x": "svg_2x",
115
+ "3x": "svg_3x",
116
+ "4x": "svg_4x",
117
+ "5x": "svg_5x",
118
+ "6x": "svg_6x",
119
+ "7x": "svg_7x",
120
+ "8x": "svg_8x",
121
+ "9x": "svg_9x",
122
+ "10x": "svg_10x",
123
+ "": ""
124
+ }
125
+
62
126
  }
63
127
 
64
128
  declare global {
@@ -130,16 +194,44 @@ const Icon = (props: IconProps) => {
130
194
  }
131
195
  }
132
196
 
133
- const classes = classnames(
134
- flipMap[flip],
197
+ const isFA = !iconElement && !customIcon
198
+
199
+ let classes = classnames(
135
200
  (!iconElement && !customIcon) ? 'pb_icon_kit' : '',
136
201
  (iconElement || customIcon) ? 'pb_custom_icon' : fontStyle,
137
202
  iconElement ? 'svg-inline--fa' : '',
138
- faClasses,
203
+ isFA? fontStyle : null,
139
204
  globalProps(props),
140
205
  className
141
206
  )
142
207
 
208
+ const transformClasses = classnames(
209
+ flip ? flipMap[isFA ? 'fa' : 'svg'][flip] : null,
210
+ pulse ? pulseMap[isFA ? 'fa' : 'svg'] : null,
211
+ rotation ? rotateMap[isFA ? 'fa' : 'svg'][rotation] : null,
212
+ spin ? spinMap[isFA ? 'fa' : 'svg'] : null,
213
+ size ? sizeMap[isFA ? 'fa' : 'svg'][size] : null,
214
+ border ? isFA ? 'fa-border' : 'svg_border' : null,
215
+ fixedWidth ? isFA ? 'fa-fw' : 'svg_fw' : null,
216
+ inverse ? isFA ? 'fa-inverse' : 'svg_inverse' : null,
217
+ listItem ? isFA ? 'fa-li' : 'svg_li' : null,
218
+ pull ? isFA ? `fa-pull-${pull}` : `pull_${pull}` : null,
219
+ )
220
+ classes += ` ${transformClasses}`
221
+
222
+ if (isFA) {
223
+ const faClassList = {
224
+ 'fa-border': border,
225
+ 'fa-fw': (iconElement) ? false : fixedWidth,
226
+ 'fa-inverse': inverse,
227
+ 'fa-li': listItem,
228
+ [`fa-${size}`]: size,
229
+ [`fa-pull-${pull}`]: pull,
230
+ }
231
+ faClassList[`fa-${icon}`] = icon as string
232
+ classes += ` ${classnames(faClassList)}`
233
+ }
234
+
143
235
  const classesEmoji = classnames(
144
236
  'pb_icon_kit_emoji',
145
237
  globalProps(props),
@@ -1,7 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- # rubocop:disable Style/HashLikeCase
4
-
5
3
  require "open-uri"
6
4
  require "json"
7
5
 
@@ -131,11 +129,13 @@ module Playbook
131
129
  end
132
130
 
133
131
  def border_class
134
- border ? "fa-border" : nil
132
+ prefix = is_svg? ? "svg_border" : "fa-border"
133
+ border ? prefix : nil
135
134
  end
136
135
 
137
136
  def fixed_width_class
138
- fixed_width ? "fa-fw" : nil
137
+ prefix = is_svg? ? "svg_fw" : "fa-fw"
138
+ fixed_width ? prefix : nil
139
139
  end
140
140
 
141
141
  def icon_class
@@ -143,38 +143,45 @@ module Playbook
143
143
  end
144
144
 
145
145
  def inverse_class
146
- inverse ? "fa-inverse" : nil
146
+ class_name = is_svg? ? "svg_inverse" : "fa-inverse"
147
+ inverse ? class_name : nil
147
148
  end
148
149
 
149
150
  def list_item_class
150
- list_item ? "fa-li" : nil
151
+ class_name = is_svg? ? "svg_li" : "fa-li"
152
+ list_item ? class_name : nil
151
153
  end
152
154
 
153
155
  def flip_class
156
+ prefix = is_svg? ? "flip_" : "fa-flip-"
154
157
  case flip
155
158
  when "horizontal"
156
- "fa-flip-horizontal"
159
+ "#{prefix}horizontal"
157
160
  when "vertical"
158
- "fa-flip-vertical"
161
+ "#{prefix}vertical"
159
162
  when "both"
160
- "fa-flip-horizontal fa-flip-vertical"
163
+ "#{prefix}horizontal #{prefix}vertical"
161
164
  end
162
165
  end
163
166
 
164
167
  def pull_class
165
- pull ? "fa-pull-#{pull}" : nil
168
+ class_name = is_svg? ? "pull_#{pull}" : "fa-pull-#{pull}"
169
+ pull ? class_name : nil
166
170
  end
167
171
 
168
172
  def pulse_class
169
- pulse ? "fa-pulse" : nil
173
+ class_name = is_svg? ? "pulse" : "fa-pulse"
174
+ pulse ? class_name : nil
170
175
  end
171
176
 
172
177
  def rotation_class
173
- rotation ? "fa-rotate-#{rotation}" : nil
178
+ class_name = is_svg? ? "rotate_#{rotation}" : "fa-rotate-#{rotation}"
179
+ rotation ? class_name : nil
174
180
  end
175
181
 
176
182
  def size_class
177
- size ? "fa-#{size}" : nil
183
+ class_name = is_svg? ? "svg_#{size}" : "fa-#{size}"
184
+ size ? class_name : nil
178
185
  end
179
186
 
180
187
  def font_style_class
@@ -182,10 +189,9 @@ module Playbook
182
189
  end
183
190
 
184
191
  def spin_class
185
- spin ? "fa-spin" : nil
192
+ class_name = is_svg? ? "spin" : "fa-spin"
193
+ spin ? class_name : nil
186
194
  end
187
195
  end
188
196
  end
189
197
  end
190
-
191
- # rubocop:enable Style/HashLikeCase
@@ -95,11 +95,11 @@ test('should not have a left border', () => {
95
95
  test('should have a right icon', () => {
96
96
  render(<NavDefault iconRight="angle-down" />)
97
97
  const kit = screen.getByTestId(itemTestId)
98
- expect(kit).toContainHTML('<i class="pb_icon_kit far fa-fw fa-angle-down pb_nav_list_item_icon_right" />')
98
+ expect(kit).toContainHTML('<i class="pb_icon_kit far far pb_nav_list_item_icon_right fa-fw fa-fw fa-angle-down" />')
99
99
  })
100
100
 
101
101
  test('should have a left icon', () => {
102
102
  render(<NavDefault iconLeft="users-class" />)
103
103
  const kit = screen.getByTestId(itemTestId)
104
- expect(kit).toContainHTML('<i class="pb_icon_kit far fa-fw fa-users-class pb_nav_list_item_icon_left" />')
104
+ expect(kit).toContainHTML('<i class="pb_icon_kit far far pb_nav_list_item_icon_left fa-fw fa-fw fa-users-class" />')
105
105
  })
@@ -86,18 +86,33 @@ const RichTextEditor = (props: RichTextEditorProps): React.ReactElement => {
86
86
  const toolbarElement = element.parentElement.querySelector('trix-toolbar') as HTMLElement,
87
87
  blockCodeButton = toolbarElement.querySelector('[data-trix-attribute=code]') as HTMLElement
88
88
 
89
- // replace default trix "block code" button with "inline code" button
90
89
  let inlineCodeButton = toolbarElement.querySelector('[data-trix-attribute=inlineCode]') as HTMLElement
91
- if (!inlineCodeButton) {
92
- inlineCodeButton = blockCodeButton.cloneNode(true) as HTMLElement
93
- blockCodeButton.hidden = true
94
- // set button attributes
95
- inlineCodeButton.dataset.trixAttribute = 'inlineCode'
96
- blockCodeButton.insertAdjacentElement('afterend', inlineCodeButton)
97
- }
90
+ if (!inlineCodeButton) inlineCodeButton = blockCodeButton.cloneNode(true) as HTMLElement
91
+
92
+ // set button attributes
93
+ inlineCodeButton.dataset.trixAttribute = 'inlineCode'
94
+ blockCodeButton.insertAdjacentElement('afterend', inlineCodeButton)
98
95
 
99
96
  if (toolbarBottom) editor.element.after(toolbarElement)
100
97
 
98
+ const getCodeFormattingType = (): string => {
99
+ if (editor.attributeIsActive('code')) return 'block'
100
+ if (editor.attributeIsActive('inlineCode')) return 'inline'
101
+
102
+ const range = editor.getSelectedRange()
103
+ if (range[0] == range[1]) return 'block'
104
+
105
+ const text = editor.getSelectedDocument().toString().trim()
106
+ return /\n/.test(text) ? 'block' : 'inline'
107
+ }
108
+
109
+ // DOM event listeners
110
+ element.addEventListener('trix-selection-change', () => {
111
+ const type = getCodeFormattingType()
112
+ blockCodeButton.hidden = type == 'inline'
113
+ inlineCodeButton.hidden = type == 'block'
114
+ })
115
+
101
116
  focus
102
117
  ? (document.addEventListener('trix-focus', useFocus),
103
118
  document.addEventListener('trix-blur', useFocus),
@@ -33,7 +33,7 @@ type TableProps = {
33
33
  verticalBorder?: boolean,
34
34
  } & GlobalProps
35
35
 
36
- const Table = (props: TableProps): React.ReactElement => {
36
+ const Table = (props: TableProps) => {
37
37
  const {
38
38
  aria = {},
39
39
  children,
@@ -1,19 +1,19 @@
1
1
  import PbEnhancedElement from '../pb_enhanced_element'
2
2
 
3
3
  export default class PbTable extends PbEnhancedElement {
4
- static get selector(): string {
4
+ static get selector() {
5
5
  return '.table-responsive-collapse'
6
6
  }
7
7
 
8
- connect(): void {
8
+ connect() {
9
9
  const tables = document.querySelectorAll('.table-responsive-collapse');
10
10
 
11
11
  // Each Table
12
12
  [].forEach.call(tables, (table: HTMLTableElement) => {
13
13
  // Header Titles
14
- const headers: string[] = [];
14
+ let headers: string[] = [];
15
15
  [].forEach.call(table.querySelectorAll('th'), (header: HTMLTableCellElement) => {
16
- const colSpan = header.colSpan
16
+ let colSpan = header.colSpan
17
17
  for (let i = 0; i < colSpan; i++) {
18
18
  headers.push(header.textContent.replace(/\r?\n|\r/, ''));
19
19
  }
@@ -17,7 +17,7 @@ type TableBodyPropTypes = {
17
17
  tag?: "table" | "div";
18
18
  };
19
19
 
20
- const TableBody = (props: TableBodyPropTypes): React.ReactElement => {
20
+ const TableBody = (props: TableBodyPropTypes) => {
21
21
  const {
22
22
  aria = {},
23
23
  children,
@@ -18,7 +18,7 @@ type TableCellPropTypes = {
18
18
  text?: string
19
19
  };
20
20
 
21
- const TableCell = (props: TableCellPropTypes): React.ReactElement => {
21
+ const TableCell = (props: TableCellPropTypes) => {
22
22
  const {
23
23
  aria = {},
24
24
  children,
@@ -17,7 +17,7 @@ type TableHeadPropTypes = {
17
17
  tag?: "table" | "div";
18
18
  };
19
19
 
20
- const TableHead = (props: TableHeadPropTypes): React.ReactElement => {
20
+ const TableHead = (props: TableHeadPropTypes) => {
21
21
  const {
22
22
  aria = {},
23
23
  children,
@@ -18,7 +18,7 @@ type TableHeaderPropTypes = {
18
18
  text?: string;
19
19
  };
20
20
 
21
- const TableHeader = (props: TableHeaderPropTypes): React.ReactElement => {
21
+ const TableHeader = (props: TableHeaderPropTypes) => {
22
22
  const {
23
23
  aria = {},
24
24
  children,
@@ -19,7 +19,7 @@ type TableRowPropTypes = {
19
19
  tag?: "table" | "div";
20
20
  };
21
21
 
22
- const TableRow = (props: TableRowPropTypes): React.ReactElement => {
22
+ const TableRow = (props: TableRowPropTypes) => {
23
23
  const {
24
24
  aria = {},
25
25
  children,
@@ -1,5 +1,3 @@
1
- /* eslint-disable react/no-multi-comp */
2
-
3
1
  import React from "react";
4
2
  import { ensureAccessible, renderKit, render, screen } from "../utilities/test-utils"
5
3
 
@@ -107,7 +107,7 @@ const TextInput = (props: TextInputProps, ref: React.LegacyRef<HTMLInputElement>
107
107
  required={required}
108
108
  type={type}
109
109
  value={value}
110
- />)
110
+ />)
111
111
  )
112
112
 
113
113
  const addOnInput = (
@@ -5,12 +5,12 @@ import TextInput from '../../pb_text_input/_text_input'
5
5
  import Title from '../../pb_title/_title'
6
6
 
7
7
  const TextInputDefault = (props) => {
8
- const [firstName, setFirstName] = useState('')
9
8
  const handleOnChangeFirstName = ({ target }) => {
10
9
  setFirstName(target.value)
11
10
  }
12
11
  const ref = React.createRef()
13
12
 
13
+ const [firstName, setFirstName] = useState('')
14
14
  const [formFields, setFormFields] = useState({
15
15
  firstName: 'Jane',
16
16
  lastName: 'Doe',