playbook_ui 14.22.0.pre.rc.0 → 14.22.0.pre.rc.1
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 +3 -12
- 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/subcomponents/DropdownOption.tsx +10 -14
- data/app/pb_kits/playbook/pb_dropdown/subcomponents/DropdownTrigger.tsx +15 -26
- data/dist/chunks/{_weekday_stacked-B_jpa2Rz.js → _weekday_stacked-CB0ZsFbo.js} +2 -2
- data/dist/chunks/lazysizes-DHz07jlL.js +1 -0
- data/dist/chunks/vendor.js +1 -1
- data/dist/playbook-doc.js +1 -1
- data/dist/playbook-rails.js +1 -1
- data/lib/playbook/version.rb +2 -2
- metadata +4 -6
- data/app/pb_kits/playbook/pb_dropdown/docs/_dropdown_close_on_select.jsx +0 -42
- data/app/pb_kits/playbook/pb_dropdown/docs/_dropdown_close_on_select.md +0 -1
- data/dist/chunks/lazysizes-B7xYodB-.js +0 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 5cb194ab2e45362e4433d559233b18a29cd5b355b1c87e734ec46055cb152e19
|
4
|
+
data.tar.gz: 9cc6498f631a1524c0f74750c81c70e32d75637cd19b1b7c70d1dc855f00b41a
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: aeeb4ebd0997a5dd807f100a6bb1433274738d06994cca6d6f0b4819805677371cf979a573cf275eb40467bac57fccf4a76b2e65c7733877db657f8c841b6bdc
|
7
|
+
data.tar.gz: 1bd60c9e7bfcce21dd1fbacf43e9e03c5404dad0da6a688379564c50c79532241a91c56f7a47a43512a75a8b728feb23e850690f717308993909923fc47df032
|
@@ -25,7 +25,6 @@ type DropdownProps = {
|
|
25
25
|
blankSelection?: string;
|
26
26
|
children?: React.ReactChild[] | React.ReactChild | React.ReactElement[];
|
27
27
|
className?: string;
|
28
|
-
closeOnSelection?: boolean;
|
29
28
|
formPillProps?: GenericObject;
|
30
29
|
dark?: boolean;
|
31
30
|
data?: { [key: string]: string };
|
@@ -56,7 +55,6 @@ let Dropdown = (props: DropdownProps, ref: any): React.ReactElement | null => {
|
|
56
55
|
blankSelection = '',
|
57
56
|
children,
|
58
57
|
className,
|
59
|
-
closeOnSelection = true,
|
60
58
|
dark = false,
|
61
59
|
data = {},
|
62
60
|
defaultValue = {},
|
@@ -154,7 +152,7 @@ let Dropdown = (props: DropdownProps, ref: any): React.ReactElement | null => {
|
|
154
152
|
if (!multiSelect) return optionsWithBlankSelection;
|
155
153
|
return optionsWithBlankSelection.filter((option: GenericObject) => !selectedArray.some((sel) => sel.label === option.label));
|
156
154
|
}, [optionsWithBlankSelection, selectedArray, multiSelect]);
|
157
|
-
|
155
|
+
|
158
156
|
const filteredOptions = useMemo(() => {
|
159
157
|
return availableOptions.filter((opt: GenericObject) =>
|
160
158
|
String(opt.label).toLowerCase().includes(filterItem.toLowerCase())
|
@@ -194,18 +192,12 @@ let Dropdown = (props: DropdownProps, ref: any): React.ReactElement | null => {
|
|
194
192
|
return next;
|
195
193
|
});
|
196
194
|
setFilterItem("");
|
197
|
-
|
198
|
-
if (closeOnSelection) {
|
199
|
-
setIsDropDownClosed(true);
|
200
|
-
}
|
195
|
+
setIsDropDownClosed(true);
|
201
196
|
} else {
|
202
197
|
setSelected(clickedItem);
|
203
198
|
setFilterItem("");
|
199
|
+
setIsDropDownClosed(true);
|
204
200
|
onSelect && onSelect(clickedItem);
|
205
|
-
// Only close dropdown if closeOnSelection is true
|
206
|
-
if (closeOnSelection) {
|
207
|
-
setIsDropDownClosed(true);
|
208
|
-
}
|
209
201
|
}
|
210
202
|
};
|
211
203
|
|
@@ -260,7 +252,6 @@ let Dropdown = (props: DropdownProps, ref: any): React.ReactElement | null => {
|
|
260
252
|
<DropdownContext.Provider
|
261
253
|
value={{
|
262
254
|
autocomplete,
|
263
|
-
closeOnSelection,
|
264
255
|
dropdownContainerRef,
|
265
256
|
filteredOptions,
|
266
257
|
filterItem,
|
@@ -19,5 +19,4 @@ export { default as DropdownMultiSelect } from './_dropdown_multi_select.jsx'
|
|
19
19
|
export { default as DropdownMultiSelectDisplay } from './_dropdown_multi_select_display.jsx'
|
20
20
|
export { default as DropdownMultiSelectWithAutocomplete } from './_dropdown_multi_select_with_autocomplete.jsx'
|
21
21
|
export { default as DropdownMultiSelectWithDefault } from './_dropdown_multi_select_with_default.jsx'
|
22
|
-
export { default as DropdownMultiSelectWithCustomOptions } from './_dropdown_multi_select_with_custom_options.jsx'
|
23
|
-
export { default as DropdownCloseOnSelect } from './_dropdown_close_on_select.jsx'
|
22
|
+
export { default as DropdownMultiSelectWithCustomOptions } from './_dropdown_multi_select_with_custom_options.jsx'
|
@@ -25,7 +25,7 @@ type DropdownOptionProps = {
|
|
25
25
|
key?: string | number;
|
26
26
|
option?: GenericObject;
|
27
27
|
padding?: string;
|
28
|
-
}
|
28
|
+
} & GlobalProps;
|
29
29
|
|
30
30
|
const DropdownOption = (props: DropdownOptionProps) => {
|
31
31
|
const {
|
@@ -56,17 +56,16 @@ const DropdownOption = (props: DropdownOptionProps) => {
|
|
56
56
|
|
57
57
|
// When multiSelect, then if an option is selected, remove from dropdown
|
58
58
|
const isSelected = Array.isArray(selected)
|
59
|
-
|
60
|
-
|
59
|
+
? selected.some((item) => item.label === option?.label)
|
60
|
+
: (selected as GenericObject)?.label === option?.label;
|
61
61
|
|
62
|
+
|
62
63
|
if (!isItemMatchingFilter(option) || (multiSelect && isSelected)) {
|
63
64
|
return null;
|
64
65
|
}
|
65
|
-
|
66
66
|
const isFocused =
|
67
67
|
focusedOptionIndex >= 0 &&
|
68
68
|
filteredOptions[focusedOptionIndex].label === option?.label;
|
69
|
-
|
70
69
|
const focusedClass = isFocused && "focused";
|
71
70
|
|
72
71
|
const selectedClass = isSelected ? "selected" : "list";
|
@@ -92,10 +91,7 @@ const DropdownOption = (props: DropdownOptionProps) => {
|
|
92
91
|
className={classes}
|
93
92
|
id={id}
|
94
93
|
key={key}
|
95
|
-
onClick={(
|
96
|
-
e.stopPropagation();
|
97
|
-
handleOptionClick(option);
|
98
|
-
}}
|
94
|
+
onClick= {() => handleOptionClick(option)}
|
99
95
|
>
|
100
96
|
<ListItem
|
101
97
|
cursor="pointer"
|
@@ -104,12 +100,12 @@ const DropdownOption = (props: DropdownOptionProps) => {
|
|
104
100
|
key={option?.label}
|
105
101
|
padding="none"
|
106
102
|
>
|
107
|
-
|
103
|
+
{children ?
|
108
104
|
<div className="dropdown_option_wrapper">{children}</div> :
|
109
|
-
|
110
|
-
|
111
|
-
|
112
|
-
|
105
|
+
<Body dark={dark}
|
106
|
+
text={option?.label}
|
107
|
+
/>
|
108
|
+
}
|
113
109
|
</ListItem>
|
114
110
|
</div>
|
115
111
|
);
|
@@ -44,7 +44,6 @@ const DropdownTrigger = (props: DropdownTriggerProps) => {
|
|
44
44
|
|
45
45
|
const {
|
46
46
|
autocomplete,
|
47
|
-
closeOnSelection,
|
48
47
|
filterItem,
|
49
48
|
handleBackspace,
|
50
49
|
handleChange,
|
@@ -55,7 +54,6 @@ const DropdownTrigger = (props: DropdownTriggerProps) => {
|
|
55
54
|
isInputFocused,
|
56
55
|
multiSelect,
|
57
56
|
selected,
|
58
|
-
setIsDropDownClosed,
|
59
57
|
setIsInputFocused,
|
60
58
|
toggleDropdown,
|
61
59
|
} = useContext(DropdownContext);
|
@@ -105,26 +103,11 @@ const DropdownTrigger = (props: DropdownTriggerProps) => {
|
|
105
103
|
? placeholder
|
106
104
|
: "Select...";
|
107
105
|
|
108
|
-
// Click handler that respects closeOnSelection
|
109
|
-
const handleInputClick = (e: React.MouseEvent) => {
|
110
|
-
e.stopPropagation(); // keep the wrapper's handler from firing
|
111
|
-
if (isDropDownClosed) {
|
112
|
-
// Always open if closed
|
113
|
-
setIsDropDownClosed(false);
|
114
|
-
} else if (!closeOnSelection) {
|
115
|
-
// Keep open if closeOnSelection is false
|
116
|
-
return;
|
117
|
-
} else {
|
118
|
-
// Default behavior - toggle
|
119
|
-
toggleDropdown();
|
120
|
-
}
|
121
|
-
};
|
122
|
-
|
123
106
|
return (
|
124
|
-
<div {...ariaProps}
|
125
|
-
{...dataProps}
|
107
|
+
<div {...ariaProps}
|
108
|
+
{...dataProps}
|
126
109
|
{...htmlProps}
|
127
|
-
className={classes}
|
110
|
+
className={classes}
|
128
111
|
id={id}
|
129
112
|
>
|
130
113
|
{
|
@@ -162,7 +145,7 @@ const DropdownTrigger = (props: DropdownTriggerProps) => {
|
|
162
145
|
{customDisplay ? (
|
163
146
|
<Flex align="center">
|
164
147
|
{customDisplay}
|
165
|
-
<Body dark={dark}
|
148
|
+
<Body dark={dark}
|
166
149
|
paddingLeft={`${joinedLabels ? "xs" : "none"}`}
|
167
150
|
>
|
168
151
|
{customDisplayPlaceholder}
|
@@ -181,7 +164,10 @@ const DropdownTrigger = (props: DropdownTriggerProps) => {
|
|
181
164
|
<input
|
182
165
|
className="dropdown_input"
|
183
166
|
onChange={handleChange}
|
184
|
-
onClick={
|
167
|
+
onClick={(e) => {
|
168
|
+
e.stopPropagation();// keep the wrapper’s handler from firing
|
169
|
+
toggleDropdown();
|
170
|
+
}}
|
185
171
|
onFocus={() => setIsInputFocused(true)}
|
186
172
|
onKeyDown={(e) => {
|
187
173
|
handleKeyDown(e);
|
@@ -200,8 +186,8 @@ const DropdownTrigger = (props: DropdownTriggerProps) => {
|
|
200
186
|
)}
|
201
187
|
</>
|
202
188
|
) : (
|
203
|
-
<Body dark={dark}
|
204
|
-
text={defaultDisplayPlaceholder}
|
189
|
+
<Body dark={dark}
|
190
|
+
text={defaultDisplayPlaceholder}
|
205
191
|
/>
|
206
192
|
)
|
207
193
|
)}
|
@@ -209,7 +195,10 @@ const DropdownTrigger = (props: DropdownTriggerProps) => {
|
|
209
195
|
<input
|
210
196
|
className="dropdown_input"
|
211
197
|
onChange={handleChange}
|
212
|
-
onClick={
|
198
|
+
onClick={(e) => {
|
199
|
+
e.stopPropagation();// keep the wrapper’s handler from firing
|
200
|
+
toggleDropdown();
|
201
|
+
}}
|
213
202
|
onFocus={() => setIsInputFocused(true)}
|
214
203
|
onKeyDown={handleKeyDown}
|
215
204
|
placeholder={
|
@@ -234,7 +223,7 @@ const DropdownTrigger = (props: DropdownTriggerProps) => {
|
|
234
223
|
onClick: (e: Event) => {e.stopPropagation();handleWrapperClick()}
|
235
224
|
}}
|
236
225
|
key={`${isDropDownClosed ? "chevron-down" : "chevron-up"}`}
|
237
|
-
>
|
226
|
+
>
|
238
227
|
{
|
239
228
|
selectedArray.length > 0 && (
|
240
229
|
<div onClick={(e)=>{e.stopPropagation();handleBackspace()}}>
|