playbook_ui 15.2.0.pre.alpha.testingquickpick11606 → 15.2.0.pre.alpha.testingtiptap11313
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/_playbook.scss +5 -5
- data/app/pb_kits/playbook/pb_advanced_table/advanced_table.html.erb +2 -2
- data/app/pb_kits/playbook/pb_advanced_table/docs/_advanced_table_beta.md +1 -3
- data/app/pb_kits/playbook/pb_advanced_table/docs/_advanced_table_beta_sort.html.erb +3 -3
- data/app/pb_kits/playbook/pb_advanced_table/docs/_advanced_table_beta_subrow_headers.html.erb +3 -3
- data/app/pb_kits/playbook/pb_advanced_table/docs/_advanced_table_collapsible_trail_rails.html.erb +2 -2
- data/app/pb_kits/playbook/pb_advanced_table/docs/_advanced_table_column_styling.md +1 -1
- data/app/pb_kits/playbook/pb_advanced_table/docs/_advanced_table_column_styling_column_headers_rails.html.erb +2 -2
- data/app/pb_kits/playbook/pb_advanced_table/docs/_advanced_table_column_styling_rails.html.erb +2 -2
- data/app/pb_kits/playbook/pb_advanced_table/docs/_advanced_table_column_styling_rails.md +1 -1
- data/app/pb_kits/playbook/pb_advanced_table/docs/_advanced_table_row_styling_rails.md +1 -1
- data/app/pb_kits/playbook/pb_advanced_table/docs/_advanced_table_row_styling_react.md +1 -1
- data/app/pb_kits/playbook/pb_advanced_table/docs/_advanced_table_selectable_rows_rails.html.erb +2 -2
- data/app/pb_kits/playbook/pb_advanced_table/docs/example.yml +0 -3
- data/app/pb_kits/playbook/pb_advanced_table/index.js +1 -5
- data/app/pb_kits/playbook/pb_advanced_table/table_body.rb +6 -6
- data/app/pb_kits/playbook/pb_advanced_table/table_header.rb +6 -6
- data/app/pb_kits/playbook/pb_advanced_table/table_row.html.erb +2 -3
- data/app/pb_kits/playbook/pb_advanced_table/table_row.rb +5 -49
- data/app/pb_kits/playbook/pb_button/_button.scss +0 -6
- data/app/pb_kits/playbook/pb_button/docs/_button_loading.html.erb +3 -7
- data/app/pb_kits/playbook/pb_button/docs/_button_loading.jsx +0 -29
- data/app/pb_kits/playbook/pb_date_picker/docs/_date_picker_range_pattern.jsx +1 -1
- data/app/pb_kits/playbook/pb_date_picker/sass_partials/_quick_pick_styles.scss +30 -11
- data/app/pb_kits/playbook/pb_draggable/_draggable.scss +0 -8
- data/app/pb_kits/playbook/pb_fixed_confirmation_toast/_fixed_confirmation_toast.scss +1 -0
- data/app/pb_kits/playbook/pb_fixed_confirmation_toast/_fixed_confirmation_toast.tsx +3 -5
- data/app/pb_kits/playbook/pb_fixed_confirmation_toast/docs/_description.md +0 -2
- data/app/pb_kits/playbook/pb_fixed_confirmation_toast/fixed_confirmation_toast.rb +1 -4
- data/app/pb_kits/playbook/pb_fixed_confirmation_toast/fixed_confirmation_toast.test.js +0 -10
- data/app/pb_kits/playbook/pb_form/docs/_form_form_with_validate.html.erb +1 -1
- data/app/pb_kits/playbook/pb_pb_bar_graph/_pb_bar_graph.tsx +6 -8
- data/app/pb_kits/playbook/pb_pb_bar_graph/pb_bar_graph.rb +10 -7
- data/app/pb_kits/playbook/pb_pb_bar_graph/pbbargraph.test.jsx +1 -73
- data/app/pb_kits/playbook/pb_pb_circle_chart/_pb_circle_chart.tsx +1 -1
- data/app/pb_kits/playbook/pb_pb_circle_chart/pb_circle_chart.rb +10 -7
- data/app/pb_kits/playbook/pb_pb_circle_chart/pb_circle_chart.test.jsx +0 -47
- data/app/pb_kits/playbook/pb_phone_number_input/_phone_number_input.tsx +22 -105
- data/app/pb_kits/playbook/pb_timeline/_timeline.scss +233 -250
- data/app/pb_kits/playbook/pb_timeline/_timeline.tsx +1 -1
- data/app/pb_kits/playbook/pb_timeline/timeline.test.js +2 -2
- data/app/pb_kits/playbook/tokens/_positioning.scss +0 -1
- data/app/pb_kits/playbook/utilities/_positioning.scss +1 -6
- data/app/pb_kits/playbook/utilities/globalProps.ts +1 -3
- data/dist/chunks/{_line_graph-BnVgr42C.js → _line_graph-BoA3Vs81.js} +1 -1
- data/dist/chunks/_typeahead-BkqswwwC.js +6 -0
- data/dist/chunks/{_weekday_stacked-Bz13QeMW.js → _weekday_stacked-CjVj28hU.js} +2 -2
- data/dist/chunks/vendor.js +1 -1
- data/dist/menu.yml +0 -12
- data/dist/playbook-doc.js +2 -2
- data/dist/playbook-rails-react-bindings.js +1 -1
- data/dist/playbook-rails.js +1 -1
- data/dist/playbook.css +1 -1
- data/lib/playbook/pb_forms_helper.rb +6 -7
- data/lib/playbook/version.rb +1 -1
- data/lib/playbook/z_index.rb +1 -1
- metadata +5 -72
- data/app/pb_kits/playbook/pb_advanced_table/docs/_advanced_table_background_control_rails.html.erb +0 -39
- data/app/pb_kits/playbook/pb_advanced_table/docs/_advanced_table_background_control_rails.md +0 -1
- data/app/pb_kits/playbook/pb_advanced_table/docs/_advanced_table_padding_control_per_row_rails.html.erb +0 -51
- data/app/pb_kits/playbook/pb_advanced_table/docs/_advanced_table_padding_control_per_row_rails.md +0 -1
- data/app/pb_kits/playbook/pb_advanced_table/docs/_advanced_table_padding_control_rails.html.erb +0 -40
- data/app/pb_kits/playbook/pb_advanced_table/docs/_advanced_table_padding_control_rails.md +0 -1
- data/app/pb_kits/playbook/pb_pb_bar_graph/docs/_description.md +0 -3
- data/app/pb_kits/playbook/pb_pb_circle_chart/docs/_description.md +0 -3
- data/app/pb_kits/playbook/pb_pb_gauge_chart/_pb_gauge_chart.scss +0 -3
- data/app/pb_kits/playbook/pb_pb_gauge_chart/_pb_gauge_chart.tsx +0 -69
- data/app/pb_kits/playbook/pb_pb_gauge_chart/docs/_description.md +0 -3
- data/app/pb_kits/playbook/pb_pb_gauge_chart/docs/_pb_gauge_chart_color.html.erb +0 -12
- data/app/pb_kits/playbook/pb_pb_gauge_chart/docs/_pb_gauge_chart_color.jsx +0 -24
- data/app/pb_kits/playbook/pb_pb_gauge_chart/docs/_pb_gauge_chart_color.md +0 -5
- data/app/pb_kits/playbook/pb_pb_gauge_chart/docs/_pb_gauge_chart_complex.html.erb +0 -45
- data/app/pb_kits/playbook/pb_pb_gauge_chart/docs/_pb_gauge_chart_complex.jsx +0 -119
- data/app/pb_kits/playbook/pb_pb_gauge_chart/docs/_pb_gauge_chart_complex.md +0 -1
- data/app/pb_kits/playbook/pb_pb_gauge_chart/docs/_pb_gauge_chart_default.html.erb +0 -5
- data/app/pb_kits/playbook/pb_pb_gauge_chart/docs/_pb_gauge_chart_default.jsx +0 -17
- data/app/pb_kits/playbook/pb_pb_gauge_chart/docs/_pb_gauge_chart_disable_animation.html.erb +0 -12
- data/app/pb_kits/playbook/pb_pb_gauge_chart/docs/_pb_gauge_chart_disable_animation.jsx +0 -24
- data/app/pb_kits/playbook/pb_pb_gauge_chart/docs/_pb_gauge_chart_full_circle.html.erb +0 -23
- data/app/pb_kits/playbook/pb_pb_gauge_chart/docs/_pb_gauge_chart_full_circle.jsx +0 -37
- data/app/pb_kits/playbook/pb_pb_gauge_chart/docs/_pb_gauge_chart_height.html.erb +0 -40
- data/app/pb_kits/playbook/pb_pb_gauge_chart/docs/_pb_gauge_chart_height.jsx +0 -56
- data/app/pb_kits/playbook/pb_pb_gauge_chart/docs/_pb_gauge_chart_live_data.jsx +0 -64
- data/app/pb_kits/playbook/pb_pb_gauge_chart/docs/_pb_gauge_chart_min_max.html.erb +0 -27
- data/app/pb_kits/playbook/pb_pb_gauge_chart/docs/_pb_gauge_chart_min_max.jsx +0 -40
- data/app/pb_kits/playbook/pb_pb_gauge_chart/docs/_pb_gauge_chart_min_max.md +0 -1
- data/app/pb_kits/playbook/pb_pb_gauge_chart/docs/_pb_gauge_chart_sizing.html.erb +0 -19
- data/app/pb_kits/playbook/pb_pb_gauge_chart/docs/_pb_gauge_chart_sizing.jsx +0 -65
- data/app/pb_kits/playbook/pb_pb_gauge_chart/docs/_pb_gauge_chart_sizing.md +0 -3
- data/app/pb_kits/playbook/pb_pb_gauge_chart/docs/_pb_gauge_chart_title.html.erb +0 -14
- data/app/pb_kits/playbook/pb_pb_gauge_chart/docs/_pb_gauge_chart_title.jsx +0 -27
- data/app/pb_kits/playbook/pb_pb_gauge_chart/docs/_pb_gauge_chart_units.html.erb +0 -39
- data/app/pb_kits/playbook/pb_pb_gauge_chart/docs/_pb_gauge_chart_units.jsx +0 -58
- data/app/pb_kits/playbook/pb_pb_gauge_chart/docs/_pb_gauge_chart_units.md +0 -1
- data/app/pb_kits/playbook/pb_pb_gauge_chart/docs/example.yml +0 -29
- data/app/pb_kits/playbook/pb_pb_gauge_chart/docs/index.js +0 -11
- data/app/pb_kits/playbook/pb_pb_gauge_chart/pbGaugeGraphTheme.ts +0 -91
- data/app/pb_kits/playbook/pb_pb_gauge_chart/pb_gauge_chart.html.erb +0 -1
- data/app/pb_kits/playbook/pb_pb_gauge_chart/pb_gauge_chart.rb +0 -25
- data/app/pb_kits/playbook/pb_pb_gauge_chart/pb_gauge_chart.test.jsx +0 -80
- data/app/pb_kits/playbook/pb_pb_line_graph/_pb_line_graph.scss +0 -3
- data/app/pb_kits/playbook/pb_pb_line_graph/_pb_line_graph.tsx +0 -61
- data/app/pb_kits/playbook/pb_pb_line_graph/docs/_description.md +0 -3
- data/app/pb_kits/playbook/pb_pb_line_graph/docs/_pb_line_graph_colors.html.erb +0 -34
- data/app/pb_kits/playbook/pb_pb_line_graph/docs/_pb_line_graph_colors.jsx +0 -52
- data/app/pb_kits/playbook/pb_pb_line_graph/docs/_pb_line_graph_colors.md +0 -5
- data/app/pb_kits/playbook/pb_pb_line_graph/docs/_pb_line_graph_default.html.erb +0 -34
- data/app/pb_kits/playbook/pb_pb_line_graph/docs/_pb_line_graph_default.jsx +0 -45
- data/app/pb_kits/playbook/pb_pb_line_graph/docs/_pb_line_graph_height.html.erb +0 -47
- data/app/pb_kits/playbook/pb_pb_line_graph/docs/_pb_line_graph_height.jsx +0 -64
- data/app/pb_kits/playbook/pb_pb_line_graph/docs/_pb_line_graph_height.md +0 -3
- data/app/pb_kits/playbook/pb_pb_line_graph/docs/_pb_line_graph_legend.html.erb +0 -24
- data/app/pb_kits/playbook/pb_pb_line_graph/docs/_pb_line_graph_legend.jsx +0 -37
- data/app/pb_kits/playbook/pb_pb_line_graph/docs/_pb_line_graph_legend_nonclickable.html.erb +0 -39
- data/app/pb_kits/playbook/pb_pb_line_graph/docs/_pb_line_graph_legend_nonclickable.jsx +0 -45
- data/app/pb_kits/playbook/pb_pb_line_graph/docs/_pb_line_graph_legend_position.html.erb +0 -86
- data/app/pb_kits/playbook/pb_pb_line_graph/docs/_pb_line_graph_legend_position.jsx +0 -116
- data/app/pb_kits/playbook/pb_pb_line_graph/docs/_pb_line_graph_legend_position.md +0 -11
- data/app/pb_kits/playbook/pb_pb_line_graph/docs/example.yml +0 -20
- data/app/pb_kits/playbook/pb_pb_line_graph/docs/index.js +0 -6
- data/app/pb_kits/playbook/pb_pb_line_graph/pbLineGraphTheme.ts +0 -125
- data/app/pb_kits/playbook/pb_pb_line_graph/pb_line_graph.html.erb +0 -1
- data/app/pb_kits/playbook/pb_pb_line_graph/pb_line_graph.rb +0 -25
- data/app/pb_kits/playbook/pb_pb_line_graph/pb_line_graph.test.jsx +0 -110
- data/dist/chunks/_typeahead-BH_dkgOy.js +0 -6
|
@@ -75,14 +75,4 @@ test('renders position when provided', () => {
|
|
|
75
75
|
/>
|
|
76
76
|
);
|
|
77
77
|
expect(container.querySelector('.positioned_toast')).toBeInTheDocument();
|
|
78
|
-
});
|
|
79
|
-
|
|
80
|
-
test('renders max zIndex by default', () => {
|
|
81
|
-
const { container } = render(<FixedConfirmationToast />);
|
|
82
|
-
expect(container.querySelector('.z_index_max')).toBeInTheDocument();
|
|
83
|
-
});
|
|
84
|
-
|
|
85
|
-
test('applies custom zIndex when provided', () => {
|
|
86
|
-
const { container } = render(<FixedConfirmationToast zIndex={10} />);
|
|
87
|
-
expect(container.querySelector('.z_index_10')).toBeInTheDocument();
|
|
88
78
|
});
|
|
@@ -101,7 +101,7 @@
|
|
|
101
101
|
<%= form.typeahead :example_typeahead_validation_react, props: { options: example_typeahead_options, pills: true, label: "Example Typeahead (React Rendered)", placeholder: "Search for a user", required: true, validation: { message: "Please select a color." } } %>
|
|
102
102
|
<%= form.typeahead :example_typeahead_validation_react_2, props: { options: example_typeahead_options, pills: true, label: "Example Typeahead 2 (React Rendered)", placeholder: "Search for a user", required: true } %>
|
|
103
103
|
<%= form.text_field :example_text_field_validation, props: { label: true, required: true } %>
|
|
104
|
-
<%= form.phone_number_field :example_phone_number_field_validation, props: { label: "Example phone field", hidden_inputs: true
|
|
104
|
+
<%= form.phone_number_field :example_phone_number_field_validation, props: { label: "Example phone field", hidden_inputs: true } %>
|
|
105
105
|
<%= form.email_field :example_email_field_validation, props: { label: true, required: true } %>
|
|
106
106
|
<%= form.number_field :example_number_field_validation, props: { label: true, required: true } %>
|
|
107
107
|
<%= form.search_field :example_project_number_validation, props: { label: true, required: true, validation: { pattern: "[0-9]{2}-[0-9]{5}", message: "Please enter a valid project number (example: 33-12345)." } } %>
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import React, { useMemo } from "react"
|
|
2
2
|
import { globalProps } from "../utilities/globalProps";
|
|
3
|
-
import { buildAriaProps, buildDataProps,
|
|
3
|
+
import { buildAriaProps, buildDataProps, buildHtmlProps } from "../utilities/props";
|
|
4
4
|
import Highcharts from "highcharts"
|
|
5
5
|
import HighchartsReact from "highcharts-react-official"
|
|
6
6
|
|
|
@@ -18,25 +18,23 @@ type PbBarGraphProps = {
|
|
|
18
18
|
htmlOptions?: {[key: string]: string | number | boolean | (() => void)};
|
|
19
19
|
}
|
|
20
20
|
|
|
21
|
-
const PbBarGraph = (
|
|
22
|
-
const {
|
|
21
|
+
const PbBarGraph = ({
|
|
23
22
|
aria = {},
|
|
24
23
|
data = {},
|
|
25
24
|
id,
|
|
26
25
|
htmlOptions = {},
|
|
27
26
|
options,
|
|
28
|
-
className,
|
|
29
|
-
}
|
|
27
|
+
className = "pb_pb_bar_graph",
|
|
28
|
+
}: PbBarGraphProps): React.ReactElement => {
|
|
30
29
|
|
|
31
30
|
const ariaProps = buildAriaProps(aria);
|
|
32
31
|
const dataProps = buildDataProps(data)
|
|
33
32
|
const htmlProps = buildHtmlProps(htmlOptions);
|
|
34
|
-
const classes = classnames(buildCss('pb_pb_bar_graph'), globalProps(props), className)
|
|
35
33
|
|
|
36
34
|
const mergedOptions = useMemo(() => {
|
|
37
35
|
if (!options || typeof options !== "object") {
|
|
38
36
|
// eslint-disable-next-line no-console
|
|
39
|
-
console.error("❌ Invalid options passed to <
|
|
37
|
+
console.error("❌ Invalid options passed to <BarGraph />", options)
|
|
40
38
|
return {}
|
|
41
39
|
}
|
|
42
40
|
|
|
@@ -48,7 +46,7 @@ const {
|
|
|
48
46
|
<div>
|
|
49
47
|
<HighchartsReact
|
|
50
48
|
containerProps={{
|
|
51
|
-
className: classnames(
|
|
49
|
+
className: classnames(globalProps, className),
|
|
52
50
|
id: id,
|
|
53
51
|
...ariaProps,
|
|
54
52
|
...dataProps,
|
|
@@ -4,21 +4,24 @@ module Playbook
|
|
|
4
4
|
module PbPbBarGraph
|
|
5
5
|
class PbBarGraph < ::Playbook::KitBase
|
|
6
6
|
prop :options, default: {}
|
|
7
|
+
prop :container_props, default: {}
|
|
7
8
|
|
|
8
9
|
def react_props
|
|
9
10
|
{
|
|
10
|
-
className: classname,
|
|
11
|
-
data: data,
|
|
12
11
|
options: options,
|
|
13
|
-
|
|
12
|
+
containerProps: container_props_hash,
|
|
14
13
|
}
|
|
15
14
|
end
|
|
16
15
|
|
|
16
|
+
def container_props_hash
|
|
17
|
+
container_props.merge({
|
|
18
|
+
id: id,
|
|
19
|
+
className: classname,
|
|
20
|
+
}).compact
|
|
21
|
+
end
|
|
22
|
+
|
|
17
23
|
def classname
|
|
18
|
-
|
|
19
|
-
# we pass an empty string here to avoid conflicts, classname is built in the TSX
|
|
20
|
-
# We still need generate_classnames to retain ability to pass in custom classnames or global props
|
|
21
|
-
generate_classname("")
|
|
24
|
+
generate_classname("pb_pb_bar_graph")
|
|
22
25
|
end
|
|
23
26
|
end
|
|
24
27
|
end
|
|
@@ -15,41 +15,6 @@ afterEach(() => {
|
|
|
15
15
|
console.warn.mockRestore();
|
|
16
16
|
});
|
|
17
17
|
|
|
18
|
-
const chartData = [{
|
|
19
|
-
name: 'Installation',
|
|
20
|
-
data: [1475, 200, 3000, 654, 656],
|
|
21
|
-
}, {
|
|
22
|
-
name: 'Manufacturing',
|
|
23
|
-
data: [4434, 524, 2320, 440, 500],
|
|
24
|
-
}, {
|
|
25
|
-
name: 'Sales & Distribution',
|
|
26
|
-
data: [3387, 743, 1344, 434, 440],
|
|
27
|
-
}, {
|
|
28
|
-
name: 'Project Development',
|
|
29
|
-
data: [3227, 878, 999, 780, 1000],
|
|
30
|
-
}, {
|
|
31
|
-
name: 'Other',
|
|
32
|
-
data: [1111, 677, 3245, 500, 200],
|
|
33
|
-
}]
|
|
34
|
-
|
|
35
|
-
const chartOptions = {
|
|
36
|
-
series: chartData,
|
|
37
|
-
title: {
|
|
38
|
-
text: 'Solar Employment Growth by Sector, 2010-2016',
|
|
39
|
-
},
|
|
40
|
-
subtitle: {
|
|
41
|
-
text: 'Source: thesolarfoundation.com',
|
|
42
|
-
},
|
|
43
|
-
xAxis: {
|
|
44
|
-
categories: ['Jan', 'Feb', 'Mar', 'Apr', 'May'],
|
|
45
|
-
},
|
|
46
|
-
yAxis: {
|
|
47
|
-
title: {
|
|
48
|
-
text: 'Number of Employees',
|
|
49
|
-
},
|
|
50
|
-
},
|
|
51
|
-
}
|
|
52
|
-
|
|
53
18
|
const testId = 'bargraph1';
|
|
54
19
|
|
|
55
20
|
test('bargraph uses exact classname', () => {
|
|
@@ -58,46 +23,9 @@ test('bargraph uses exact classname', () => {
|
|
|
58
23
|
className='super_important_class'
|
|
59
24
|
data={{ testid: testId }}
|
|
60
25
|
id='bar-default'
|
|
61
|
-
options={chartOptions}
|
|
62
26
|
/>
|
|
63
27
|
);
|
|
64
28
|
|
|
65
29
|
const kit = screen.getByTestId(testId);
|
|
66
30
|
expect(kit).toHaveClass('super_important_class');
|
|
67
|
-
});
|
|
68
|
-
|
|
69
|
-
test('Kit to apply base classname', () => {
|
|
70
|
-
render(
|
|
71
|
-
<PbBarGraph
|
|
72
|
-
data={{testid: testId}}
|
|
73
|
-
options={chartOptions}
|
|
74
|
-
/>
|
|
75
|
-
)
|
|
76
|
-
|
|
77
|
-
expect(screen.getByTestId(testId)).toHaveClass('pb_pb_bar_graph')
|
|
78
|
-
})
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
test('Kit to apply global props', () => {
|
|
82
|
-
render(
|
|
83
|
-
<PbBarGraph
|
|
84
|
-
data={{testid: testId}}
|
|
85
|
-
margin="lg"
|
|
86
|
-
options={chartOptions}
|
|
87
|
-
/>
|
|
88
|
-
)
|
|
89
|
-
|
|
90
|
-
expect(screen.getByTestId(testId)).toHaveClass('m_lg')
|
|
91
|
-
})
|
|
92
|
-
|
|
93
|
-
test('kit to apply id', () => {
|
|
94
|
-
render(
|
|
95
|
-
<PbBarGraph
|
|
96
|
-
data={{testid: testId}}
|
|
97
|
-
id='bar-graph-id'
|
|
98
|
-
options={chartOptions}
|
|
99
|
-
/>
|
|
100
|
-
)
|
|
101
|
-
|
|
102
|
-
expect(screen.getByTestId(testId)).toHaveAttribute('id', 'bar-graph-id')
|
|
103
|
-
})
|
|
31
|
+
});
|
|
@@ -4,21 +4,24 @@ module Playbook
|
|
|
4
4
|
module PbPbCircleChart
|
|
5
5
|
class PbCircleChart < ::Playbook::KitBase
|
|
6
6
|
prop :options, default: {}
|
|
7
|
+
prop :container_props, default: {}
|
|
7
8
|
|
|
8
9
|
def react_props
|
|
9
10
|
{
|
|
10
|
-
className: classname,
|
|
11
|
-
data: data,
|
|
12
11
|
options: options,
|
|
13
|
-
|
|
12
|
+
containerProps: container_props_hash,
|
|
14
13
|
}
|
|
15
14
|
end
|
|
16
15
|
|
|
16
|
+
def container_props_hash
|
|
17
|
+
container_props.merge({
|
|
18
|
+
id: id,
|
|
19
|
+
className: classname,
|
|
20
|
+
}).compact
|
|
21
|
+
end
|
|
22
|
+
|
|
17
23
|
def classname
|
|
18
|
-
|
|
19
|
-
# we pass an empty string here to avoid conflicts, classname is built in the TSX
|
|
20
|
-
# We still need generate_classnames to retain ability to pass in custom classnames or global props
|
|
21
|
-
generate_classname("")
|
|
24
|
+
generate_classname("pb_pb_circle_chart")
|
|
22
25
|
end
|
|
23
26
|
end
|
|
24
27
|
end
|
|
@@ -49,50 +49,3 @@ test('Kit to exist', () => {
|
|
|
49
49
|
expect(screen.getByTestId(testId)).toBeInTheDocument()
|
|
50
50
|
})
|
|
51
51
|
|
|
52
|
-
test('Kit to apply base classname', () => {
|
|
53
|
-
render(
|
|
54
|
-
<PbCircleChart
|
|
55
|
-
data={{testid: testId}}
|
|
56
|
-
options={chartOptions}
|
|
57
|
-
/>
|
|
58
|
-
)
|
|
59
|
-
|
|
60
|
-
expect(screen.getByTestId(testId)).toHaveClass('pb_pb_circle_chart')
|
|
61
|
-
})
|
|
62
|
-
|
|
63
|
-
test('Kit to have custom class', () => {
|
|
64
|
-
render(
|
|
65
|
-
<PbCircleChart
|
|
66
|
-
className='custom-class'
|
|
67
|
-
data={{testid: testId}}
|
|
68
|
-
options={chartOptions}
|
|
69
|
-
/>
|
|
70
|
-
)
|
|
71
|
-
|
|
72
|
-
expect(screen.getByTestId(testId)).toHaveClass('custom-class')
|
|
73
|
-
})
|
|
74
|
-
|
|
75
|
-
test('Kit to apply global props', () => {
|
|
76
|
-
render(
|
|
77
|
-
<PbCircleChart
|
|
78
|
-
data={{testid: testId}}
|
|
79
|
-
margin="lg"
|
|
80
|
-
options={chartOptions}
|
|
81
|
-
/>
|
|
82
|
-
)
|
|
83
|
-
|
|
84
|
-
expect(screen.getByTestId(testId)).toHaveClass('m_lg')
|
|
85
|
-
})
|
|
86
|
-
|
|
87
|
-
test('kit to apply id', () => {
|
|
88
|
-
render(
|
|
89
|
-
<PbCircleChart
|
|
90
|
-
data={{testid: testId}}
|
|
91
|
-
id='circle-chart-id'
|
|
92
|
-
options={chartOptions}
|
|
93
|
-
/>
|
|
94
|
-
)
|
|
95
|
-
|
|
96
|
-
expect(screen.getByTestId(testId)).toHaveAttribute('id', 'circle-chart-id')
|
|
97
|
-
})
|
|
98
|
-
|
|
@@ -111,7 +111,7 @@ const PhoneNumberInput = (props: PhoneNumberInputProps, ref?: React.Ref<unknown>
|
|
|
111
111
|
const inputRef = useRef<HTMLInputElement | null>(null)
|
|
112
112
|
const itiRef = useRef<any>(null);
|
|
113
113
|
const [inputValue, setInputValue] = useState(value)
|
|
114
|
-
const [error, setError] = useState(props.error
|
|
114
|
+
const [error, setError] = useState(props.error)
|
|
115
115
|
const [dropDownIsOpen, setDropDownIsOpen] = useState(false)
|
|
116
116
|
const [selectedData, setSelectedData] = useState()
|
|
117
117
|
const [hasTyped, setHasTyped] = useState(false)
|
|
@@ -124,6 +124,24 @@ const PhoneNumberInput = (props: PhoneNumberInputProps, ref?: React.Ref<unknown>
|
|
|
124
124
|
}
|
|
125
125
|
}, [error, onValidate])
|
|
126
126
|
|
|
127
|
+
/*
|
|
128
|
+
useImperativeHandle exposes the kit's input element to a parent component via a ref.
|
|
129
|
+
See the Playbook docs for use cases.
|
|
130
|
+
Read: https://react.dev/reference/react/useImperativeHandle
|
|
131
|
+
*/
|
|
132
|
+
useImperativeHandle(ref, () => {
|
|
133
|
+
return {
|
|
134
|
+
clearField() {
|
|
135
|
+
setInputValue("")
|
|
136
|
+
setError("")
|
|
137
|
+
setHasTyped(false)
|
|
138
|
+
},
|
|
139
|
+
inputNode() {
|
|
140
|
+
return inputRef.current
|
|
141
|
+
}
|
|
142
|
+
}
|
|
143
|
+
})
|
|
144
|
+
|
|
127
145
|
const unformatNumber = (formattedNumber: any) => {
|
|
128
146
|
return formattedNumber.replace(/\D/g, "")
|
|
129
147
|
}
|
|
@@ -146,13 +164,6 @@ const PhoneNumberInput = (props: PhoneNumberInputProps, ref?: React.Ref<unknown>
|
|
|
146
164
|
|
|
147
165
|
const validateTooShortNumber = (itiInit: any) => {
|
|
148
166
|
if (!itiInit) return
|
|
149
|
-
|
|
150
|
-
// If field is empty, don't show "too short" error
|
|
151
|
-
if (!inputValue || inputValue.trim() === '') {
|
|
152
|
-
setError('')
|
|
153
|
-
return false
|
|
154
|
-
}
|
|
155
|
-
|
|
156
167
|
if (itiInit.getValidationError() === ValidationError.TooShort) {
|
|
157
168
|
return showFormattedError('too short')
|
|
158
169
|
} else {
|
|
@@ -172,7 +183,7 @@ const PhoneNumberInput = (props: PhoneNumberInputProps, ref?: React.Ref<unknown>
|
|
|
172
183
|
}
|
|
173
184
|
|
|
174
185
|
const validateUnhandledError = (itiInit: any) => {
|
|
175
|
-
if (!itiInit) return
|
|
186
|
+
if (!required || !itiInit) return
|
|
176
187
|
if (itiInit.getValidationError() === ValidationError.SomethingWentWrong) {
|
|
177
188
|
if (inputValue.length === 1) {
|
|
178
189
|
return showFormattedError('too short')
|
|
@@ -195,27 +206,14 @@ const PhoneNumberInput = (props: PhoneNumberInputProps, ref?: React.Ref<unknown>
|
|
|
195
206
|
|
|
196
207
|
const validateRepeatCountryCode = (itiInit: any) => {
|
|
197
208
|
if (!itiInit) return
|
|
198
|
-
const countryDialCode =
|
|
209
|
+
const countryDialCode = itiInit.getSelectedCountryData().dialCode;
|
|
199
210
|
if (unformatNumber(inputValue).startsWith(countryDialCode)) {
|
|
200
211
|
return showFormattedError('repeat country code')
|
|
201
212
|
}
|
|
202
213
|
}
|
|
203
214
|
|
|
204
|
-
const validateRequiredField = () => {
|
|
205
|
-
if (!inputValue || inputValue.trim() === '') {
|
|
206
|
-
setError('Missing phone number')
|
|
207
|
-
return true
|
|
208
|
-
}
|
|
209
|
-
return false
|
|
210
|
-
}
|
|
211
215
|
|
|
212
216
|
const validateErrors = () => {
|
|
213
|
-
// If field is empty, show error message
|
|
214
|
-
if (!inputValue || inputValue.trim() === '') {
|
|
215
|
-
if (validateRequiredField()) return
|
|
216
|
-
return
|
|
217
|
-
}
|
|
218
|
-
|
|
219
217
|
if (!hasTyped && !error) return
|
|
220
218
|
|
|
221
219
|
if (itiRef.current) isValid(itiRef.current.isValidNumber())
|
|
@@ -227,87 +225,6 @@ const PhoneNumberInput = (props: PhoneNumberInputProps, ref?: React.Ref<unknown>
|
|
|
227
225
|
if (validateRepeatCountryCode(itiRef.current)) return
|
|
228
226
|
}
|
|
229
227
|
|
|
230
|
-
/*
|
|
231
|
-
useImperativeHandle exposes the kit's input element to a parent component via a ref.
|
|
232
|
-
See the Playbook docs for use cases.
|
|
233
|
-
Read: https://react.dev/reference/react/useImperativeHandle
|
|
234
|
-
*/
|
|
235
|
-
useImperativeHandle(ref, () => {
|
|
236
|
-
return {
|
|
237
|
-
clearField() {
|
|
238
|
-
setInputValue("")
|
|
239
|
-
setError("")
|
|
240
|
-
setHasTyped(false)
|
|
241
|
-
},
|
|
242
|
-
inputNode() {
|
|
243
|
-
return inputRef.current
|
|
244
|
-
},
|
|
245
|
-
// Expose validation method for React Hook Form
|
|
246
|
-
validate() {
|
|
247
|
-
// Run validation and return error message or true
|
|
248
|
-
const isEmpty = !inputValue || inputValue.trim() === ''
|
|
249
|
-
|
|
250
|
-
if (isEmpty) {
|
|
251
|
-
// Show missing phone number error
|
|
252
|
-
const errorMessage = 'Missing phone number'
|
|
253
|
-
setError(errorMessage)
|
|
254
|
-
setHasTyped(true)
|
|
255
|
-
// Only return error for React Hook Form if field is required
|
|
256
|
-
return required ? errorMessage : true
|
|
257
|
-
}
|
|
258
|
-
|
|
259
|
-
if (!itiRef.current) {
|
|
260
|
-
return true
|
|
261
|
-
}
|
|
262
|
-
|
|
263
|
-
// Check for repeat country code first
|
|
264
|
-
const countryDialCode = itiRef.current.getSelectedCountryData().dialCode;
|
|
265
|
-
if (unformatNumber(inputValue).startsWith(countryDialCode)) {
|
|
266
|
-
const countryName = itiRef.current.getSelectedCountryData().name
|
|
267
|
-
const errorMessage = `Invalid ${countryName} phone number (repeat country code)`
|
|
268
|
-
setError(errorMessage)
|
|
269
|
-
setHasTyped(true)
|
|
270
|
-
return errorMessage
|
|
271
|
-
}
|
|
272
|
-
|
|
273
|
-
// Check if it only contains valid characters
|
|
274
|
-
if (!containOnlyNumbers(inputValue)) {
|
|
275
|
-
const countryName = itiRef.current.getSelectedCountryData().name
|
|
276
|
-
const errorMessage = `Invalid ${countryName} phone number (enter numbers only)`
|
|
277
|
-
setError(errorMessage)
|
|
278
|
-
setHasTyped(true)
|
|
279
|
-
return errorMessage
|
|
280
|
-
}
|
|
281
|
-
|
|
282
|
-
// Check if valid number
|
|
283
|
-
if (!itiRef.current.isValidNumber()) {
|
|
284
|
-
const countryName = itiRef.current.getSelectedCountryData().name
|
|
285
|
-
const validationError = itiRef.current.getValidationError()
|
|
286
|
-
let errorMessage = ''
|
|
287
|
-
|
|
288
|
-
if (validationError === ValidationError.TooShort) {
|
|
289
|
-
errorMessage = `Invalid ${countryName} phone number (too short)`
|
|
290
|
-
} else if (validationError === ValidationError.TooLong) {
|
|
291
|
-
errorMessage = `Invalid ${countryName} phone number (too long)`
|
|
292
|
-
} else if (validationError === ValidationError.MissingAreaCode) {
|
|
293
|
-
errorMessage = `Invalid ${countryName} phone number (missing area code)`
|
|
294
|
-
} else {
|
|
295
|
-
errorMessage = `Invalid ${countryName} phone number`
|
|
296
|
-
}
|
|
297
|
-
|
|
298
|
-
setError(errorMessage)
|
|
299
|
-
setHasTyped(true)
|
|
300
|
-
|
|
301
|
-
return errorMessage
|
|
302
|
-
}
|
|
303
|
-
|
|
304
|
-
// Clear error if valid
|
|
305
|
-
setError('')
|
|
306
|
-
return true
|
|
307
|
-
}
|
|
308
|
-
}
|
|
309
|
-
})
|
|
310
|
-
|
|
311
228
|
const getCurrentSelectedData = (itiInit: any, inputValue: string) => {
|
|
312
229
|
return { ...itiInit.getSelectedCountryData(), number: inputValue }
|
|
313
230
|
}
|
|
@@ -383,7 +300,7 @@ const PhoneNumberInput = (props: PhoneNumberInputProps, ref?: React.Ref<unknown>
|
|
|
383
300
|
dark,
|
|
384
301
|
"data-phone-number": JSON.stringify(selectedData),
|
|
385
302
|
disabled,
|
|
386
|
-
error
|
|
303
|
+
error,
|
|
387
304
|
type: 'tel',
|
|
388
305
|
id,
|
|
389
306
|
label,
|