playbook_ui 15.7.0.pre.alpha.PLAY2675dropdownquickpickcustomquickpickdates13330 → 15.7.0.pre.alpha.PLAY2704multilevelselectsingledisabledoptions13404
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_dropdown/_dropdown.tsx +1 -13
- data/app/pb_kits/playbook/pb_dropdown/docs/example.yml +0 -2
- data/app/pb_kits/playbook/pb_dropdown/docs/index.js +1 -2
- data/app/pb_kits/playbook/pb_dropdown/dropdown.rb +1 -6
- data/app/pb_kits/playbook/pb_dropdown/dropdown.test.jsx +0 -121
- data/app/pb_kits/playbook/pb_dropdown/quickpick/index.ts +9 -85
- data/app/pb_kits/playbook/pb_dropdown/quickpick_helper.rb +2 -83
- data/app/pb_kits/playbook/pb_fixed_confirmation_toast/fixed_confirmation_toast.rb +9 -7
- data/app/pb_kits/playbook/pb_fixed_confirmation_toast/index.js +3 -8
- data/app/pb_kits/playbook/pb_multi_level_select/_multi_level_select.tsx +7 -0
- data/app/pb_kits/playbook/pb_multi_level_select/docs/_multi_level_select_disabled_options.md +1 -1
- data/app/pb_kits/playbook/pb_multi_level_select/docs/_multi_level_select_single_disabled.html.erb +135 -0
- data/app/pb_kits/playbook/pb_multi_level_select/docs/_multi_level_select_single_disabled.jsx +147 -0
- data/app/pb_kits/playbook/pb_multi_level_select/docs/_multi_level_select_single_disabled.md +1 -0
- data/app/pb_kits/playbook/pb_multi_level_select/docs/example.yml +2 -0
- 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.test.jsx +402 -27
- data/app/pb_kits/playbook/pb_multi_level_select/multi_level_select_options.tsx +1 -0
- data/app/pb_kits/playbook/pb_radio/_radio.scss +8 -0
- data/app/pb_kits/playbook/pb_text_input/_text_input.tsx +41 -3
- data/app/pb_kits/playbook/pb_text_input/docs/_text_input_emoji_mask.html.erb +7 -0
- data/app/pb_kits/playbook/pb_text_input/docs/_text_input_emoji_mask.jsx +24 -0
- data/app/pb_kits/playbook/pb_text_input/docs/_text_input_emoji_mask.md +2 -0
- data/app/pb_kits/playbook/pb_text_input/docs/example.yml +2 -0
- data/app/pb_kits/playbook/pb_text_input/docs/index.js +1 -0
- data/app/pb_kits/playbook/pb_text_input/index.js +49 -8
- data/app/pb_kits/playbook/pb_text_input/text_input.rb +5 -1
- data/app/pb_kits/playbook/pb_text_input/text_input.test.js +53 -0
- data/app/pb_kits/playbook/pb_textarea/_textarea.tsx +38 -2
- data/app/pb_kits/playbook/pb_textarea/docs/_textarea_emoji_mask.html.erb +5 -0
- data/app/pb_kits/playbook/pb_textarea/docs/_textarea_emoji_mask.jsx +24 -0
- data/app/pb_kits/playbook/pb_textarea/docs/_textarea_emoji_mask.md +1 -0
- data/app/pb_kits/playbook/pb_textarea/docs/example.yml +2 -0
- data/app/pb_kits/playbook/pb_textarea/docs/index.js +1 -0
- data/app/pb_kits/playbook/pb_textarea/index.ts +62 -5
- data/app/pb_kits/playbook/pb_textarea/textarea.html.erb +1 -0
- data/app/pb_kits/playbook/pb_textarea/textarea.rb +8 -0
- data/app/pb_kits/playbook/pb_textarea/textarea.test.js +57 -2
- data/app/pb_kits/playbook/utilities/emojiMask.ts +42 -0
- data/dist/chunks/{_typeahead-Ckz1ce-2.js → _typeahead-DQWz6v7R.js} +2 -2
- data/dist/chunks/{lib-DxDBrGZX.js → lib-DxCgrqqG.js} +1 -1
- data/dist/chunks/vendor.js +3 -3
- 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/forms/builder/form_field_builder.rb +2 -0
- data/lib/playbook/version.rb +1 -1
- metadata +14 -8
- data/app/pb_kits/playbook/pb_dropdown/docs/_dropdown_quickpick_custom.jsx +0 -56
- data/app/pb_kits/playbook/pb_dropdown/docs/_dropdown_quickpick_custom.md +0 -10
- data/app/pb_kits/playbook/pb_dropdown/docs/_dropdown_quickpick_custom_rails.html.erb +0 -64
- data/app/pb_kits/playbook/pb_dropdown/docs/_dropdown_quickpick_custom_rails.md +0 -10
|
@@ -0,0 +1,147 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
import MultiLevelSelect from "../_multi_level_select";
|
|
3
|
+
|
|
4
|
+
const treeData = [
|
|
5
|
+
{
|
|
6
|
+
label: "HQ",
|
|
7
|
+
value: "hQ",
|
|
8
|
+
id: "hq2",
|
|
9
|
+
},
|
|
10
|
+
{
|
|
11
|
+
label: "Philadelphia",
|
|
12
|
+
value: "philadelphia",
|
|
13
|
+
id: "phl2",
|
|
14
|
+
disabled: true,
|
|
15
|
+
children: [
|
|
16
|
+
{
|
|
17
|
+
label: "Marketing & Sales PHL",
|
|
18
|
+
value: "marketingAndSalesPhl",
|
|
19
|
+
id: "marketingPHL2",
|
|
20
|
+
},
|
|
21
|
+
{
|
|
22
|
+
label: "Installation Office PHL",
|
|
23
|
+
value: "installationOfficePhl",
|
|
24
|
+
id: "installationPHL2",
|
|
25
|
+
},
|
|
26
|
+
{
|
|
27
|
+
label: "Warehouse PHL",
|
|
28
|
+
value: "warehousePhl",
|
|
29
|
+
id: "warehousePHL2",
|
|
30
|
+
},
|
|
31
|
+
]
|
|
32
|
+
},
|
|
33
|
+
{
|
|
34
|
+
label: "New Jersey",
|
|
35
|
+
value: "newJersey",
|
|
36
|
+
id: "nj2",
|
|
37
|
+
children: [
|
|
38
|
+
{
|
|
39
|
+
label: "New Jersey",
|
|
40
|
+
value: "newJersey",
|
|
41
|
+
id: "nj12",
|
|
42
|
+
children: [
|
|
43
|
+
{
|
|
44
|
+
label: "Marketing & Sales NJ",
|
|
45
|
+
value: "marketingAndSalesNj",
|
|
46
|
+
id: "marketingNJ2",
|
|
47
|
+
disabled: true,
|
|
48
|
+
},
|
|
49
|
+
{
|
|
50
|
+
label: "Installation Office NJ",
|
|
51
|
+
value: "installationOfficeNj",
|
|
52
|
+
id: "installationNJ2",
|
|
53
|
+
},
|
|
54
|
+
{
|
|
55
|
+
label: "Warehouse NJ",
|
|
56
|
+
value: "warehouseNj",
|
|
57
|
+
id: "warehouseNJ2",
|
|
58
|
+
},
|
|
59
|
+
],
|
|
60
|
+
},
|
|
61
|
+
{
|
|
62
|
+
label: "Princeton",
|
|
63
|
+
value: "princeton",
|
|
64
|
+
id: "princeton2",
|
|
65
|
+
children: [
|
|
66
|
+
{
|
|
67
|
+
label: "Marketing & Sales Princeton",
|
|
68
|
+
value: "marketingAndSalesPrinceton",
|
|
69
|
+
id: "marketingPR2",
|
|
70
|
+
},
|
|
71
|
+
{
|
|
72
|
+
label: "Installation Office Princeton",
|
|
73
|
+
value: "installationOfficePrinceton",
|
|
74
|
+
id: "installationPR2",
|
|
75
|
+
disabled: true,
|
|
76
|
+
},
|
|
77
|
+
{
|
|
78
|
+
label: "Warehouse Princeton",
|
|
79
|
+
value: "warehousePrinceton",
|
|
80
|
+
id: "warehousePR2",
|
|
81
|
+
},
|
|
82
|
+
]
|
|
83
|
+
},
|
|
84
|
+
]
|
|
85
|
+
},
|
|
86
|
+
{
|
|
87
|
+
label: "Maryland",
|
|
88
|
+
value: "maryland",
|
|
89
|
+
id: "MD2",
|
|
90
|
+
children: [
|
|
91
|
+
{
|
|
92
|
+
label: "Marketing & Sales MD",
|
|
93
|
+
value: "marketingAndSalesMd",
|
|
94
|
+
id: "marketingMD2",
|
|
95
|
+
},
|
|
96
|
+
{
|
|
97
|
+
label: "Installation Office MD",
|
|
98
|
+
value: "installationOfficeMd",
|
|
99
|
+
id: "installationMD2",
|
|
100
|
+
},
|
|
101
|
+
{
|
|
102
|
+
label: "Warehouse MD",
|
|
103
|
+
value: "warehouseMd",
|
|
104
|
+
id: "warehouseMD2",
|
|
105
|
+
},
|
|
106
|
+
]
|
|
107
|
+
},
|
|
108
|
+
{
|
|
109
|
+
label: "Connecticut",
|
|
110
|
+
value: "connecticut",
|
|
111
|
+
id: "CT2",
|
|
112
|
+
children: [
|
|
113
|
+
{
|
|
114
|
+
label: "Marketing & Sales CT",
|
|
115
|
+
value: "marketingAndSalesCt",
|
|
116
|
+
id: "marketingCT2",
|
|
117
|
+
},
|
|
118
|
+
{
|
|
119
|
+
label: "Installation Office CT",
|
|
120
|
+
value: "installationOfficeCt",
|
|
121
|
+
id: "installationCT2",
|
|
122
|
+
},
|
|
123
|
+
{
|
|
124
|
+
label: "Warehouse CT",
|
|
125
|
+
value: "warehouseCt",
|
|
126
|
+
id: "warehouseCT2",
|
|
127
|
+
},
|
|
128
|
+
]
|
|
129
|
+
},
|
|
130
|
+
];
|
|
131
|
+
|
|
132
|
+
const MultiLevelSelectSingleDisabled = (props) => {
|
|
133
|
+
return (
|
|
134
|
+
<div>
|
|
135
|
+
<MultiLevelSelect
|
|
136
|
+
id="multiselect-single-disabled"
|
|
137
|
+
inputName="Power"
|
|
138
|
+
onSelect={(selectedNode) => console.log("Selected Node", selectedNode)}
|
|
139
|
+
treeData={treeData}
|
|
140
|
+
variant="single"
|
|
141
|
+
{...props}
|
|
142
|
+
/>
|
|
143
|
+
</div>
|
|
144
|
+
)
|
|
145
|
+
};
|
|
146
|
+
|
|
147
|
+
export default MultiLevelSelectSingleDisabled;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
Individual items can be disabled by including `disabled: true` within the object on the treeData for the `single` variant. Disabled options are visibly disabled in the dropdown UI and cannot be selected via mouse click or keyboard navigation. When a parent node is disabled, all of its children are automatically disabled as well.
|
|
@@ -15,6 +15,7 @@ examples:
|
|
|
15
15
|
- multi_level_select_disabled_options: Disabled Options (Return All Selected)
|
|
16
16
|
- multi_level_select_disabled_options_parent_default: Disabled Parent Option (Default)
|
|
17
17
|
- multi_level_select_disabled_options_parent: Disabled Parent Option (Return All Selected)
|
|
18
|
+
- multi_level_select_single_disabled: Disabled Options (Single Select)
|
|
18
19
|
|
|
19
20
|
react:
|
|
20
21
|
- multi_level_select_default: Default
|
|
@@ -33,3 +34,4 @@ examples:
|
|
|
33
34
|
- multi_level_select_disabled_options: Disabled Options (Return All Selected)
|
|
34
35
|
- multi_level_select_disabled_options_parent_default: Disabled Parent Option (Default)
|
|
35
36
|
- multi_level_select_disabled_options_parent: Disabled Parent Option (Return All Selected)
|
|
37
|
+
- multi_level_select_single_disabled: Disabled Options (Single Select)
|
|
@@ -14,3 +14,4 @@ export { default as MultiLevelSelectDisabledOptionsParent } from './_multi_level
|
|
|
14
14
|
export { default as MultiLevelSelectDisabledOptionsParentDefault } from './_multi_level_select_disabled_options_parent_default.jsx'
|
|
15
15
|
export { default as MultiLevelSelectDisabledOptionsDefault } from './_multi_level_select_disabled_options_default.jsx'
|
|
16
16
|
export { default as MultiLevelSelectLabel } from './_multi_level_select_label.jsx'
|
|
17
|
+
export { default as MultiLevelSelectSingleDisabled } from './_multi_level_select_single_disabled.jsx'
|
|
@@ -1,39 +1,414 @@
|
|
|
1
1
|
import React from 'react'
|
|
2
|
-
import { render, screen } from '../utilities/test-utils'
|
|
2
|
+
import { render, screen, fireEvent } from '../utilities/test-utils'
|
|
3
3
|
|
|
4
4
|
import { MultiLevelSelect } from 'playbook-ui'
|
|
5
5
|
|
|
6
|
-
const treeData =
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
6
|
+
const treeData = [
|
|
7
|
+
{
|
|
8
|
+
label: 'Power Home Remodeling',
|
|
9
|
+
value: 'powerHomeRemodeling',
|
|
10
|
+
id: 'powerhome1',
|
|
11
|
+
expanded: true,
|
|
12
|
+
children: [
|
|
13
|
+
{
|
|
14
|
+
label: 'People',
|
|
15
|
+
value: 'people',
|
|
16
|
+
id: 'people1',
|
|
17
|
+
children: [
|
|
18
|
+
{
|
|
19
|
+
label: 'Talent Acquisition',
|
|
20
|
+
value: 'talentAcquisition',
|
|
21
|
+
id: 'talent1',
|
|
22
|
+
},
|
|
23
|
+
{
|
|
24
|
+
label: 'Business Affairs',
|
|
25
|
+
value: 'businessAffairs',
|
|
26
|
+
id: 'business1',
|
|
27
|
+
},
|
|
28
|
+
],
|
|
29
|
+
},
|
|
30
|
+
{
|
|
31
|
+
label: 'Contact Center',
|
|
32
|
+
value: 'contactCenter',
|
|
33
|
+
id: 'contact1',
|
|
34
|
+
},
|
|
35
|
+
],
|
|
36
|
+
},
|
|
37
|
+
]
|
|
38
|
+
|
|
39
|
+
const treeDataWithDisabledOptions = [
|
|
40
|
+
{
|
|
41
|
+
label: 'Power Home Remodeling',
|
|
42
|
+
value: 'powerHomeRemodeling',
|
|
43
|
+
id: 'powerhome1',
|
|
44
|
+
expanded: true,
|
|
45
|
+
children: [
|
|
46
|
+
{
|
|
47
|
+
label: 'People',
|
|
48
|
+
value: 'people',
|
|
49
|
+
id: 'people1',
|
|
50
|
+
disabled: true,
|
|
51
|
+
},
|
|
52
|
+
{
|
|
53
|
+
label: 'Contact Center',
|
|
54
|
+
value: 'contactCenter',
|
|
55
|
+
id: 'contact1',
|
|
56
|
+
},
|
|
57
|
+
],
|
|
58
|
+
},
|
|
59
|
+
]
|
|
60
|
+
|
|
61
|
+
const treeDataWithDisabledParent = [
|
|
62
|
+
{
|
|
63
|
+
label: 'Power Home Remodeling',
|
|
64
|
+
value: 'powerHomeRemodeling',
|
|
65
|
+
id: 'powerhome1',
|
|
66
|
+
expanded: true,
|
|
67
|
+
disabled: true,
|
|
68
|
+
children: [
|
|
69
|
+
{
|
|
70
|
+
label: 'People',
|
|
71
|
+
value: 'people',
|
|
72
|
+
id: 'people1',
|
|
73
|
+
},
|
|
74
|
+
{
|
|
75
|
+
label: 'Contact Center',
|
|
76
|
+
value: 'contactCenter',
|
|
77
|
+
id: 'contact1',
|
|
78
|
+
},
|
|
79
|
+
],
|
|
80
|
+
},
|
|
81
|
+
]
|
|
25
82
|
|
|
26
83
|
const testId = "multiselect-test"
|
|
27
|
-
|
|
28
|
-
|
|
84
|
+
|
|
85
|
+
describe('MultiLevelSelect', () => {
|
|
86
|
+
test('should render custom class', () => {
|
|
87
|
+
render(
|
|
29
88
|
<MultiLevelSelect
|
|
30
89
|
className='custom-class'
|
|
31
|
-
data={{ testid: testId}}
|
|
90
|
+
data={{ testid: testId }}
|
|
91
|
+
treeData={treeData}
|
|
92
|
+
/>
|
|
93
|
+
)
|
|
94
|
+
const kit = screen.getByTestId(testId)
|
|
95
|
+
expect(kit).toHaveClass('custom-class')
|
|
96
|
+
})
|
|
97
|
+
|
|
98
|
+
test('should render with default multi variant', () => {
|
|
99
|
+
render(
|
|
100
|
+
<MultiLevelSelect
|
|
101
|
+
data={{ testid: testId }}
|
|
102
|
+
treeData={treeData}
|
|
103
|
+
/>
|
|
104
|
+
)
|
|
105
|
+
const kit = screen.getByTestId(testId)
|
|
106
|
+
expect(kit).toHaveClass('pb_multi_level_select')
|
|
107
|
+
})
|
|
108
|
+
|
|
109
|
+
test('should render label when provided', () => {
|
|
110
|
+
render(
|
|
111
|
+
<MultiLevelSelect
|
|
112
|
+
data={{ testid: testId }}
|
|
113
|
+
label="Select Location"
|
|
114
|
+
treeData={treeData}
|
|
115
|
+
/>
|
|
116
|
+
)
|
|
117
|
+
const kit = screen.getByTestId(testId)
|
|
118
|
+
expect(kit).toHaveTextContent('Select Location')
|
|
119
|
+
})
|
|
120
|
+
|
|
121
|
+
test('should render error message when provided', () => {
|
|
122
|
+
render(
|
|
123
|
+
<MultiLevelSelect
|
|
124
|
+
data={{ testid: testId }}
|
|
125
|
+
error="Please select an option"
|
|
126
|
+
treeData={treeData}
|
|
127
|
+
/>
|
|
128
|
+
)
|
|
129
|
+
const kit = screen.getByTestId(testId)
|
|
130
|
+
expect(kit).toHaveTextContent('Please select an option')
|
|
131
|
+
expect(kit).toHaveClass('error')
|
|
132
|
+
})
|
|
133
|
+
|
|
134
|
+
test('should disable input when disabled prop is true', () => {
|
|
135
|
+
render(
|
|
136
|
+
<MultiLevelSelect
|
|
137
|
+
data={{ testid: testId }}
|
|
138
|
+
disabled
|
|
32
139
|
treeData={treeData}
|
|
33
|
-
/>
|
|
34
|
-
|
|
140
|
+
/>
|
|
141
|
+
)
|
|
142
|
+
const kit = screen.getByTestId(testId)
|
|
143
|
+
const input = kit.querySelector('#multiselect_input')
|
|
144
|
+
expect(input).toBeDisabled()
|
|
145
|
+
})
|
|
146
|
+
})
|
|
35
147
|
|
|
36
|
-
|
|
37
|
-
|
|
148
|
+
describe('MultiLevelSelect multi variant', () => {
|
|
149
|
+
test('should render checkboxes for multi variant', () => {
|
|
150
|
+
render(
|
|
151
|
+
<MultiLevelSelect
|
|
152
|
+
data={{ testid: testId }}
|
|
153
|
+
treeData={treeData}
|
|
154
|
+
variant="multi"
|
|
155
|
+
/>
|
|
156
|
+
)
|
|
157
|
+
const kit = screen.getByTestId(testId)
|
|
158
|
+
const input = kit.querySelector('#multiselect_input')
|
|
159
|
+
fireEvent.click(input)
|
|
160
|
+
|
|
161
|
+
const checkboxes = kit.querySelectorAll('input[type="checkbox"]')
|
|
162
|
+
expect(checkboxes.length).toBeGreaterThan(0)
|
|
163
|
+
})
|
|
164
|
+
|
|
165
|
+
test('should call onSelect when checkbox is clicked', () => {
|
|
166
|
+
const mockOnSelect = jest.fn()
|
|
167
|
+
render(
|
|
168
|
+
<MultiLevelSelect
|
|
169
|
+
data={{ testid: testId }}
|
|
170
|
+
onSelect={mockOnSelect}
|
|
171
|
+
treeData={treeData}
|
|
172
|
+
variant="multi"
|
|
173
|
+
/>
|
|
174
|
+
)
|
|
175
|
+
const kit = screen.getByTestId(testId)
|
|
176
|
+
const input = kit.querySelector('#multiselect_input')
|
|
177
|
+
fireEvent.click(input)
|
|
178
|
+
|
|
179
|
+
const checkbox = kit.querySelector('input[type="checkbox"]')
|
|
180
|
+
fireEvent.click(checkbox)
|
|
181
|
+
|
|
182
|
+
expect(mockOnSelect).toHaveBeenCalled()
|
|
183
|
+
})
|
|
184
|
+
|
|
185
|
+
test('should render disabled checkbox inputs for disabled options', () => {
|
|
186
|
+
render(
|
|
187
|
+
<MultiLevelSelect
|
|
188
|
+
data={{ testid: testId }}
|
|
189
|
+
id="multi-disabled-test"
|
|
190
|
+
treeData={treeDataWithDisabledOptions}
|
|
191
|
+
variant="multi"
|
|
192
|
+
/>
|
|
193
|
+
)
|
|
194
|
+
const kit = screen.getByTestId(testId)
|
|
195
|
+
const input = kit.querySelector('#multiselect_input')
|
|
196
|
+
fireEvent.click(input)
|
|
197
|
+
|
|
198
|
+
const disabledCheckbox = kit.querySelector('input[type="checkbox"][disabled]')
|
|
199
|
+
expect(disabledCheckbox).toBeInTheDocument()
|
|
200
|
+
})
|
|
38
201
|
})
|
|
39
202
|
|
|
203
|
+
describe('MultiLevelSelect single variant', () => {
|
|
204
|
+
test('should render radio buttons for single variant', () => {
|
|
205
|
+
render(
|
|
206
|
+
<MultiLevelSelect
|
|
207
|
+
data={{ testid: testId }}
|
|
208
|
+
treeData={treeData}
|
|
209
|
+
variant="single"
|
|
210
|
+
/>
|
|
211
|
+
)
|
|
212
|
+
const kit = screen.getByTestId(testId)
|
|
213
|
+
const input = kit.querySelector('#multiselect_input')
|
|
214
|
+
fireEvent.click(input)
|
|
215
|
+
|
|
216
|
+
const radios = kit.querySelectorAll('input[type="radio"]')
|
|
217
|
+
expect(radios.length).toBeGreaterThan(0)
|
|
218
|
+
})
|
|
219
|
+
|
|
220
|
+
test('should render disabled radio inputs for disabled options', () => {
|
|
221
|
+
render(
|
|
222
|
+
<MultiLevelSelect
|
|
223
|
+
data={{ testid: testId }}
|
|
224
|
+
id="single-disabled-test"
|
|
225
|
+
treeData={treeDataWithDisabledOptions}
|
|
226
|
+
variant="single"
|
|
227
|
+
/>
|
|
228
|
+
)
|
|
229
|
+
const kit = screen.getByTestId(testId)
|
|
230
|
+
const input = kit.querySelector('#multiselect_input')
|
|
231
|
+
fireEvent.click(input)
|
|
232
|
+
|
|
233
|
+
const disabledRadio = kit.querySelector('input[type="radio"][disabled]')
|
|
234
|
+
expect(disabledRadio).toBeInTheDocument()
|
|
235
|
+
})
|
|
236
|
+
|
|
237
|
+
test('disabled options cannot be selected', () => {
|
|
238
|
+
const mockOnSelect = jest.fn()
|
|
239
|
+
render(
|
|
240
|
+
<MultiLevelSelect
|
|
241
|
+
data={{ testid: testId }}
|
|
242
|
+
id="single-disabled-click-test"
|
|
243
|
+
onSelect={mockOnSelect}
|
|
244
|
+
treeData={treeDataWithDisabledOptions}
|
|
245
|
+
variant="single"
|
|
246
|
+
/>
|
|
247
|
+
)
|
|
248
|
+
const kit = screen.getByTestId(testId)
|
|
249
|
+
const input = kit.querySelector('#multiselect_input')
|
|
250
|
+
fireEvent.click(input)
|
|
251
|
+
|
|
252
|
+
const disabledRadio = kit.querySelector('input[type="radio"][disabled]')
|
|
253
|
+
fireEvent.click(disabledRadio)
|
|
254
|
+
|
|
255
|
+
expect(mockOnSelect).not.toHaveBeenCalled()
|
|
256
|
+
})
|
|
257
|
+
|
|
258
|
+
test('enabled options can be selected', () => {
|
|
259
|
+
const mockOnSelect = jest.fn()
|
|
260
|
+
render(
|
|
261
|
+
<MultiLevelSelect
|
|
262
|
+
data={{ testid: testId }}
|
|
263
|
+
id="single-enabled-click-test"
|
|
264
|
+
onSelect={mockOnSelect}
|
|
265
|
+
treeData={treeDataWithDisabledOptions}
|
|
266
|
+
variant="single"
|
|
267
|
+
/>
|
|
268
|
+
)
|
|
269
|
+
const kit = screen.getByTestId(testId)
|
|
270
|
+
const input = kit.querySelector('#multiselect_input')
|
|
271
|
+
fireEvent.click(input)
|
|
272
|
+
|
|
273
|
+
const enabledRadio = kit.querySelector('input[type="radio"]:not([disabled])')
|
|
274
|
+
fireEvent.click(enabledRadio)
|
|
275
|
+
|
|
276
|
+
expect(mockOnSelect).toHaveBeenCalled()
|
|
277
|
+
})
|
|
278
|
+
|
|
279
|
+
test('should close dropdown after selection', () => {
|
|
280
|
+
render(
|
|
281
|
+
<MultiLevelSelect
|
|
282
|
+
data={{ testid: testId }}
|
|
283
|
+
treeData={treeDataWithDisabledOptions}
|
|
284
|
+
variant="single"
|
|
285
|
+
/>
|
|
286
|
+
)
|
|
287
|
+
const kit = screen.getByTestId(testId)
|
|
288
|
+
const input = kit.querySelector('#multiselect_input')
|
|
289
|
+
fireEvent.click(input)
|
|
290
|
+
|
|
291
|
+
const enabledRadio = kit.querySelector('input[type="radio"]:not([disabled])')
|
|
292
|
+
fireEvent.click(enabledRadio)
|
|
293
|
+
|
|
294
|
+
const dropdownClosed = kit.querySelector('.dropdown_menu.close')
|
|
295
|
+
expect(dropdownClosed).toBeInTheDocument()
|
|
296
|
+
})
|
|
297
|
+
|
|
298
|
+
test('should update input value after selection', () => {
|
|
299
|
+
render(
|
|
300
|
+
<MultiLevelSelect
|
|
301
|
+
data={{ testid: testId }}
|
|
302
|
+
treeData={treeDataWithDisabledOptions}
|
|
303
|
+
variant="single"
|
|
304
|
+
/>
|
|
305
|
+
)
|
|
306
|
+
const kit = screen.getByTestId(testId)
|
|
307
|
+
const input = kit.querySelector('#multiselect_input')
|
|
308
|
+
fireEvent.click(input)
|
|
309
|
+
|
|
310
|
+
const enabledRadio = kit.querySelector('input[type="radio"]:not([disabled])')
|
|
311
|
+
fireEvent.click(enabledRadio)
|
|
312
|
+
|
|
313
|
+
expect(input.value).toBe('Power Home Remodeling')
|
|
314
|
+
})
|
|
315
|
+
})
|
|
316
|
+
|
|
317
|
+
describe('MultiLevelSelect disabled parent behavior', () => {
|
|
318
|
+
test('children of disabled parent should also be disabled in single variant', () => {
|
|
319
|
+
render(
|
|
320
|
+
<MultiLevelSelect
|
|
321
|
+
data={{ testid: testId }}
|
|
322
|
+
treeData={treeDataWithDisabledParent}
|
|
323
|
+
variant="single"
|
|
324
|
+
/>
|
|
325
|
+
)
|
|
326
|
+
const kit = screen.getByTestId(testId)
|
|
327
|
+
const input = kit.querySelector('#multiselect_input')
|
|
328
|
+
fireEvent.click(input)
|
|
329
|
+
|
|
330
|
+
const radios = kit.querySelectorAll('input[type="radio"]')
|
|
331
|
+
radios.forEach(radio => {
|
|
332
|
+
expect(radio).toBeDisabled()
|
|
333
|
+
})
|
|
334
|
+
})
|
|
335
|
+
|
|
336
|
+
test('children of disabled parent should also be disabled in multi variant', () => {
|
|
337
|
+
render(
|
|
338
|
+
<MultiLevelSelect
|
|
339
|
+
data={{ testid: testId }}
|
|
340
|
+
treeData={treeDataWithDisabledParent}
|
|
341
|
+
variant="multi"
|
|
342
|
+
/>
|
|
343
|
+
)
|
|
344
|
+
const kit = screen.getByTestId(testId)
|
|
345
|
+
const input = kit.querySelector('#multiselect_input')
|
|
346
|
+
fireEvent.click(input)
|
|
347
|
+
|
|
348
|
+
const checkboxes = kit.querySelectorAll('input[type="checkbox"]')
|
|
349
|
+
checkboxes.forEach(checkbox => {
|
|
350
|
+
expect(checkbox).toBeDisabled()
|
|
351
|
+
})
|
|
352
|
+
})
|
|
353
|
+
})
|
|
354
|
+
|
|
355
|
+
describe('MultiLevelSelect onChange callback', () => {
|
|
356
|
+
test('should call onChange when selection changes in multi variant', () => {
|
|
357
|
+
const mockOnChange = jest.fn()
|
|
358
|
+
render(
|
|
359
|
+
<MultiLevelSelect
|
|
360
|
+
data={{ testid: testId }}
|
|
361
|
+
onChange={mockOnChange}
|
|
362
|
+
treeData={treeData}
|
|
363
|
+
variant="multi"
|
|
364
|
+
/>
|
|
365
|
+
)
|
|
366
|
+
const kit = screen.getByTestId(testId)
|
|
367
|
+
const input = kit.querySelector('#multiselect_input')
|
|
368
|
+
fireEvent.click(input)
|
|
369
|
+
|
|
370
|
+
const checkbox = kit.querySelector('input[type="checkbox"]')
|
|
371
|
+
fireEvent.click(checkbox)
|
|
372
|
+
|
|
373
|
+
expect(mockOnChange).toHaveBeenCalled()
|
|
374
|
+
})
|
|
375
|
+
|
|
376
|
+
test('should call onChange when selection changes in single variant', () => {
|
|
377
|
+
const mockOnChange = jest.fn()
|
|
378
|
+
render(
|
|
379
|
+
<MultiLevelSelect
|
|
380
|
+
data={{ testid: testId }}
|
|
381
|
+
onChange={mockOnChange}
|
|
382
|
+
treeData={treeDataWithDisabledOptions}
|
|
383
|
+
variant="single"
|
|
384
|
+
/>
|
|
385
|
+
)
|
|
386
|
+
const kit = screen.getByTestId(testId)
|
|
387
|
+
const input = kit.querySelector('#multiselect_input')
|
|
388
|
+
fireEvent.click(input)
|
|
389
|
+
|
|
390
|
+
const enabledRadio = kit.querySelector('input[type="radio"]:not([disabled])')
|
|
391
|
+
fireEvent.click(enabledRadio)
|
|
392
|
+
|
|
393
|
+
expect(mockOnChange).toHaveBeenCalled()
|
|
394
|
+
})
|
|
395
|
+
})
|
|
396
|
+
|
|
397
|
+
describe('MultiLevelSelect inputName prop', () => {
|
|
398
|
+
test('should use inputName for radio button name attribute', () => {
|
|
399
|
+
render(
|
|
400
|
+
<MultiLevelSelect
|
|
401
|
+
data={{ testid: testId }}
|
|
402
|
+
inputName="location_select"
|
|
403
|
+
treeData={treeData}
|
|
404
|
+
variant="single"
|
|
405
|
+
/>
|
|
406
|
+
)
|
|
407
|
+
const kit = screen.getByTestId(testId)
|
|
408
|
+
const input = kit.querySelector('#multiselect_input')
|
|
409
|
+
fireEvent.click(input)
|
|
410
|
+
|
|
411
|
+
const radio = kit.querySelector('input[type="radio"]')
|
|
412
|
+
expect(radio).toHaveAttribute('name', 'location_select')
|
|
413
|
+
})
|
|
414
|
+
})
|
|
@@ -13,6 +13,10 @@
|
|
|
13
13
|
display: inline-flex;
|
|
14
14
|
cursor: pointer;
|
|
15
15
|
|
|
16
|
+
&:has(input:disabled) {
|
|
17
|
+
cursor: not-allowed;
|
|
18
|
+
}
|
|
19
|
+
|
|
16
20
|
.pb_radio_button {
|
|
17
21
|
width: 22px;
|
|
18
22
|
min-width: 22px;
|
|
@@ -84,6 +88,10 @@
|
|
|
84
88
|
.pb_radio_kit.dark.error.vertical,
|
|
85
89
|
.pb_radio_kit_vertical.dark,
|
|
86
90
|
.pb_radio_kit_vertical.dark.error {
|
|
91
|
+
&:has(input:disabled) {
|
|
92
|
+
cursor: not-allowed;
|
|
93
|
+
}
|
|
94
|
+
|
|
87
95
|
.pb_radio_button {
|
|
88
96
|
border-color: $border_dark;
|
|
89
97
|
}
|