playbook_ui 11.12.1.pre.alpha.charts1 → 11.12.1.pre.alpha.passphrase1
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/index.js +1 -0
- data/app/pb_kits/playbook/pb_bar_graph/_bar_graph.jsx +111 -0
- data/app/pb_kits/playbook/pb_circle_chart/_circle_chart.jsx +151 -0
- data/app/pb_kits/playbook/pb_circle_chart/circle_chart.html.erb +21 -9
- data/app/pb_kits/playbook/pb_circle_chart/circle_chart.rb +47 -7
- data/app/pb_kits/playbook/pb_dashboard/{pbChartsDarkTheme.ts → pbChartsDarkTheme.js} +21 -6
- data/app/pb_kits/playbook/pb_dashboard/{pbChartsLightTheme.ts → pbChartsLightTheme.js} +21 -6
- data/app/pb_kits/playbook/pb_gauge/_gauge.jsx +112 -0
- data/app/pb_kits/playbook/pb_gauge/_gauge.scss +0 -4
- data/app/pb_kits/playbook/pb_gauge/docs/_gauge_complex.html.erb +1 -1
- data/app/pb_kits/playbook/pb_gauge/docs/_gauge_complex.jsx +8 -8
- data/app/pb_kits/playbook/pb_gauge/gauge.html.erb +11 -1
- data/app/pb_kits/playbook/pb_gauge/gauge.rb +8 -3
- data/app/pb_kits/playbook/pb_line_graph/_line_graph.jsx +113 -0
- data/app/pb_kits/playbook/pb_passphrase/_passphrase.jsx +56 -97
- data/app/pb_kits/playbook/pb_passphrase/docs/_passphrase_breached.html.erb +145 -1
- data/app/pb_kits/playbook/pb_passphrase/docs/_passphrase_breached.jsx +127 -3
- data/app/pb_kits/playbook/pb_passphrase/docs/_passphrase_breached.md +11 -2
- data/app/pb_kits/playbook/pb_passphrase/docs/_passphrase_common.html.erb +136 -0
- data/app/pb_kits/playbook/pb_passphrase/docs/_passphrase_common.jsx +90 -8
- data/app/pb_kits/playbook/pb_passphrase/docs/_passphrase_common.md +5 -0
- data/app/pb_kits/playbook/pb_passphrase/docs/_passphrase_confirmation.html.erb +51 -0
- data/app/pb_kits/playbook/pb_passphrase/docs/_passphrase_confirmation.jsx +39 -0
- data/app/pb_kits/playbook/pb_passphrase/docs/_passphrase_default.html.erb +0 -2
- data/app/pb_kits/playbook/pb_passphrase/docs/_passphrase_default.jsx +6 -20
- data/app/pb_kits/playbook/pb_passphrase/docs/_passphrase_input_props.html.erb +2 -2
- data/app/pb_kits/playbook/pb_passphrase/docs/_passphrase_input_props.jsx +1 -1
- data/app/pb_kits/playbook/pb_passphrase/docs/_passphrase_meter_settings.html.erb +318 -5
- data/app/pb_kits/playbook/pb_passphrase/docs/_passphrase_meter_settings.jsx +134 -48
- data/app/pb_kits/playbook/pb_passphrase/docs/_passphrase_meter_settings.md +11 -5
- data/app/pb_kits/playbook/pb_passphrase/docs/_passphrase_strength_change.html.erb +123 -0
- data/app/pb_kits/playbook/pb_passphrase/docs/_passphrase_strength_change.jsx +96 -20
- data/app/pb_kits/playbook/pb_passphrase/docs/_passphrase_strength_change.md +6 -2
- data/app/pb_kits/playbook/pb_passphrase/docs/example.yml +4 -0
- data/app/pb_kits/playbook/pb_passphrase/docs/index.js +1 -0
- data/app/pb_kits/playbook/pb_passphrase/passphrase.html.erb +1 -1
- data/app/pb_kits/playbook/pb_passphrase/passphrase.rb +5 -9
- data/app/pb_kits/playbook/pb_passphrase/passphrase.test.jsx +0 -47
- data/app/pb_kits/playbook/pb_treemap_chart/_treemap_chart.jsx +79 -0
- data/app/pb_kits/playbook/pb_treemap_chart/docs/_treemap_chart_tooltip.jsx +1 -1
- data/app/pb_kits/playbook/playbook-rails-react-bindings.js +0 -4
- data/app/pb_kits/playbook/playbook-rails.js +4 -0
- data/app/pb_kits/playbook/plugins/pb_chart.js +322 -0
- data/lib/playbook/version.rb +1 -1
- metadata +15 -16
- data/app/pb_kits/playbook/pb_bar_graph/_bar_graph.tsx +0 -145
- data/app/pb_kits/playbook/pb_circle_chart/ChartsTypes.ts +0 -2
- data/app/pb_kits/playbook/pb_circle_chart/_circle_chart.tsx +0 -216
- data/app/pb_kits/playbook/pb_dashboard/pbChartsColorsHelper.ts +0 -16
- data/app/pb_kits/playbook/pb_dashboard/themeTypes.ts +0 -16
- data/app/pb_kits/playbook/pb_gauge/_gauge.tsx +0 -213
- data/app/pb_kits/playbook/pb_line_graph/_line_graph.tsx +0 -148
- data/app/pb_kits/playbook/pb_passphrase/docs/_passphrase_default.md +0 -1
- data/app/pb_kits/playbook/pb_passphrase/passwordStrength.js +0 -55
- data/app/pb_kits/playbook/pb_passphrase/useHaveIBeenPwned.js +0 -52
- data/app/pb_kits/playbook/pb_passphrase/useZxcvbn.js +0 -58
- data/app/pb_kits/playbook/pb_treemap_chart/_treemap_chart.tsx +0 -111
@@ -1,216 +0,0 @@
|
|
1
|
-
import React, { useEffect, useRef, useState } from "react";
|
2
|
-
import classnames from "classnames";
|
3
|
-
import HighchartsReact from "highcharts-react-official";
|
4
|
-
|
5
|
-
import Highcharts from "highcharts";
|
6
|
-
|
7
|
-
import { highchartsTheme } from "../pb_dashboard/pbChartsLightTheme";
|
8
|
-
import { highchartsDarkTheme } from "../pb_dashboard/pbChartsDarkTheme";
|
9
|
-
import mapColors from "../pb_dashboard/pbChartsColorsHelper";
|
10
|
-
import { globalProps } from "../utilities/globalProps";
|
11
|
-
import { buildAriaProps, buildDataProps } from "../utilities/props";
|
12
|
-
|
13
|
-
type CircleChartProps = {
|
14
|
-
align?: "left" | "right" | "center";
|
15
|
-
aria: { [key: string]: string };
|
16
|
-
chartData?: [];
|
17
|
-
children?: Node;
|
18
|
-
className?: string;
|
19
|
-
colors?: string[];
|
20
|
-
dark?: Boolean;
|
21
|
-
data?: Object;
|
22
|
-
dataLabelHtml?: string;
|
23
|
-
dataLabels?: boolean;
|
24
|
-
height?: string;
|
25
|
-
id?: string;
|
26
|
-
innerSize?: "sm" | "md" | "lg" | "none";
|
27
|
-
legend?: boolean;
|
28
|
-
maxPointSize?: number;
|
29
|
-
minPointSize?: number;
|
30
|
-
rounded?: boolean;
|
31
|
-
startAngle?: number;
|
32
|
-
style?: string;
|
33
|
-
title?: string;
|
34
|
-
useHtml?: boolean;
|
35
|
-
zMin?: number;
|
36
|
-
layout?: "horizontal" | "vertical" | "proximate";
|
37
|
-
verticalAlign?: "top" | "middle" | "bottom";
|
38
|
-
x?: number;
|
39
|
-
y?: number;
|
40
|
-
borderColor?: string;
|
41
|
-
borderWidth?: number;
|
42
|
-
};
|
43
|
-
|
44
|
-
// Adjust Circle Chart Block Kit Dimensions to Match the Chart for Centering
|
45
|
-
const alignBlockElement = (event: any) => {
|
46
|
-
const itemToMove = document.querySelector(
|
47
|
-
`#wrapper-circle-chart-${event.target.renderTo.id} .pb-circle-chart-block`
|
48
|
-
) as HTMLElement;
|
49
|
-
const chartContainer = document.querySelector(`#${event.target.renderTo.id}`);
|
50
|
-
if (itemToMove !== null) {
|
51
|
-
itemToMove.style.height = `${event.target.chartHeight}px`;
|
52
|
-
itemToMove.style.width = `${event.target.chartWidth}px`;
|
53
|
-
chartContainer.firstChild.before(itemToMove);
|
54
|
-
}
|
55
|
-
};
|
56
|
-
|
57
|
-
const CircleChart = ({
|
58
|
-
align = "center",
|
59
|
-
aria = {},
|
60
|
-
rounded = false,
|
61
|
-
borderColor = rounded ? null : "",
|
62
|
-
borderWidth = rounded ? 20 : null,
|
63
|
-
chartData,
|
64
|
-
children,
|
65
|
-
className,
|
66
|
-
colors = [],
|
67
|
-
dark = false,
|
68
|
-
data = {},
|
69
|
-
dataLabelHtml = "<div>{point.name}</div>",
|
70
|
-
dataLabels = false,
|
71
|
-
height,
|
72
|
-
id,
|
73
|
-
innerSize = "md",
|
74
|
-
legend = false,
|
75
|
-
maxPointSize = null,
|
76
|
-
minPointSize = null,
|
77
|
-
startAngle = null,
|
78
|
-
style = "pie",
|
79
|
-
title,
|
80
|
-
useHtml = false,
|
81
|
-
zMin = null,
|
82
|
-
layout = "horizontal",
|
83
|
-
verticalAlign = "bottom",
|
84
|
-
x = 0,
|
85
|
-
y = 0,
|
86
|
-
...props
|
87
|
-
}: CircleChartProps) => {
|
88
|
-
const ariaProps = buildAriaProps(aria);
|
89
|
-
const dataProps = buildDataProps(data);
|
90
|
-
const setupTheme = () => {
|
91
|
-
dark
|
92
|
-
? Highcharts.setOptions(highchartsDarkTheme)
|
93
|
-
: Highcharts.setOptions(highchartsTheme);
|
94
|
-
};
|
95
|
-
setupTheme();
|
96
|
-
|
97
|
-
Highcharts.setOptions({
|
98
|
-
tooltip: {
|
99
|
-
headerFormat: null,
|
100
|
-
pointFormat:
|
101
|
-
'<span style="font-weight: bold; color:{point.color};">●</span>{point.name}: ' +
|
102
|
-
"<b>{point.y}</b>",
|
103
|
-
useHTML: useHtml,
|
104
|
-
},
|
105
|
-
});
|
106
|
-
|
107
|
-
const innerSizes = { sm: "35%", md: "50%", lg: "85%", none: "0%" };
|
108
|
-
const innerSizeFormat = (size: "sm" | "md" | "lg" | "none") =>
|
109
|
-
innerSizes[size];
|
110
|
-
|
111
|
-
const componentDidMount = useRef(false);
|
112
|
-
|
113
|
-
const [options, setOptions] = useState({});
|
114
|
-
|
115
|
-
useEffect(() => {
|
116
|
-
const formattedChartData = chartData.map((obj: any) => {
|
117
|
-
obj.y = obj.value;
|
118
|
-
delete obj.value;
|
119
|
-
return obj;
|
120
|
-
});
|
121
|
-
|
122
|
-
const staticOptions = {
|
123
|
-
title: {
|
124
|
-
text: title,
|
125
|
-
},
|
126
|
-
chart: {
|
127
|
-
height: height,
|
128
|
-
type: style,
|
129
|
-
events: {
|
130
|
-
render: (event: any) => alignBlockElement(event),
|
131
|
-
redraw: (event: any) => alignBlockElement(event),
|
132
|
-
},
|
133
|
-
},
|
134
|
-
|
135
|
-
legend: {
|
136
|
-
align: align,
|
137
|
-
verticalAlign: verticalAlign,
|
138
|
-
layout: layout,
|
139
|
-
x: x,
|
140
|
-
y: y,
|
141
|
-
},
|
142
|
-
plotOptions: {
|
143
|
-
pie: {
|
144
|
-
colors:
|
145
|
-
colors.length > 0 ? mapColors(colors) : highchartsTheme.colors,
|
146
|
-
dataLabels: {
|
147
|
-
enabled: dataLabels,
|
148
|
-
connectorShape: "straight",
|
149
|
-
connectorWidth: 3,
|
150
|
-
format: dataLabelHtml,
|
151
|
-
},
|
152
|
-
showInLegend: legend,
|
153
|
-
},
|
154
|
-
},
|
155
|
-
series: [
|
156
|
-
{
|
157
|
-
minPointSize: minPointSize,
|
158
|
-
maxPointSize: maxPointSize,
|
159
|
-
innerSize: borderWidth == 20 ? "100%" : innerSizeFormat(innerSize),
|
160
|
-
data: formattedChartData,
|
161
|
-
zMin: zMin,
|
162
|
-
startAngle: startAngle,
|
163
|
-
borderWidth: borderWidth,
|
164
|
-
borderColor: borderColor,
|
165
|
-
},
|
166
|
-
],
|
167
|
-
credits: false,
|
168
|
-
};
|
169
|
-
setOptions({ ...staticOptions });
|
170
|
-
if (componentDidMount.current) {
|
171
|
-
Highcharts.charts.forEach((chart: any) => {
|
172
|
-
if (chart && chart.renderTo.id === id) {
|
173
|
-
const updatedValueArray = chartData.map((obj: any) => {
|
174
|
-
return obj.value;
|
175
|
-
});
|
176
|
-
chart.series[0].setData(updatedValueArray);
|
177
|
-
}
|
178
|
-
});
|
179
|
-
} else {
|
180
|
-
componentDidMount.current = true;
|
181
|
-
}
|
182
|
-
}, [chartData]);
|
183
|
-
|
184
|
-
return (
|
185
|
-
<>
|
186
|
-
{children ? (
|
187
|
-
<div id={`wrapper-circle-chart-${id}`}>
|
188
|
-
<HighchartsReact
|
189
|
-
containerProps={{
|
190
|
-
className: classnames("pb_circle_chart", globalProps(props)),
|
191
|
-
id: id,
|
192
|
-
...ariaProps,
|
193
|
-
...dataProps,
|
194
|
-
}}
|
195
|
-
highcharts={Highcharts}
|
196
|
-
options={options}
|
197
|
-
/>
|
198
|
-
<div className="pb-circle-chart-block">{children}</div>
|
199
|
-
</div>
|
200
|
-
) : (
|
201
|
-
<HighchartsReact
|
202
|
-
containerProps={{
|
203
|
-
className: classnames("pb_circle_chart", globalProps(props)),
|
204
|
-
id: id,
|
205
|
-
...ariaProps,
|
206
|
-
...dataProps,
|
207
|
-
}}
|
208
|
-
highcharts={Highcharts}
|
209
|
-
options={options}
|
210
|
-
/>
|
211
|
-
)}
|
212
|
-
</>
|
213
|
-
);
|
214
|
-
};
|
215
|
-
|
216
|
-
export default CircleChart;
|
@@ -1,16 +0,0 @@
|
|
1
|
-
import colors from "../tokens/exports/_colors.scss";
|
2
|
-
|
3
|
-
|
4
|
-
// Map Data Color String Props to our SCSS Variables
|
5
|
-
const mapColors = (array: string[]) => {
|
6
|
-
const regex = /(data)\-[1-8]/; //eslint-disable-line
|
7
|
-
|
8
|
-
const newArray = array.map((item) => {
|
9
|
-
return regex.test(item)
|
10
|
-
? `${colors[`data_${item[item.length - 1]}`]}`
|
11
|
-
: item;
|
12
|
-
});
|
13
|
-
return newArray;
|
14
|
-
};
|
15
|
-
|
16
|
-
export default mapColors
|
@@ -1,16 +0,0 @@
|
|
1
|
-
export type ThemeProps = {
|
2
|
-
lang?: {[key: string]: string}
|
3
|
-
credits?: {[key: string]: boolean}
|
4
|
-
colors?: string[]
|
5
|
-
chart?: {[key: string]: any}
|
6
|
-
title?: {[key: string]: string | {}}
|
7
|
-
subtitle?: {[key: string]: string | {};}
|
8
|
-
xAxis?: {[key: string]: any;}
|
9
|
-
yAxis?: {[key: string]: any;}
|
10
|
-
legend?: {[key: string]: string | {};}
|
11
|
-
labels?: {[key: string]: {};}
|
12
|
-
tooltip?: {[key: string]: any;}
|
13
|
-
pane?: {[key: string]: {};}
|
14
|
-
plotOptions?: {[key: string]: any;}
|
15
|
-
colorKey?: string
|
16
|
-
}
|
@@ -1,213 +0,0 @@
|
|
1
|
-
import React, { useState, useEffect, useRef } from "react";
|
2
|
-
import classnames from "classnames";
|
3
|
-
import HighchartsReact from "highcharts-react-official";
|
4
|
-
import Highcharts from "highcharts";
|
5
|
-
import { highchartsTheme } from "../pb_dashboard/pbChartsLightTheme";
|
6
|
-
import { highchartsDarkTheme } from "../pb_dashboard/pbChartsDarkTheme";
|
7
|
-
import mapColors from "../pb_dashboard/pbChartsColorsHelper";
|
8
|
-
import highchartsMore from "highcharts/highcharts-more";
|
9
|
-
import solidGauge from "highcharts/modules/solid-gauge";
|
10
|
-
import defaultColors from "../tokens/exports/_colors.scss";
|
11
|
-
import typography from "../tokens/exports/_typography.scss";
|
12
|
-
|
13
|
-
import { buildAriaProps, buildCss, buildDataProps } from "../utilities/props";
|
14
|
-
import { globalProps } from "../utilities/globalProps";
|
15
|
-
|
16
|
-
type GaugeProps = {
|
17
|
-
aria: { [key: string]: string };
|
18
|
-
className?: string;
|
19
|
-
chartData?: { name: string; value: number[] | number }[];
|
20
|
-
dark?: Boolean;
|
21
|
-
data?: { [key: string]: string };
|
22
|
-
disableAnimation?: boolean;
|
23
|
-
fullCircle?: boolean;
|
24
|
-
height?: string;
|
25
|
-
id?: string;
|
26
|
-
max?: number;
|
27
|
-
min?: number;
|
28
|
-
prefix?: string;
|
29
|
-
showLabels?: boolean;
|
30
|
-
style?: string;
|
31
|
-
suffix?: string;
|
32
|
-
title?: string;
|
33
|
-
tooltipHtml?: string;
|
34
|
-
colors: string[];
|
35
|
-
minorTickInterval: any;
|
36
|
-
circumference: number[];
|
37
|
-
};
|
38
|
-
|
39
|
-
const Gauge = ({
|
40
|
-
aria = {},
|
41
|
-
className,
|
42
|
-
chartData,
|
43
|
-
dark = false,
|
44
|
-
data = {},
|
45
|
-
disableAnimation = false,
|
46
|
-
fullCircle = false,
|
47
|
-
height = null,
|
48
|
-
id,
|
49
|
-
max = 100,
|
50
|
-
min = 0,
|
51
|
-
prefix = "",
|
52
|
-
showLabels = false,
|
53
|
-
style = "solidgauge",
|
54
|
-
suffix = "",
|
55
|
-
title = "",
|
56
|
-
tooltipHtml = '<span style="font-weight: bold; color:{point.color};">●</span>{point.name}: ' +
|
57
|
-
"<b>{point.y}</b>",
|
58
|
-
colors = [],
|
59
|
-
minorTickInterval = null,
|
60
|
-
circumference = fullCircle ? [0, 360] : [-100, 100],
|
61
|
-
...props
|
62
|
-
}: GaugeProps) => {
|
63
|
-
const ariaProps = buildAriaProps(aria);
|
64
|
-
const dataProps = buildDataProps(data);
|
65
|
-
highchartsMore(Highcharts);
|
66
|
-
solidGauge(Highcharts);
|
67
|
-
const setupTheme = () => {
|
68
|
-
dark
|
69
|
-
? Highcharts.setOptions(highchartsDarkTheme)
|
70
|
-
: Highcharts.setOptions(highchartsTheme);
|
71
|
-
};
|
72
|
-
setupTheme();
|
73
|
-
|
74
|
-
//set tooltip directly to prevent being overriden by Highcharts defaults
|
75
|
-
Highcharts.setOptions({
|
76
|
-
tooltip: {
|
77
|
-
pointFormat: tooltipHtml,
|
78
|
-
followPointer: true,
|
79
|
-
},
|
80
|
-
});
|
81
|
-
|
82
|
-
const css = buildCss({
|
83
|
-
pb_gauge_kit: true,
|
84
|
-
});
|
85
|
-
|
86
|
-
const componentDidMount = useRef(false);
|
87
|
-
const [options, setOptions] = useState({});
|
88
|
-
|
89
|
-
useEffect(() => {
|
90
|
-
const formattedChartData = chartData.map((obj: any) => {
|
91
|
-
obj.y = obj.value;
|
92
|
-
delete obj.value;
|
93
|
-
return obj;
|
94
|
-
});
|
95
|
-
|
96
|
-
const staticOptions = {
|
97
|
-
chart: {
|
98
|
-
events: {
|
99
|
-
load() {
|
100
|
-
setTimeout(this.reflow.bind(this), 0);
|
101
|
-
},
|
102
|
-
},
|
103
|
-
type: style,
|
104
|
-
height: height,
|
105
|
-
},
|
106
|
-
title: {
|
107
|
-
text: title,
|
108
|
-
},
|
109
|
-
yAxis: {
|
110
|
-
min: min,
|
111
|
-
max: max,
|
112
|
-
lineWidth: 0,
|
113
|
-
tickWidth: 0,
|
114
|
-
minorTickInterval: minorTickInterval,
|
115
|
-
tickAmount: 2,
|
116
|
-
tickPositions: [min, max],
|
117
|
-
labels: {
|
118
|
-
y: 26,
|
119
|
-
enabled: showLabels,
|
120
|
-
},
|
121
|
-
},
|
122
|
-
credits: false,
|
123
|
-
series: [
|
124
|
-
{
|
125
|
-
data: formattedChartData,
|
126
|
-
},
|
127
|
-
],
|
128
|
-
pane: {
|
129
|
-
center: ["50%", "50%"],
|
130
|
-
size: "90%",
|
131
|
-
startAngle: circumference[0],
|
132
|
-
endAngle: circumference[1],
|
133
|
-
background: {
|
134
|
-
borderWidth: 20,
|
135
|
-
innerRadius: "90%",
|
136
|
-
outerRadius: "90%",
|
137
|
-
shape: "arc",
|
138
|
-
className: "gauge-pane",
|
139
|
-
},
|
140
|
-
},
|
141
|
-
colors:
|
142
|
-
colors !== undefined && colors.length > 0
|
143
|
-
? mapColors(colors)
|
144
|
-
: highchartsTheme.colors,
|
145
|
-
plotOptions: {
|
146
|
-
series: {
|
147
|
-
animation: !disableAnimation,
|
148
|
-
},
|
149
|
-
solidgauge: {
|
150
|
-
borderColor:
|
151
|
-
colors !== undefined && colors.length === 1
|
152
|
-
? mapColors(colors).join()
|
153
|
-
: highchartsTheme.colors[0],
|
154
|
-
borderWidth: 20,
|
155
|
-
radius: 90,
|
156
|
-
innerRadius: "90%",
|
157
|
-
dataLabels: {
|
158
|
-
borderWidth: 0,
|
159
|
-
color: defaultColors.text_lt_default,
|
160
|
-
enabled: true,
|
161
|
-
format:
|
162
|
-
`<span class="prefix">${prefix}</span>` +
|
163
|
-
'<span class="fix">{y:,f}</span>' +
|
164
|
-
`<span class="suffix">${suffix}</span>`,
|
165
|
-
style: {
|
166
|
-
fontFamily: typography.font_family_base,
|
167
|
-
fontWeight: typography.regular,
|
168
|
-
fontSize: typography.heading_2,
|
169
|
-
},
|
170
|
-
y: -26,
|
171
|
-
},
|
172
|
-
},
|
173
|
-
},
|
174
|
-
};
|
175
|
-
|
176
|
-
setOptions({ ...staticOptions });
|
177
|
-
|
178
|
-
if (document.querySelector(".prefix")) {
|
179
|
-
document.querySelectorAll(".prefix").forEach((prefix) => {
|
180
|
-
prefix.setAttribute("y", "28");
|
181
|
-
});
|
182
|
-
document
|
183
|
-
.querySelectorAll(".fix")
|
184
|
-
.forEach((fix) => fix.setAttribute("y", "38"));
|
185
|
-
}
|
186
|
-
|
187
|
-
if (componentDidMount.current) {
|
188
|
-
Highcharts.charts.forEach((chart: any) => {
|
189
|
-
if (chart && chart.renderTo.id === id) {
|
190
|
-
chart.series[0].setData([chartData[0].value]);
|
191
|
-
chart.series[0].data[0].name = chartData[0].name;
|
192
|
-
}
|
193
|
-
});
|
194
|
-
} else {
|
195
|
-
componentDidMount.current = true;
|
196
|
-
}
|
197
|
-
}, [chartData]);
|
198
|
-
|
199
|
-
return (
|
200
|
-
<HighchartsReact
|
201
|
-
containerProps={{
|
202
|
-
className: classnames(css, globalProps(props)),
|
203
|
-
id: id,
|
204
|
-
...ariaProps,
|
205
|
-
...dataProps,
|
206
|
-
}}
|
207
|
-
highcharts={Highcharts}
|
208
|
-
options={options}
|
209
|
-
/>
|
210
|
-
);
|
211
|
-
};
|
212
|
-
|
213
|
-
export default Gauge;
|
@@ -1,148 +0,0 @@
|
|
1
|
-
import React, { useState, useEffect } from "react";
|
2
|
-
import classnames from "classnames";
|
3
|
-
import { globalProps } from "../utilities/globalProps";
|
4
|
-
import { buildAriaProps, buildDataProps } from "../utilities/props";
|
5
|
-
|
6
|
-
import HighchartsReact from "highcharts-react-official";
|
7
|
-
import Highcharts from "highcharts";
|
8
|
-
import { highchartsTheme } from "../pb_dashboard/pbChartsLightTheme";
|
9
|
-
import { highchartsDarkTheme } from "../pb_dashboard/pbChartsDarkTheme";
|
10
|
-
import mapColors from "../pb_dashboard/pbChartsColorsHelper";
|
11
|
-
|
12
|
-
type LineGraphProps = {
|
13
|
-
align?: "left" | "right" | "center";
|
14
|
-
axisTitle?: string;
|
15
|
-
dark?: Boolean;
|
16
|
-
xAxisCategories: [];
|
17
|
-
yAxisMin: number;
|
18
|
-
yAxisMax: number;
|
19
|
-
className?: string;
|
20
|
-
chartData: {
|
21
|
-
name: string;
|
22
|
-
data: number[];
|
23
|
-
}[];
|
24
|
-
gradient?: boolean;
|
25
|
-
id: string;
|
26
|
-
pointStart: number;
|
27
|
-
subTitle?: string;
|
28
|
-
title: string;
|
29
|
-
type?: string;
|
30
|
-
legend?: boolean;
|
31
|
-
toggleLegendClick?: boolean;
|
32
|
-
height?: string;
|
33
|
-
colors: string[];
|
34
|
-
layout?: "horizontal" | "vertical" | "proximate";
|
35
|
-
verticalAlign?: "top" | "middle" | "bottom";
|
36
|
-
x?: number;
|
37
|
-
y?: number;
|
38
|
-
aria?: { [key: string]: string };
|
39
|
-
data?: { [key: string]: string };
|
40
|
-
};
|
41
|
-
|
42
|
-
const LineGraph = ({
|
43
|
-
aria = {},
|
44
|
-
data = {},
|
45
|
-
align = "center",
|
46
|
-
className = "pb_bar_graph",
|
47
|
-
dark = false,
|
48
|
-
gradient = false,
|
49
|
-
type = "line",
|
50
|
-
id,
|
51
|
-
legend = false,
|
52
|
-
toggleLegendClick = true,
|
53
|
-
layout = "horizontal",
|
54
|
-
verticalAlign = "bottom",
|
55
|
-
x = 0,
|
56
|
-
y = 0,
|
57
|
-
axisTitle,
|
58
|
-
xAxisCategories,
|
59
|
-
yAxisMin,
|
60
|
-
yAxisMax,
|
61
|
-
chartData,
|
62
|
-
pointStart,
|
63
|
-
subTitle,
|
64
|
-
title,
|
65
|
-
height,
|
66
|
-
colors = [],
|
67
|
-
...props
|
68
|
-
}: LineGraphProps) => {
|
69
|
-
const ariaProps = buildAriaProps(aria);
|
70
|
-
const dataProps = buildDataProps(data);
|
71
|
-
const setupTheme = () => {
|
72
|
-
dark
|
73
|
-
? Highcharts.setOptions(highchartsDarkTheme)
|
74
|
-
: Highcharts.setOptions(highchartsTheme);
|
75
|
-
};
|
76
|
-
setupTheme();
|
77
|
-
|
78
|
-
const staticOptions = {
|
79
|
-
title: {
|
80
|
-
text: title,
|
81
|
-
},
|
82
|
-
chart: {
|
83
|
-
height: height,
|
84
|
-
type: type,
|
85
|
-
},
|
86
|
-
subtitle: {
|
87
|
-
text: subTitle,
|
88
|
-
},
|
89
|
-
yAxis: {
|
90
|
-
min: yAxisMin,
|
91
|
-
max: yAxisMax,
|
92
|
-
title: {
|
93
|
-
text: axisTitle,
|
94
|
-
},
|
95
|
-
},
|
96
|
-
xAxis: {
|
97
|
-
categories: xAxisCategories,
|
98
|
-
},
|
99
|
-
legend: {
|
100
|
-
enabled: legend,
|
101
|
-
align: align,
|
102
|
-
verticalAlign: verticalAlign,
|
103
|
-
layout: layout,
|
104
|
-
x: x,
|
105
|
-
y: y,
|
106
|
-
},
|
107
|
-
colors:
|
108
|
-
colors !== undefined && colors.length > 0
|
109
|
-
? mapColors(colors)
|
110
|
-
: highchartsTheme.colors,
|
111
|
-
plotOptions: {
|
112
|
-
series: {
|
113
|
-
pointStart: pointStart,
|
114
|
-
events: {},
|
115
|
-
dataLabels: {
|
116
|
-
enabled: false,
|
117
|
-
},
|
118
|
-
},
|
119
|
-
},
|
120
|
-
series: chartData,
|
121
|
-
credits: false,
|
122
|
-
};
|
123
|
-
|
124
|
-
if (!toggleLegendClick) {
|
125
|
-
staticOptions.plotOptions.series.events = { legendItemClick: () => false };
|
126
|
-
}
|
127
|
-
|
128
|
-
const [options, setOptions] = useState({});
|
129
|
-
|
130
|
-
useEffect(() => {
|
131
|
-
setOptions({ ...staticOptions });
|
132
|
-
}, [chartData]);
|
133
|
-
|
134
|
-
return (
|
135
|
-
<HighchartsReact
|
136
|
-
containerProps={{
|
137
|
-
className: classnames(globalProps(props), className),
|
138
|
-
id: id,
|
139
|
-
...ariaProps,
|
140
|
-
...dataProps,
|
141
|
-
}}
|
142
|
-
highcharts={Highcharts}
|
143
|
-
options={options}
|
144
|
-
/>
|
145
|
-
);
|
146
|
-
};
|
147
|
-
|
148
|
-
export default LineGraph;
|
@@ -1 +0,0 @@
|
|
1
|
-
Use the `confirmation` prop to only include the label and show/hide icon.
|
@@ -1,55 +0,0 @@
|
|
1
|
-
import zxcvbn from 'zxcvbn'
|
2
|
-
|
3
|
-
export const zxcvbnPasswordScore = (options) => {
|
4
|
-
const {
|
5
|
-
calculate = zxcvbn,
|
6
|
-
averageThreshold = 2,
|
7
|
-
strongThreshold = 3,
|
8
|
-
minLength = 12,
|
9
|
-
} = options
|
10
|
-
|
11
|
-
return {
|
12
|
-
minLength,
|
13
|
-
averageThreshold,
|
14
|
-
strongThreshold,
|
15
|
-
test: function (password = '', common = false) {
|
16
|
-
const feedbackValues = (str) => {
|
17
|
-
let percent, variant, text
|
18
|
-
|
19
|
-
if (password.length <= 0) {
|
20
|
-
percent = '0'
|
21
|
-
variant = 'negative'
|
22
|
-
text = '\u00A0' //nbsp to keep form from jumping when typing beings
|
23
|
-
} else if (common) {
|
24
|
-
percent = '25'
|
25
|
-
variant = 'negative'
|
26
|
-
text = 'This passphrase is too common'
|
27
|
-
} else if (password.length < this.minLength || str < this.averageThreshold) {
|
28
|
-
percent = '25'
|
29
|
-
variant = 'negative'
|
30
|
-
text = 'Too weak'
|
31
|
-
} else if (str < this.strongThreshold){
|
32
|
-
percent = '50'
|
33
|
-
variant = 'warning'
|
34
|
-
text = 'Almost there, keep going!'
|
35
|
-
} else if (str >= this.strongThreshold) {
|
36
|
-
percent = '100'
|
37
|
-
variant = 'positive'
|
38
|
-
text = 'Success! Strong passphrase'
|
39
|
-
}
|
40
|
-
return { percent, variant, text }
|
41
|
-
}
|
42
|
-
|
43
|
-
const result = calculate(password)
|
44
|
-
|
45
|
-
return (
|
46
|
-
{
|
47
|
-
suggestions: result.feedback.suggestions,
|
48
|
-
warning: result.feedback.warning,
|
49
|
-
strength: result.score,
|
50
|
-
...feedbackValues(result.score),
|
51
|
-
}
|
52
|
-
)
|
53
|
-
},
|
54
|
-
}
|
55
|
-
}
|