playbook_ui 14.24.0.pre.alpha.play23649503 → 14.24.0.pre.alpha.testingwithoutdatepicker9614

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.
Files changed (36) hide show
  1. checksums.yaml +4 -4
  2. data/app/pb_kits/playbook/pb_bar_graph/_bar_graph.tsx +175 -26
  3. data/app/pb_kits/playbook/pb_bar_graph/barGraph.test.js +2 -1
  4. data/app/pb_kits/playbook/pb_bar_graph/bar_graph.html.erb +1 -1
  5. data/app/pb_kits/playbook/pb_bar_graph/bar_graph.rb +78 -12
  6. data/app/pb_kits/playbook/pb_bar_graph/docs/_bar_graph_default.html.erb +9 -21
  7. data/app/pb_kits/playbook/pb_circle_icon_button/circle_icon_button.html.erb +10 -1
  8. data/app/pb_kits/playbook/pb_circle_icon_button/circle_icon_button.rb +2 -0
  9. data/app/pb_kits/playbook/pb_circle_icon_button/docs/_circle_icon_button_input_options.html.erb +24 -0
  10. data/app/pb_kits/playbook/pb_circle_icon_button/docs/_circle_icon_button_input_options.md +3 -0
  11. data/app/pb_kits/playbook/pb_circle_icon_button/docs/example.yml +1 -0
  12. data/app/pb_kits/playbook/pb_date_picker/_date_picker.tsx +1 -33
  13. data/app/pb_kits/playbook/pb_date_picker/date_picker.html.erb +1 -10
  14. data/app/pb_kits/playbook/pb_date_picker/date_picker.test.js +1 -215
  15. data/app/pb_kits/playbook/pb_fixed_confirmation_toast/_fixed_confirmation_toast.tsx +2 -2
  16. data/app/pb_kits/playbook/pb_fixed_confirmation_toast/docs/_fixed_confirmation_toast_no_icon.html.erb +22 -0
  17. data/app/pb_kits/playbook/pb_fixed_confirmation_toast/docs/_fixed_confirmation_toast_no_icon.jsx +43 -0
  18. data/app/pb_kits/playbook/pb_fixed_confirmation_toast/docs/_fixed_confirmation_toast_no_icon.md +1 -0
  19. data/app/pb_kits/playbook/pb_fixed_confirmation_toast/docs/example.yml +2 -0
  20. data/app/pb_kits/playbook/pb_fixed_confirmation_toast/docs/index.js +1 -0
  21. data/app/pb_kits/playbook/pb_fixed_confirmation_toast/fixed_confirmation_toast.html.erb +2 -1
  22. data/app/pb_kits/playbook/pb_fixed_confirmation_toast/fixed_confirmation_toast.rb +1 -1
  23. data/app/pb_kits/playbook/pb_fixed_confirmation_toast/fixed_confirmation_toast.test.js +6 -0
  24. data/app/pb_kits/playbook/pb_phone_number_input/_phone_number_input.tsx +11 -1
  25. data/dist/chunks/_line_graph-B0SsQi-l.js +1 -0
  26. data/dist/chunks/{_typeahead-CKvqSXWH.js → _typeahead-BgBecRbi.js} +2 -2
  27. data/dist/chunks/{_weekday_stacked-tedYzlIq.js → _weekday_stacked-BlsASRoi.js} +3 -3
  28. data/dist/chunks/{lib-BplzvaaY.js → lib-DujEDjJx.js} +2 -2
  29. data/dist/chunks/{pb_form_validation-CA_noofR.js → pb_form_validation-D3vVNE8Q.js} +1 -1
  30. data/dist/chunks/vendor.js +1 -1
  31. data/dist/playbook-doc.js +1 -1
  32. data/dist/playbook-rails-react-bindings.js +1 -1
  33. data/dist/playbook-rails.js +1 -1
  34. data/lib/playbook/version.rb +1 -1
  35. metadata +12 -7
  36. data/dist/chunks/_line_graph-BsZ3DcJo.js +0 -1
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 7b6125bc029c939ad15a726d63897d11251203a4b3529c1e5909cf5a017938a1
4
- data.tar.gz: 03153bcee4384a533f7e1b9c91447ee748077b8f52b097e3cee2134f3a14afa6
3
+ metadata.gz: fc2e4d67d666358c86897872c9a77d8ba2662808cd42ba496b31941786528f6a
4
+ data.tar.gz: 19b5ab16c5dd94a84e0f93fac4d28dce35420006af8b57b463094fa6b9865e0b
5
5
  SHA512:
6
- metadata.gz: c635cb4af1e58eaddb56b5ba82f10e440e70201aa6eab3a1d469b4b568335ef1099cfd5986ac53dd841fb1b0cb2f4f796d33eb1155f5b5bde188f664f64e5b38
7
- data.tar.gz: 76080ead057d43b8d5b794bdd4eadca9abe86495b1d1281edb677d58dfc1fe53dabf98269326b5623974543188da4e83191b01c28d74206512c9bc3b70cab646
6
+ metadata.gz: bd20e54aac1feb77f9cc987350df78951438f2c0a0e22a2ee7ae92088f15fd73be35a6390187cd198df9413564263780c571acce1ada6c228069933fac0058aa
7
+ data.tar.gz: 0ad927a661e4cdad5eaac8574e7d0659972316641132dc7eba96a3f620864f4cba407437f2862e684027cdc354482453db299181bb106d5b18f623b239b512a4
@@ -1,41 +1,190 @@
1
- import React, { useMemo } from "react"
1
+ import React, { useState, useEffect } from "react";
2
+ import { globalProps } from "../utilities/globalProps";
2
3
  import { buildAriaProps, buildDataProps, buildHtmlProps } from "../utilities/props";
3
- import Highcharts from "highcharts"
4
- import HighchartsReact from "highcharts-react-official"
5
4
 
6
- import barGraphTheme from "./barGraphTheme"
5
+ import HighchartsReact from "highcharts-react-official";
6
+ import Highcharts from "highcharts";
7
+ import { highchartsTheme } from "../pb_dashboard/pbChartsLightTheme";
8
+ import { highchartsDarkTheme } from "../pb_dashboard/pbChartsDarkTheme";
9
+ import mapColors from "../pb_dashboard/pbChartsColorsHelper";
10
+ import { merge } from '../utilities/object'
11
+
12
+ import classnames from "classnames";
7
13
 
8
14
  type BarGraphProps = {
9
- options: Record<string, unknown>
10
- containerProps?: React.HTMLProps<HTMLDivElement>
11
- data?: Record<string, unknown>
12
- }
15
+ align?: "left" | "right" | "center";
16
+ axisTitle: { name: string; }[] | string;
17
+ dark?: boolean;
18
+ xAxisCategories: [];
19
+ yAxisMin: number;
20
+ yAxisMax: number;
21
+ chartData: { name: string; data: number[], yAxis: number }[];
22
+ className?: string;
23
+ customOptions?: Partial<Highcharts.Options>;
24
+ id: string;
25
+ pointStart: number;
26
+ htmlOptions?: {[key: string]: string | number | boolean | (() => void)},
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
+ stacking?: "normal" | "percent"
41
+ axisFormat?: { format: string; }[] | string;
42
+ };
13
43
 
14
- const BarGraph = ({
15
- options,
16
- containerProps = {},
17
- data = {}
18
- }: BarGraphProps): React.ReactElement => {
19
44
 
45
+ const BarGraph = ({
46
+ aria = {},
47
+ data = {},
48
+ align = "center",
49
+ axisTitle,
50
+ dark = false,
51
+ chartData,
52
+ className = "pb_bar_graph",
53
+ colors,
54
+ htmlOptions = {},
55
+ customOptions = {},
56
+ axisFormat,
57
+ id,
58
+ pointStart,
59
+ stacking,
60
+ subTitle,
61
+ type = "column",
62
+ title = "Title",
63
+ xAxisCategories,
64
+ yAxisMin,
65
+ yAxisMax,
66
+ legend = false,
67
+ toggleLegendClick = true,
68
+ height,
69
+ layout = "horizontal",
70
+ verticalAlign = "bottom",
71
+ x = 0,
72
+ y = 0,
73
+ ...props
74
+ }: BarGraphProps): React.ReactElement => {
75
+ const ariaProps = buildAriaProps(aria);
20
76
  const dataProps = buildDataProps(data)
77
+ const htmlProps = buildHtmlProps(htmlOptions);
78
+ const setupTheme = () => {
79
+ dark
80
+ ? Highcharts.setOptions(highchartsDarkTheme)
81
+ : Highcharts.setOptions(highchartsTheme);
82
+ };
83
+ setupTheme();
84
+
85
+ const staticOptions = {
86
+ title: {
87
+ text: title,
88
+ },
89
+ chart: {
90
+ height: height,
91
+ type: type,
92
+ },
93
+ subtitle: {
94
+ text: subTitle,
95
+ },
96
+ yAxis: [{
97
+ labels: {
98
+ format: typeof axisFormat === 'string' ? axisFormat : (axisFormat && axisFormat[0] ? axisFormat[0].format : "")
21
99
 
22
- const mergedOptions = useMemo(() => {
23
- if (!options || typeof options !== "object") {
24
- // eslint-disable-next-line no-console
25
- console.error("❌ Invalid options passed to <BarGraph />", options)
26
- return {}
27
- }
100
+ },
101
+ min: yAxisMin,
102
+ max: yAxisMax,
103
+ opposite: false,
104
+ title: {
105
+ text: Array.isArray(axisTitle) ? (axisTitle.length > 0 ? axisTitle[0].name : null) : axisTitle,
106
+ },
107
+ plotLines: typeof yAxisMin !== 'undefined' && yAxisMin !== null ? [] : [{
108
+ value: 0,
109
+ zIndex: 10,
110
+ color: "#E4E8F0"
111
+ }],
112
+ }],
113
+ xAxis: {
114
+ categories: xAxisCategories,
115
+ },
116
+ legend: {
117
+ enabled: legend,
118
+ align: align,
119
+ verticalAlign: verticalAlign,
120
+ layout: layout,
121
+ x: x,
122
+ y: y,
123
+ },
124
+ colors:
125
+ colors !== undefined && colors.length > 0
126
+ ? mapColors(colors)
127
+ : highchartsTheme.colors,
128
+ plotOptions: {
129
+ series: {
130
+ stacking: stacking,
131
+ pointStart: pointStart,
132
+ borderWidth: stacking ? 0 : "",
133
+ events: {},
134
+ dataLabels: {
135
+ enabled: false,
136
+ },
137
+ },
138
+ },
139
+ series: chartData,
140
+ credits: false,
141
+ };
28
142
 
29
- return Highcharts.merge({}, barGraphTheme, options)
30
- }, [options])
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
+
162
+ if (!toggleLegendClick) {
163
+ staticOptions.plotOptions.series.events = { legendItemClick: () => false };
164
+ }
165
+
166
+ const filteredProps: any = {...props};
167
+ delete filteredProps.verticalAlign;
168
+
169
+ const [options, setOptions] = useState({});
170
+
171
+ useEffect(() => {
172
+ setOptions(merge(staticOptions, customOptions));
173
+ }, [chartData]);
31
174
 
32
175
  return (
33
176
  <HighchartsReact
34
- containerProps={{ ...containerProps, ...dataProps }}
177
+ containerProps={{
178
+ className: classnames(globalProps(filteredProps), className),
179
+ id: id,
180
+ ...ariaProps,
181
+ ...dataProps,
182
+ ...htmlProps
183
+ }}
35
184
  highcharts={Highcharts}
36
- options={mergedOptions}
185
+ options={options}
37
186
  />
38
- )
39
- }
187
+ );
188
+ };
40
189
 
41
- export default BarGraph
190
+ export default BarGraph;
@@ -20,8 +20,9 @@ const testId = 'bargraph1';
20
20
  test('bargraph uses exact classname', () => {
21
21
  render(
22
22
  <BarGraph
23
- containerProps={{ className: 'super_important_class' }}
23
+ className='super_important_class'
24
24
  data={{ testid: testId }}
25
+ id='bar-default'
25
26
  />
26
27
  );
27
28
 
@@ -1 +1 @@
1
- <%= react_component('BarGraph', object.react_props) %>
1
+ <%= react_component('BarGraph', object.chart_options) %>
@@ -3,25 +3,91 @@
3
3
  module Playbook
4
4
  module PbBarGraph
5
5
  class BarGraph < Playbook::KitBase
6
- prop :options, default: {}
7
- prop :container_props, default: {}
6
+ prop :align, type: Playbook::Props::Enum,
7
+ values: %w[left right center],
8
+ default: "center"
9
+ prop :axis_title
10
+ prop :axis_format
11
+ prop :chart_data, type: Playbook::Props::Array,
12
+ default: []
13
+ prop :custom_options, default: {}
14
+ prop :orientation, type: Playbook::Props::Enum,
15
+ values: %w[vertical horizontal],
16
+ default: "vertical"
17
+ prop :point_start, type: Playbook::Props::Numeric
18
+ prop :stacking
19
+ prop :subtitle
20
+ prop :title
21
+ prop :x_axis_categories, type: Playbook::Props::Array,
22
+ default: []
23
+ prop :y_axis_min, type: Playbook::Props::Numeric
24
+ prop :y_axis_max, type: Playbook::Props::Numeric
25
+ prop :legend, type: Playbook::Props::Boolean,
26
+ default: false
27
+ prop :toggle_legend_click, type: Playbook::Props::Boolean,
28
+ default: true
29
+ prop :height
30
+ prop :colors, type: Playbook::Props::Array,
31
+ default: []
32
+ prop :layout, type: Playbook::Props::Enum,
33
+ values: %w[horizontal vertical proximate],
34
+ default: "horizontal"
35
+ prop :vertical_align, type: Playbook::Props::Enum,
36
+ values: %w[top middle bottom],
37
+ default: "bottom"
38
+ prop :x, type: Playbook::Props::Numeric
39
+ prop :y, type: Playbook::Props::Numeric
8
40
 
9
- def chart_options
10
- options
41
+ def chart_type
42
+ orientation == "horizontal" ? "bar" : "column"
11
43
  end
12
44
 
13
- def react_props
45
+ def standard_options
14
46
  {
15
- options: options,
16
- containerProps: container_props_hash,
47
+ align: align,
48
+ id: id,
49
+ className: classname,
50
+ chartData: chart_data,
51
+ dark: dark ? "dark" : "",
52
+ type: chart_type,
53
+ title: title,
54
+ stacking: stacking,
55
+ subTitle: subtitle,
56
+ axisTitle: axis_title,
57
+ axisFormat: axis_format,
58
+ pointStart: point_start,
59
+ xAxisCategories: x_axis_categories,
60
+ yAxisMin: y_axis_min,
61
+ yAxisMax: y_axis_max,
62
+ legend: legend,
63
+ toggleLegendClick: toggle_legend_click,
64
+ height: height,
65
+ colors: colors,
66
+ layout: layout,
67
+ verticalAlign: vertical_align,
68
+ x: x,
69
+ y: y,
17
70
  }
18
71
  end
19
72
 
20
- def container_props_hash
21
- container_props.merge({
22
- id: id,
23
- className: classname,
24
- }).compact
73
+ def chart_options
74
+ standard_options.deep_merge(custom_options)
75
+ end
76
+
77
+ def vertical_align_props
78
+ if vertical_align
79
+ if object.vertical_align
80
+ original_result = super
81
+ class_to_remove = "vertical_align_#{object.vertical_align}"
82
+
83
+ modified_result = original_result.gsub(class_to_remove, "").strip
84
+ modified_result.empty? ? nil : modified_result
85
+ else
86
+ super
87
+ end
88
+ else
89
+ super
90
+ end
25
91
  end
26
92
 
27
93
  def classname
@@ -15,24 +15,12 @@
15
15
  data: [1111,677,3245,500,200]
16
16
  }] %>
17
17
 
18
-
19
- <% chart_options = {
20
- series: data,
21
- title: {
22
- text: 'Solar Employment Growth by Sector, 2010-2016',
23
- },
24
- subtitle: {
25
- text: 'Source: thesolarfoundation.com',
26
- },
27
- xAxis: {
28
- categories: ['Jan', 'Feb', 'Mar', 'Apr', 'May'],
29
- },
30
- yAxis: {
31
- title: {
32
- text: 'Number of Employees',
33
- },
34
- },
35
- }
36
- %>
37
-
38
- <%= pb_rails("bar_graph", props: {options: chart_options}) %>
18
+ <%= pb_rails("bar_graph", props: {
19
+ axis_title: 'Number of Employees',
20
+ chart_data: data,
21
+ id: "bar-default",
22
+ y_axis_min: 0,
23
+ x_axis_categories:['Jan','Feb','Mar','Apr','May','Jun','Jul','Aug','Sep','Oct','Nov','Dec'],
24
+ subtitle: 'Source: thesolarfoundation.com',
25
+ title: 'Solar Employment Growth by Sector, 2010-2016',
26
+ }) %>
@@ -1,5 +1,14 @@
1
1
  <%= pb_content_tag do %>
2
- <%= pb_rails("button", props: {type: object.type, loading: object.loading, link: object.link, new_window:object.new_window, variant: object.variant, target: object.target, disabled: object.disabled, dark: object.dark}) do %>
2
+ <%= pb_rails("button", props: {
3
+ type: object.type,
4
+ loading: object.loading,
5
+ link: object.link,
6
+ new_window: object.new_window,
7
+ variant: object.variant,
8
+ target: object.target,
9
+ disabled: object.disabled,
10
+ dark: object.dark
11
+ }.merge(object.input_options)) do %>
3
12
  <%= pb_rails("icon", props: {icon: object.icon, fixed_width: true, dark: object.dark}) %>
4
13
  <% end %>
5
14
  <% end %>
@@ -21,6 +21,8 @@ module Playbook
21
21
  prop :size, type: Playbook::Props::Enum,
22
22
  values: %w[default sm],
23
23
  default: "default"
24
+ prop :input_options, type: Playbook::Props::HashProp,
25
+ default: {}
24
26
 
25
27
  def classname
26
28
  generate_classname("pb_circle_icon_button_kit") + size_class
@@ -0,0 +1,24 @@
1
+ <%= pb_rails("circle_icon_button", props: {
2
+ icon: "plus",
3
+ input_options: {
4
+ data: { "test-id": "add-button", remote: true },
5
+ }
6
+ }) %>
7
+ <br/>
8
+ <%= pb_rails("circle_icon_button", props: {
9
+ icon: "pen",
10
+ variant: "secondary",
11
+ input_options: {
12
+ data: { "test-id": "edit-button" },
13
+ classname: "custom-secondary-button-class"
14
+ }
15
+ }) %>
16
+ <br/>
17
+ <%= pb_rails("circle_icon_button", props: {
18
+ icon: "user",
19
+ variant: "link",
20
+ input_options: {
21
+ data: { "test-id": "user-button" },
22
+ id: "user-button-id"
23
+ }
24
+ }) %>
@@ -0,0 +1,3 @@
1
+ Use the `input_options` prop to pass additional attributes directly to the internal Playbook Button component. While the wrapper div has access to the standard `data` prop from KitBase, `input_options` allows you to attach attributes specifically to the internal button element.
2
+
3
+ This is particularly useful when you need data attributes or other HTML attributes to apply to the button itself.
@@ -5,6 +5,7 @@ examples:
5
5
  - circle_icon_button_link: Link
6
6
  - circle_icon_button_loading: Loading
7
7
  - circle_icon_button_size: Size
8
+ - circle_icon_button_input_options: Input Options
8
9
 
9
10
  react:
10
11
  - circle_icon_button_default: Default
@@ -115,39 +115,7 @@ const DatePicker = (props: DatePickerProps): React.ReactElement => {
115
115
  const inputDataProps = buildDataProps(inputData)
116
116
 
117
117
  useEffect(() => {
118
- datePickerHelper({
119
- allowInput,
120
- customQuickPickDates,
121
- defaultDate,
122
- disableDate,
123
- disableRange,
124
- disableWeekdays,
125
- enableTime,
126
- format,
127
- hideIcon,
128
- inLine,
129
- maxDate,
130
- minDate,
131
- mode,
132
- onChange,
133
- onClose,
134
- pickerId,
135
- plugins,
136
- // eslint-disable-next-line @typescript-eslint/ban-ts-comment
137
- // @ts-ignore
138
- position,
139
- positionElement,
140
- selectionType,
141
- showTimezone,
142
- staticPosition,
143
- thisRangesEndToday,
144
- yearRange,
145
- controlsStartId,
146
- controlsEndId,
147
- syncStartWith,
148
- syncEndWith,
149
- required: false,
150
- }, scrollContainer)
118
+ console.log("Hi, I'm the React Date Picker useEffect")
151
119
  }, initializeOnce ? [] : undefined)
152
120
  const filteredProps = {...props}
153
121
  if (filteredProps.marginBottom === undefined) {
@@ -69,16 +69,7 @@
69
69
  <%= javascript_tag do %>
70
70
  (function() {
71
71
  const loadDatePicker = () => {
72
- datePickerHelper(<%= object.date_picker_config %>, "<%= object.scroll_container %>")
73
-
74
- if (<%= object.selection_type == "quickpick" %>) {
75
- document.getElementById("<%= object.picker_id %>").addEventListener("change", ({ target }) => {
76
- const startDate = document.getElementById("<%= object.start_date_id %>")
77
- const endDate = document.getElementById("<%= object.end_date_id %>")
78
- const splittedValue = target.value.split(" to ")
79
- startDate.value = splittedValue[0]
80
- endDate.value = splittedValue[1] ? splittedValue[1] : splittedValue[0]
81
- })
72
+ console.log("Hi, I'm the Rails Date Picker 'loadDatePicker' function")
82
73
  }
83
74
  }
84
75