playbook_ui 13.23.0 → 13.24.0.pre.alpha.PLAY998backgroundkitremoveemptyinlinline2666
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_avatar/avatar.html.erb +1 -6
- data/app/pb_kits/playbook/pb_background/_background.tsx +7 -5
- data/app/pb_kits/playbook/pb_bar_graph/_bar_graph.tsx +41 -6
- data/app/pb_kits/playbook/pb_bar_graph/bar_graph.rb +4 -0
- data/app/pb_kits/playbook/pb_bar_graph/docs/_bar_graph_negative_numbers.html.erb +23 -0
- data/app/pb_kits/playbook/pb_bar_graph/docs/_bar_graph_negative_numbers.jsx +35 -0
- data/app/pb_kits/playbook/pb_bar_graph/docs/_bar_graph_secondary_y_axis.html.erb +26 -0
- data/app/pb_kits/playbook/pb_bar_graph/docs/_bar_graph_secondary_y_axis.jsx +36 -0
- data/app/pb_kits/playbook/pb_bar_graph/docs/_bar_graph_secondary_y_axis.md +3 -0
- data/app/pb_kits/playbook/pb_bar_graph/docs/_bar_graph_stacked.html.erb +22 -0
- data/app/pb_kits/playbook/pb_bar_graph/docs/_bar_graph_stacked.jsx +34 -0
- data/app/pb_kits/playbook/pb_bar_graph/docs/_bar_graph_stacked.md +1 -0
- data/app/pb_kits/playbook/pb_bar_graph/docs/example.yml +6 -0
- data/app/pb_kits/playbook/pb_bar_graph/docs/index.js +3 -0
- data/app/pb_kits/playbook/pb_body/_body.scss +3 -3
- data/app/pb_kits/playbook/pb_typeahead/_typeahead.tsx +27 -19
- data/app/pb_kits/playbook/pb_typeahead/components/MenuList.tsx +4 -2
- data/app/pb_kits/playbook/pb_typeahead/components/index.tsx +19 -0
- data/app/pb_kits/playbook/pb_typeahead/docs/_typeahead_custom_menu_list.jsx +51 -0
- data/app/pb_kits/playbook/pb_typeahead/docs/_typeahead_with_highlight.jsx +1 -1
- data/app/pb_kits/playbook/pb_typeahead/docs/example.yml +1 -0
- data/app/pb_kits/playbook/pb_typeahead/docs/index.js +1 -0
- data/app/pb_kits/playbook/tokens/_colors.scss +1 -1
- data/dist/playbook-rails.js +6 -6
- data/lib/playbook/kit_base.rb +21 -1
- data/lib/playbook/version.rb +2 -2
- metadata +15 -29
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: d91c1689890fbb2e1392ecc83ad7b869eea650744de932d645ed6ea4e566d161
|
4
|
+
data.tar.gz: e53e677351b6221797ed074c4cfdcb6ea842c33af17060167257101af7978db2
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: da048d8e1f09cb0d4640c8a1f50e6a1acaf5bb05707d9a843dc011b963b683e8931ec13f80d3f4c98a320addbacd3ca3e9c2a9eca20ff3242d05f4336362f156
|
7
|
+
data.tar.gz: 19a49a4274d753b4b496e8299df73a224ad6356f3ba2bf04d0817d9a69272b48f0c41eab40cb05a46a3dd041ce38a8f67b6cfaffdcf4a7c9092143b1e91950d4
|
@@ -1,9 +1,4 @@
|
|
1
|
-
<%=
|
2
|
-
id: object.id,
|
3
|
-
data: object.data.merge(initials: object.initials),
|
4
|
-
class: object.classname,
|
5
|
-
aria: object.aria,
|
6
|
-
**combined_html_options) do %>
|
1
|
+
<%= object.pb_content_tag(:div, data: object.data.merge(initials: object.initials)) do %>
|
7
2
|
<%= content_tag(:div, data: { initials: object.initials }, class: "avatar_wrapper") do %>
|
8
3
|
<%= pb_rails("image", props: { alt: object.alt_text, url: object.image_url, on_error: object.handle_img_error }) if object.image_url.present? %>
|
9
4
|
<% end %>
|
@@ -65,7 +65,7 @@ const getResponsiveValue = <T extends string | undefined>(prop: ResponsiveProp<T
|
|
65
65
|
|
66
66
|
const Background = (props: BackgroundProps): React.ReactElement => {
|
67
67
|
const {
|
68
|
-
alt =
|
68
|
+
alt = undefined,
|
69
69
|
aria = {},
|
70
70
|
backgroundColor = 'light',
|
71
71
|
backgroundPosition = '',
|
@@ -130,11 +130,13 @@ const Background = (props: BackgroundProps): React.ReactElement => {
|
|
130
130
|
);
|
131
131
|
|
132
132
|
const backgroundStyle = {
|
133
|
-
backgroundImage: resImageUrl ? `url(${resImageUrl})` : undefined,
|
134
|
-
backgroundRepeat: resBackgroundRepeat || undefined,
|
135
|
-
backgroundSize: resBackgroundSize || undefined,
|
136
|
-
backgroundPosition: resBackgroundPosition || undefined,
|
137
133
|
backgroundColor: customColor || undefined,
|
134
|
+
...(resImageUrl !== '' ? {
|
135
|
+
backgroundImage: resImageUrl ? `url(${resImageUrl})` : undefined,
|
136
|
+
backgroundRepeat: resBackgroundRepeat || undefined,
|
137
|
+
backgroundPosition: resBackgroundPosition || undefined,
|
138
|
+
backgroundSize: resBackgroundSize || undefined,
|
139
|
+
} : {})
|
138
140
|
};
|
139
141
|
|
140
142
|
const Tag: React.ReactElement | any = `${tag}`;
|
@@ -13,12 +13,12 @@ import classnames from "classnames";
|
|
13
13
|
|
14
14
|
type BarGraphProps = {
|
15
15
|
align?: "left" | "right" | "center";
|
16
|
-
axisTitle: string;
|
16
|
+
axisTitle: { name: string; }[] | string;
|
17
17
|
dark?: boolean;
|
18
18
|
xAxisCategories: [];
|
19
19
|
yAxisMin: number;
|
20
20
|
yAxisMax: number;
|
21
|
-
chartData: { name: string; data: number[] }[];
|
21
|
+
chartData: { name: string; data: number[], yAxis: number }[];
|
22
22
|
className?: string;
|
23
23
|
customOptions?: Partial<Highcharts.Options>;
|
24
24
|
id: string;
|
@@ -37,6 +37,8 @@ type BarGraphProps = {
|
|
37
37
|
y?: number;
|
38
38
|
aria?: { [key: string]: string };
|
39
39
|
data?: { [key: string]: string };
|
40
|
+
stacking?: "normal" | "percent"
|
41
|
+
axisFormat?: { format: string; }[] | string;
|
40
42
|
};
|
41
43
|
|
42
44
|
|
@@ -51,8 +53,10 @@ const BarGraph = ({
|
|
51
53
|
colors,
|
52
54
|
htmlOptions = {},
|
53
55
|
customOptions = {},
|
56
|
+
axisFormat,
|
54
57
|
id,
|
55
58
|
pointStart,
|
59
|
+
stacking,
|
56
60
|
subTitle,
|
57
61
|
type = "column",
|
58
62
|
title = "Title",
|
@@ -67,7 +71,7 @@ const BarGraph = ({
|
|
67
71
|
x = 0,
|
68
72
|
y = 0,
|
69
73
|
...props
|
70
|
-
}: BarGraphProps): React.ReactElement => {
|
74
|
+
}: BarGraphProps): React.ReactElement => {
|
71
75
|
const ariaProps = buildAriaProps(aria);
|
72
76
|
const dataProps = buildDataProps(data)
|
73
77
|
const htmlProps = buildHtmlProps(htmlOptions);
|
@@ -89,13 +93,23 @@ const BarGraph = ({
|
|
89
93
|
subtitle: {
|
90
94
|
text: subTitle,
|
91
95
|
},
|
92
|
-
yAxis: {
|
96
|
+
yAxis: [{
|
97
|
+
labels: {
|
98
|
+
format: typeof axisFormat === 'string' ? axisFormat : (axisFormat && axisFormat[0] ? axisFormat[0].format : "")
|
99
|
+
|
100
|
+
},
|
93
101
|
min: yAxisMin,
|
94
102
|
max: yAxisMax,
|
103
|
+
opposite: false,
|
95
104
|
title: {
|
96
|
-
text: axisTitle,
|
105
|
+
text: typeof axisTitle === 'string' ? axisTitle : axisTitle[0].name,
|
97
106
|
},
|
98
|
-
|
107
|
+
plotLines: typeof yAxisMin !== 'undefined' && yAxisMin !== null ? [] : [{
|
108
|
+
value: 0,
|
109
|
+
zIndex: 10,
|
110
|
+
color: "#E4E8F0"
|
111
|
+
}],
|
112
|
+
}],
|
99
113
|
xAxis: {
|
100
114
|
categories: xAxisCategories,
|
101
115
|
},
|
@@ -113,7 +127,9 @@ const BarGraph = ({
|
|
113
127
|
: highchartsTheme.colors,
|
114
128
|
plotOptions: {
|
115
129
|
series: {
|
130
|
+
stacking: stacking,
|
116
131
|
pointStart: pointStart,
|
132
|
+
borderWidth: stacking ? 0 : "",
|
117
133
|
events: {},
|
118
134
|
dataLabels: {
|
119
135
|
enabled: false,
|
@@ -124,6 +140,25 @@ const BarGraph = ({
|
|
124
140
|
credits: false,
|
125
141
|
};
|
126
142
|
|
143
|
+
if (Array.isArray(axisTitle) && axisTitle.length > 1 && axisTitle[1].name) {
|
144
|
+
staticOptions.yAxis.push({
|
145
|
+
labels: {
|
146
|
+
format: typeof axisFormat === 'string' ? axisFormat : axisFormat[1].format,
|
147
|
+
},
|
148
|
+
min: yAxisMin,
|
149
|
+
max: yAxisMax,
|
150
|
+
opposite: true,
|
151
|
+
title: {
|
152
|
+
text: axisTitle[1].name,
|
153
|
+
},
|
154
|
+
plotLines: typeof yAxisMin !== 'undefined' && yAxisMin !== null ? [] : [{
|
155
|
+
value: 0,
|
156
|
+
zIndex: 10,
|
157
|
+
color: "#E4E8F0"
|
158
|
+
}],
|
159
|
+
});
|
160
|
+
}
|
161
|
+
|
127
162
|
if (!toggleLegendClick) {
|
128
163
|
staticOptions.plotOptions.series.events = { legendItemClick: () => false };
|
129
164
|
}
|
@@ -7,6 +7,7 @@ module Playbook
|
|
7
7
|
values: %w[left right center],
|
8
8
|
default: "center"
|
9
9
|
prop :axis_title
|
10
|
+
prop :axis_format
|
10
11
|
prop :chart_data, type: Playbook::Props::Array,
|
11
12
|
default: []
|
12
13
|
prop :custom_options, default: {}
|
@@ -14,6 +15,7 @@ module Playbook
|
|
14
15
|
values: %w[vertical horizontal],
|
15
16
|
default: "vertical"
|
16
17
|
prop :point_start, type: Playbook::Props::Numeric
|
18
|
+
prop :stacking
|
17
19
|
prop :subtitle
|
18
20
|
prop :title
|
19
21
|
prop :x_axis_categories, type: Playbook::Props::Array,
|
@@ -49,8 +51,10 @@ module Playbook
|
|
49
51
|
dark: dark ? "dark" : "",
|
50
52
|
type: chart_type,
|
51
53
|
title: title,
|
54
|
+
stacking: stacking,
|
52
55
|
subTitle: subtitle,
|
53
56
|
axisTitle: axis_title,
|
57
|
+
axisFormat: axis_format,
|
54
58
|
pointStart: point_start,
|
55
59
|
xAxisCategories: x_axis_categories,
|
56
60
|
yAxisMin: y_axis_min,
|
@@ -0,0 +1,23 @@
|
|
1
|
+
<% data = [{
|
2
|
+
name: 'Installation',
|
3
|
+
data: [-475, 400, -1000, 354, -856],
|
4
|
+
threshold: 0
|
5
|
+
}, {
|
6
|
+
name: 'Manufacturing',
|
7
|
+
data: [1475, 200, 1000, 654, -656],
|
8
|
+
threshold: 0
|
9
|
+
},
|
10
|
+
{
|
11
|
+
name: 'Sales & Distribution',
|
12
|
+
data: [1270, 100, -1200, 554, 756],
|
13
|
+
threshold: 0
|
14
|
+
}] %>
|
15
|
+
|
16
|
+
<%= pb_rails("bar_graph", props: {
|
17
|
+
axis_title: 'Number of Employees',
|
18
|
+
chart_data: data,
|
19
|
+
id: "bar-default",
|
20
|
+
x_axis_categories:['Jan','Feb','Mar','Apr','May','Jun','Jul','Aug','Sep','Oct','Nov','Dec'],
|
21
|
+
title: 'Bar Graph with Negative Numbers',
|
22
|
+
legend: true,
|
23
|
+
}) %>
|
@@ -0,0 +1,35 @@
|
|
1
|
+
import React from 'react'
|
2
|
+
|
3
|
+
import BarGraph from '../_bar_graph'
|
4
|
+
|
5
|
+
const chartData = [{
|
6
|
+
name: 'Installation',
|
7
|
+
data: [-475, 400, -1000, 354, -856],
|
8
|
+
threshold: 0
|
9
|
+
}, {
|
10
|
+
name: 'Manufacturing',
|
11
|
+
data: [1475, 200, 1000, 654, -656],
|
12
|
+
threshold: 0
|
13
|
+
},
|
14
|
+
{
|
15
|
+
name: 'Sales & Distribution',
|
16
|
+
data: [1270, 100, -1200, 554, 756],
|
17
|
+
threshold: 0
|
18
|
+
}]
|
19
|
+
|
20
|
+
|
21
|
+
const BarGraphStacked = (props) => (
|
22
|
+
<div>
|
23
|
+
<BarGraph
|
24
|
+
axisTitle="Number of Employees"
|
25
|
+
chartData={chartData}
|
26
|
+
id="bar-default"
|
27
|
+
legend
|
28
|
+
title="Bar Graph with Negative Numbers"
|
29
|
+
xAxisCategories={['Jan', 'Feb', 'Mar', 'Apr', 'May']}
|
30
|
+
{...props}
|
31
|
+
/>
|
32
|
+
</div>
|
33
|
+
)
|
34
|
+
|
35
|
+
export default BarGraphStacked
|
@@ -0,0 +1,26 @@
|
|
1
|
+
<% data = [{
|
2
|
+
name: 'Number of Installations',
|
3
|
+
data: [1475,200,3000,654,656]
|
4
|
+
}, {
|
5
|
+
type: 'spline',
|
6
|
+
name: 'Percentage',
|
7
|
+
data: [48, 70, 25, 55, 72],
|
8
|
+
color: '#F9BB00',
|
9
|
+
yAxis: 1
|
10
|
+
}] %>
|
11
|
+
|
12
|
+
<% axis_titles = [{name: "Number of Installations"}, {name: "Percentage"}] %>
|
13
|
+
|
14
|
+
<% axis_formats = [{format: ""}, {format: "{value}%"}] %>
|
15
|
+
|
16
|
+
<%= pb_rails("bar_graph", props: {
|
17
|
+
axis_format: axis_formats,
|
18
|
+
axis_title: axis_titles,
|
19
|
+
chart_data: data,
|
20
|
+
id: "bar-spline",
|
21
|
+
y_axis_min: 0,
|
22
|
+
x_axis_categories:['Jan','Feb','Mar','Apr','May','Jun','Jul','Aug','Sep','Oct','Nov','Dec'],
|
23
|
+
subtitle: 'Source: thesolarfoundation.com',
|
24
|
+
title: 'Bar Graph with Secondary Y-axis',
|
25
|
+
legend: true,
|
26
|
+
}) %>
|
@@ -0,0 +1,36 @@
|
|
1
|
+
import React from 'react'
|
2
|
+
|
3
|
+
import BarGraph from '../_bar_graph'
|
4
|
+
|
5
|
+
const chartData = [{
|
6
|
+
name: 'Number of Installations',
|
7
|
+
data: [1475, 200, 3000, 654, 656],
|
8
|
+
}, {
|
9
|
+
type: 'spline',
|
10
|
+
name: 'Percentage',
|
11
|
+
data: [48, 70, 25, 55, 72],
|
12
|
+
color: '#F9BB00',
|
13
|
+
yAxis: 1
|
14
|
+
}]
|
15
|
+
|
16
|
+
const axisTitles = [ {name: "Number of Installations"}, {name: "Percentage"}]
|
17
|
+
|
18
|
+
const axisFormats = [{format: ""}, {format: "{value}%"}]
|
19
|
+
|
20
|
+
const BarGraphSecondaryYAxis= (props) => (
|
21
|
+
<div>
|
22
|
+
<BarGraph
|
23
|
+
axisFormat={axisFormats}
|
24
|
+
axisTitle={axisTitles}
|
25
|
+
chartData={chartData}
|
26
|
+
id="bar-spline"
|
27
|
+
legend
|
28
|
+
title="Bar Graph with Secondary Y-axis"
|
29
|
+
xAxisCategories={['Jan', 'Feb', 'Mar', 'Apr', 'May']}
|
30
|
+
yAxisMin={0}
|
31
|
+
{...props}
|
32
|
+
/>
|
33
|
+
</div>
|
34
|
+
)
|
35
|
+
|
36
|
+
export default BarGraphSecondaryYAxis
|
@@ -0,0 +1,3 @@
|
|
1
|
+
Optionally add a second yAxis to support secondary datasets (e.x., a spline) by passing` yAxis: 1` to the second node of your `chartData` array.
|
2
|
+
|
3
|
+
To customize the format and/or title of your secondary yAxis, pass your desired values as arrays through the `axisFormat` and `axisTitle` props, respectively.
|
@@ -0,0 +1,22 @@
|
|
1
|
+
<% data = [{
|
2
|
+
name: 'Installation',
|
3
|
+
data: [1475, 200, 3000, 654, 656],
|
4
|
+
},
|
5
|
+
{
|
6
|
+
name: 'Manufacturing',
|
7
|
+
data: [1270, 800, 200, 454, 956],
|
8
|
+
}, {
|
9
|
+
name: 'Sales & Distribution',
|
10
|
+
data: [975, 1600, 1500, 924, 500],
|
11
|
+
}] %>
|
12
|
+
|
13
|
+
<%= pb_rails("bar_graph", props: {
|
14
|
+
axis_title: 'Number of Employees',
|
15
|
+
chart_data: data,
|
16
|
+
id: "bar-default",
|
17
|
+
y_axis_min: 0,
|
18
|
+
x_axis_categories:['Jan','Feb','Mar','Apr','May','Jun','Jul','Aug','Sep','Oct','Nov','Dec'],
|
19
|
+
stacking: "normal",
|
20
|
+
title: 'Bar Graph with Stacked Columns',
|
21
|
+
legend: true,
|
22
|
+
}) %>
|
@@ -0,0 +1,34 @@
|
|
1
|
+
import React from 'react'
|
2
|
+
|
3
|
+
import BarGraph from '../_bar_graph'
|
4
|
+
|
5
|
+
const chartData = [{
|
6
|
+
name: 'Installation',
|
7
|
+
data: [1475, 200, 3000, 654, 656],
|
8
|
+
},
|
9
|
+
{
|
10
|
+
name: 'Manufacturing',
|
11
|
+
data: [1270, 800, 200, 454, 956],
|
12
|
+
}, {
|
13
|
+
name: 'Sales & Distribution',
|
14
|
+
data: [975, 1600, 1500, 924, 500],
|
15
|
+
}]
|
16
|
+
|
17
|
+
|
18
|
+
const BarGraphStacked = (props) => (
|
19
|
+
<div>
|
20
|
+
<BarGraph
|
21
|
+
axisTitle="Number Of Employees"
|
22
|
+
chartData={chartData}
|
23
|
+
id="bar-default"
|
24
|
+
legend
|
25
|
+
stacking="normal"
|
26
|
+
title="Bar Graph with Stacked Columns"
|
27
|
+
xAxisCategories={['Jan', 'Feb', 'Mar', 'Apr', 'May']}
|
28
|
+
yAxisMin={0}
|
29
|
+
{...props}
|
30
|
+
/>
|
31
|
+
</div>
|
32
|
+
)
|
33
|
+
|
34
|
+
export default BarGraphStacked
|
@@ -0,0 +1 @@
|
|
1
|
+
The `stacking` prop can be used for a stacked bar graph. The prop allows for `normal` or `percent` as options.
|
@@ -9,6 +9,9 @@ examples:
|
|
9
9
|
- bar_graph_spline: Spline
|
10
10
|
- bar_graph_colors: Color Overrides
|
11
11
|
- bar_graph_custom: Custom Overrides
|
12
|
+
- bar_graph_stacked: Stacked
|
13
|
+
- bar_graph_negative_numbers: Negative Numbers
|
14
|
+
- bar_graph_secondary_y_axis: Secondary Y-Axis
|
12
15
|
|
13
16
|
|
14
17
|
react:
|
@@ -20,3 +23,6 @@ examples:
|
|
20
23
|
- bar_graph_spline: Spline
|
21
24
|
- bar_graph_colors: Color Overrides
|
22
25
|
- bar_graph_custom: Custom Overrides
|
26
|
+
- bar_graph_stacked: Stacked
|
27
|
+
- bar_graph_negative_numbers: Negative Numbers
|
28
|
+
- bar_graph_secondary_y_axis: Secondary Y-Axis
|
@@ -6,3 +6,6 @@ export { default as BarGraphHeight } from './_bar_graph_height.jsx'
|
|
6
6
|
export { default as BarGraphSpline } from './_bar_graph_spline.jsx'
|
7
7
|
export { default as BarGraphColors } from './_bar_graph_colors.jsx'
|
8
8
|
export { default as BarGraphCustom } from './_bar_graph_custom.jsx'
|
9
|
+
export { default as BarGraphStacked } from './_bar_graph_stacked.jsx'
|
10
|
+
export { default as BarGraphNegativeNumbers } from './_bar_graph_negative_numbers.jsx'
|
11
|
+
export { default as BarGraphSecondaryYAxis } from './_bar_graph_secondary_y_axis.jsx'
|
@@ -7,17 +7,21 @@ import { get, isString, uniqueId } from 'lodash'
|
|
7
7
|
import { globalProps } from '../utilities/globalProps'
|
8
8
|
import classnames from 'classnames'
|
9
9
|
|
10
|
-
import
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
10
|
+
import {
|
11
|
+
Control,
|
12
|
+
ClearIndicator,
|
13
|
+
IndicatorsContainer,
|
14
|
+
MenuList,
|
15
|
+
MultiValue,
|
16
|
+
Option,
|
17
|
+
Placeholder,
|
18
|
+
ValueContainer,
|
19
|
+
} from "./components"
|
20
|
+
|
21
|
+
import * as kitComponents from "./components"
|
18
22
|
|
19
23
|
import { noop, buildDataProps, buildHtmlProps } from '../utilities/props'
|
20
|
-
import { Noop } from '../types'
|
24
|
+
import { GenericObject, Noop } from '../types'
|
21
25
|
|
22
26
|
/**
|
23
27
|
* @typedef {object} Props
|
@@ -29,7 +33,7 @@ import { Noop } from '../types'
|
|
29
33
|
type TypeaheadProps = {
|
30
34
|
async?: boolean,
|
31
35
|
className?: string,
|
32
|
-
components?:
|
36
|
+
components?: GenericObject,
|
33
37
|
createable?: boolean,
|
34
38
|
dark?: boolean,
|
35
39
|
data?: { [key: string]: string },
|
@@ -100,7 +104,7 @@ const Typeahead = ({
|
|
100
104
|
multiKit: '',
|
101
105
|
onCreateOption: null as null,
|
102
106
|
plusIcon: false,
|
103
|
-
onMultiValueClick: (_option: SelectValueType) =>
|
107
|
+
onMultiValueClick: (_option: SelectValueType): any => undefined,
|
104
108
|
...props,
|
105
109
|
}
|
106
110
|
|
@@ -137,19 +141,23 @@ const Typeahead = ({
|
|
137
141
|
const inlineClass = selectProps.inline ? 'inline' : null
|
138
142
|
|
139
143
|
return (
|
140
|
-
<div
|
141
|
-
|
142
|
-
|
143
|
-
|
144
|
+
<div
|
145
|
+
{...dataProps}
|
146
|
+
{...htmlProps}
|
147
|
+
className={classnames(classes, inlineClass)}
|
144
148
|
>
|
145
149
|
<Tag
|
146
|
-
|
147
|
-
|
148
|
-
|
149
|
-
|
150
|
+
classNamePrefix="typeahead-kit-select"
|
151
|
+
error={error}
|
152
|
+
onChange={handleOnChange}
|
153
|
+
{...selectProps}
|
150
154
|
/>
|
151
155
|
</div>
|
152
156
|
)
|
153
157
|
}
|
154
158
|
|
159
|
+
Object.keys(kitComponents).forEach((k) => {
|
160
|
+
(Typeahead as GenericObject)[k] = (kitComponents as {[key: string]: unknown})[k]
|
161
|
+
})
|
162
|
+
|
155
163
|
export default Typeahead
|
@@ -1,10 +1,12 @@
|
|
1
1
|
import React from 'react'
|
2
2
|
import { components } from 'react-select'
|
3
3
|
|
4
|
-
const MenuList = (props: any) =>
|
4
|
+
const MenuList = (props: any) => {
|
5
|
+
return (
|
5
6
|
<components.MenuList {...props}>
|
6
7
|
{props.children}
|
8
|
+
{props.footer}
|
7
9
|
</components.MenuList>
|
8
|
-
)
|
10
|
+
)}
|
9
11
|
|
10
12
|
export default MenuList
|
@@ -0,0 +1,19 @@
|
|
1
|
+
import Control from './Control'
|
2
|
+
import ClearIndicator from './ClearIndicator'
|
3
|
+
import IndicatorsContainer from './IndicatorsContainer'
|
4
|
+
import MenuList from './MenuList'
|
5
|
+
import MultiValue from './MultiValue'
|
6
|
+
import Option from './Option'
|
7
|
+
import Placeholder from './Placeholder'
|
8
|
+
import ValueContainer from './ValueContainer'
|
9
|
+
|
10
|
+
export {
|
11
|
+
Control,
|
12
|
+
ClearIndicator,
|
13
|
+
IndicatorsContainer,
|
14
|
+
MenuList,
|
15
|
+
MultiValue,
|
16
|
+
Option,
|
17
|
+
Placeholder,
|
18
|
+
ValueContainer,
|
19
|
+
}
|
@@ -0,0 +1,51 @@
|
|
1
|
+
import React, { useState } from 'react'
|
2
|
+
|
3
|
+
import {
|
4
|
+
Button,
|
5
|
+
} from '../..'
|
6
|
+
|
7
|
+
import Typeahead from '../_typeahead'
|
8
|
+
|
9
|
+
const options = [
|
10
|
+
{ label: 'Orange', value: '#FFA500' },
|
11
|
+
{ label: 'Red', value: '#FF0000' },
|
12
|
+
{ label: 'Green', value: '#00FF00' },
|
13
|
+
{ label: 'Blue', value: '#0000FF' },
|
14
|
+
{ label: 'Amaranth', value: '#9F2B68' },
|
15
|
+
{ label: 'Key Lime', value: '#DAF7A6' },
|
16
|
+
{ label: 'Turquois', value: '#00FFD0' },
|
17
|
+
]
|
18
|
+
|
19
|
+
const TypeaheadCustomMenuList = (props) => {
|
20
|
+
const defaultColorOptions = options.slice(0, 3)
|
21
|
+
const [colorOptions, setColorOptions] = useState(defaultColorOptions)
|
22
|
+
|
23
|
+
const moreToLoad = colorOptions.length == defaultColorOptions.length
|
24
|
+
const loadColors = moreToLoad ? () => setColorOptions(options) : () => setColorOptions(defaultColorOptions)
|
25
|
+
|
26
|
+
const menuListProps = {
|
27
|
+
footer: (<Button
|
28
|
+
margin="sm"
|
29
|
+
onClick={loadColors}
|
30
|
+
text={`Load ${moreToLoad ? "More" : "Less"}`}
|
31
|
+
/>)
|
32
|
+
}
|
33
|
+
|
34
|
+
const MenuList = (props) => (
|
35
|
+
<Typeahead.MenuList
|
36
|
+
{...menuListProps}
|
37
|
+
{...props}
|
38
|
+
/>
|
39
|
+
)
|
40
|
+
|
41
|
+
return (
|
42
|
+
<Typeahead
|
43
|
+
components={{ MenuList }}
|
44
|
+
label="Colors"
|
45
|
+
options={colorOptions}
|
46
|
+
{...props}
|
47
|
+
/>
|
48
|
+
)
|
49
|
+
}
|
50
|
+
|
51
|
+
export default TypeaheadCustomMenuList
|
@@ -9,3 +9,4 @@ export { default as TypeaheadMultiKit } from './_typeahead_multi_kit.jsx'
|
|
9
9
|
export { default as TypeaheadCreateable } from './_typeahead_createable.jsx'
|
10
10
|
export { default as TypeaheadAsyncCreateable } from './_typeahead_async_createable.jsx'
|
11
11
|
export { default as TypeaheadErrorState } from './_typeahead_error_state.jsx'
|
12
|
+
export { default as TypeaheadCustomMenuList } from './_typeahead_custom_menu_list.jsx'
|