playbook_ui 16.1.0.pre.alpha.play274314102 → 16.1.0.pre.alpha.play276813969
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.
- checksums.yaml +4 -4
- data/app/pb_kits/playbook/pb_advanced_table/Components/RegularTableView.tsx +2 -12
- data/app/pb_kits/playbook/pb_advanced_table/advanced_table.test.jsx +0 -33
- data/app/pb_kits/playbook/pb_advanced_table/docs/example.yml +0 -1
- data/app/pb_kits/playbook/pb_advanced_table/docs/index.js +1 -2
- data/app/pb_kits/playbook/pb_checkbox/_checkbox.scss +1 -1
- data/app/pb_kits/playbook/pb_checkbox/_checkbox.tsx +0 -17
- data/app/pb_kits/playbook/pb_checkbox/checkbox.html.erb +1 -10
- data/app/pb_kits/playbook/pb_checkbox/checkbox.rb +0 -2
- data/app/pb_kits/playbook/pb_checkbox/docs/example.yml +0 -2
- data/app/pb_kits/playbook/pb_checkbox/docs/index.js +0 -1
- data/app/pb_kits/playbook/pb_date_picker/_date_picker.tsx +5 -14
- data/app/pb_kits/playbook/pb_form/docs/_form_with_required_indicator.html.erb +3 -6
- data/app/pb_kits/playbook/pb_form/pb_form_validation.js +2 -9
- data/app/pb_kits/playbook/pb_passphrase/_passphrase.tsx +2 -20
- data/app/pb_kits/playbook/pb_rich_text_editor/_rich_text_editor.tsx +34 -71
- data/app/pb_kits/playbook/pb_rich_text_editor/docs/_rich_text_editor_advanced_required_indicator.jsx +0 -1
- data/app/pb_kits/playbook/pb_rich_text_editor/docs/_rich_text_editor_attributes.html.erb +5 -0
- data/app/pb_kits/playbook/pb_rich_text_editor/docs/_rich_text_editor_attributes.jsx +0 -4
- data/app/pb_kits/playbook/pb_rich_text_editor/docs/_rich_text_editor_default.html.erb +1 -0
- data/app/pb_kits/playbook/pb_rich_text_editor/docs/_rich_text_editor_default.jsx +0 -4
- data/app/pb_kits/playbook/pb_rich_text_editor/docs/_rich_text_editor_focus.html.erb +3 -0
- data/app/pb_kits/playbook/pb_rich_text_editor/docs/_rich_text_editor_focus.jsx +0 -5
- data/app/pb_kits/playbook/pb_rich_text_editor/docs/_rich_text_editor_inline.html.erb +6 -0
- data/app/pb_kits/playbook/pb_rich_text_editor/docs/_rich_text_editor_inline.jsx +0 -4
- data/app/pb_kits/playbook/pb_rich_text_editor/docs/_rich_text_editor_preview.html.erb +35 -0
- data/app/pb_kits/playbook/pb_rich_text_editor/docs/_rich_text_editor_preview.jsx +0 -4
- data/app/pb_kits/playbook/pb_rich_text_editor/docs/_rich_text_editor_required_indicator.html.erb +10 -0
- data/app/pb_kits/playbook/pb_rich_text_editor/docs/_rich_text_editor_required_indicator.jsx +0 -5
- data/app/pb_kits/playbook/pb_rich_text_editor/docs/_rich_text_editor_simple.html.erb +1 -0
- data/app/pb_kits/playbook/pb_rich_text_editor/docs/_rich_text_editor_simple.jsx +0 -4
- data/app/pb_kits/playbook/pb_rich_text_editor/docs/_rich_text_editor_sticky.html.erb +1 -0
- data/app/pb_kits/playbook/pb_rich_text_editor/docs/_rich_text_editor_sticky.jsx +0 -4
- data/app/pb_kits/playbook/pb_rich_text_editor/docs/_rich_text_editor_templates.html.erb +115 -0
- data/app/pb_kits/playbook/pb_rich_text_editor/docs/_rich_text_editor_templates.jsx +0 -4
- data/app/pb_kits/playbook/pb_rich_text_editor/docs/_rich_text_editor_toolbar_bottom.html.erb +4 -0
- data/app/pb_kits/playbook/pb_rich_text_editor/docs/_rich_text_editor_toolbar_bottom.jsx +14 -0
- data/app/pb_kits/playbook/pb_rich_text_editor/docs/example.yml +20 -23
- data/app/pb_kits/playbook/pb_rich_text_editor/docs/index.js +1 -2
- data/app/pb_kits/playbook/pb_rich_text_editor/rich_text_editor.html.erb +5 -0
- data/app/pb_kits/playbook/pb_rich_text_editor/rich_text_editor.rb +63 -0
- data/app/pb_kits/playbook/pb_table/index.ts +27 -29
- data/app/pb_kits/playbook/pb_text_input/text_input.html.erb +10 -10
- data/app/pb_kits/playbook/pb_textarea/_textarea.tsx +0 -10
- data/app/pb_kits/playbook/pb_textarea/docs/_textarea_default.html.erb +3 -3
- data/app/pb_kits/playbook/pb_textarea/docs/_textarea_default.jsx +0 -3
- data/app/pb_kits/playbook/pb_textarea/textarea.html.erb +9 -25
- data/app/pb_kits/playbook/pb_textarea/textarea.rb +1 -7
- data/app/pb_kits/playbook/pb_time_picker/_time_picker.tsx +11 -97
- data/app/pb_kits/playbook/pb_time_picker/docs/_time_picker_on_handler.jsx +2 -5
- data/app/pb_kits/playbook/pb_time_picker/docs/example.yml +0 -2
- data/app/pb_kits/playbook/pb_time_picker/docs/index.js +0 -1
- data/app/pb_kits/playbook/pb_time_picker/time_picker.rb +0 -3
- data/app/pb_kits/playbook/pb_time_picker/time_picker.test.jsx +1 -47
- data/app/pb_kits/playbook/pb_typeahead/_typeahead.tsx +323 -410
- data/app/pb_kits/playbook/pb_typeahead/components/Control.tsx +0 -2
- data/app/pb_kits/playbook/pb_typeahead/docs/example.yml +0 -2
- data/app/pb_kits/playbook/pb_typeahead/docs/index.js +21 -22
- data/app/pb_kits/playbook/pb_typeahead/typeahead.html.erb +2 -3
- data/app/pb_kits/playbook/pb_typeahead/typeahead.rb +1 -3
- data/dist/chunks/{_pb_line_graph-DuJNCf7N.js → _pb_line_graph-BgKF_zz1.js} +1 -1
- data/dist/chunks/_typeahead-C4YsbA48.js +1 -0
- data/dist/chunks/{globalProps-Bc-FVsRt.js → globalProps-BhVYCqRf.js} +1 -1
- data/dist/chunks/lib-DD34ZrWL.js +29 -0
- data/dist/chunks/vendor.js +3 -3
- data/dist/menu.yml +2 -2
- data/dist/playbook-rails-react-bindings.js +1 -1
- data/dist/playbook-rails.js +1 -1
- data/lib/playbook/forms/builder/form_field_builder.rb +1 -1
- data/lib/playbook/forms/builder/typeahead_field.rb +1 -15
- data/lib/playbook/forms/builder.rb +2 -2
- data/lib/playbook/version.rb +1 -1
- metadata +19 -23
- data/app/pb_kits/playbook/pb_advanced_table/docs/_advanced_table_column_styling_background_custom.jsx +0 -71
- data/app/pb_kits/playbook/pb_advanced_table/docs/_advanced_table_column_styling_background_custom.md +0 -4
- data/app/pb_kits/playbook/pb_checkbox/docs/_checkbox_required_indicator.html.erb +0 -6
- data/app/pb_kits/playbook/pb_checkbox/docs/_checkbox_required_indicator.jsx +0 -17
- data/app/pb_kits/playbook/pb_checkbox/docs/_checkbox_required_indicator.md +0 -3
- data/app/pb_kits/playbook/pb_date_picker/docs/_date_picker_default.md +0 -1
- data/app/pb_kits/playbook/pb_rich_text_editor/docs/_rich_text_editor_advanced_label.jsx +0 -44
- data/app/pb_kits/playbook/pb_rich_text_editor/docs/_rich_text_editor_advanced_label.md +0 -1
- data/app/pb_kits/playbook/pb_rich_text_editor/docs/_rich_text_editor_label.jsx +0 -33
- data/app/pb_kits/playbook/pb_rich_text_editor/docs/_rich_text_editor_label.md +0 -1
- data/app/pb_kits/playbook/pb_textarea/docs/_textarea_default.md +0 -1
- data/app/pb_kits/playbook/pb_time_picker/docs/_time_picker_required_indicator.html.erb +0 -6
- data/app/pb_kits/playbook/pb_time_picker/docs/_time_picker_required_indicator.jsx +0 -16
- data/app/pb_kits/playbook/pb_time_picker/docs/_time_picker_required_indicator.md +0 -3
- data/app/pb_kits/playbook/pb_typeahead/docs/_typeahead_required_indicator.html.erb +0 -16
- data/app/pb_kits/playbook/pb_typeahead/docs/_typeahead_required_indicator.jsx +0 -23
- data/app/pb_kits/playbook/pb_typeahead/docs/_typeahead_required_indicator.md +0 -3
- data/dist/chunks/_typeahead-Cx2lp7TD.js +0 -1
- data/dist/chunks/lib-BwX82vim.js +0 -29
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 387f03d299bddebe2e4ac7e9800fddf28bb00cdeceb0ffcd9a5c4ea1ed211d20
|
|
4
|
+
data.tar.gz: 03b9b1cbcb66afd3afd4d28eb8c0226dc4d7a2ddc883dadb0844bc427f857831
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: e4f7c1a63a205b06dadc63869cbfb9f761d88775d9d625efe37bd896d1cbd5269107b71fc0c24714bb781c2b314e949aa5a37bcab80eed8689fe0d90b72796f9
|
|
7
|
+
data.tar.gz: 7933fda91c7fe525372cb559bcc56147fe86bc877cac737603ee0694b62f34fdef93cd2e40b88860de6a51f0c389e21ac2ae6d858cd1cb14531a31083e78bd7c
|
|
@@ -66,18 +66,8 @@ const TableCellRenderer = ({
|
|
|
66
66
|
// Find the "owning" colDefinition by accessor. Needed for multi column logic
|
|
67
67
|
const colDef = findColumnDefByAccessor(columnDefinitions ?? [], column.id)
|
|
68
68
|
const cellAlignment = colDef?.columnStyling?.cellAlignment ?? "right"
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
const cellFontColorValue = colDef?.columnStyling?.fontColor
|
|
72
|
-
const cellFontColor = typeof cellFontColorValue === 'function'
|
|
73
|
-
? cellFontColorValue(row)
|
|
74
|
-
: cellFontColorValue
|
|
75
|
-
|
|
76
|
-
const cellBackgroundColorValue = colDef?.columnStyling?.cellBackgroundColor
|
|
77
|
-
const cellBackgroundColor = typeof cellBackgroundColorValue === 'function'
|
|
78
|
-
? cellBackgroundColorValue(row)
|
|
79
|
-
: cellBackgroundColorValue
|
|
80
|
-
|
|
69
|
+
const cellFontColor = colDef?.columnStyling?.fontColor
|
|
70
|
+
const cellBackgroundColor = colDef?.columnStyling?.cellBackgroundColor
|
|
81
71
|
const paddingValue = colDef?.columnStyling?.cellPadding ?? customRowStyle?.cellPadding
|
|
82
72
|
const paddingClass = paddingValue ? `p_${paddingValue}` : undefined
|
|
83
73
|
|
|
@@ -920,39 +920,6 @@ test("columnStyling.backgroundColor works as excpected", () => {
|
|
|
920
920
|
expect(firstEnrollmentCell).toHaveStyle({ backgroundColor: colors.error_subtle });
|
|
921
921
|
});
|
|
922
922
|
|
|
923
|
-
test("columnStyling.cellBackgroundColor works as expected with function", () => {
|
|
924
|
-
const styledColumnDefs = [
|
|
925
|
-
{
|
|
926
|
-
accessor: "year",
|
|
927
|
-
label: "Year",
|
|
928
|
-
cellAccessors: ["quarter", "month", "day"],
|
|
929
|
-
},
|
|
930
|
-
{
|
|
931
|
-
accessor: "newEnrollments",
|
|
932
|
-
label: "New Enrollments",
|
|
933
|
-
columnStyling:{
|
|
934
|
-
cellBackgroundColor: (row) => row.original.newEnrollments > 15 ? colors.success_subtle : colors.error_subtle,
|
|
935
|
-
fontColor: (row) => row.original.newEnrollments > 15 ? colors.success : colors.error,
|
|
936
|
-
},
|
|
937
|
-
},
|
|
938
|
-
{
|
|
939
|
-
accessor: "scheduledMeetings",
|
|
940
|
-
label: "Scheduled Meetings",
|
|
941
|
-
},
|
|
942
|
-
];
|
|
943
|
-
|
|
944
|
-
render(
|
|
945
|
-
<AdvancedTable
|
|
946
|
-
columnDefinitions={styledColumnDefs}
|
|
947
|
-
data={{ testid: testId }}
|
|
948
|
-
tableData={MOCK_DATA}
|
|
949
|
-
/>
|
|
950
|
-
);
|
|
951
|
-
|
|
952
|
-
const firstEnrollmentCell = screen.getAllByText("20")[0].closest("td");
|
|
953
|
-
expect(firstEnrollmentCell).toHaveStyle({ backgroundColor: colors.success_subtle, color: colors.success });
|
|
954
|
-
});
|
|
955
|
-
|
|
956
923
|
test("columnStyling.headerBackgroundColor works as excpected", () => {
|
|
957
924
|
const styledColumnDefs = [
|
|
958
925
|
{
|
|
@@ -78,7 +78,6 @@ examples:
|
|
|
78
78
|
- advanced_table_column_styling: Column Styling
|
|
79
79
|
- advanced_table_column_styling_column_headers: Column Styling with Multiple Headers
|
|
80
80
|
- advanced_table_column_styling_background: Column Styling Background Color
|
|
81
|
-
- advanced_table_column_styling_background_custom: Column Styling Background Color (Custom)
|
|
82
81
|
- advanced_table_column_styling_background_multi: Column Styling Background Color with Multiple Headers
|
|
83
82
|
- advanced_table_padding_control: Padding Control using Column Styling
|
|
84
83
|
- advanced_table_column_border_color: Column Group Border Color
|
|
@@ -47,5 +47,4 @@ export { default as AdvancedTableSortPerColumnForMultiColumn } from './_advanced
|
|
|
47
47
|
export { default as AdvancedTablePaddingControl } from './_advanced_table_padding_control.jsx'
|
|
48
48
|
export { default as AdvancedTablePaddingControlPerRow } from './_advanced_table_padding_control_per_row.jsx'
|
|
49
49
|
export { default as AdvancedTableColumnStylingBackground } from './_advanced_table_column_styling_background.jsx'
|
|
50
|
-
export { default as AdvancedTableColumnStylingBackgroundMulti } from './_advanced_table_column_styling_background_multi.jsx'
|
|
51
|
-
export { default as AdvancedTableColumnStylingBackgroundCustom } from './_advanced_table_column_styling_background_custom.jsx'
|
|
50
|
+
export { default as AdvancedTableColumnStylingBackgroundMulti } from './_advanced_table_column_styling_background_multi.jsx'
|
|
@@ -4,8 +4,6 @@ import Icon from '../pb_icon/_icon'
|
|
|
4
4
|
import { buildAriaProps, buildCss, buildDataProps, buildHtmlProps } from '../utilities/props'
|
|
5
5
|
import classnames from 'classnames'
|
|
6
6
|
import { globalProps, GlobalProps } from '../utilities/globalProps'
|
|
7
|
-
import colors from '../tokens/exports/_colors.module.scss'
|
|
8
|
-
import spacing from '../tokens/exports/_spacing.module.scss'
|
|
9
7
|
|
|
10
8
|
type CheckboxProps = {
|
|
11
9
|
aria?: {[key: string]: string},
|
|
@@ -21,7 +19,6 @@ type CheckboxProps = {
|
|
|
21
19
|
indeterminate?: boolean,
|
|
22
20
|
name?: string,
|
|
23
21
|
onChange?: (event: React.FormEvent<HTMLInputElement>) => void,
|
|
24
|
-
requiredIndicator?: boolean,
|
|
25
22
|
tabIndex?: number,
|
|
26
23
|
text?: string,
|
|
27
24
|
value?: string,
|
|
@@ -42,7 +39,6 @@ const Checkbox = forwardRef<HTMLInputElement, CheckboxProps>((props, ref) => {
|
|
|
42
39
|
indeterminate = false,
|
|
43
40
|
name = '',
|
|
44
41
|
onChange = () => { void 0 },
|
|
45
|
-
requiredIndicator = false,
|
|
46
42
|
tabIndex,
|
|
47
43
|
text = '',
|
|
48
44
|
value = '',
|
|
@@ -128,20 +124,7 @@ const Checkbox = forwardRef<HTMLInputElement, CheckboxProps>((props, ref) => {
|
|
|
128
124
|
variant={null}
|
|
129
125
|
>
|
|
130
126
|
{text}
|
|
131
|
-
{requiredIndicator && (
|
|
132
|
-
<span
|
|
133
|
-
aria-hidden="true"
|
|
134
|
-
className="pb_required_indicator"
|
|
135
|
-
style={{
|
|
136
|
-
color: colors.error,
|
|
137
|
-
marginLeft: spacing.space_xs,
|
|
138
|
-
}}
|
|
139
|
-
>
|
|
140
|
-
{'*'}
|
|
141
|
-
</span>
|
|
142
|
-
)}
|
|
143
127
|
</Body>
|
|
144
|
-
|
|
145
128
|
</label>
|
|
146
129
|
)
|
|
147
130
|
})
|
|
@@ -5,15 +5,6 @@
|
|
|
5
5
|
<%= pb_rails("icon", props: { icon: "minus", classname: "indeterminate_icon hidden", fixed_width: true}) %>
|
|
6
6
|
</span>
|
|
7
7
|
<span class="pb_checkbox_label">
|
|
8
|
-
<%= pb_rails("body", props: { status: object.checkbox_label_status, dark: object.dark, margin_right: object.form_spacing ? "xs" : "" })
|
|
9
|
-
<%= object.text%>
|
|
10
|
-
<% if object.required_indicator %>
|
|
11
|
-
<span
|
|
12
|
-
class="pb_checkbox_required_indicator"
|
|
13
|
-
aria-hidden="true"
|
|
14
|
-
style="color: #DA0014;"
|
|
15
|
-
>*</span>
|
|
16
|
-
<% end %>
|
|
17
|
-
<% end %>
|
|
8
|
+
<%= pb_rails("body", props: { status: object.checkbox_label_status, text: object.text, dark: object.dark, margin_right: object.form_spacing ? "xs" : "" }) %>
|
|
18
9
|
</span>
|
|
19
10
|
<% end %>
|
|
@@ -23,8 +23,6 @@ module Playbook
|
|
|
23
23
|
prop :hidden_input, type: Playbook::Props::Boolean,
|
|
24
24
|
default: false
|
|
25
25
|
prop :hidden_value
|
|
26
|
-
prop :required_indicator, type: Playbook::Props::Boolean,
|
|
27
|
-
default: false
|
|
28
26
|
|
|
29
27
|
def classname
|
|
30
28
|
generate_classname("pb_checkbox_kit", checked_class) + error_class
|
|
@@ -8,7 +8,6 @@ examples:
|
|
|
8
8
|
- checkbox_indeterminate: Indeterminate Checkbox
|
|
9
9
|
- checkbox_disabled: Disabled Checkbox
|
|
10
10
|
- checkbox_form: Form and Hidden Input
|
|
11
|
-
# - checkbox_required_indicator: Required Indicator
|
|
12
11
|
|
|
13
12
|
react:
|
|
14
13
|
- checkbox_default: Default
|
|
@@ -18,7 +17,6 @@ examples:
|
|
|
18
17
|
- checkbox_error: Default w/ Error
|
|
19
18
|
- checkbox_indeterminate: Indeterminate Checkbox
|
|
20
19
|
- checkbox_disabled: Disabled Checkbox
|
|
21
|
-
# - checkbox_required_indicator: Required Indicator
|
|
22
20
|
|
|
23
21
|
swift:
|
|
24
22
|
- checkbox_default_swift: Default
|
|
@@ -5,4 +5,3 @@ export { default as CheckboxError } from './_checkbox_error.jsx'
|
|
|
5
5
|
export { default as CheckboxChecked } from './_checkbox_checked.jsx'
|
|
6
6
|
export { default as CheckboxIndeterminate } from './_checkbox_indeterminate.jsx'
|
|
7
7
|
export { default as CheckboxDisabled } from './_checkbox_disabled.jsx'
|
|
8
|
-
export { default as CheckboxRequiredIndicator } from './_checkbox_required_indicator.jsx'
|
|
@@ -40,7 +40,7 @@ type DatePickerProps = {
|
|
|
40
40
|
maxDate: string,
|
|
41
41
|
minDate: string,
|
|
42
42
|
name: string,
|
|
43
|
-
pickerId
|
|
43
|
+
pickerId?: string,
|
|
44
44
|
placeholder?: string,
|
|
45
45
|
positionElement?: HTMLElement | null,
|
|
46
46
|
scrollContainer?: string,
|
|
@@ -196,8 +196,6 @@ const DatePicker = (props: DatePickerProps): React.ReactElement => {
|
|
|
196
196
|
|
|
197
197
|
const angleDown = getAllIcons()["angleDown"].icon as unknown as { [key: string]: SVGElement }
|
|
198
198
|
|
|
199
|
-
const errorId = error ? `${pickerId}-error` : undefined
|
|
200
|
-
|
|
201
199
|
return (
|
|
202
200
|
<div
|
|
203
201
|
{...ariaProps}
|
|
@@ -213,18 +211,14 @@ const DatePicker = (props: DatePickerProps): React.ReactElement => {
|
|
|
213
211
|
>
|
|
214
212
|
|
|
215
213
|
{!hideLabel && (
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
/>
|
|
221
|
-
</label>
|
|
214
|
+
<Caption
|
|
215
|
+
className="pb_date_picker_kit_label"
|
|
216
|
+
text={label}
|
|
217
|
+
/>
|
|
222
218
|
)}
|
|
223
219
|
<>
|
|
224
220
|
<div className="date_picker_input_wrapper">
|
|
225
221
|
<input
|
|
226
|
-
aria-describedby={errorId}
|
|
227
|
-
aria-invalid={!!error}
|
|
228
222
|
autoComplete="off"
|
|
229
223
|
className="date_picker_input"
|
|
230
224
|
disabled={disableInput}
|
|
@@ -238,9 +232,6 @@ const DatePicker = (props: DatePickerProps): React.ReactElement => {
|
|
|
238
232
|
|
|
239
233
|
{error &&
|
|
240
234
|
<Body
|
|
241
|
-
aria={{ atomic: "true", live: "polite" }}
|
|
242
|
-
htmlOptions={{ role: "alert" }}
|
|
243
|
-
id={errorId}
|
|
244
235
|
status="negative"
|
|
245
236
|
text={error}
|
|
246
237
|
variant={null}
|
|
@@ -1,17 +1,14 @@
|
|
|
1
1
|
<%= pb_form_with(scope: :example, url: "", method: :get, validate: true) do |form| %>
|
|
2
|
-
<%= form.typeahead :example_typeahead_field, props: { label: true, required: true, required_indicator: true } %>
|
|
3
2
|
<%= form.text_field :example_text_field, props: { label: true, required: true, required_indicator: true } %>
|
|
4
3
|
<%= form.text_field :example_text_field_2, props: { label: "Text Field Custom Label", required: true, required_indicator: true } %>
|
|
5
|
-
<%= form.
|
|
4
|
+
<%= form.text_area :example_text_area, props: { label: true, required: true, required_indicator: true } %>
|
|
5
|
+
<%= form.text_area :example_text_area_2, props: { label: "Textarea Custom Label", required: true, required_indicator: true } %>
|
|
6
6
|
<%= form.email_field :example_email_field, props: { label: true, required: true, required_indicator: true } %>
|
|
7
7
|
<%= form.number_field :example_number_field, props: { label: true, required: true, required_indicator: true } %>
|
|
8
8
|
<%= form.search_field :example_search_field, props: { label: true, required: true, required_indicator: true } %>
|
|
9
9
|
<%= form.password_field :example_password_field, props: { label: true, required: true, required_indicator: true } %>
|
|
10
10
|
<%= form.url_field :example_url_field, props: { label: true, required: true, required_indicator: true } %>
|
|
11
|
-
<%= form.
|
|
12
|
-
<%= form.text_area :example_text_area_2, props: { label: "Textarea Custom Label", required: true, required_indicator: true } %>
|
|
13
|
-
<%# <%= form.check_box :example_checkbox, props: { label: true, text: "Checkbox Label", required: true, required_indicator: true } %>
|
|
14
|
-
<%= form.time_picker :example_time_picker_required_indicator, props: { label: true, required: true, required_indicator: true } %>
|
|
11
|
+
<%= form.phone_number_field :example_phone_number_field, props: { label: true, required: true, required_indicator: true } %>
|
|
15
12
|
|
|
16
13
|
<%= form.actions do |action| %>
|
|
17
14
|
<%= action.submit %>
|
|
@@ -26,10 +26,6 @@ class PbFormValidation extends PbEnhancedElement {
|
|
|
26
26
|
const isPhoneNumberInput = field.closest('.pb_phone_number_input')
|
|
27
27
|
if (isPhoneNumberInput) return
|
|
28
28
|
|
|
29
|
-
// Skip TimePicker inputs - they handle their own validation
|
|
30
|
-
const isTimePickerInput = field.closest('.pb_time_picker')
|
|
31
|
-
if (isTimePickerInput) return
|
|
32
|
-
|
|
33
29
|
FIELD_EVENTS.forEach((e) => {
|
|
34
30
|
field.addEventListener(e, debounce((event) => {
|
|
35
31
|
this.validateFormField(event)
|
|
@@ -71,16 +67,13 @@ class PbFormValidation extends PbEnhancedElement {
|
|
|
71
67
|
|
|
72
68
|
// Check if this is a phone number input
|
|
73
69
|
const isPhoneNumberInput = kitElement.classList.contains('pb_phone_number_input')
|
|
74
|
-
|
|
75
|
-
// Check if this is a TimePicker input
|
|
76
|
-
const isTimePickerInput = kitElement.classList.contains('pb_time_picker')
|
|
77
70
|
|
|
78
71
|
// ensure clean error message state
|
|
79
72
|
this.clearError(target)
|
|
80
73
|
kitElement.classList.add('error')
|
|
81
74
|
|
|
82
|
-
// Only add error message if it's NOT a phone number input
|
|
83
|
-
if (!isPhoneNumberInput
|
|
75
|
+
// Only add error message if it's NOT a phone number input
|
|
76
|
+
if (!isPhoneNumberInput) {
|
|
84
77
|
// set the error message element
|
|
85
78
|
const errorMessageContainer = this.errorMessageContainer
|
|
86
79
|
|
|
@@ -178,40 +178,22 @@ const Passphrase = (props: PassphraseProps): React.ReactElement => {
|
|
|
178
178
|
{...inputProps}
|
|
179
179
|
/>
|
|
180
180
|
<span
|
|
181
|
-
aria-label={
|
|
182
|
-
showPassphrase
|
|
183
|
-
? "Passphrase currently visible. Click icon to hide password"
|
|
184
|
-
: "Passphrase currently hidden. Click icon to reveal password"
|
|
185
|
-
}
|
|
186
|
-
aria-pressed={showPassphrase}
|
|
187
181
|
className="show-passphrase-icon"
|
|
188
182
|
onClick={toggleShowPassphrase}
|
|
189
|
-
onKeyDown={(e) => {
|
|
190
|
-
if (e.key === "Enter" || e.key === " ") {
|
|
191
|
-
e.preventDefault()
|
|
192
|
-
toggleShowPassphrase(e as any)
|
|
193
|
-
}
|
|
194
|
-
}}
|
|
195
|
-
role="button"
|
|
196
|
-
tabIndex={0}
|
|
197
183
|
>
|
|
198
184
|
<Body
|
|
199
185
|
className={showPassphrase ? "hide-icon" : ""}
|
|
200
186
|
color="light"
|
|
201
187
|
dark={dark}
|
|
202
188
|
>
|
|
203
|
-
<Icon
|
|
204
|
-
aria={{ label: "eye icon" }}
|
|
205
|
-
icon="eye-slash"
|
|
206
|
-
/>
|
|
189
|
+
<Icon icon="eye-slash" />
|
|
207
190
|
</Body>
|
|
208
191
|
<Body
|
|
209
192
|
className={showPassphrase ? "" : "hide-icon"}
|
|
210
193
|
color="light"
|
|
211
194
|
dark={dark}
|
|
212
195
|
>
|
|
213
|
-
<Icon
|
|
214
|
-
aria={{ label: "eye icon" }}
|
|
196
|
+
<Icon
|
|
215
197
|
className="svg-inline--fa"
|
|
216
198
|
customIcon={eyeIcon.icon as unknown as { [key: string]: SVGElement }}
|
|
217
199
|
/>
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import React, { useEffect, useState, useRef } from 'react'
|
|
2
2
|
import classnames from 'classnames'
|
|
3
|
-
|
|
3
|
+
import { TrixEditor } from 'react-trix'
|
|
4
4
|
|
|
5
5
|
import inlineFocus from './inlineFocus'
|
|
6
6
|
import useFocus from './useFocus'
|
|
@@ -9,6 +9,14 @@ import colors from '../tokens/exports/_colors.module.scss'
|
|
|
9
9
|
import { globalProps, GlobalProps } from '../utilities/globalProps'
|
|
10
10
|
import { buildAriaProps, buildDataProps, noop, buildHtmlProps } from '../utilities/props'
|
|
11
11
|
|
|
12
|
+
import Trix from 'trix'
|
|
13
|
+
import './_dedupe_trix_toolbar'
|
|
14
|
+
|
|
15
|
+
Trix.config.textAttributes.inlineCode = {
|
|
16
|
+
tagName: 'code',
|
|
17
|
+
inheritable: true,
|
|
18
|
+
}
|
|
19
|
+
|
|
12
20
|
import EditorToolbar from './TipTap/Toolbar'
|
|
13
21
|
|
|
14
22
|
type Editor = {
|
|
@@ -47,7 +55,6 @@ type RichTextEditorProps = {
|
|
|
47
55
|
template: string,
|
|
48
56
|
value?: string,
|
|
49
57
|
maxWidth?: string
|
|
50
|
-
TrixEditor?: React.ComponentType<any>,
|
|
51
58
|
} & GlobalProps
|
|
52
59
|
|
|
53
60
|
const RichTextEditor = (props: RichTextEditorProps): React.ReactElement => {
|
|
@@ -77,7 +84,6 @@ const RichTextEditor = (props: RichTextEditorProps): React.ReactElement => {
|
|
|
77
84
|
maxWidth = "md",
|
|
78
85
|
requiredIndicator = false,
|
|
79
86
|
label,
|
|
80
|
-
TrixEditor,
|
|
81
87
|
} = props
|
|
82
88
|
|
|
83
89
|
const ariaProps = buildAriaProps(aria),
|
|
@@ -88,51 +94,25 @@ const RichTextEditor = (props: RichTextEditorProps): React.ReactElement => {
|
|
|
88
94
|
|
|
89
95
|
const htmlProps = buildHtmlProps(htmlOptions)
|
|
90
96
|
|
|
91
|
-
const fieldId = id ? (id as string) : null
|
|
92
|
-
const labelElementId = fieldId ? `${fieldId}-label` : null
|
|
93
|
-
|
|
94
97
|
const handleOnEditorReady = (editorInstance: Editor) => {
|
|
95
98
|
setEditor(editorInstance)
|
|
96
|
-
|
|
97
99
|
setTimeout(() => {
|
|
98
|
-
const oldId = editorInstance.element
|
|
99
|
-
if (
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
if (inputOptions.name) {
|
|
112
|
-
hiddenInput.setAttribute("name", inputOptions.name as string)
|
|
113
|
-
}
|
|
114
|
-
|
|
115
|
-
const editorDomId = (id as string) || `${hiddenInputId}_trix`
|
|
116
|
-
const trixLabelId = ((id as string) || hiddenInputId) + "-label"
|
|
117
|
-
|
|
118
|
-
if (label) {
|
|
119
|
-
editorInstance.element?.setAttribute("aria-labelledby", trixLabelId)
|
|
100
|
+
const oldId = editorInstance.element.getAttribute('input')
|
|
101
|
+
if (oldId) {
|
|
102
|
+
const hiddenInput = document.getElementById(oldId)
|
|
103
|
+
if (hiddenInput) {
|
|
104
|
+
const newId = (inputOptions.id as string) || oldId
|
|
105
|
+
hiddenInput.id = newId
|
|
106
|
+
editorInstance.element.setAttribute('input', newId)
|
|
107
|
+
|
|
108
|
+
if (inputOptions.name) {
|
|
109
|
+
hiddenInput.setAttribute('name', inputOptions.name as string)
|
|
110
|
+
}
|
|
111
|
+
}
|
|
120
112
|
}
|
|
121
|
-
editorInstance.element!.id = editorDomId
|
|
122
113
|
})
|
|
123
114
|
}
|
|
124
115
|
|
|
125
|
-
useEffect(() => {
|
|
126
|
-
if (!advancedEditor || !fieldId || !labelElementId) return
|
|
127
|
-
|
|
128
|
-
const dom = advancedEditor.view?.dom as HTMLElement | undefined
|
|
129
|
-
if (!dom) return
|
|
130
|
-
|
|
131
|
-
dom.setAttribute("aria-labelledby", labelElementId)
|
|
132
|
-
dom.setAttribute("role", "textbox")
|
|
133
|
-
dom.setAttribute("aria-multiline", "true")
|
|
134
|
-
}, [advancedEditor, fieldId, labelElementId])
|
|
135
|
-
|
|
136
116
|
// DOM manipulation must wait for editor to be ready
|
|
137
117
|
if (editor && editor.element) {
|
|
138
118
|
const toolbarElement = editor.element.parentElement.querySelector('trix-toolbar') as HTMLElement,
|
|
@@ -234,8 +214,6 @@ const RichTextEditor = (props: RichTextEditorProps): React.ReactElement => {
|
|
|
234
214
|
// Determine if toolbar should be shown
|
|
235
215
|
const shouldShowToolbar = focus && advancedEditor ? showToolbarOnFocus : advancedEditorToolbar
|
|
236
216
|
|
|
237
|
-
const labelFor = advancedEditor ? fieldId : (id ? id : (inputOptions.id ? `${inputOptions.id}_trix` : undefined))
|
|
238
|
-
|
|
239
217
|
return (
|
|
240
218
|
<div
|
|
241
219
|
{...ariaProps}
|
|
@@ -245,14 +223,7 @@ const RichTextEditor = (props: RichTextEditorProps): React.ReactElement => {
|
|
|
245
223
|
ref={focus ? containerRef : undefined}
|
|
246
224
|
>
|
|
247
225
|
{label && (
|
|
248
|
-
<label
|
|
249
|
-
{...(labelFor ? { htmlFor: labelFor, id: labelElementId } : {})}
|
|
250
|
-
onMouseDown={(e) => {
|
|
251
|
-
if (!advancedEditor || !fieldId) return
|
|
252
|
-
e.preventDefault()
|
|
253
|
-
advancedEditor.commands.focus()
|
|
254
|
-
}}
|
|
255
|
-
>
|
|
226
|
+
<label htmlFor={id}>
|
|
256
227
|
{
|
|
257
228
|
requiredIndicator ? (
|
|
258
229
|
<Caption className="pb_text_input_kit_label"
|
|
@@ -275,9 +246,9 @@ const RichTextEditor = (props: RichTextEditorProps): React.ReactElement => {
|
|
|
275
246
|
advancedEditor ? (
|
|
276
247
|
<div
|
|
277
248
|
className={classnames(
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
249
|
+
"pb_rich_text_editor_advanced_container",
|
|
250
|
+
{ [`input_height_${inputHeight}`]: !!inputHeight,[`input_min_height_${inputMinHeight}`]: !!inputMinHeight ,["toolbar-active"]: shouldShowToolbar }
|
|
251
|
+
)}
|
|
281
252
|
>
|
|
282
253
|
{shouldShowToolbar && (
|
|
283
254
|
<EditorToolbar editor={advancedEditor}
|
|
@@ -289,23 +260,15 @@ const RichTextEditor = (props: RichTextEditorProps): React.ReactElement => {
|
|
|
289
260
|
{ children }
|
|
290
261
|
</div>
|
|
291
262
|
) : (
|
|
292
|
-
TrixEditor
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
/>
|
|
302
|
-
) : (
|
|
303
|
-
<div style={{ color: 'red', padding: '1em', border: '1px solid #f00', background: '#fff0f0' }}>
|
|
304
|
-
<strong>Trix Editor is not available.</strong><br />
|
|
305
|
-
Please import <code>TrixEditor</code> from <code>react-trix</code> and pass it as a prop to <code>RichTextEditor</code>.<br />
|
|
306
|
-
<pre>{`import { TrixEditor } from 'react-trix';\n<RichTextEditor TrixEditor={TrixEditor} ... />`}</pre>
|
|
307
|
-
</div>
|
|
308
|
-
)
|
|
263
|
+
<TrixEditor
|
|
264
|
+
className=""
|
|
265
|
+
fileParamName={name}
|
|
266
|
+
mergeTags={[]}
|
|
267
|
+
onChange={onChange}
|
|
268
|
+
onEditorReady={handleOnEditorReady}
|
|
269
|
+
placeholder={placeholder}
|
|
270
|
+
value={value}
|
|
271
|
+
/>
|
|
309
272
|
)
|
|
310
273
|
}
|
|
311
274
|
</div>
|
|
@@ -1,13 +1,9 @@
|
|
|
1
1
|
import React from 'react'
|
|
2
2
|
import RichTextEditor from '../../pb_rich_text_editor/_rich_text_editor'
|
|
3
|
-
import { TrixEditor } from 'react-trix'
|
|
4
|
-
// eslint-disable-next-line no-unused-vars
|
|
5
|
-
import Trix from 'trix'
|
|
6
3
|
|
|
7
4
|
const RichTextEditorAttributes = (props) => (
|
|
8
5
|
<div>
|
|
9
6
|
<RichTextEditor
|
|
10
|
-
TrixEditor={TrixEditor}
|
|
11
7
|
aria={{ label: 'rich textarea' }}
|
|
12
8
|
data={{ key: 'value', key2: 'value2' }}
|
|
13
9
|
name="name-attribute"
|
|
@@ -0,0 +1 @@
|
|
|
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,8 +1,5 @@
|
|
|
1
1
|
import React, { useState } from 'react'
|
|
2
2
|
import RichTextEditor from '../../pb_rich_text_editor/_rich_text_editor'
|
|
3
|
-
import { TrixEditor } from 'react-trix'
|
|
4
|
-
// eslint-disable-next-line no-unused-vars
|
|
5
|
-
import Trix from 'trix'
|
|
6
3
|
|
|
7
4
|
const RichTextEditorDefault = (props) => {
|
|
8
5
|
const [value, setValue] = useState('Add your text here. You can format your text, add links, quotes, and bullets.'),
|
|
@@ -11,7 +8,6 @@ const RichTextEditorDefault = (props) => {
|
|
|
11
8
|
return (
|
|
12
9
|
<div>
|
|
13
10
|
<RichTextEditor
|
|
14
|
-
TrixEditor={TrixEditor}
|
|
15
11
|
onChange={handleOnChange}
|
|
16
12
|
value={value}
|
|
17
13
|
{...props}
|
|
@@ -1,19 +1,14 @@
|
|
|
1
1
|
import React from 'react'
|
|
2
2
|
import RichTextEditor from '../../pb_rich_text_editor/_rich_text_editor'
|
|
3
|
-
import { TrixEditor } from 'react-trix'
|
|
4
|
-
// eslint-disable-next-line no-unused-vars
|
|
5
|
-
import Trix from 'trix'
|
|
6
3
|
|
|
7
4
|
const RichTextEditorFocus = (props) => (
|
|
8
5
|
<>
|
|
9
6
|
<RichTextEditor
|
|
10
|
-
TrixEditor={TrixEditor}
|
|
11
7
|
focus
|
|
12
8
|
{...props}
|
|
13
9
|
/>
|
|
14
10
|
<br />
|
|
15
11
|
<RichTextEditor
|
|
16
|
-
TrixEditor={TrixEditor}
|
|
17
12
|
focus
|
|
18
13
|
{...props}
|
|
19
14
|
/>
|
|
@@ -1,13 +1,9 @@
|
|
|
1
1
|
import React from 'react'
|
|
2
2
|
import RichTextEditor from '../../pb_rich_text_editor/_rich_text_editor'
|
|
3
|
-
import { TrixEditor } from 'react-trix'
|
|
4
|
-
// eslint-disable-next-line no-unused-vars
|
|
5
|
-
import Trix from 'trix'
|
|
6
3
|
|
|
7
4
|
const RichTextEditorInline = (props) => (
|
|
8
5
|
<div>
|
|
9
6
|
<RichTextEditor
|
|
10
|
-
TrixEditor={TrixEditor}
|
|
11
7
|
id="inline"
|
|
12
8
|
inline
|
|
13
9
|
toolbarBottom
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
|
|
2
|
+
<%= pb_rails("rich_text_editor", props: { id: "content-preview-editor" }) %>
|
|
3
|
+
<div id="card-obfuscation" style="display:none">
|
|
4
|
+
<%= pb_rails("card", props: { margin_top: "md", max_width: "md", padding: "sm" }) do %>
|
|
5
|
+
<div id="content-preview" class="trix-content">
|
|
6
|
+
</div>
|
|
7
|
+
<% end %>
|
|
8
|
+
</div>
|
|
9
|
+
<%= pb_rails("button", props: { id: "preview-button", variant: "secondary", margin_top: "md" }) do %>
|
|
10
|
+
<span>Preview Output</span>
|
|
11
|
+
<% end %>
|
|
12
|
+
|
|
13
|
+
<script>
|
|
14
|
+
document.addEventListener('DOMContentLoaded', () => {
|
|
15
|
+
function handleButtonClick() {
|
|
16
|
+
const editorContainer = [...document.querySelectorAll('[data-pb-react-props]')]
|
|
17
|
+
.find(element => element.getAttribute('data-pb-react-props')?.includes('"id":"content-preview-editor"'))
|
|
18
|
+
|
|
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
|
+
})
|
|
35
|
+
</script>
|