playbook_ui 13.22.0.pre.alpha.playbookgemspecrailsversion2608 → 13.23.0.pre.alpha.PLAY1284investigation2657
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/app/pb_kits/playbook/pb_avatar/avatar.html.erb +1 -6
- data/app/pb_kits/playbook/pb_bar_graph/_bar_graph.tsx +28 -7
- data/app/pb_kits/playbook/pb_bar_graph/bar_graph.rb +2 -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/example.yml +2 -0
- data/app/pb_kits/playbook/pb_bar_graph/docs/index.js +1 -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/dist/playbook-rails.js +5 -5
- data/lib/playbook/kit_base.rb +21 -1
- data/lib/playbook/version.rb +2 -2
- metadata +7 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 8f32666e4b2500b014dc2554c3ebf3f5f4e3695cc726a3fc1d53bf5b332455a5
|
4
|
+
data.tar.gz: ff93821e0818cfbf57b09ece3fe03ce0c5459e4d29161f896d5771a3e8eb3761
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 93c9e3de45864e757c047b19dd7eeed12610d97f234a160183143155ab0dbb88ea6087414e212ffd1037eff4064b239ba7eecfbb30627753f4b4ab1bfcacf1a9
|
7
|
+
data.tar.gz: a5264af573a6eac322795be8739d2a3974a72085e3d5d163b79f4b1882899483b5e82f5205c1ced23c85d1dcc10f53d67570c3067645169fe9cf41f08062eca6
|
@@ -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 %>
|
@@ -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,7 @@ type BarGraphProps = {
|
|
37
37
|
y?: number;
|
38
38
|
aria?: { [key: string]: string };
|
39
39
|
data?: { [key: string]: string };
|
40
|
+
axisFormat?: { format: string; }[] | string;
|
40
41
|
};
|
41
42
|
|
42
43
|
|
@@ -51,6 +52,7 @@ const BarGraph = ({
|
|
51
52
|
colors,
|
52
53
|
htmlOptions = {},
|
53
54
|
customOptions = {},
|
55
|
+
axisFormat,
|
54
56
|
id,
|
55
57
|
pointStart,
|
56
58
|
subTitle,
|
@@ -67,7 +69,7 @@ const BarGraph = ({
|
|
67
69
|
x = 0,
|
68
70
|
y = 0,
|
69
71
|
...props
|
70
|
-
}: BarGraphProps): React.ReactElement => {
|
72
|
+
}: BarGraphProps): React.ReactElement => {
|
71
73
|
const ariaProps = buildAriaProps(aria);
|
72
74
|
const dataProps = buildDataProps(data)
|
73
75
|
const htmlProps = buildHtmlProps(htmlOptions);
|
@@ -89,13 +91,18 @@ const BarGraph = ({
|
|
89
91
|
subtitle: {
|
90
92
|
text: subTitle,
|
91
93
|
},
|
92
|
-
yAxis: {
|
94
|
+
yAxis: [{
|
95
|
+
labels: {
|
96
|
+
format: typeof axisFormat === 'string' ? axisFormat : (axisFormat && axisFormat[0] ? axisFormat[0].format : "")
|
97
|
+
|
98
|
+
},
|
93
99
|
min: yAxisMin,
|
94
100
|
max: yAxisMax,
|
101
|
+
opposite: false,
|
95
102
|
title: {
|
96
|
-
text: axisTitle,
|
97
|
-
}
|
98
|
-
},
|
103
|
+
text: typeof axisTitle === 'string' ? axisTitle : axisTitle[0].name,
|
104
|
+
}
|
105
|
+
}],
|
99
106
|
xAxis: {
|
100
107
|
categories: xAxisCategories,
|
101
108
|
},
|
@@ -124,6 +131,20 @@ const BarGraph = ({
|
|
124
131
|
credits: false,
|
125
132
|
};
|
126
133
|
|
134
|
+
if (Array.isArray(axisTitle) && axisTitle.length > 1 && axisTitle[1].name) {
|
135
|
+
staticOptions.yAxis.push({
|
136
|
+
labels: {
|
137
|
+
format: typeof axisFormat === 'string' ? axisFormat : axisFormat[1].format,
|
138
|
+
},
|
139
|
+
min: yAxisMin,
|
140
|
+
max: yAxisMax,
|
141
|
+
opposite: true,
|
142
|
+
title: {
|
143
|
+
text: axisTitle[1].name,
|
144
|
+
}
|
145
|
+
});
|
146
|
+
}
|
147
|
+
|
127
148
|
if (!toggleLegendClick) {
|
128
149
|
staticOptions.plotOptions.series.events = { legendItemClick: () => false };
|
129
150
|
}
|
@@ -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: {}
|
@@ -51,6 +52,7 @@ module Playbook
|
|
51
52
|
title: title,
|
52
53
|
subTitle: subtitle,
|
53
54
|
axisTitle: axis_title,
|
55
|
+
axisFormat: axis_format,
|
54
56
|
pointStart: point_start,
|
55
57
|
xAxisCategories: x_axis_categories,
|
56
58
|
yAxisMin: y_axis_min,
|
@@ -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.
|
@@ -9,6 +9,7 @@ examples:
|
|
9
9
|
- bar_graph_spline: Spline
|
10
10
|
- bar_graph_colors: Color Overrides
|
11
11
|
- bar_graph_custom: Custom Overrides
|
12
|
+
- bar_graph_secondary_y_axis: Secondary Y-Axis
|
12
13
|
|
13
14
|
|
14
15
|
react:
|
@@ -20,3 +21,4 @@ examples:
|
|
20
21
|
- bar_graph_spline: Spline
|
21
22
|
- bar_graph_colors: Color Overrides
|
22
23
|
- bar_graph_custom: Custom Overrides
|
24
|
+
- bar_graph_secondary_y_axis: Secondary Y-Axis
|
@@ -6,3 +6,4 @@ 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 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'
|