playbook_ui 14.16.0.pre.alpha.play1957inlinedatepickericonbugfix6872 → 14.16.0.pre.alpha.play1959tablekitstripedlogicoverridesbackground6893

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 (39) hide show
  1. checksums.yaml +4 -4
  2. data/app/pb_kits/playbook/pb_advanced_table/_advanced_table.tsx +86 -84
  3. data/app/pb_kits/playbook/pb_advanced_table/docs/_advanced_table_pagination.jsx +0 -1
  4. data/app/pb_kits/playbook/pb_button/_button.scss +5 -5
  5. data/app/pb_kits/playbook/pb_date_picker/_date_picker.tsx +34 -34
  6. data/app/pb_kits/playbook/pb_date_picker/date_picker.html.erb +2 -2
  7. data/app/pb_kits/playbook/pb_date_picker/date_picker_helper.ts +0 -16
  8. data/app/pb_kits/playbook/pb_date_picker/docs/_date_picker_inline.html.erb +11 -0
  9. data/app/pb_kits/playbook/pb_date_picker/docs/_date_picker_inline.jsx +7 -0
  10. data/app/pb_kits/playbook/pb_date_picker/sass_partials/_inline_styles.scss +24 -28
  11. data/app/pb_kits/playbook/pb_rich_text_editor/_rich_text_editor.tsx +29 -11
  12. data/app/pb_kits/playbook/pb_rich_text_editor/docs/_rich_text_editor_default.html.erb +1 -1
  13. data/app/pb_kits/playbook/pb_rich_text_editor/rich_text_editor.html.erb +4 -4
  14. data/app/pb_kits/playbook/pb_rich_text_editor/rich_text_editor.rb +2 -0
  15. data/app/pb_kits/playbook/pb_table/_table.tsx +4 -0
  16. data/app/pb_kits/playbook/pb_table/docs/_table_with_header_style_borderless.jsx +50 -0
  17. data/app/pb_kits/playbook/pb_table/docs/_table_with_header_style_borderless_react.md +1 -0
  18. data/app/pb_kits/playbook/pb_table/docs/_table_with_header_style_floating.jsx +59 -0
  19. data/app/pb_kits/playbook/pb_table/docs/_table_with_header_style_floating_react.md +1 -0
  20. data/app/pb_kits/playbook/pb_table/docs/example.yml +2 -0
  21. data/app/pb_kits/playbook/pb_table/docs/index.js +2 -0
  22. data/app/pb_kits/playbook/pb_table/styles/_headers.scss +76 -0
  23. data/app/pb_kits/playbook/pb_table/styles/_striped.scss +3 -3
  24. data/app/pb_kits/playbook/pb_table/subcomponents/_table_head.tsx +11 -1
  25. data/app/pb_kits/playbook/pb_table/subcomponents/_table_header.tsx +11 -1
  26. data/app/pb_kits/playbook/pb_table/subcomponents/_table_row.tsx +5 -0
  27. data/app/pb_kits/playbook/pb_table/table.test.js +17 -0
  28. data/dist/chunks/{_typeahead-BniHPQq8.js → _typeahead-N-EFroAX.js} +2 -2
  29. data/dist/chunks/_weekday_stacked-Db780bKR.js +45 -0
  30. data/dist/chunks/{lib-UIelzz2O.js → lib-Co5y3V4K.js} +1 -1
  31. data/dist/chunks/{pb_form_validation-EUv1tqtI.js → pb_form_validation-DMajaRt3.js} +1 -1
  32. data/dist/chunks/vendor.js +1 -1
  33. data/dist/playbook-doc.js +1 -1
  34. data/dist/playbook-rails-react-bindings.js +1 -1
  35. data/dist/playbook-rails.js +1 -1
  36. data/dist/playbook.css +1 -1
  37. data/lib/playbook/version.rb +1 -1
  38. metadata +10 -6
  39. data/dist/chunks/_weekday_stacked-CuaFaMk8.js +0 -45
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 6ac4260b02869cad3eaa3d0c49e523d9f4a4463cfccf98858f504172eaf1d601
4
- data.tar.gz: 1f91664b626b1362cf6b61ebf15ae1681830e96a3fb6d2bcd8601a2c50ea4a7a
3
+ metadata.gz: b1b61bbe353c51c6d0b9b65fe43a989ecd07bc6383f816a8ca36385541a8fab3
4
+ data.tar.gz: 9e0b3698c30553e33d081a9cd6eb70d1a299b5a309ae197cbb44ce65b1be3e69
5
5
  SHA512:
6
- metadata.gz: 1176546d1665cfe26fa78e48ad632470539f9b5bef9be47c28f60b238901c6237e236b413d09856ecde5d8f1166b3f9cc22e0c45e3e1d96c170b68d28dc2eeef
7
- data.tar.gz: 327c8ebe3c86777bffeb9af8b56ba1ab2ff2033b2245d728170ae3d86a164881abd90a0bbf691a01bce8c000a2bef515609e3c463313a4869ec36915e9e396c7
6
+ metadata.gz: db55d048eb70afdb219b9e6bcc9eb44301414a209daf19fff52a4b858e744eda43764ce1e3abb7f94c3eb4d8b1fbd208405f1ec45a00bb9bf33cc2049a7cba51
7
+ data.tar.gz: 0afca121c5aab26a344906909da824344db35d0fcf0b74c5f4450a1204cd1606ac0888e26c2c7a8dd71a2f4ae128864aae0bb25b928c1da482c78e213522cbe1
@@ -167,93 +167,95 @@ const AdvancedTable = (props: AdvancedTableProps) => {
167
167
  const isActionBarVisible = selectableRows && showActionsBar && selectedRowsLength > 0;
168
168
 
169
169
  return (
170
- <div
171
- {...ariaProps}
172
- {...dataProps}
173
- {...htmlProps}
174
- className={classes}
175
- id={id}
176
- onScroll={virtualizedRows ? e => fetchMoreOnBottomReached(
177
- e.currentTarget,
178
- fetchNextPage,
179
- isFetching,
180
- totalFetched,
181
- fullData.length
182
- ) : undefined}
183
- ref={tableWrapperRef}
184
- style={tableWrapperStyle as React.CSSProperties}
185
- >
186
- <AdvancedTableProvider
187
- columnDefinitions={columnDefinitions}
188
- enableToggleExpansion={enableToggleExpansion}
189
- enableVirtualization={virtualizedRows}
190
- expanded={expanded}
191
- expandedControl={expandedControl}
192
- handleExpandOrCollapse={handleExpandOrCollapse}
193
- hasAnySubRows={hasAnySubRows}
194
- inlineRowLoading={inlineRowLoading}
195
- isActionBarVisible={isActionBarVisible}
196
- loading={loading}
197
- responsive={responsive}
198
- selectableRows={selectableRows}
199
- setExpanded={setExpanded}
200
- showActionsBar={showActionsBar}
201
- sortControl={sortControl}
202
- subRowHeaders={tableOptions?.subRowHeaders}
203
- table={table}
204
- tableContainerRef={tableWrapperRef}
205
- toggleExpansionIcon={toggleExpansionIcon}
206
- virtualizedRows={virtualizedRows}
170
+ <>
171
+ {/* Top Pagination */}
172
+ {pagination && (
173
+ <TablePagination
174
+ onChange={onPageChange}
175
+ position="top"
176
+ range={paginationProps?.range}
177
+ table={table}
178
+ />
179
+ )}
180
+
181
+ <div
182
+ {...ariaProps}
183
+ {...dataProps}
184
+ {...htmlProps}
185
+ className={classes}
186
+ id={id}
187
+ onScroll={virtualizedRows ? e => fetchMoreOnBottomReached(
188
+ e.currentTarget,
189
+ fetchNextPage,
190
+ isFetching,
191
+ totalFetched,
192
+ fullData.length
193
+ ) : undefined}
194
+ ref={tableWrapperRef}
195
+ style={tableWrapperStyle as React.CSSProperties}
207
196
  >
208
- <React.Fragment>
209
- {/* Top Pagination */}
210
- {pagination && (
211
- <TablePagination
212
- onChange={onPageChange}
213
- position="top"
214
- range={paginationProps?.range}
215
- table={table}
197
+ <AdvancedTableProvider
198
+ columnDefinitions={columnDefinitions}
199
+ enableToggleExpansion={enableToggleExpansion}
200
+ enableVirtualization={virtualizedRows}
201
+ expanded={expanded}
202
+ expandedControl={expandedControl}
203
+ handleExpandOrCollapse={handleExpandOrCollapse}
204
+ hasAnySubRows={hasAnySubRows}
205
+ inlineRowLoading={inlineRowLoading}
206
+ isActionBarVisible={isActionBarVisible}
207
+ loading={loading}
208
+ responsive={responsive}
209
+ selectableRows={selectableRows}
210
+ setExpanded={setExpanded}
211
+ showActionsBar={showActionsBar}
212
+ sortControl={sortControl}
213
+ subRowHeaders={tableOptions?.subRowHeaders}
214
+ table={table}
215
+ tableContainerRef={tableWrapperRef}
216
+ toggleExpansionIcon={toggleExpansionIcon}
217
+ virtualizedRows={virtualizedRows}
218
+ >
219
+ <React.Fragment>
220
+ {/* Selection Action Bar */}
221
+ <TableActionBar
222
+ actions={actions}
223
+ isVisible={isActionBarVisible}
224
+ selectedCount={selectedRowsLength}
216
225
  />
217
- )}
218
-
219
- {/* Selection Action Bar */}
220
- <TableActionBar
221
- actions={actions}
222
- isVisible={isActionBarVisible}
223
- selectedCount={selectedRowsLength}
224
- />
225
226
 
226
- {/* Main Table */}
227
- <Table
228
- className={`${loading ? "content-loading" : ""}`}
229
- dark={dark}
230
- dataTable
231
- numberSpacing="tabular"
232
- responsive="none"
233
- {...tableProps}
234
- >
235
- {children ? (
236
- children
237
- ) : (
238
- <>
239
- <TableHeader />
240
- <TableBody />
241
- </>
242
- )}
243
- </Table>
244
-
245
- {/* Bottom Pagination */}
246
- {pagination && (
247
- <TablePagination
248
- onChange={onPageChange}
249
- position="bottom"
250
- range={paginationProps?.range}
251
- table={table}
252
- />
253
- )}
254
- </React.Fragment>
255
- </AdvancedTableProvider>
256
- </div>
227
+ {/* Main Table */}
228
+ <Table
229
+ className={`${loading ? "content-loading" : ""}`}
230
+ dark={dark}
231
+ dataTable
232
+ numberSpacing="tabular"
233
+ responsive="none"
234
+ {...tableProps}
235
+ >
236
+ {children ? (
237
+ children
238
+ ) : (
239
+ <>
240
+ <TableHeader />
241
+ <TableBody />
242
+ </>
243
+ )}
244
+ </Table>
245
+ </React.Fragment>
246
+ </AdvancedTableProvider>
247
+
248
+ </div>
249
+ {/* Bottom Pagination */}
250
+ {pagination && (
251
+ <TablePagination
252
+ onChange={onPageChange}
253
+ position="bottom"
254
+ range={paginationProps?.range}
255
+ table={table}
256
+ />
257
+ )}
258
+ </>
257
259
  );
258
260
  };
259
261
 
@@ -40,7 +40,6 @@ const AdvancedTablePagination = (props) => {
40
40
  <AdvancedTable
41
41
  columnDefinitions={columnDefinitions}
42
42
  pagination
43
- responsive="none"
44
43
  tableData={PAGINATION_MOCK_DATA}
45
44
  {...props}
46
45
  />
@@ -63,11 +63,6 @@ $pb_button_sizes: (
63
63
  color: $text_lt_lighter;
64
64
  }
65
65
 
66
- // Disabled =================
67
- &[class*=_disabled] {
68
- @include pb_button_disabled;
69
- }
70
-
71
66
  // Block ====================
72
67
  &[class*=_block] {
73
68
  @include pb_button_block;
@@ -83,6 +78,11 @@ $pb_button_sizes: (
83
78
  @include pb_button_danger;
84
79
  }
85
80
 
81
+ // Disabled =================
82
+ &[class*=_disabled] {
83
+ @include pb_button_disabled;
84
+ }
85
+
86
86
  // Dark Variants =============
87
87
  &.dark {
88
88
  &[class*=_primary] {
@@ -106,41 +106,41 @@ const DatePicker = (props: DatePickerProps): React.ReactElement => {
106
106
  const inputAriaProps = buildAriaProps(inputAria)
107
107
  const inputDataProps = buildDataProps(inputData)
108
108
 
109
- useEffect(() => {
110
- datePickerHelper({
111
- allowInput,
112
- customQuickPickDates,
113
- defaultDate,
114
- disableDate,
115
- disableRange,
116
- disableWeekdays,
117
- enableTime,
118
- format,
119
- hideIcon,
120
- inLine,
121
- maxDate,
122
- minDate,
123
- mode,
124
- onChange,
125
- onClose,
126
- pickerId,
127
- plugins,
128
- // eslint-disable-next-line @typescript-eslint/ban-ts-comment
129
- // @ts-ignore
130
- position,
131
- positionElement,
132
- selectionType,
133
- showTimezone,
134
- staticPosition,
135
- thisRangesEndToday,
136
- yearRange,
137
- required: false,
138
- }, scrollContainer)
139
- }, initializeOnce ? [] : undefined)
109
+ useEffect(() => {
110
+ datePickerHelper({
111
+ allowInput,
112
+ customQuickPickDates,
113
+ defaultDate,
114
+ disableDate,
115
+ disableRange,
116
+ disableWeekdays,
117
+ enableTime,
118
+ format,
119
+ hideIcon,
120
+ inLine,
121
+ maxDate,
122
+ minDate,
123
+ mode,
124
+ onChange,
125
+ onClose,
126
+ pickerId,
127
+ plugins,
128
+ // eslint-disable-next-line @typescript-eslint/ban-ts-comment
129
+ // @ts-ignore
130
+ position,
131
+ positionElement,
132
+ selectionType,
133
+ showTimezone,
134
+ staticPosition,
135
+ thisRangesEndToday,
136
+ yearRange,
137
+ required: false,
138
+ }, scrollContainer)
139
+ }, initializeOnce ? [] : undefined)
140
140
  const filteredProps = {...props}
141
141
  if (filteredProps.marginBottom === undefined) {
142
142
  filteredProps.marginBottom = "sm"
143
- }
143
+ }
144
144
  delete filteredProps?.position
145
145
 
146
146
  const classes = classnames(
@@ -221,7 +221,7 @@ const DatePicker = (props: DatePickerProps): React.ReactElement => {
221
221
  {hideIcon && inLine ?
222
222
  <div>
223
223
  <div
224
- className={`${iconWrapperClass()} date-picker-inline-icon-plus`}
224
+ className={iconWrapperClass()}
225
225
  id={`${pickerId}-icon-plus`}
226
226
  >
227
227
  <Icon
@@ -230,7 +230,7 @@ const DatePicker = (props: DatePickerProps): React.ReactElement => {
230
230
  />
231
231
  </div>
232
232
  <div
233
- className={`${iconWrapperClass()} date-picker-inline-angle-down`}
233
+ className={iconWrapperClass()}
234
234
  id={`${pickerId}-angle-down`}
235
235
  >
236
236
  <Icon
@@ -44,7 +44,7 @@
44
44
  <% if object.hide_icon && object.inline %>
45
45
  <!-- Plus Icon -->
46
46
  <div
47
- class="<%= object.icon_wrapper_class %> date-picker-inline-icon-plus"
47
+ class="<%= object.icon_wrapper_class %>"
48
48
  id="<%= object.picker_id %>-icon-plus"
49
49
  >
50
50
  <%= pb_rails("icon", props: {
@@ -55,7 +55,7 @@
55
55
 
56
56
  <!-- Angle Down Icon -->
57
57
  <div
58
- class="<%= object.icon_wrapper_class %> date-picker-inline-angle-down"
58
+ class="<%= object.icon_wrapper_class %>"
59
59
  id="<%= object.picker_id %>-angle-down"
60
60
  >
61
61
  <%= pb_rails("icon", props: {
@@ -174,21 +174,6 @@ const datePickerHelper = (config: DatePickerConfig, scrollContainer: string | HT
174
174
  yearInput.value = fp.currentYear?.toString()
175
175
  }
176
176
 
177
- const handleDatePickerChange = (fp: Instance, selectedDates: Date[]) => {
178
- const inputEl = fp.input
179
-
180
- if (inputEl) {
181
- const inlineDatePickerElem = inputEl.closest('.inline-date-picker')
182
- if (inlineDatePickerElem) {
183
- if (selectedDates && selectedDates.length > 0) {
184
- inlineDatePickerElem.classList.add('show-angle-down-icon')
185
- } else {
186
- inlineDatePickerElem.classList.remove('show-angle-down-icon')
187
- }
188
- }
189
- }
190
- }
191
-
192
177
  // ===========================================================
193
178
  // | Flatpickr initializer w/ config |
194
179
  // ===========================================================
@@ -219,7 +204,6 @@ const datePickerHelper = (config: DatePickerConfig, scrollContainer: string | HT
219
204
  onClose(selectedDates, dateStr)
220
205
  }],
221
206
  onChange: [(selectedDates, dateStr, fp) => {
222
- handleDatePickerChange(fp, selectedDates)
223
207
  yearChangeHook(fp)
224
208
  onChange(dateStr, selectedDates)
225
209
  }],
@@ -4,3 +4,14 @@
4
4
  inline: true,
5
5
  picker_id: "date-picker-inline"
6
6
  }) %>
7
+
8
+ <%= javascript_tag do %>
9
+ window.addEventListener("DOMContentLoaded", (event) => {
10
+ const fpInline = document.querySelector("#date-picker-inline")._flatpickr
11
+ <!-- Display the angle-down icon when a date has been selected -->
12
+ const showAngleDownHandler = () => {
13
+ document.querySelector('.inline-date-picker').classList.add('show-angle-down-icon')
14
+ }
15
+ fpInline.config.onChange.push(showAngleDownHandler)
16
+ })
17
+ <% end %>
@@ -3,12 +3,19 @@ import React from 'react'
3
3
  import DatePicker from '../_date_picker'
4
4
 
5
5
  const DatePickerInline = (props) => {
6
+ const showAngleDownHandler = (dateSelected) => {
7
+ if (dateSelected) {
8
+ document.querySelector('.inline-date-picker').classList.add('show-angle-down-icon')
9
+ }
10
+ }
11
+
6
12
  return (
7
13
  <div>
8
14
  <DatePicker
9
15
  className="inline-date-picker"
10
16
  hideIcon
11
17
  inLine
18
+ onChange={showAngleDownHandler}
12
19
  pickerId="date-picker-inline"
13
20
  {...props}
14
21
  />
@@ -14,12 +14,12 @@
14
14
  opacity: 1;
15
15
  }
16
16
  &:not(:hover) {
17
- .date-picker-inline-angle-down.cal_icon_wrapper {
17
+ #date-picker-inline-angle-down {
18
18
  svg {
19
19
  display: none;
20
20
  }
21
21
  }
22
- .date-picker-inline-icon-plus.cal_icon_wrapper {
22
+ #date-picker-inline-icon-plus {
23
23
  svg {
24
24
  color: $slate;
25
25
  display: inline-block;
@@ -33,12 +33,12 @@
33
33
  [class^="pb_text_input_kit"] .text_input_wrapper .flatpickr-wrapper .text_input .placeholder {
34
34
  color: $primary;
35
35
  }
36
- .date-picker-inline-angle-down.cal_icon_wrapper {
36
+ #date-picker-inline-angle-down {
37
37
  svg {
38
38
  display: none;
39
39
  }
40
40
  }
41
- .date-picker-inline-icon-plus.cal_icon_wrapper {
41
+ #date-picker-inline-icon-plus {
42
42
  svg {
43
43
  display: inline-block;
44
44
  color: $primary;
@@ -47,34 +47,32 @@
47
47
  }
48
48
  &.show-angle-down-icon {
49
49
  &:not(:hover) {
50
- .date-picker-inline-angle-down.cal_icon_wrapper {
50
+ #date-picker-inline-angle-down {
51
51
  svg {
52
52
  display: inline-block;
53
53
  color: $text_lt_light;
54
54
  }
55
55
  }
56
- .date-picker-inline-icon-plus.cal_icon_wrapper {
56
+ #date-picker-inline-icon-plus {
57
57
  svg {
58
58
  display: none;
59
59
  }
60
60
  }
61
61
  }
62
- .date-picker-inline-icon-plus.cal_icon_wrapper {
62
+ #date-picker-inline-icon-plus {
63
63
  svg {
64
64
  display: none;
65
65
  }
66
66
  }
67
- .date-picker-inline-angle-down.cal_icon_wrapper {
67
+ #date-picker-inline-angle-down {
68
68
  svg {
69
69
  display: inline-block;
70
70
  color: $primary;
71
71
  }
72
72
  }
73
73
  }
74
- .date_picker_input.flatpickr-input,
75
- .date_picker_input.flatpickr-input .active,
76
- .text_input.flatpickr-input,
77
- .text_input.flatpickr-input .active {
74
+ #date-picker-inline,
75
+ #date-picker-inline .active {
78
76
  border: none;
79
77
  padding: 5px 5px 5px 10px;
80
78
  background-color: #FFF;
@@ -84,8 +82,8 @@
84
82
  box-shadow: none;
85
83
  }
86
84
  }
87
- .date-picker-inline-angle-down.cal_icon_wrapper,
88
- .date-picker-inline-icon-plus.cal_icon_wrapper {
85
+ #date-picker-inline-angle-down,
86
+ #date-picker-inline-icon-plus {
89
87
  height: 33px;
90
88
  border: none;
91
89
  }
@@ -98,12 +96,12 @@
98
96
  [class^=pb_date_picker_kit].dark {
99
97
  &.inline-date-picker {
100
98
  &:not(:hover) {
101
- .date-picker-inline-angle-down.cal_icon_wrapper {
99
+ #date-picker-inline-angle-down {
102
100
  svg {
103
101
  display: none;
104
102
  }
105
103
  }
106
- .date-picker-inline-icon-plus.cal_icon_wrapper {
104
+ #date-picker-inline-icon-plus {
107
105
  svg {
108
106
  display: inline-block;
109
107
  color: $white;
@@ -117,12 +115,12 @@
117
115
  [class^="pb_text_input_kit"] .text_input_wrapper .flatpickr-wrapper .text_input .placeholder {
118
116
  color: $white;
119
117
  }
120
- .date-picker-inline-angle-down.cal_icon_wrapper {
118
+ #date-picker-inline-angle-down {
121
119
  svg {
122
120
  display: none;
123
121
  }
124
122
  }
125
- .date-picker-inline-icon-plus.cal_icon_wrapper {
123
+ #date-picker-inline-icon-plus {
126
124
  svg {
127
125
  display: inline-block;
128
126
  color: $white;
@@ -131,34 +129,32 @@
131
129
  }
132
130
  &.show-angle-down-icon {
133
131
  &:not(:hover) {
134
- .date-picker-inline-angle-down.cal_icon_wrapper {
132
+ #date-picker-inline-angle-down {
135
133
  svg {
136
134
  display: inline-block;
137
135
  color: $white;
138
136
  }
139
137
  }
140
- .date-picker-inline-icon-plus.cal_icon_wrapper {
138
+ #date-picker-inline-icon-plus {
141
139
  svg {
142
140
  display: none;
143
141
  }
144
142
  }
145
143
  }
146
- .date-picker-inline-icon-plus.cal_icon_wrapper {
144
+ #date-picker-inline-icon-plus {
147
145
  svg {
148
146
  display: none;
149
147
  }
150
148
  }
151
- .date-picker-inline-angle-down.cal_icon_wrapper {
149
+ #date-picker-inline-angle-down {
152
150
  svg {
153
151
  display: inline-block;
154
152
  color: $white;
155
153
  }
156
154
  }
157
155
  }
158
- .date_picker_input.flatpickr-input,
159
- .date_picker_input.flatpickr-input .active,
160
- .text_input.flatpickr-input,
161
- .text_input.flatpickr-input .active {
156
+ #date-picker-inline,
157
+ #date-picker-inline .active {
162
158
  background-color: rgba($white,.10);
163
159
  border: none;
164
160
  padding: 5px 5px 5px 10px;
@@ -168,8 +164,8 @@
168
164
  box-shadow: none;
169
165
  }
170
166
  }
171
- .date-picker-inline-angle-down.cal_icon_wrapper,
172
- .date-picker-inline-icon-plus.cal_icon_wrapper {
167
+ #date-picker-inline-angle-down,
168
+ #date-picker-inline-icon-plus {
173
169
  height: 33px;
174
170
  border: none;
175
171
  }
@@ -32,11 +32,12 @@ type RichTextEditorProps = {
32
32
  advancedEditor?: any,
33
33
  advancedEditorToolbar?: boolean,
34
34
  toolbarBottom?: boolean,
35
- children?: React.ReactNode | React.ReactNode[]
35
+ children?: React.ReactNode | React.ReactNode[],
36
36
  className?: string,
37
37
  data?: { [key: string]: string },
38
38
  focus?: boolean,
39
- htmlOptions?: {[key: string]: string | number | boolean | (() => void)},
39
+ htmlOptions?: { [key: string]: string | number | boolean | (() => void) },
40
+ inputOptions?: { [key: string]: string | number | boolean | (() => void) },
40
41
  id?: string,
41
42
  inline?: boolean,
42
43
  extensions?: { [key: string]: string }[],
@@ -61,6 +62,7 @@ const RichTextEditor = (props: RichTextEditorProps): React.ReactElement => {
61
62
  data = {},
62
63
  focus = false,
63
64
  htmlOptions = {},
65
+ inputOptions = {},
64
66
  inline = false,
65
67
  extensions,
66
68
  name,
@@ -70,7 +72,7 @@ const RichTextEditor = (props: RichTextEditorProps): React.ReactElement => {
70
72
  sticky = false,
71
73
  template = '',
72
74
  value = '',
73
- maxWidth="md"
75
+ maxWidth = "md"
74
76
  } = props
75
77
 
76
78
  const ariaProps = buildAriaProps(aria),
@@ -79,12 +81,28 @@ const RichTextEditor = (props: RichTextEditorProps): React.ReactElement => {
79
81
 
80
82
  const htmlProps = buildHtmlProps(htmlOptions)
81
83
 
82
- const handleOnEditorReady = (editorInstance: Editor) => setEditor(editorInstance),
83
- element = editor?.element
84
+ const handleOnEditorReady = (editorInstance: Editor) => {
85
+ setEditor(editorInstance)
86
+ setTimeout(() => {
87
+ const oldId = editorInstance.element.getAttribute('input')
88
+ if (oldId) {
89
+ const hiddenInput = document.getElementById(oldId)
90
+ if (hiddenInput) {
91
+ const newId = (inputOptions.id as string) || oldId
92
+ hiddenInput.id = newId
93
+ editorInstance.element.setAttribute('input', newId)
94
+
95
+ if (inputOptions.name) {
96
+ hiddenInput.setAttribute('name', inputOptions.name as string)
97
+ }
98
+ }
99
+ }
100
+ })
101
+ }
84
102
 
85
103
  // DOM manipulation must wait for editor to be ready
86
- if (editor) {
87
- const toolbarElement = element.parentElement.querySelector('trix-toolbar') as HTMLElement,
104
+ if (editor && editor.element) {
105
+ const toolbarElement = editor.element.parentElement.querySelector('trix-toolbar') as HTMLElement,
88
106
  blockCodeButton = toolbarElement.querySelector('[data-trix-attribute=code]') as HTMLElement
89
107
 
90
108
  // replace default trix "block code" button with "inline code" button
@@ -118,8 +136,8 @@ const RichTextEditor = (props: RichTextEditorProps): React.ReactElement => {
118
136
  }, [editor, template])
119
137
 
120
138
  useEffect(() => {
121
- if (!element) return
122
- element.addEventListener('click', ({ target }: Event) => {
139
+ if (!editor?.element) return
140
+ editor.element.addEventListener('click', ({ target }: Event) => {
123
141
  const trixEditorContainer = (target as Element).closest('.pb_rich_text_editor_kit')
124
142
  if (!trixEditorContainer) return
125
143
 
@@ -128,7 +146,7 @@ const RichTextEditor = (props: RichTextEditorProps): React.ReactElement => {
128
146
 
129
147
  if (anchorElement.hasAttribute('href')) window.open(anchorElement.href)
130
148
  })
131
- }, [element])
149
+ }, [editor])
132
150
 
133
151
  const richTextEditorClass = 'pb_rich_text_editor_kit',
134
152
  simpleClass = simple ? 'simple' : '',
@@ -137,7 +155,7 @@ const RichTextEditor = (props: RichTextEditorProps): React.ReactElement => {
137
155
  inlineClass = inline ? 'inline' : '',
138
156
  toolbarBottomClass = toolbarBottom ? 'toolbar-bottom' : ''
139
157
 
140
- let css = classnames(globalProps(props, {maxWidth}), className)
158
+ let css = classnames(globalProps(props, { maxWidth }), className)
141
159
  css = classnames(
142
160
  richTextEditorClass,
143
161
  simpleClass,
@@ -1 +1 @@
1
- <%= pb_rails("rich_text_editor", props: {id: "default", value: "Add your text here. You can format your text, add links, quotes, and bullets."}) %>
1
+ <%= pb_rails("rich_text_editor", props: {input_options: { id: 'hidden_input_id', name: "hidden_input_name" }, value: "Add your text here. You can format your text, add links, quotes, and bullets."}) %>
@@ -1,5 +1,5 @@
1
1
  <%= react_component('RichTextEditor',
2
- object.rich_text_options,
3
- aria: object.aria,
4
- data: object.data
5
- ) %>
2
+ object.rich_text_options,
3
+ aria: object.aria,
4
+ data: object.data
5
+ ) %>