playbook_ui 14.15.0.pre.alpha.play1910emptystatekitreactbeta6685 → 14.15.0.pre.alpha.play1917lodashremoval2of36613
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 +2 -4
- data/app/pb_kits/playbook/pb_advanced_table/_advanced_table.scss +0 -7
- data/app/pb_kits/playbook/pb_advanced_table/docs/example.yml +1 -2
- data/app/pb_kits/playbook/pb_advanced_table/docs/index.js +1 -2
- data/app/pb_kits/playbook/pb_bar_graph/_bar_graph.tsx +1 -1
- data/app/pb_kits/playbook/pb_circle_chart/_circle_chart.tsx +1 -1
- data/app/pb_kits/playbook/pb_filter/Filter/SortMenu.tsx +2 -1
- data/app/pb_kits/playbook/pb_form/docs/_form_form_with.html.erb +1 -1
- data/app/pb_kits/playbook/pb_form/docs/_form_form_with_validate.html.erb +1 -1
- data/app/pb_kits/playbook/pb_gauge/_gauge.tsx +1 -1
- data/app/pb_kits/playbook/pb_icon_button/_icon_button.tsx +1 -1
- data/app/pb_kits/playbook/pb_icon_button/icon_button.html.erb +1 -1
- data/app/pb_kits/playbook/pb_lightbox/Carousel/Slide.tsx +1 -1
- data/app/pb_kits/playbook/pb_lightbox/Carousel/Slides.tsx +1 -1
- data/app/pb_kits/playbook/pb_lightbox/Carousel/Thumbnails.tsx +1 -1
- data/app/pb_kits/playbook/pb_line_graph/_line_graph.tsx +1 -1
- data/app/pb_kits/playbook/pb_multi_level_select/_multi_level_select.tsx +5 -32
- data/app/pb_kits/playbook/pb_multi_level_select/docs/example.yml +0 -1
- data/app/pb_kits/playbook/pb_multi_level_select/docs/index.js +0 -1
- data/app/pb_kits/playbook/pb_multi_level_select/multi_level_select.rb +1 -1
- data/app/pb_kits/playbook/pb_phone_number_input/_phone_number_input.tsx +0 -6
- data/app/pb_kits/playbook/pb_phone_number_input/docs/_phone_number_input_default.html.erb +1 -1
- data/app/pb_kits/playbook/pb_phone_number_input/docs/example.yml +1 -3
- data/app/pb_kits/playbook/pb_phone_number_input/phone_number_input.rb +0 -3
- data/app/pb_kits/playbook/pb_treemap_chart/_treemap_chart.tsx +1 -1
- data/app/pb_kits/playbook/utilities/object.ts +74 -0
- data/app/pb_kits/playbook/utilities/text.ts +1 -1
- data/dist/chunks/_typeahead-CdVbIURO.js +36 -0
- data/dist/chunks/_weekday_stacked-BSTKfYPJ.js +45 -0
- data/dist/chunks/{lib-5OzNgeeu.js → lib-e7oBFFDo.js} +2 -2
- data/dist/chunks/{pb_form_validation-DGhKbZtO.js → pb_form_validation-CMXevI1t.js} +1 -1
- data/dist/chunks/vendor.js +1 -1
- data/dist/menu.yml +1 -9
- data/dist/playbook-doc.js +1 -1
- 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/version.rb +1 -1
- metadata +6 -22
- data/app/pb_kits/playbook/pb_advanced_table/docs/_advanced_table_inline_editing.jsx +0 -102
- data/app/pb_kits/playbook/pb_advanced_table/docs/_advanced_table_inline_editing.md +0 -4
- data/app/pb_kits/playbook/pb_empty_state/_empty_state.scss +0 -38
- data/app/pb_kits/playbook/pb_empty_state/_empty_state.tsx +0 -213
- data/app/pb_kits/playbook/pb_empty_state/docs/_empty_state_alignment.jsx +0 -38
- data/app/pb_kits/playbook/pb_empty_state/docs/_empty_state_orientation.jsx +0 -19
- data/app/pb_kits/playbook/pb_empty_state/docs/_empty_state_size.jsx +0 -35
- data/app/pb_kits/playbook/pb_empty_state/docs/default_image/computer_fly_no_branding.svg +0 -21
- data/app/pb_kits/playbook/pb_empty_state/docs/default_image/utils.tsx +0 -122
- data/app/pb_kits/playbook/pb_empty_state/docs/example.yml +0 -7
- data/app/pb_kits/playbook/pb_empty_state/docs/index.js +0 -3
- data/app/pb_kits/playbook/pb_empty_state/empty_state.test.jsx +0 -17
- data/app/pb_kits/playbook/pb_multi_level_select/docs/_multi_level_select_react_hook.jsx +0 -91
- data/app/pb_kits/playbook/pb_multi_level_select/docs/_multi_level_select_react_hook.md +0 -1
- data/app/pb_kits/playbook/pb_phone_number_input/docs/_phone_number_input_hidden_inputs.html.erb +0 -5
- data/app/pb_kits/playbook/pb_phone_number_input/docs/_phone_number_input_hidden_inputs.md +0 -1
- data/dist/chunks/_typeahead-Z1NtlQ7Y.js +0 -36
- data/dist/chunks/_weekday_stacked-Bh2hQ0JB.js +0 -45
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 02e0b2959617acf35e73e785a01537eb8bb39c0b6b00aef5c6d013c9f48b6340
|
4
|
+
data.tar.gz: d6145400e8f289e968c68a521efd36598f09477db5ca012fe1404c72941bae1b
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 95b6226943493be0424146f6da2b39ee5d28695a222a31e9da129a3dabba898589df0721a133b849170908d9020e6e27154f0a46329e07ec992e10acbe99b5d0
|
7
|
+
data.tar.gz: 6f115c33f3cc07859f331497dc3f0dab1c53d6d59b2f0f08386a1025083c0b46da24099e5a9e5bfd13426677a7d1bf4ffa44be431577a6e602db49167dbd2a7c
|
@@ -1,5 +1,4 @@
|
|
1
1
|
|
2
|
-
|
3
2
|
@import 'pb_advanced_table/advanced_table';
|
4
3
|
@import 'pb_avatar/avatar';
|
5
4
|
@import 'pb_background/background';
|
@@ -15,8 +14,8 @@
|
|
15
14
|
@import 'pb_circle_chart/circle_chart';
|
16
15
|
@import 'pb_circle_icon_button/circle_icon_button';
|
17
16
|
@import 'pb_collapsible/collapsible';
|
18
|
-
@import 'pb_contact/contact';
|
19
17
|
@import 'pb_copy_button/copy_button';
|
18
|
+
@import 'pb_contact/contact';
|
20
19
|
@import 'pb_currency/currency';
|
21
20
|
@import 'pb_dashboard_value/dashboard_value';
|
22
21
|
@import 'pb_date/date';
|
@@ -46,7 +45,6 @@
|
|
46
45
|
@import 'pb_highlight/highlight';
|
47
46
|
@import 'pb_home_address_street/home_address_street';
|
48
47
|
@import 'pb_icon/icon';
|
49
|
-
@import 'pb_icon_button/icon_button';
|
50
48
|
@import 'pb_icon_circle/icon_circle';
|
51
49
|
@import 'pb_icon_stat_value/icon_stat_value';
|
52
50
|
@import 'pb_icon_value/icon_value';
|
@@ -111,7 +109,7 @@
|
|
111
109
|
@import 'pb_user_badge/user_badge';
|
112
110
|
@import 'pb_walkthrough/walkthrough';
|
113
111
|
@import 'pb_weekday_stacked/weekday_stacked';
|
114
|
-
@import '
|
112
|
+
@import 'pb_icon_button/icon_button';
|
115
113
|
@import 'utilities/mixins';
|
116
114
|
@import 'utilities/spacing';
|
117
115
|
@import 'utilities/cursor';
|
@@ -36,5 +36,4 @@ examples:
|
|
36
36
|
- advanced_table_selectable_rows: Selectable Rows
|
37
37
|
- advanced_table_selectable_rows_no_subrows: Selectable Rows (No Subrows)
|
38
38
|
- advanced_table_selectable_rows_actions: Selectable Rows (With Actions)
|
39
|
-
- advanced_table_selectable_rows_header: Selectable Rows (No Actions Bar)
|
40
|
-
- advanced_table_inline_editing: Inline Cell Editing
|
39
|
+
- advanced_table_selectable_rows_header: Selectable Rows (No Actions Bar)
|
@@ -20,5 +20,4 @@ export { default as AdvancedTableNoSubrows } from './_advanced_table_no_subrows.
|
|
20
20
|
export { default as AdvancedTableSelectableRowsHeader } from './_advanced_table_selectable_rows_header.jsx'
|
21
21
|
export { default as AdvancedTableSelectableRowsActions } from './_advanced_table_selectable_rows_actions.jsx'
|
22
22
|
export { default as AdvancedTableTablePropsStickyHeader } from './_advanced_table_table_props_sticky_header.jsx'
|
23
|
-
export { default as AdvancedTableColumnHeadersCustomCell } from './_advanced_table_column_headers_custom_cell.jsx'
|
24
|
-
export { default as AdvancedTableInlineEditing } from './_advanced_table_inline_editing.jsx'
|
23
|
+
export { default as AdvancedTableColumnHeadersCustomCell } from './_advanced_table_column_headers_custom_cell.jsx'
|
@@ -7,7 +7,7 @@ import Highcharts from "highcharts";
|
|
7
7
|
import { highchartsTheme } from "../pb_dashboard/pbChartsLightTheme";
|
8
8
|
import { highchartsDarkTheme } from "../pb_dashboard/pbChartsDarkTheme";
|
9
9
|
import mapColors from "../pb_dashboard/pbChartsColorsHelper";
|
10
|
-
import { merge } from '
|
10
|
+
import { merge } from '../utilities/object'
|
11
11
|
|
12
12
|
import classnames from "classnames";
|
13
13
|
|
@@ -10,7 +10,7 @@ import { highchartsDarkTheme } from "../pb_dashboard/pbChartsDarkTheme";
|
|
10
10
|
import mapColors from "../pb_dashboard/pbChartsColorsHelper";
|
11
11
|
import { globalProps } from "../utilities/globalProps";
|
12
12
|
import { buildAriaProps, buildDataProps, buildHtmlProps } from "../utilities/props";
|
13
|
-
import { merge } from '
|
13
|
+
import { merge } from '../utilities/object'
|
14
14
|
|
15
15
|
type CircleChartProps = {
|
16
16
|
align?: "left" | "right" | "center";
|
@@ -25,7 +25,7 @@
|
|
25
25
|
<%= pb_form_with(scope: :example, url: "", method: :get) do |form| %>
|
26
26
|
<%= form.typeahead :example_typeahead, props: { data: { typeahead_example1: true, user: {} }, label: true, placeholder: "Search for a user" } %>
|
27
27
|
<%= form.text_field :example_text_field, props: { label: true } %>
|
28
|
-
<%= form.phone_number_field :example_phone_number_field, props: { label: "Example phone field"
|
28
|
+
<%= form.phone_number_field :example_phone_number_field, props: { label: "Example phone field" } %>
|
29
29
|
<%= form.email_field :example_email_field, props: { label: true } %>
|
30
30
|
<%= form.number_field :example_number_field, props: { label: true } %>
|
31
31
|
<%= form.search_field :example_search_field, props: { label: true } %>
|
@@ -24,7 +24,7 @@
|
|
24
24
|
<%= pb_form_with(scope: :example, method: :get, url: "", validate: true) do |form| %>
|
25
25
|
<%= form.typeahead :example_typeahead_validation, props: { data: { typeahead_example2: true, user: {} }, label: true, placeholder: "Search for a user", required: true, validation: { message: "Please select a user." } } %>
|
26
26
|
<%= form.text_field :example_text_field_validation, props: { label: true, required: true } %>
|
27
|
-
<%= form.phone_number_field :example_phone_number_field_validation, props: { label: "Example phone field"
|
27
|
+
<%= form.phone_number_field :example_phone_number_field_validation, props: { label: "Example phone field" } %>
|
28
28
|
<%= form.email_field :example_email_field_validation, props: { label: true, required: true } %>
|
29
29
|
<%= form.number_field :example_number_field_validation, props: { label: true, required: true } %>
|
30
30
|
<%= 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)." } } %>
|
@@ -13,7 +13,7 @@ import typography from "../tokens/exports/_typography.module.scss";
|
|
13
13
|
import { buildAriaProps, buildCss, buildDataProps, buildHtmlProps } from "../utilities/props";
|
14
14
|
import { globalProps } from "../utilities/globalProps";
|
15
15
|
import { GenericObject } from "../types";
|
16
|
-
import { merge } from '
|
16
|
+
import { merge } from '../utilities/object'
|
17
17
|
|
18
18
|
type GaugeProps = {
|
19
19
|
aria: { [key: string]: string };
|
@@ -8,7 +8,7 @@ import Highcharts from "highcharts";
|
|
8
8
|
import { highchartsTheme } from "../pb_dashboard/pbChartsLightTheme";
|
9
9
|
import { highchartsDarkTheme } from "../pb_dashboard/pbChartsDarkTheme";
|
10
10
|
import mapColors from "../pb_dashboard/pbChartsColorsHelper";
|
11
|
-
import { merge } from '
|
11
|
+
import { merge } from '../utilities/object'
|
12
12
|
|
13
13
|
type LineGraphProps = {
|
14
14
|
align?: "left" | "right" | "center";
|
@@ -1,4 +1,4 @@
|
|
1
|
-
import React, { useState, useEffect, useRef
|
1
|
+
import React, { useState, useEffect, useRef } from "react";
|
2
2
|
import classnames from "classnames";
|
3
3
|
import { globalProps, GlobalProps } from "../utilities/globalProps";
|
4
4
|
import {
|
@@ -23,13 +23,6 @@ import {
|
|
23
23
|
getExpandedItems,
|
24
24
|
} from "./_helper_functions";
|
25
25
|
|
26
|
-
interface MultiLevelSelectComponent
|
27
|
-
extends React.ForwardRefExoticComponent<
|
28
|
-
MultiLevelSelectProps & React.RefAttributes<HTMLInputElement>
|
29
|
-
> {
|
30
|
-
Options: typeof MultiLevelSelectOptions;
|
31
|
-
}
|
32
|
-
|
33
26
|
type MultiLevelSelectProps = {
|
34
27
|
aria?: { [key: string]: string }
|
35
28
|
className?: string
|
@@ -42,7 +35,6 @@ type MultiLevelSelectProps = {
|
|
42
35
|
name?: string
|
43
36
|
returnAllSelected?: boolean
|
44
37
|
treeData?: { [key: string]: string; }[] | any
|
45
|
-
onChange?: (event: { target: { name?: string; value: any } }) => void
|
46
38
|
onSelect?: (prop: { [key: string]: any }) => void
|
47
39
|
selectedIds?: string[] | any
|
48
40
|
variant?: "multi" | "single"
|
@@ -50,7 +42,7 @@ type MultiLevelSelectProps = {
|
|
50
42
|
pillColor?: "primary" | "neutral" | "success" | "warning" | "error" | "info" | "data_1" | "data_2" | "data_3" | "data_4" | "data_5" | "data_6" | "data_7" | "data_8" | "windows" | "siding" | "roofing" | "doors" | "gutters" | "solar" | "insulation" | "accessories",
|
51
43
|
} & GlobalProps
|
52
44
|
|
53
|
-
const MultiLevelSelect =
|
45
|
+
const MultiLevelSelect = (props: MultiLevelSelectProps) => {
|
54
46
|
const {
|
55
47
|
aria = {},
|
56
48
|
className,
|
@@ -63,7 +55,6 @@ const MultiLevelSelect = forwardRef<HTMLInputElement, MultiLevelSelectProps>((pr
|
|
63
55
|
name,
|
64
56
|
returnAllSelected = false,
|
65
57
|
treeData,
|
66
|
-
onChange = () => null,
|
67
58
|
onSelect = () => null,
|
68
59
|
selectedIds,
|
69
60
|
variant = "multi",
|
@@ -296,10 +287,8 @@ const MultiLevelSelect = forwardRef<HTMLInputElement, MultiLevelSelectProps>((pr
|
|
296
287
|
// Logic for removing items from returnArray or defaultReturn when pills clicked
|
297
288
|
if (returnAllSelected) {
|
298
289
|
onSelect(getCheckedItems(updatedTree));
|
299
|
-
onChange({ target: { name, value: getCheckedItems(updatedTree) } });
|
300
290
|
} else {
|
301
291
|
onSelect(getDefaultCheckedItems(updatedTree));
|
302
|
-
onChange({ target: { name, value: getDefaultCheckedItems(updatedTree) } });
|
303
292
|
}
|
304
293
|
};
|
305
294
|
|
@@ -325,10 +314,8 @@ const MultiLevelSelect = forwardRef<HTMLInputElement, MultiLevelSelectProps>((pr
|
|
325
314
|
const updatedTree = changeItem(filtered[0], check);
|
326
315
|
if (returnAllSelected) {
|
327
316
|
onSelect(getCheckedItems(updatedTree));
|
328
|
-
onChange({ target: { name, value: getCheckedItems(updatedTree) } });
|
329
317
|
} else {
|
330
318
|
onSelect(getDefaultCheckedItems(updatedTree));
|
331
|
-
onChange({ target: { name, value: getDefaultCheckedItems(updatedTree) } });
|
332
319
|
}
|
333
320
|
};
|
334
321
|
|
@@ -361,7 +348,6 @@ const MultiLevelSelect = forwardRef<HTMLInputElement, MultiLevelSelectProps>((pr
|
|
361
348
|
setIsDropdownClosed(true);
|
362
349
|
|
363
350
|
onSelect(selectedItem);
|
364
|
-
onChange({ target: { name, value: selectedItem } });
|
365
351
|
};
|
366
352
|
|
367
353
|
// Single select: reset the tree state upon typing
|
@@ -403,12 +389,12 @@ const MultiLevelSelect = forwardRef<HTMLInputElement, MultiLevelSelectProps>((pr
|
|
403
389
|
// Rendering formattedData to UI based on typeahead
|
404
390
|
const renderNestedOptions = (items: { [key: string]: string; }[] | any ) => {
|
405
391
|
const hasOptionsChild = React.Children.toArray(props.children).some(
|
406
|
-
(child) =>
|
392
|
+
(child: any) => child.type === MultiLevelSelect.Options
|
407
393
|
);
|
408
394
|
|
409
395
|
if (hasOptionsChild) {
|
410
396
|
return React.Children.map(props.children, (child) => {
|
411
|
-
if (
|
397
|
+
if (child.type === MultiLevelSelect.Options) {
|
412
398
|
return React.cloneElement(child, { items });
|
413
399
|
}
|
414
400
|
return null;
|
@@ -473,18 +459,6 @@ const MultiLevelSelect = forwardRef<HTMLInputElement, MultiLevelSelectProps>((pr
|
|
473
459
|
))
|
474
460
|
: null}
|
475
461
|
|
476
|
-
{!returnAllSelected
|
477
|
-
? defaultReturn.map((item) => (
|
478
|
-
<input
|
479
|
-
disabled={disabled}
|
480
|
-
key={item.id}
|
481
|
-
name={`${name}[]`}
|
482
|
-
type="hidden"
|
483
|
-
value={item.id}
|
484
|
-
/>
|
485
|
-
))
|
486
|
-
: null}
|
487
|
-
|
488
462
|
{returnAllSelected &&
|
489
463
|
returnedArray.length !== 0 &&
|
490
464
|
inputDisplay === "pills"
|
@@ -573,9 +547,8 @@ const MultiLevelSelect = forwardRef<HTMLInputElement, MultiLevelSelectProps>((pr
|
|
573
547
|
</MultiLevelSelectContext.Provider>
|
574
548
|
</div>
|
575
549
|
);
|
576
|
-
}
|
550
|
+
};
|
577
551
|
|
578
|
-
MultiLevelSelect.displayName = "MultiLevelSelect";
|
579
552
|
MultiLevelSelect.Options = MultiLevelSelectOptions;
|
580
553
|
|
581
554
|
export default MultiLevelSelect;
|
@@ -12,7 +12,6 @@ examples:
|
|
12
12
|
|
13
13
|
react:
|
14
14
|
- multi_level_select_default: Default
|
15
|
-
- multi_level_select_react_hook: React Hook
|
16
15
|
- multi_level_select_single: Single Select
|
17
16
|
- multi_level_select_single_children_only: Single Select w/ Hidden Radios
|
18
17
|
- multi_level_select_return_all_selected: Return All Selected
|
@@ -7,4 +7,3 @@ export { default as MultiLevelSelectColor } from './_multi_level_select_color.js
|
|
7
7
|
export { default as MultiLevelSelectWithChildren } from './_multi_level_select_with_children.jsx'
|
8
8
|
export { default as MultiLevelSelectWithChildrenWithRadios } from './_multi_level_select_with_children_with_radios.jsx'
|
9
9
|
export { default as MultiLevelSelectDisabled } from './_multi_level_select_disabled.jsx'
|
10
|
-
export { default as MultiLevelSelectReactHook } from './_multi_level_select_react_hook.jsx'
|
@@ -23,7 +23,6 @@ type PhoneNumberInputProps = {
|
|
23
23
|
data?: { [key: string]: string },
|
24
24
|
disabled?: boolean,
|
25
25
|
error?: string,
|
26
|
-
hiddenInputs?: boolean,
|
27
26
|
htmlOptions?: {[key: string]: string | number | boolean | (() => void)},
|
28
27
|
id?: string,
|
29
28
|
initialCountry?: string,
|
@@ -73,7 +72,6 @@ const PhoneNumberInput = (props: PhoneNumberInputProps, ref?: React.MutableRefOb
|
|
73
72
|
dark = false,
|
74
73
|
data = {},
|
75
74
|
disabled = false,
|
76
|
-
hiddenInputs = false,
|
77
75
|
htmlOptions = {},
|
78
76
|
id = "",
|
79
77
|
initialCountry = "",
|
@@ -245,10 +243,6 @@ const PhoneNumberInput = (props: PhoneNumberInputProps, ref?: React.MutableRefOb
|
|
245
243
|
countrySearch: false,
|
246
244
|
fixDropdownWidth: false,
|
247
245
|
formatAsYouType: formatAsYouType,
|
248
|
-
hiddenInput: hiddenInputs ? () => ({
|
249
|
-
phone: `${name}_full`,
|
250
|
-
country: `${name}_country_code`,
|
251
|
-
}) : null,
|
252
246
|
})
|
253
247
|
|
254
248
|
itiRef.current = telInputInit;
|
@@ -16,6 +16,4 @@ examples:
|
|
16
16
|
- phone_number_input_initial_country: Initial Country
|
17
17
|
- phone_number_input_only_countries: Limited Countries
|
18
18
|
- phone_number_input_validation: Form Validation
|
19
|
-
- phone_number_input_format: Format as You Type
|
20
|
-
- phone_number_input_hidden_inputs: Hidden Inputs
|
21
|
-
|
19
|
+
- phone_number_input_format: Format as You Type
|
@@ -23,8 +23,6 @@ module Playbook
|
|
23
23
|
default: ""
|
24
24
|
prop :format_as_you_type, type: Playbook::Props::Boolean,
|
25
25
|
default: false
|
26
|
-
prop :hidden_inputs, type: Playbook::Props::Boolean,
|
27
|
-
default: false
|
28
26
|
|
29
27
|
def classname
|
30
28
|
generate_classname("pb_phone_number_input")
|
@@ -37,7 +35,6 @@ module Playbook
|
|
37
35
|
disabled: disabled,
|
38
36
|
error: error,
|
39
37
|
formatAsYouType: format_as_you_type,
|
40
|
-
hiddenInputs: hidden_inputs,
|
41
38
|
initialCountry: initial_country,
|
42
39
|
label: label,
|
43
40
|
name: name,
|
@@ -10,7 +10,7 @@ import { highchartsTheme } from "../pb_dashboard/pbChartsLightTheme";
|
|
10
10
|
import { highchartsDarkTheme } from "../pb_dashboard/pbChartsDarkTheme";
|
11
11
|
import mapColors from "../pb_dashboard/pbChartsColorsHelper";
|
12
12
|
import treemap from 'highcharts/modules/treemap'
|
13
|
-
import { merge } from '
|
13
|
+
import { merge } from '../utilities/object'
|
14
14
|
|
15
15
|
type TreemapChartProps = {
|
16
16
|
chartData: {
|
@@ -29,3 +29,77 @@ export const omitBy = (obj: Record<string, any>, predicate: (value: any, key: st
|
|
29
29
|
return result;
|
30
30
|
}, {})
|
31
31
|
}
|
32
|
+
|
33
|
+
export const noop = (): void => {
|
34
|
+
// empty
|
35
|
+
};
|
36
|
+
|
37
|
+
export const merge = (...objects: any[]): any => {
|
38
|
+
const isObject = (obj: any): boolean => obj && typeof obj === 'object';
|
39
|
+
const result = {} as any;
|
40
|
+
objects.forEach(obj => {
|
41
|
+
if (isObject(obj)) {
|
42
|
+
Object.keys(obj).forEach(key => {
|
43
|
+
const existingVal = result[key];
|
44
|
+
const newVal = obj[key];
|
45
|
+
if (isObject(existingVal) && isObject(newVal)) {
|
46
|
+
result[key] = merge(existingVal, newVal);
|
47
|
+
} else {
|
48
|
+
result[key] = newVal;
|
49
|
+
}
|
50
|
+
});
|
51
|
+
}
|
52
|
+
});
|
53
|
+
return result;
|
54
|
+
};
|
55
|
+
|
56
|
+
const createIteratee = (predicate: any) => {
|
57
|
+
if (typeof predicate === 'function') {
|
58
|
+
return predicate;
|
59
|
+
}
|
60
|
+
if (typeof predicate === 'string') {
|
61
|
+
return (obj: any) => obj[predicate];
|
62
|
+
}
|
63
|
+
if (Array.isArray(predicate)) {
|
64
|
+
const [key, value] = predicate;
|
65
|
+
return (obj: any) => obj[key] === value;
|
66
|
+
}
|
67
|
+
if (typeof predicate === 'object' && predicate !== null) {
|
68
|
+
return (obj: any) => {
|
69
|
+
for (const key in predicate) {
|
70
|
+
if (Object.prototype.hasOwnProperty.call(predicate, key)) {
|
71
|
+
if (obj[key] !== predicate[key]) return false;
|
72
|
+
}
|
73
|
+
}
|
74
|
+
return true;
|
75
|
+
};
|
76
|
+
}
|
77
|
+
return () => false;
|
78
|
+
};
|
79
|
+
|
80
|
+
export const filter = <T>(array: T[], predicate: any): T[] => {
|
81
|
+
const iteratee = createIteratee(predicate);
|
82
|
+
return array.filter(iteratee);
|
83
|
+
};
|
84
|
+
|
85
|
+
export const find = <T>(array: T[], predicate: any): T | undefined => {
|
86
|
+
const iteratee = createIteratee(predicate);
|
87
|
+
return array.find(iteratee);
|
88
|
+
};
|
89
|
+
|
90
|
+
export const partial = <F extends (...args: unknown[]) => unknown>(
|
91
|
+
fn: F,
|
92
|
+
...partials: unknown[]
|
93
|
+
): ((...args: unknown[]) => ReturnType<F>) => {
|
94
|
+
const placeholder = partial.placeholder;
|
95
|
+
return (...args: unknown[]): ReturnType<F> => {
|
96
|
+
let argIndex = 0;
|
97
|
+
const finalArgs = partials.map(arg =>
|
98
|
+
arg === placeholder ? args[argIndex++] : arg
|
99
|
+
);
|
100
|
+
return fn(...(finalArgs.concat(args.slice(argIndex)) as Parameters<F>));
|
101
|
+
};
|
102
|
+
};
|
103
|
+
|
104
|
+
partial.placeholder = Symbol();
|
105
|
+
export const _ = partial.placeholder;
|