playbook_ui 14.15.0.pre.rc.4 → 14.15.0
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_advanced_table/Components/RegularTableView.tsx +127 -0
- data/app/pb_kits/playbook/pb_advanced_table/Components/TableActionBar.tsx +55 -0
- data/app/pb_kits/playbook/pb_advanced_table/Components/TablePagination.tsx +33 -0
- data/app/pb_kits/playbook/pb_advanced_table/Components/VirtualizedTableView.tsx +275 -0
- data/app/pb_kits/playbook/pb_advanced_table/Context/AdvancedTableContext.tsx +143 -3
- data/app/pb_kits/playbook/pb_advanced_table/Hooks/useTableActions.ts +66 -0
- data/app/pb_kits/playbook/pb_advanced_table/Hooks/useTableState.ts +195 -0
- data/app/pb_kits/playbook/pb_advanced_table/SubKits/TableBody.tsx +45 -99
- data/app/pb_kits/playbook/pb_advanced_table/Utilities/CellRendererUtils.tsx +73 -0
- data/app/pb_kits/playbook/pb_advanced_table/Utilities/RowUtils.ts +52 -0
- data/app/pb_kits/playbook/pb_advanced_table/Utilities/TableContainerStyles.ts +80 -0
- data/app/pb_kits/playbook/pb_advanced_table/_advanced_table.scss +123 -7
- data/app/pb_kits/playbook/pb_advanced_table/_advanced_table.tsx +153 -299
- data/app/pb_kits/playbook/pb_advanced_table/docs/_advanced_table_infinite_scroll.jsx +50 -0
- data/app/pb_kits/playbook/pb_advanced_table/docs/advanced_table_mock_data_infinite_scroll.json +152002 -0
- data/app/pb_kits/playbook/pb_card/_card.tsx +2 -1
- data/app/pb_kits/playbook/pb_date_picker/date_picker.html.erb +4 -1
- data/app/pb_kits/playbook/pb_date_picker/date_picker.rb +2 -0
- data/app/pb_kits/playbook/pb_date_picker/index.ts +38 -0
- data/app/pb_kits/playbook/pb_drawer/_drawer.scss +19 -3
- data/app/pb_kits/playbook/pb_drawer/docs/_drawer_borders.jsx +3 -3
- data/app/pb_kits/playbook/pb_drawer/docs/_drawer_breakpoints.jsx +20 -37
- data/app/pb_kits/playbook/pb_drawer/docs/_drawer_menu.jsx +6 -6
- data/app/pb_kits/playbook/pb_drawer/docs/_drawer_overlay.jsx +1 -0
- data/app/pb_kits/playbook/pb_drawer/docs/example.yml +1 -0
- data/app/pb_kits/playbook/pb_filter/Filter/CurrentFilters.tsx +5 -4
- data/app/pb_kits/playbook/pb_filter/Filter/FilterSingle.tsx +2 -2
- data/app/pb_kits/playbook/pb_form/docs/_form_form_with_validate.html.erb +1 -1
- data/app/pb_kits/playbook/pb_form_pill/_form_pill.scss +9 -2
- data/app/pb_kits/playbook/pb_form_pill/_form_pill.tsx +4 -0
- data/app/pb_kits/playbook/pb_form_pill/docs/_form_pill_wrapped.html.erb +40 -0
- data/app/pb_kits/playbook/pb_form_pill/docs/_form_pill_wrapped.jsx +50 -0
- data/app/pb_kits/playbook/pb_form_pill/docs/_form_pill_wrapped.md +3 -0
- data/app/pb_kits/playbook/pb_form_pill/docs/example.yml +2 -0
- data/app/pb_kits/playbook/pb_form_pill/docs/index.js +1 -0
- data/app/pb_kits/playbook/pb_form_pill/form_pill.rb +7 -1
- data/app/pb_kits/playbook/pb_multi_level_select/_multi_level_select.scss +7 -0
- data/app/pb_kits/playbook/pb_multi_level_select/_multi_level_select.tsx +13 -3
- data/app/pb_kits/playbook/pb_multi_level_select/docs/_multi_level_select_disabled.html.erb +72 -0
- data/app/pb_kits/playbook/pb_multi_level_select/docs/_multi_level_select_disabled.jsx +91 -0
- data/app/pb_kits/playbook/pb_multi_level_select/docs/example.yml +2 -1
- data/app/pb_kits/playbook/pb_multi_level_select/docs/index.js +1 -0
- data/app/pb_kits/playbook/pb_multi_level_select/multi_level_select.rb +6 -0
- data/app/pb_kits/playbook/pb_popover/_popover.tsx +1 -1
- data/app/pb_kits/playbook/pb_radio/_radio.tsx +85 -74
- data/app/pb_kits/playbook/pb_radio/docs/_radio_react_hook.jsx +60 -0
- data/app/pb_kits/playbook/pb_radio/docs/_radio_react_hook.md +1 -0
- data/app/pb_kits/playbook/pb_radio/docs/example.yml +2 -1
- data/app/pb_kits/playbook/pb_radio/docs/index.js +1 -0
- data/app/pb_kits/playbook/pb_radio/radio.test.js +16 -0
- data/app/pb_kits/playbook/pb_select/docs/_select_react_hook.jsx +58 -0
- data/app/pb_kits/playbook/pb_select/docs/_select_react_hook.md +1 -0
- data/app/pb_kits/playbook/pb_select/docs/example.yml +1 -0
- data/app/pb_kits/playbook/pb_select/docs/index.js +1 -0
- data/app/pb_kits/playbook/pb_select/select.html.erb +3 -5
- data/app/pb_kits/playbook/pb_selectable_card/selectable_card.html.erb +1 -5
- data/app/pb_kits/playbook/pb_selectable_card_icon/selectable_card_icon.html.erb +1 -4
- data/app/pb_kits/playbook/pb_selectable_icon/selectable_icon.html.erb +1 -5
- data/app/pb_kits/playbook/pb_timeline/_timeline.scss +2 -2
- data/app/pb_kits/playbook/pb_title/_title.scss +32 -0
- data/app/pb_kits/playbook/pb_title/_title.tsx +10 -1
- data/app/pb_kits/playbook/pb_title/docs/_title_default.html.erb +1 -2
- data/app/pb_kits/playbook/pb_title/docs/_title_default.jsx +1 -1
- data/app/pb_kits/playbook/pb_title/docs/_title_display_size.html.erb +7 -0
- data/app/pb_kits/playbook/pb_title/docs/_title_display_size.jsx +54 -0
- data/app/pb_kits/playbook/pb_title/docs/_title_display_size.md +1 -0
- data/app/pb_kits/playbook/pb_title/docs/example.yml +2 -0
- data/app/pb_kits/playbook/pb_title/docs/index.js +1 -0
- data/app/pb_kits/playbook/pb_title/title.rb +10 -1
- data/app/pb_kits/playbook/pb_tooltip/_tooltip.tsx +25 -0
- data/app/pb_kits/playbook/pb_tooltip/docs/_tooltip_sizing.jsx +69 -0
- data/app/pb_kits/playbook/pb_tooltip/docs/_tooltip_sizing.md +3 -0
- data/app/pb_kits/playbook/pb_tooltip/docs/example.yml +1 -1
- data/app/pb_kits/playbook/pb_tooltip/docs/index.js +1 -0
- data/app/pb_kits/playbook/pb_typeahead/_typeahead.tsx +2 -1
- data/app/pb_kits/playbook/pb_typeahead/components/MultiValue.tsx +5 -1
- data/app/pb_kits/playbook/pb_typeahead/typeahead.rb +4 -1
- data/app/pb_kits/playbook/utilities/object.test.js +99 -0
- data/app/pb_kits/playbook/utilities/object.ts +29 -1
- data/dist/chunks/_typeahead-BhfaW1J9.js +36 -0
- data/dist/chunks/_weekday_stacked-CKRIELiF.js +45 -0
- data/dist/chunks/lazysizes-DHz07jlL.js +1 -0
- data/dist/chunks/{lib-Dmay5Z6U.js → lib-5OzNgeeu.js} +2 -2
- data/dist/chunks/{pb_form_validation-DdP7BnVX.js → pb_form_validation-DGhKbZtO.js} +1 -1
- data/dist/chunks/vendor.js +1 -1
- 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 +34 -7
- data/dist/chunks/_typeahead-NXKDTf__.js +0 -36
- data/dist/chunks/_weekday_stacked-DtCYkCXM.js +0 -45
- data/dist/chunks/lazysizes-B7xYodB-.js +0 -1
@@ -0,0 +1,72 @@
|
|
1
|
+
<% treeData = [{
|
2
|
+
label: "Power Home Remodeling",
|
3
|
+
value: "Power Home Remodeling",
|
4
|
+
id: "100",
|
5
|
+
expanded: true,
|
6
|
+
children: [
|
7
|
+
{
|
8
|
+
label: "People",
|
9
|
+
value: "People",
|
10
|
+
id: "101",
|
11
|
+
expanded: true,
|
12
|
+
children: [
|
13
|
+
{
|
14
|
+
label: "Talent Acquisition",
|
15
|
+
value: "Talent Acquisition",
|
16
|
+
id: "102",
|
17
|
+
},
|
18
|
+
{
|
19
|
+
label: "Business Affairs",
|
20
|
+
value: "Business Affairs",
|
21
|
+
id: "103",
|
22
|
+
children: [
|
23
|
+
{
|
24
|
+
label: "Initiatives",
|
25
|
+
value: "Initiatives",
|
26
|
+
id: "104",
|
27
|
+
},
|
28
|
+
{
|
29
|
+
label: "Learning & Development",
|
30
|
+
value: "Learning & Development",
|
31
|
+
id: "105",
|
32
|
+
},
|
33
|
+
],
|
34
|
+
},
|
35
|
+
{
|
36
|
+
label: "People Experience",
|
37
|
+
value: "People Experience",
|
38
|
+
id: "106",
|
39
|
+
},
|
40
|
+
],
|
41
|
+
},
|
42
|
+
{
|
43
|
+
label: "Contact Center",
|
44
|
+
value: "Contact Center",
|
45
|
+
id: "107",
|
46
|
+
children: [
|
47
|
+
{
|
48
|
+
label: "Appointment Management",
|
49
|
+
value: "Appointment Management",
|
50
|
+
id: "108",
|
51
|
+
},
|
52
|
+
{
|
53
|
+
label: "Customer Service",
|
54
|
+
value: "Customer Service",
|
55
|
+
id: "109",
|
56
|
+
},
|
57
|
+
{
|
58
|
+
label: "Energy",
|
59
|
+
value: "Energy",
|
60
|
+
id: "110",
|
61
|
+
},
|
62
|
+
],
|
63
|
+
},
|
64
|
+
],
|
65
|
+
}] %>
|
66
|
+
|
67
|
+
<%= pb_rails("multi_level_select", props: {
|
68
|
+
disabled: true,
|
69
|
+
id: "multi-level-select-default-rails",
|
70
|
+
name: "my_array",
|
71
|
+
tree_data: treeData
|
72
|
+
}) %>
|
@@ -0,0 +1,91 @@
|
|
1
|
+
import React from "react";
|
2
|
+
import MultiLevelSelect from "../_multi_level_select";
|
3
|
+
|
4
|
+
const treeData = [
|
5
|
+
{
|
6
|
+
label: "Power Home Remodeling",
|
7
|
+
value: "Power Home Remodeling",
|
8
|
+
id: "powerhome1",
|
9
|
+
expanded: true,
|
10
|
+
children: [
|
11
|
+
{
|
12
|
+
label: "People",
|
13
|
+
value: "People",
|
14
|
+
id: "people1",
|
15
|
+
expanded: true,
|
16
|
+
children: [
|
17
|
+
{
|
18
|
+
label: "Talent Acquisition",
|
19
|
+
value: "Talent Acquisition",
|
20
|
+
id: "talent1",
|
21
|
+
},
|
22
|
+
{
|
23
|
+
label: "Business Affairs",
|
24
|
+
value: "Business Affairs",
|
25
|
+
id: "business1",
|
26
|
+
children: [
|
27
|
+
{
|
28
|
+
label: "Initiatives",
|
29
|
+
value: "Initiatives",
|
30
|
+
id: "initiative1",
|
31
|
+
},
|
32
|
+
{
|
33
|
+
label: "Learning & Development",
|
34
|
+
value: "Learning & Development",
|
35
|
+
id: "development1",
|
36
|
+
},
|
37
|
+
],
|
38
|
+
},
|
39
|
+
{
|
40
|
+
label: "People Experience",
|
41
|
+
value: "People Experience",
|
42
|
+
id: "experience1",
|
43
|
+
},
|
44
|
+
],
|
45
|
+
},
|
46
|
+
{
|
47
|
+
label: "Contact Center",
|
48
|
+
value: "Contact Center",
|
49
|
+
id: "contact1",
|
50
|
+
children: [
|
51
|
+
{
|
52
|
+
label: "Appointment Management",
|
53
|
+
value: "Appointment Management",
|
54
|
+
id: "appointment1",
|
55
|
+
},
|
56
|
+
{
|
57
|
+
label: "Customer Service",
|
58
|
+
value: "Customer Service",
|
59
|
+
id: "customer1",
|
60
|
+
},
|
61
|
+
{
|
62
|
+
label: "Energy",
|
63
|
+
value: "Energy",
|
64
|
+
id: "energy1",
|
65
|
+
},
|
66
|
+
],
|
67
|
+
},
|
68
|
+
],
|
69
|
+
},
|
70
|
+
];
|
71
|
+
|
72
|
+
const MultiLevelSelectDisabled = (props) => {
|
73
|
+
return (
|
74
|
+
<>
|
75
|
+
<MultiLevelSelect
|
76
|
+
disabled
|
77
|
+
id='multiselect-default'
|
78
|
+
onSelect={(selectedNodes) =>
|
79
|
+
console.log(
|
80
|
+
"Selected Items",
|
81
|
+
selectedNodes
|
82
|
+
)
|
83
|
+
}
|
84
|
+
treeData={treeData}
|
85
|
+
{...props}
|
86
|
+
/>
|
87
|
+
</>
|
88
|
+
)
|
89
|
+
};
|
90
|
+
|
91
|
+
export default MultiLevelSelectDisabled
|
@@ -8,6 +8,7 @@ examples:
|
|
8
8
|
- multi_level_select_with_form: With Form
|
9
9
|
- multi_level_select_color: With Pills (Custom Color)
|
10
10
|
- multi_level_select_reset: Reset Selection
|
11
|
+
- multi_level_select_disabled: Disabled
|
11
12
|
|
12
13
|
react:
|
13
14
|
- multi_level_select_default: Default
|
@@ -18,4 +19,4 @@ examples:
|
|
18
19
|
- multi_level_select_color: With Pills (Custom Color)
|
19
20
|
- multi_level_select_with_children: Checkboxes With Children
|
20
21
|
- multi_level_select_with_children_with_radios: Single Select With Children
|
21
|
-
|
22
|
+
- multi_level_select_disabled: Disabled
|
@@ -6,3 +6,4 @@ export { default as MultiLevelSelectSelectedIdsReact } from "./_multi_level_sele
|
|
6
6
|
export { default as MultiLevelSelectColor } from './_multi_level_select_color.jsx'
|
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
|
+
export { default as MultiLevelSelectDisabled } from './_multi_level_select_disabled.jsx'
|
@@ -22,6 +22,10 @@ module Playbook
|
|
22
22
|
prop :pill_color, type: Playbook::Props::Enum,
|
23
23
|
values: %w[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],
|
24
24
|
default: "primary"
|
25
|
+
prop :wrapped, type: Playbook::Props::Boolean,
|
26
|
+
default: false
|
27
|
+
prop :disabled, type: Playbook::Props::Boolean,
|
28
|
+
default: false
|
25
29
|
|
26
30
|
def classname
|
27
31
|
generate_classname("pb_multi_level_select")
|
@@ -29,6 +33,7 @@ module Playbook
|
|
29
33
|
|
30
34
|
def multi_level_select_options
|
31
35
|
{
|
36
|
+
disabled: disabled,
|
32
37
|
id: id,
|
33
38
|
inputDisplay: input_display,
|
34
39
|
name: name,
|
@@ -38,6 +43,7 @@ module Playbook
|
|
38
43
|
input_name: input_name,
|
39
44
|
variant: variant,
|
40
45
|
pillColor: pill_color,
|
46
|
+
wrapped: wrapped,
|
41
47
|
}
|
42
48
|
end
|
43
49
|
end
|
@@ -19,7 +19,7 @@ import {
|
|
19
19
|
|
20
20
|
import classnames from "classnames";
|
21
21
|
import { globalProps, GlobalProps } from "../utilities/globalProps";
|
22
|
-
import { uniqueId } from '
|
22
|
+
import { uniqueId } from '../utilities/object';
|
23
23
|
|
24
24
|
type ModifiedGlobalProps = Omit<GlobalProps, 'minWidth' | 'maxHeight' | 'minHeight'>
|
25
25
|
|
@@ -1,6 +1,4 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
import React, { forwardRef, useRef } from 'react'
|
1
|
+
import React, { useRef, forwardRef } from 'react'
|
4
2
|
import Body from '../pb_body/_body'
|
5
3
|
import Flex from '../pb_flex/_flex'
|
6
4
|
import classnames from 'classnames'
|
@@ -10,7 +8,7 @@ import { globalProps, GlobalProps } from '../utilities/globalProps'
|
|
10
8
|
type RadioProps = {
|
11
9
|
aria?: { [key: string]: string },
|
12
10
|
alignment?: string,
|
13
|
-
checked?: boolean,
|
11
|
+
checked?: boolean, // removed default assignment here
|
14
12
|
children?: React.ReactChild[] | React.ReactChild,
|
15
13
|
customChildren?: boolean,
|
16
14
|
className?: string,
|
@@ -24,10 +22,10 @@ type RadioProps = {
|
|
24
22
|
name?: string,
|
25
23
|
value?: string,
|
26
24
|
text?: string,
|
27
|
-
onChange
|
25
|
+
onChange?: (event: React.FormEvent<HTMLInputElement> | null) => void,
|
28
26
|
} & GlobalProps
|
29
27
|
|
30
|
-
const Radio = ({
|
28
|
+
const Radio = forwardRef<HTMLInputElement, RadioProps>(({
|
31
29
|
aria = {},
|
32
30
|
alignment,
|
33
31
|
children,
|
@@ -43,110 +41,123 @@ const Radio = ({
|
|
43
41
|
name = 'radio_name',
|
44
42
|
text = 'Radio Text',
|
45
43
|
value = 'radio_text',
|
44
|
+
checked,
|
46
45
|
onChange = () => { void 0 },
|
47
46
|
...props
|
48
|
-
}
|
49
|
-
const
|
47
|
+
}, ref) => {
|
48
|
+
const internalRef = useRef<HTMLInputElement>(null)
|
49
|
+
const setRefs = (el: HTMLInputElement) => {
|
50
|
+
internalRef.current = el
|
51
|
+
if (typeof ref === 'function') {
|
52
|
+
ref(el)
|
53
|
+
} else if (ref) {
|
54
|
+
(ref as React.MutableRefObject<HTMLInputElement | null>).current = el
|
55
|
+
}
|
56
|
+
}
|
57
|
+
|
58
|
+
const ariaProps = buildAriaProps(aria)
|
59
|
+
const dataProps = buildDataProps(data)
|
60
|
+
const htmlProps = buildHtmlProps(htmlOptions)
|
50
61
|
|
51
|
-
const ariaProps = buildAriaProps(aria);
|
52
|
-
const dataProps = buildDataProps(data);
|
53
|
-
const htmlProps = buildHtmlProps(htmlOptions);
|
54
62
|
const classes = classnames(
|
55
63
|
buildCss('pb_radio_kit', alignment),
|
56
64
|
dark ? 'dark' : null,
|
57
65
|
error ? 'error' : null,
|
58
66
|
globalProps(props),
|
59
67
|
className
|
60
|
-
)
|
68
|
+
)
|
61
69
|
|
62
70
|
const classesCustom = classnames(
|
63
71
|
dark ? 'dark' : null,
|
64
72
|
error ? 'error' : null,
|
65
73
|
globalProps(props),
|
66
74
|
className
|
67
|
-
)
|
75
|
+
)
|
76
|
+
|
77
|
+
const checkedProps = checked !== undefined ? { checked } : {}
|
68
78
|
|
69
|
-
const displayRadio = (
|
70
|
-
if (children && customChildren
|
71
|
-
return
|
79
|
+
const displayRadio = (inputProps: any) => {
|
80
|
+
if (children && customChildren === false)
|
81
|
+
return children
|
72
82
|
else
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
|
83
|
+
return (
|
84
|
+
<input
|
85
|
+
{...checkedProps}
|
86
|
+
disabled={disabled}
|
87
|
+
id={id}
|
88
|
+
name={name}
|
89
|
+
onChange={onChange}
|
90
|
+
ref={setRefs}
|
91
|
+
type="radio"
|
92
|
+
value={value}
|
93
|
+
{...inputProps}
|
94
|
+
/>
|
95
|
+
)
|
96
|
+
}
|
86
97
|
|
87
98
|
const handleContainerClick = (event: React.MouseEvent<HTMLDivElement, MouseEvent> | undefined) => {
|
88
99
|
if (event) {
|
89
|
-
const target = event.target as HTMLElement
|
100
|
+
const target = event.target as HTMLElement
|
90
101
|
if (
|
91
102
|
target.id === 'pb-radio-children-wrapper' ||
|
92
103
|
target.closest('#pb-radio-children-wrapper')
|
93
104
|
) {
|
94
|
-
|
105
|
+
internalRef.current?.click()
|
95
106
|
}
|
96
107
|
}
|
97
|
-
}
|
108
|
+
}
|
98
109
|
|
99
|
-
return (
|
100
|
-
|
101
|
-
|
102
|
-
|
103
|
-
|
104
|
-
|
105
|
-
|
106
|
-
|
107
|
-
|
108
|
-
|
109
|
-
|
110
|
-
|
111
|
-
|
112
|
-
|
113
|
-
|
114
|
-
|
115
|
-
>
|
116
|
-
<label className={buildCss('pb_radio_kit', alignment)}>
|
110
|
+
return customChildren ? (
|
111
|
+
<Flex
|
112
|
+
{...ariaProps}
|
113
|
+
{...dataProps}
|
114
|
+
{...htmlProps}
|
115
|
+
align="center"
|
116
|
+
className={classesCustom}
|
117
|
+
cursor="pointer"
|
118
|
+
htmlFor={id}
|
119
|
+
htmlOptions={{
|
120
|
+
onClick: ((event: React.MouseEvent<HTMLDivElement, MouseEvent>) => {
|
121
|
+
handleContainerClick(event)
|
122
|
+
}) as unknown as () => void
|
123
|
+
}}
|
124
|
+
id="radio-container"
|
125
|
+
>
|
126
|
+
<label className={buildCss('pb_radio_kit', alignment)}>
|
117
127
|
<input
|
128
|
+
{...checkedProps}
|
118
129
|
disabled={disabled}
|
119
130
|
id={id}
|
120
131
|
name={name}
|
121
132
|
onChange={onChange}
|
122
|
-
ref={
|
133
|
+
ref={setRefs}
|
123
134
|
type="radio"
|
124
135
|
value={value}
|
125
136
|
{...props}
|
126
137
|
/>
|
127
|
-
<span className="pb_radio_button" />
|
128
|
-
</label>
|
129
|
-
<div id="pb-radio-children-wrapper"> {children} </div>
|
130
|
-
</Flex>
|
131
|
-
) : (
|
132
|
-
<label
|
133
|
-
{...ariaProps}
|
134
|
-
{...dataProps}
|
135
|
-
{...htmlProps}
|
136
|
-
className={classes}
|
137
|
-
htmlFor={id}
|
138
|
-
>
|
139
|
-
<>{displayRadio(props)}</>
|
140
138
|
<span className="pb_radio_button" />
|
141
|
-
<Body
|
142
|
-
dark={dark}
|
143
|
-
status={error ? 'negative' : null}
|
144
|
-
text={label}
|
145
|
-
variant={null}
|
146
|
-
/>
|
147
139
|
</label>
|
148
|
-
|
149
|
-
|
150
|
-
|
140
|
+
<div id="pb-radio-children-wrapper"> {children} </div>
|
141
|
+
</Flex>
|
142
|
+
) : (
|
143
|
+
<label
|
144
|
+
{...ariaProps}
|
145
|
+
{...dataProps}
|
146
|
+
{...htmlProps}
|
147
|
+
className={classes}
|
148
|
+
htmlFor={id}
|
149
|
+
>
|
150
|
+
{displayRadio(props)}
|
151
|
+
<span className="pb_radio_button" />
|
152
|
+
<Body
|
153
|
+
dark={dark}
|
154
|
+
status={error ? 'negative' : null}
|
155
|
+
text={label}
|
156
|
+
variant={null}
|
157
|
+
/>
|
158
|
+
</label>
|
159
|
+
)
|
160
|
+
})
|
151
161
|
|
152
|
-
|
162
|
+
Radio.displayName = "Radio"
|
163
|
+
export default Radio
|
@@ -0,0 +1,60 @@
|
|
1
|
+
import React from "react"
|
2
|
+
import { useForm } from "react-hook-form"
|
3
|
+
import { Radio, Flex, Body } from "playbook-ui"
|
4
|
+
|
5
|
+
const RadioReactHook = () => {
|
6
|
+
const { register, watch } = useForm({
|
7
|
+
defaultValues: {
|
8
|
+
size: "Small",
|
9
|
+
},
|
10
|
+
})
|
11
|
+
|
12
|
+
const selectedSize = watch("size", "Small")
|
13
|
+
|
14
|
+
return (
|
15
|
+
<Flex orientation="row">
|
16
|
+
<Flex
|
17
|
+
align="start"
|
18
|
+
orientation="column"
|
19
|
+
paddingRight="lg"
|
20
|
+
>
|
21
|
+
<Radio
|
22
|
+
alignment="left"
|
23
|
+
label="Small"
|
24
|
+
marginBottom='sm'
|
25
|
+
name="size"
|
26
|
+
value="Small"
|
27
|
+
{...register("size")}
|
28
|
+
/>
|
29
|
+
<br />
|
30
|
+
<Radio
|
31
|
+
alignment="left"
|
32
|
+
label="Medium"
|
33
|
+
marginBottom='sm'
|
34
|
+
name="size"
|
35
|
+
value="Medium"
|
36
|
+
{...register("size")}
|
37
|
+
/>
|
38
|
+
<br />
|
39
|
+
<Radio
|
40
|
+
alignment="left"
|
41
|
+
label="Large"
|
42
|
+
marginBottom='sm'
|
43
|
+
name="size"
|
44
|
+
value="Large"
|
45
|
+
{...register("size")}
|
46
|
+
/>
|
47
|
+
</Flex>
|
48
|
+
<Flex
|
49
|
+
align="start"
|
50
|
+
orientation="column"
|
51
|
+
>
|
52
|
+
<Body
|
53
|
+
text={`Selected Size: ${selectedSize}`}
|
54
|
+
/>
|
55
|
+
</Flex>
|
56
|
+
</Flex>
|
57
|
+
)
|
58
|
+
}
|
59
|
+
|
60
|
+
export default RadioReactHook
|
@@ -0,0 +1 @@
|
|
1
|
+
You can pass react hook props to the radio kit.
|
@@ -16,6 +16,7 @@ examples:
|
|
16
16
|
- radio_alignment: Alignment
|
17
17
|
- radio_disabled: Disabled
|
18
18
|
- radio_custom_children: Custom Children
|
19
|
+
- radio_react_hook: React Hook Form
|
19
20
|
|
20
21
|
swift:
|
21
22
|
- radio_default_swift: Default
|
@@ -26,4 +27,4 @@ examples:
|
|
26
27
|
- radio_spacing_swift: Spacing
|
27
28
|
- radio_padding_swift: Padding
|
28
29
|
- radio_subtitle_swift: Subtitle
|
29
|
-
- radio_props_swift: ""
|
30
|
+
- radio_props_swift: ""
|
@@ -4,3 +4,4 @@ export { default as RadioError } from './_radio_error.jsx'
|
|
4
4
|
export { default as RadioAlignment } from './_radio_alignment.jsx'
|
5
5
|
export { default as RadioDisabled } from './_radio_disabled.jsx'
|
6
6
|
export { default as RadioCustomChildren } from './_radio_custom_children.jsx'
|
7
|
+
export { default as RadioReactHook } from './_radio_react_hook.jsx'
|
@@ -86,3 +86,19 @@ test('has disabled attribute', () => {
|
|
86
86
|
expect(input).toHaveAttribute('disabled')
|
87
87
|
})
|
88
88
|
|
89
|
+
|
90
|
+
test('has ref in the input element', () => {
|
91
|
+
const ref = React.createRef()
|
92
|
+
render(
|
93
|
+
<Radio
|
94
|
+
data={{ testid: testId }}
|
95
|
+
name="Radio-name"
|
96
|
+
ref={ref}
|
97
|
+
text="Radio"
|
98
|
+
value="radio value"
|
99
|
+
/>
|
100
|
+
)
|
101
|
+
|
102
|
+
expect(ref.current).not.toBeNull()
|
103
|
+
expect(ref.current?.tagName).toBe('INPUT')
|
104
|
+
})
|
@@ -0,0 +1,58 @@
|
|
1
|
+
import React, { useState } from "react"
|
2
|
+
import { useForm } from "react-hook-form"
|
3
|
+
import { Button, Body, Select } from "playbook-ui"
|
4
|
+
|
5
|
+
const SelectReactHook = (props) => {
|
6
|
+
const { register, handleSubmit, formState: { errors } } = useForm({
|
7
|
+
defaultValues: {
|
8
|
+
food: '',
|
9
|
+
},
|
10
|
+
})
|
11
|
+
|
12
|
+
const [submittedData, setSubmittedData] = useState({
|
13
|
+
food: '',
|
14
|
+
})
|
15
|
+
|
16
|
+
const onSubmit = (data) => {
|
17
|
+
setSubmittedData(data)
|
18
|
+
}
|
19
|
+
|
20
|
+
const options = [
|
21
|
+
{
|
22
|
+
value: 1,
|
23
|
+
text: 'Burgers',
|
24
|
+
},
|
25
|
+
{
|
26
|
+
value: 2,
|
27
|
+
text: 'Pizza',
|
28
|
+
},
|
29
|
+
{
|
30
|
+
value: 3,
|
31
|
+
text: 'Tacos',
|
32
|
+
},
|
33
|
+
]
|
34
|
+
|
35
|
+
return (
|
36
|
+
<>
|
37
|
+
<form onSubmit={handleSubmit(onSubmit)}>
|
38
|
+
<Select
|
39
|
+
{...props}
|
40
|
+
{...register("food", { required: true })}
|
41
|
+
error={errors.food ? "Please select a food." : null}
|
42
|
+
label="Favorite Food"
|
43
|
+
options={options}
|
44
|
+
/>
|
45
|
+
<br />
|
46
|
+
<Button htmlType="submit"
|
47
|
+
marginTop="sm"
|
48
|
+
text="Submit"
|
49
|
+
/>
|
50
|
+
</form>
|
51
|
+
<Body padding="xs"
|
52
|
+
text={`Food: ${submittedData.food}`}
|
53
|
+
/>
|
54
|
+
</>
|
55
|
+
)
|
56
|
+
}
|
57
|
+
|
58
|
+
export default SelectReactHook
|
@@ -0,0 +1 @@
|
|
1
|
+
You can pass react-hook-form props to a select kit. You can use `register` which will make the value available for both the form validation and submission.
|
@@ -10,3 +10,4 @@ export { default as SelectInline } from './_select_inline.jsx'
|
|
10
10
|
export { default as SelectInlineShowArrow } from './_select_inline_show_arrow.jsx'
|
11
11
|
export { default as SelectInlineCompact } from './_select_inline_compact.jsx'
|
12
12
|
export { default as SelectMultiple } from './_select_multiple.jsx'
|
13
|
+
export { default as SelectReactHook } from './_select_react_hook.jsx'
|
@@ -1,8 +1,6 @@
|
|
1
|
-
<%=
|
2
|
-
|
3
|
-
|
4
|
-
class: object.classnames,
|
5
|
-
**combined_html_options) do %>
|
1
|
+
<%= pb_content_tag(:div,
|
2
|
+
id: nil,
|
3
|
+
class: object.classnames ) do %>
|
6
4
|
<% if object.label %>
|
7
5
|
<label class="pb_select_kit_label" for="<%= object.name %>">
|
8
6
|
<%= pb_rails("caption", props: { text: object.label, dark: object.dark }) %>
|
@@ -1,8 +1,4 @@
|
|
1
|
-
<%=
|
2
|
-
id: object.id,
|
3
|
-
data: object.data,
|
4
|
-
class: object.classname,
|
5
|
-
**combined_html_options) do %>
|
1
|
+
<%= pb_content_tag do %>
|
6
2
|
|
7
3
|
<% if object.multi %>
|
8
4
|
<%= check_box_tag(object.name, object.value, object.checked, object.additional_input_options) %>
|