playbook_ui 14.20.0.pre.alpha.PLAY2178advancedtablerowpinning7978 → 14.20.0.pre.alpha.PLAY2214checkboxhiddeninput8052
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 +79 -89
- data/app/pb_kits/playbook/pb_advanced_table/Hooks/useTableState.ts +4 -1
- data/app/pb_kits/playbook/pb_advanced_table/_advanced_table.scss +8 -0
- data/app/pb_kits/playbook/pb_advanced_table/_advanced_table.tsx +5 -2
- data/app/pb_kits/playbook/pb_advanced_table/index.js +2 -0
- data/app/pb_kits/playbook/pb_checkbox/checkbox.html.erb +4 -11
- data/app/pb_kits/playbook/pb_checkbox/checkbox.rb +28 -7
- data/app/pb_kits/playbook/pb_checkbox/docs/_checkbox_custom.html.erb +1 -0
- data/app/pb_kits/playbook/pb_checkbox/docs/_checkbox_custom_rails.md +1 -0
- data/app/pb_kits/playbook/pb_checkbox/docs/_checkbox_form.html.erb +22 -0
- data/app/pb_kits/playbook/pb_checkbox/docs/_checkbox_form.md +5 -0
- data/app/pb_kits/playbook/pb_checkbox/docs/_checkbox_indeterminate.html.erb +2 -48
- data/app/pb_kits/playbook/pb_checkbox/docs/_checkbox_indeterminate_rails.md +1 -0
- data/app/pb_kits/playbook/pb_checkbox/docs/_checkbox_options.html.erb +1 -0
- data/app/pb_kits/playbook/pb_checkbox/docs/example.yml +1 -0
- data/app/pb_kits/playbook/pb_checkbox/index.js +56 -0
- data/app/pb_kits/playbook/pb_draggable/context/index.tsx +17 -58
- data/app/pb_kits/playbook/pb_dropdown/_dropdown.tsx +12 -3
- data/app/pb_kits/playbook/pb_dropdown/docs/_dropdown_close_on_select.jsx +42 -0
- data/app/pb_kits/playbook/pb_dropdown/docs/_dropdown_close_on_select.md +1 -0
- data/app/pb_kits/playbook/pb_dropdown/docs/example.yml +2 -0
- data/app/pb_kits/playbook/pb_dropdown/docs/index.js +2 -1
- data/app/pb_kits/playbook/pb_dropdown/index.js +24 -0
- data/app/pb_kits/playbook/pb_dropdown/subcomponents/DropdownOption.tsx +14 -10
- data/app/pb_kits/playbook/pb_dropdown/subcomponents/DropdownTrigger.tsx +26 -15
- data/app/pb_kits/playbook/pb_form/docs/_form_form_with_validate.html.erb +1 -1
- data/app/pb_kits/playbook/pb_popover/index.ts +9 -4
- data/app/pb_kits/playbook/pb_table/docs/_table_with_selectable_rows.html.erb +3 -51
- data/app/pb_kits/playbook/pb_table/styles/_mobile_collapse.scss +1 -1
- data/dist/chunks/{_typeahead-CRW6dJbW.js → _typeahead-CoOpeYom.js} +1 -1
- data/dist/chunks/_weekday_stacked-BppvLxTS.js +45 -0
- data/dist/chunks/{lib-D5R1BjUn.js → lib-D7Va7yqa.js} +1 -1
- data/dist/chunks/{pb_form_validation-BZ2AVAi_.js → pb_form_validation-DSkdRDMf.js} +1 -1
- data/dist/chunks/vendor.js +1 -1
- data/dist/menu.yml +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 +13 -6
- data/dist/chunks/_weekday_stacked-yWpUc_c0.js +0 -45
@@ -1,11 +1,11 @@
|
|
1
|
-
import React, { createContext, useReducer, useContext, useEffect, useMemo
|
1
|
+
import React, { createContext, useReducer, useContext, useEffect, useMemo } from "react";
|
2
2
|
import { InitialStateType, ActionType, DraggableProviderType } from "./types";
|
3
3
|
|
4
4
|
const initialState: InitialStateType = {
|
5
5
|
items: [],
|
6
6
|
dragData: { id: "", initialGroup: "" },
|
7
7
|
isDragging: "",
|
8
|
-
activeContainer: ""
|
8
|
+
activeContainer: ""
|
9
9
|
};
|
10
10
|
|
11
11
|
const reducer = (state: InitialStateType, action: ActionType) => {
|
@@ -31,23 +31,9 @@ const reducer = (state: InitialStateType, action: ActionType) => {
|
|
31
31
|
const { dragId, targetId } = action.payload;
|
32
32
|
const newItems = [...state.items];
|
33
33
|
const draggedItem = newItems.find(item => item.id === dragId);
|
34
|
-
const
|
35
|
-
|
36
|
-
if (!draggedItem || !targetItem || draggedItem.container !== targetItem.container) {
|
37
|
-
return state;
|
38
|
-
}
|
39
|
-
|
40
|
-
if (dragId === targetId) {
|
41
|
-
return state;
|
42
|
-
}
|
43
|
-
|
44
|
-
const draggedIndex = newItems.findIndex(item => item.id === dragId);
|
34
|
+
const draggedIndex = newItems.indexOf(draggedItem);
|
45
35
|
const targetIndex = newItems.findIndex(item => item.id === targetId);
|
46
36
|
|
47
|
-
if (draggedIndex === -1 || targetIndex === -1) {
|
48
|
-
return state;
|
49
|
-
}
|
50
|
-
|
51
37
|
newItems.splice(draggedIndex, 1);
|
52
38
|
newItems.splice(targetIndex, 0, draggedItem);
|
53
39
|
|
@@ -62,11 +48,7 @@ const reducer = (state: InitialStateType, action: ActionType) => {
|
|
62
48
|
const DragContext = createContext<any>({});
|
63
49
|
|
64
50
|
export const DraggableContext = () => {
|
65
|
-
|
66
|
-
if (context === undefined) {
|
67
|
-
throw new Error('DraggableContext must be used within a DraggableProvider');
|
68
|
-
}
|
69
|
-
return context;
|
51
|
+
return useContext(DragContext);
|
70
52
|
};
|
71
53
|
|
72
54
|
export const DraggableProvider = ({
|
@@ -81,11 +63,7 @@ export const DraggableProvider = ({
|
|
81
63
|
dropZone = { type: 'ghost', color: 'neutral', direction: 'vertical' }
|
82
64
|
}: DraggableProviderType) => {
|
83
65
|
const [state, dispatch] = useReducer(reducer, initialState);
|
84
|
-
|
85
|
-
// Store initial items in a ref to use if needed (for consistency when needed in future updates)
|
86
|
-
const initialItemsRef = useRef(initialItems);
|
87
|
-
const [isDragging, setIsDragging] = useState(false);
|
88
|
-
|
66
|
+
|
89
67
|
// Parse dropZone prop - handle both string format (backward compatibility) and object format
|
90
68
|
let dropZoneType = 'ghost';
|
91
69
|
let dropZoneColor = 'neutral';
|
@@ -108,64 +86,45 @@ export const DraggableProvider = ({
|
|
108
86
|
|
109
87
|
useEffect(() => {
|
110
88
|
dispatch({ type: 'SET_ITEMS', payload: initialItems });
|
111
|
-
initialItemsRef.current = initialItems;
|
112
89
|
}, [initialItems]);
|
113
90
|
|
114
91
|
useEffect(() => {
|
115
|
-
|
116
|
-
|
117
|
-
}
|
118
|
-
}, [state.items, onReorder]);
|
92
|
+
onReorder(state.items);
|
93
|
+
}, [state.items]);
|
119
94
|
|
120
95
|
const handleDragStart = (id: string, container: string) => {
|
121
|
-
|
122
|
-
dispatch({ type: 'SET_DRAG_DATA', payload: { id, initialGroup: container } });
|
96
|
+
dispatch({ type: 'SET_DRAG_DATA', payload: { id: id, initialGroup: container } });
|
123
97
|
dispatch({ type: 'SET_IS_DRAGGING', payload: id });
|
124
|
-
dispatch({ type: 'SET_ACTIVE_CONTAINER', payload: container });
|
125
98
|
if (onDragStart) onDragStart(id, container);
|
126
99
|
};
|
127
100
|
|
128
101
|
const handleDragEnter = (id: string, container: string) => {
|
129
|
-
if (
|
130
|
-
|
131
|
-
|
132
|
-
|
133
|
-
const draggedItem = state.items.find(item => item.id === state.dragData.id);
|
134
|
-
const targetItem = state.items.find(item => item.id === id);
|
135
|
-
|
136
|
-
if (!draggedItem || !targetItem || draggedItem.container !== targetItem.container) {
|
137
|
-
return;
|
102
|
+
if (state.dragData.id !== id) {
|
103
|
+
dispatch({ type: 'REORDER_ITEMS', payload: { dragId: state.dragData.id, targetId: id } });
|
104
|
+
dispatch({ type: 'SET_DRAG_DATA', payload: { id: state.dragData.id, initialGroup: container } });
|
138
105
|
}
|
139
|
-
|
140
|
-
dispatch({ type: 'REORDER_ITEMS', payload: { dragId: state.dragData.id, targetId: id } });
|
141
|
-
|
142
106
|
if (onDragEnter) onDragEnter(id, container);
|
143
107
|
};
|
144
108
|
|
145
109
|
const handleDragEnd = () => {
|
146
|
-
setIsDragging(false);
|
147
110
|
dispatch({ type: 'SET_IS_DRAGGING', payload: "" });
|
148
111
|
dispatch({ type: 'SET_ACTIVE_CONTAINER', payload: "" });
|
149
112
|
if (onDragEnd) onDragEnd();
|
150
113
|
};
|
151
114
|
|
152
|
-
const
|
153
|
-
|
154
|
-
|
155
|
-
if (draggedItem && draggedItem.container !== container) {
|
156
|
-
dispatch({ type: 'CHANGE_CATEGORY', payload: { itemId: state.dragData.id, container } });
|
157
|
-
}
|
115
|
+
const changeCategory = (itemId: string, container: string) => {
|
116
|
+
dispatch({ type: 'CHANGE_CATEGORY', payload: { itemId, container } });
|
117
|
+
};
|
158
118
|
|
119
|
+
const handleDrop = (container: string) => {
|
159
120
|
dispatch({ type: 'SET_IS_DRAGGING', payload: "" });
|
160
121
|
dispatch({ type: 'SET_ACTIVE_CONTAINER', payload: "" });
|
161
|
-
|
162
|
-
setIsDragging(false);
|
122
|
+
changeCategory(state.dragData.id, container);
|
163
123
|
if (onDrop) onDrop(container);
|
164
124
|
};
|
165
125
|
|
166
126
|
const handleDragOver = (e: Event, container: string) => {
|
167
127
|
e.preventDefault();
|
168
|
-
e.stopPropagation();
|
169
128
|
dispatch({ type: 'SET_ACTIVE_CONTAINER', payload: container });
|
170
129
|
if (onDragOver) onDragOver(e, container);
|
171
130
|
};
|
@@ -185,7 +144,7 @@ export const DraggableProvider = ({
|
|
185
144
|
handleDragEnd,
|
186
145
|
handleDrop,
|
187
146
|
handleDragOver
|
188
|
-
}), [state, dropZoneType, dropZoneColor, dropZoneDirection
|
147
|
+
}), [state, dropZoneType, dropZoneColor, dropZoneDirection]);
|
189
148
|
|
190
149
|
return (
|
191
150
|
<DragContext.Provider value={contextValue}>{children}</DragContext.Provider>
|
@@ -25,6 +25,7 @@ type DropdownProps = {
|
|
25
25
|
blankSelection?: string;
|
26
26
|
children?: React.ReactChild[] | React.ReactChild | React.ReactElement[];
|
27
27
|
className?: string;
|
28
|
+
closeOnSelection?: boolean;
|
28
29
|
formPillProps?: GenericObject;
|
29
30
|
dark?: boolean;
|
30
31
|
data?: { [key: string]: string };
|
@@ -55,6 +56,7 @@ let Dropdown = (props: DropdownProps, ref: any): React.ReactElement | null => {
|
|
55
56
|
blankSelection = '',
|
56
57
|
children,
|
57
58
|
className,
|
59
|
+
closeOnSelection = true,
|
58
60
|
dark = false,
|
59
61
|
data = {},
|
60
62
|
defaultValue = {},
|
@@ -152,7 +154,7 @@ let Dropdown = (props: DropdownProps, ref: any): React.ReactElement | null => {
|
|
152
154
|
if (!multiSelect) return optionsWithBlankSelection;
|
153
155
|
return optionsWithBlankSelection.filter((option: GenericObject) => !selectedArray.some((sel) => sel.label === option.label));
|
154
156
|
}, [optionsWithBlankSelection, selectedArray, multiSelect]);
|
155
|
-
|
157
|
+
|
156
158
|
const filteredOptions = useMemo(() => {
|
157
159
|
return availableOptions.filter((opt: GenericObject) =>
|
158
160
|
String(opt.label).toLowerCase().includes(filterItem.toLowerCase())
|
@@ -192,12 +194,18 @@ let Dropdown = (props: DropdownProps, ref: any): React.ReactElement | null => {
|
|
192
194
|
return next;
|
193
195
|
});
|
194
196
|
setFilterItem("");
|
195
|
-
|
197
|
+
// Only close dropdown if closeOnSelection is true
|
198
|
+
if (closeOnSelection) {
|
199
|
+
setIsDropDownClosed(true);
|
200
|
+
}
|
196
201
|
} else {
|
197
202
|
setSelected(clickedItem);
|
198
203
|
setFilterItem("");
|
199
|
-
setIsDropDownClosed(true);
|
200
204
|
onSelect && onSelect(clickedItem);
|
205
|
+
// Only close dropdown if closeOnSelection is true
|
206
|
+
if (closeOnSelection) {
|
207
|
+
setIsDropDownClosed(true);
|
208
|
+
}
|
201
209
|
}
|
202
210
|
};
|
203
211
|
|
@@ -252,6 +260,7 @@ let Dropdown = (props: DropdownProps, ref: any): React.ReactElement | null => {
|
|
252
260
|
<DropdownContext.Provider
|
253
261
|
value={{
|
254
262
|
autocomplete,
|
263
|
+
closeOnSelection,
|
255
264
|
dropdownContainerRef,
|
256
265
|
filteredOptions,
|
257
266
|
filterItem,
|
@@ -0,0 +1,42 @@
|
|
1
|
+
import React from 'react'
|
2
|
+
import Dropdown from '../../pb_dropdown/_dropdown'
|
3
|
+
|
4
|
+
const DropdownCloseOnSelect = (props) => {
|
5
|
+
|
6
|
+
const options = [
|
7
|
+
{
|
8
|
+
label: "United States",
|
9
|
+
value: "United States",
|
10
|
+
},
|
11
|
+
{
|
12
|
+
label: "Canada",
|
13
|
+
value: "Canada",
|
14
|
+
},
|
15
|
+
{
|
16
|
+
label: "Pakistan",
|
17
|
+
value: "Pakistan",
|
18
|
+
}
|
19
|
+
];
|
20
|
+
|
21
|
+
|
22
|
+
return (
|
23
|
+
<div>
|
24
|
+
<Dropdown
|
25
|
+
closeOnSelection={false}
|
26
|
+
label="Default"
|
27
|
+
options={options}
|
28
|
+
{...props}
|
29
|
+
/>
|
30
|
+
<br />
|
31
|
+
<Dropdown
|
32
|
+
closeOnSelection={false}
|
33
|
+
label="Multi Select"
|
34
|
+
multiSelect
|
35
|
+
options={options}
|
36
|
+
{...props}
|
37
|
+
/>
|
38
|
+
</div>
|
39
|
+
)
|
40
|
+
}
|
41
|
+
|
42
|
+
export default DropdownCloseOnSelect
|
@@ -0,0 +1 @@
|
|
1
|
+
By default, the dropdown menu will close when a selection is made. You can prevent this behavior by using the `closeOnSelection` prop, which will leave the menu open after a selection is made when set to 'false'.
|
@@ -19,4 +19,5 @@ 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'
|
22
|
+
export { default as DropdownMultiSelectWithCustomOptions } from './_dropdown_multi_select_with_custom_options.jsx'
|
23
|
+
export { default as DropdownCloseOnSelect } from './_dropdown_close_on_select.jsx'
|
@@ -115,6 +115,7 @@ export default class PbDropdown extends PbEnhancedElement {
|
|
115
115
|
|
116
116
|
handleSearch(term = "") {
|
117
117
|
const lcTerm = term.toLowerCase();
|
118
|
+
let hasMatch = false
|
118
119
|
this.element.querySelectorAll(OPTION_SELECTOR).forEach((opt) => {
|
119
120
|
//make it so that if the option is selected, it will not show up in the search results
|
120
121
|
if (this.isMultiSelect && this.selectedOptions.has(opt.dataset.dropdownOptionLabel)) {
|
@@ -128,9 +129,32 @@ export default class PbDropdown extends PbEnhancedElement {
|
|
128
129
|
// hide or show option
|
129
130
|
const match = label.includes(lcTerm);
|
130
131
|
opt.style.display = match ? "" : "none";
|
132
|
+
if (match) hasMatch = true
|
131
133
|
});
|
132
134
|
|
133
135
|
this.adjustDropdownHeight();
|
136
|
+
|
137
|
+
this.removeNoOptionsMessage()
|
138
|
+
if (!hasMatch) {
|
139
|
+
this.showNoOptionsMessage()
|
140
|
+
}
|
141
|
+
}
|
142
|
+
|
143
|
+
showNoOptionsMessage() {
|
144
|
+
if (this.element.querySelector(".dropdown_no_options")) return;
|
145
|
+
|
146
|
+
const noOptionElement = document.createElement("div");
|
147
|
+
noOptionElement.className = "pb_body_kit_light dropdown_no_options pb_item_kit p_xs display_flex justify_content_center";
|
148
|
+
noOptionElement.textContent = "no option";
|
149
|
+
|
150
|
+
this.target.appendChild(noOptionElement);
|
151
|
+
}
|
152
|
+
|
153
|
+
removeNoOptionsMessage() {
|
154
|
+
const existing = this.element.querySelector(".dropdown_no_options");
|
155
|
+
if (existing) {
|
156
|
+
existing.remove();
|
157
|
+
}
|
134
158
|
}
|
135
159
|
|
136
160
|
handleOptionClick(event) {
|
@@ -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,16 +56,17 @@ 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
|
-
|
63
62
|
if (!isItemMatchingFilter(option) || (multiSelect && isSelected)) {
|
64
63
|
return null;
|
65
64
|
}
|
65
|
+
|
66
66
|
const isFocused =
|
67
67
|
focusedOptionIndex >= 0 &&
|
68
68
|
filteredOptions[focusedOptionIndex].label === option?.label;
|
69
|
+
|
69
70
|
const focusedClass = isFocused && "focused";
|
70
71
|
|
71
72
|
const selectedClass = isSelected ? "selected" : "list";
|
@@ -91,7 +92,10 @@ const DropdownOption = (props: DropdownOptionProps) => {
|
|
91
92
|
className={classes}
|
92
93
|
id={id}
|
93
94
|
key={key}
|
94
|
-
onClick=
|
95
|
+
onClick={(e) => {
|
96
|
+
e.stopPropagation();
|
97
|
+
handleOptionClick(option);
|
98
|
+
}}
|
95
99
|
>
|
96
100
|
<ListItem
|
97
101
|
cursor="pointer"
|
@@ -100,12 +104,12 @@ const DropdownOption = (props: DropdownOptionProps) => {
|
|
100
104
|
key={option?.label}
|
101
105
|
padding="none"
|
102
106
|
>
|
103
|
-
|
107
|
+
{children ?
|
104
108
|
<div className="dropdown_option_wrapper">{children}</div> :
|
105
|
-
|
106
|
-
|
107
|
-
|
108
|
-
|
109
|
+
<Body dark={dark}
|
110
|
+
text={option?.label}
|
111
|
+
/>
|
112
|
+
}
|
109
113
|
</ListItem>
|
110
114
|
</div>
|
111
115
|
);
|
@@ -44,6 +44,7 @@ const DropdownTrigger = (props: DropdownTriggerProps) => {
|
|
44
44
|
|
45
45
|
const {
|
46
46
|
autocomplete,
|
47
|
+
closeOnSelection,
|
47
48
|
filterItem,
|
48
49
|
handleBackspace,
|
49
50
|
handleChange,
|
@@ -54,6 +55,7 @@ const DropdownTrigger = (props: DropdownTriggerProps) => {
|
|
54
55
|
isInputFocused,
|
55
56
|
multiSelect,
|
56
57
|
selected,
|
58
|
+
setIsDropDownClosed,
|
57
59
|
setIsInputFocused,
|
58
60
|
toggleDropdown,
|
59
61
|
} = useContext(DropdownContext);
|
@@ -103,11 +105,26 @@ const DropdownTrigger = (props: DropdownTriggerProps) => {
|
|
103
105
|
? placeholder
|
104
106
|
: "Select...";
|
105
107
|
|
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
|
+
|
106
123
|
return (
|
107
|
-
<div {...ariaProps}
|
108
|
-
{...dataProps}
|
124
|
+
<div {...ariaProps}
|
125
|
+
{...dataProps}
|
109
126
|
{...htmlProps}
|
110
|
-
className={classes}
|
127
|
+
className={classes}
|
111
128
|
id={id}
|
112
129
|
>
|
113
130
|
{
|
@@ -145,7 +162,7 @@ const DropdownTrigger = (props: DropdownTriggerProps) => {
|
|
145
162
|
{customDisplay ? (
|
146
163
|
<Flex align="center">
|
147
164
|
{customDisplay}
|
148
|
-
<Body dark={dark}
|
165
|
+
<Body dark={dark}
|
149
166
|
paddingLeft={`${joinedLabels ? "xs" : "none"}`}
|
150
167
|
>
|
151
168
|
{customDisplayPlaceholder}
|
@@ -164,10 +181,7 @@ const DropdownTrigger = (props: DropdownTriggerProps) => {
|
|
164
181
|
<input
|
165
182
|
className="dropdown_input"
|
166
183
|
onChange={handleChange}
|
167
|
-
onClick={
|
168
|
-
e.stopPropagation();// keep the wrapper’s handler from firing
|
169
|
-
toggleDropdown();
|
170
|
-
}}
|
184
|
+
onClick={handleInputClick}
|
171
185
|
onFocus={() => setIsInputFocused(true)}
|
172
186
|
onKeyDown={(e) => {
|
173
187
|
handleKeyDown(e);
|
@@ -186,8 +200,8 @@ const DropdownTrigger = (props: DropdownTriggerProps) => {
|
|
186
200
|
)}
|
187
201
|
</>
|
188
202
|
) : (
|
189
|
-
<Body dark={dark}
|
190
|
-
text={defaultDisplayPlaceholder}
|
203
|
+
<Body dark={dark}
|
204
|
+
text={defaultDisplayPlaceholder}
|
191
205
|
/>
|
192
206
|
)
|
193
207
|
)}
|
@@ -195,10 +209,7 @@ const DropdownTrigger = (props: DropdownTriggerProps) => {
|
|
195
209
|
<input
|
196
210
|
className="dropdown_input"
|
197
211
|
onChange={handleChange}
|
198
|
-
onClick={
|
199
|
-
e.stopPropagation();// keep the wrapper’s handler from firing
|
200
|
-
toggleDropdown();
|
201
|
-
}}
|
212
|
+
onClick={handleInputClick}
|
202
213
|
onFocus={() => setIsInputFocused(true)}
|
203
214
|
onKeyDown={handleKeyDown}
|
204
215
|
placeholder={
|
@@ -223,7 +234,7 @@ const DropdownTrigger = (props: DropdownTriggerProps) => {
|
|
223
234
|
onClick: (e: Event) => {e.stopPropagation();handleWrapperClick()}
|
224
235
|
}}
|
225
236
|
key={`${isDropDownClosed ? "chevron-down" : "chevron-up"}`}
|
226
|
-
>
|
237
|
+
>
|
227
238
|
{
|
228
239
|
selectedArray.length > 0 && (
|
229
240
|
<div onClick={(e)=>{e.stopPropagation();handleBackspace()}}>
|
@@ -101,7 +101,7 @@
|
|
101
101
|
<%= form.dropdown_field :example_dropdown_validation_multi, props: { label: true, options: example_dropdown_options, multi_select: true, required: true } %>
|
102
102
|
<%= form.select :example_select_validation, [ ["Yes", 1], ["No", 2] ], props: { label: true, blank_selection: "Select One...", required: true, validation_message: "Please, select an option." } %>
|
103
103
|
<%= form.collection_select :example_collection_select_validation, example_collection, :value, :name, props: { label: true, blank_selection: "Select One...", required: true } %>
|
104
|
-
<%= form.check_box :
|
104
|
+
<%= form.check_box :example_checkbox_validation, props: { text: "Example Checkbox Validation", label: true, required: true }, checked_value: "1", unchecked_value: "0" %>
|
105
105
|
<%= form.date_picker :example_date_picker_2, props: { label: true, required: true, validation_message: "Please, select a date.", allow_input: true } %>
|
106
106
|
<%= form.star_rating_field :example_star_rating_validation, props: { variant: "interactive", label: true, required: true } %>
|
107
107
|
<%= form.time_zone_select_field :example_time_zone_select, ActiveSupport::TimeZone.us_zones, { default: "Eastern Time (US & Canada)" }, props: { label: true, blank_selection: "Select a Time Zone...", required: true } %>
|
@@ -13,19 +13,24 @@ export default class PbPopover extends PbEnhancedElement {
|
|
13
13
|
}
|
14
14
|
|
15
15
|
moveTooltip() {
|
16
|
-
let container: HTMLElement | null;
|
16
|
+
let container: HTMLElement | null = document.querySelector('body');
|
17
17
|
|
18
18
|
if (this.appendTo === "parent") {
|
19
|
-
container = this.element.parentElement
|
19
|
+
container = this.element.parentElement && this.element.parentElement
|
20
20
|
} else if (this.appendTo) {
|
21
|
-
container = document.querySelector(this.appendTo)
|
21
|
+
container = document.querySelector(this.appendTo)
|
22
22
|
}
|
23
23
|
|
24
|
-
|
24
|
+
container.appendChild(this.tooltip);
|
25
25
|
}
|
26
26
|
|
27
27
|
connect() {
|
28
|
+
if (!this.triggerElement || !this.tooltip) {
|
29
|
+
console.warn('Popover requires both trigger and tooltip elements to be defined.')
|
30
|
+
return
|
31
|
+
}
|
28
32
|
this.moveTooltip()
|
33
|
+
|
29
34
|
this.popper = createPopper (this.triggerElement, this.tooltip, {
|
30
35
|
placement: this.position as Placement,
|
31
36
|
strategy: 'fixed',
|
@@ -18,7 +18,7 @@
|
|
18
18
|
checked: true,
|
19
19
|
value: "checkbox-value",
|
20
20
|
name: "main-checkbox-selectable",
|
21
|
-
|
21
|
+
indeterminate_main: true,
|
22
22
|
id: "checkbox-selectable"
|
23
23
|
}) %>
|
24
24
|
<% end %>
|
@@ -33,7 +33,7 @@
|
|
33
33
|
<% checkboxes.each_with_index do |checkbox, index| %>
|
34
34
|
<%= pb_rails("table/table_row") do %>
|
35
35
|
<%= pb_rails("table/table_cell") do %>
|
36
|
-
<%= pb_rails("checkbox", props: { checked: checkbox[:checked], id: "#{checkbox[:id]}-selectable-checkbox", name: "#{checkbox[:id]}-selectable-checkbox", on_change: "updateCheckboxes(#{index})", value: "check-box value" }) %>
|
36
|
+
<%= pb_rails("checkbox", props: { checked: checkbox[:checked], id: "#{checkbox[:id]}-selectable-checkbox", name: "#{checkbox[:id]}-selectable-checkbox", on_change: "updateCheckboxes(#{index})", value: "check-box value", indeterminate_parent: "checkbox-selectable" }) %>
|
37
37
|
<% end %>
|
38
38
|
<%= pb_rails("table/table_cell") do %>
|
39
39
|
<%= pb_rails("image", props: { alt: "picture of a misty forest", size: "xs", url: "https://unsplash.it/500/400/?image=634" }) %>
|
@@ -45,52 +45,4 @@
|
|
45
45
|
<% end %>
|
46
46
|
<% end %>
|
47
47
|
<% end %>
|
48
|
-
<% end %>
|
49
|
-
|
50
|
-
<script>
|
51
|
-
document.addEventListener('DOMContentLoaded', function() {
|
52
|
-
const mainCheckboxWrapper = document.getElementById('checkbox-selectable');
|
53
|
-
const mainCheckbox = document.getElementsByName("main-checkbox-selectable")[0];
|
54
|
-
const childCheckboxes = document.querySelectorAll('input[type="checkbox"][id$="selectable-checkbox"]');
|
55
|
-
const deleteButton = document.getElementById('delete-button');
|
56
|
-
|
57
|
-
const updateDeleteButton = () => {
|
58
|
-
const anyChecked = Array.from(childCheckboxes).some(checkbox => checkbox.checked);
|
59
|
-
deleteButton.style.display = anyChecked ? 'block' : 'none';
|
60
|
-
};
|
61
|
-
|
62
|
-
const updateMainCheckbox = () => {
|
63
|
-
// Count the number of checked child checkboxes
|
64
|
-
const checkedCount = Array.from(childCheckboxes).filter(cb => cb.checked).length;
|
65
|
-
// Determine if the main checkbox should be in an indeterminate state
|
66
|
-
const indeterminate = checkedCount > 0 && checkedCount < childCheckboxes.length;
|
67
|
-
|
68
|
-
// Set the main checkbox states
|
69
|
-
mainCheckbox.indeterminate = indeterminate;
|
70
|
-
mainCheckbox.checked = checkedCount > 0;
|
71
|
-
|
72
|
-
// Determine the icon class to add and remove based on the number of checked checkboxes
|
73
|
-
const iconClassToAdd = checkedCount === 0 ? 'pb_checkbox_checkmark' : 'pb_checkbox_indeterminate';
|
74
|
-
const iconClassToRemove = checkedCount === 0 ? 'pb_checkbox_indeterminate' : 'pb_checkbox_checkmark';
|
75
|
-
|
76
|
-
// Add and remove the icon class to the main checkbox wrapper
|
77
|
-
mainCheckboxWrapper.querySelector('[data-pb-checkbox-icon-span]').classList.add(iconClassToAdd);
|
78
|
-
mainCheckboxWrapper.querySelector('[data-pb-checkbox-icon-span]').classList.remove(iconClassToRemove);
|
79
|
-
|
80
|
-
// Toggle the visibility of the checkbox icon based on the indeterminate state
|
81
|
-
mainCheckboxWrapper.getElementsByClassName("indeterminate_icon")[0].classList.toggle('hidden', !indeterminate);
|
82
|
-
mainCheckboxWrapper.getElementsByClassName("check_icon")[0].classList.toggle('hidden', indeterminate);
|
83
|
-
|
84
|
-
updateDeleteButton();
|
85
|
-
};
|
86
|
-
|
87
|
-
mainCheckbox.addEventListener('change', function() {
|
88
|
-
childCheckboxes.forEach(cb => cb.checked = this.checked);
|
89
|
-
updateMainCheckbox();
|
90
|
-
});
|
91
|
-
|
92
|
-
childCheckboxes.forEach(cb => {
|
93
|
-
cb.addEventListener('change', updateMainCheckbox);
|
94
|
-
});
|
95
|
-
});
|
96
|
-
</script>
|
48
|
+
<% end %>
|
@@ -3,7 +3,7 @@
|
|
3
3
|
@import "../../pb_caption/caption_mixin";
|
4
4
|
|
5
5
|
@media only screen and (max-width: $screen-xs-max) {
|
6
|
-
[class^=pb_table] {
|
6
|
+
[class^=pb_table]:not(.table-responsive-scroll) {
|
7
7
|
&.table-sm.table-collapse-sm,
|
8
8
|
&.table-md.table-collapse-sm,
|
9
9
|
&.table-lg.table-collapse-sm {
|
@@ -1,4 +1,4 @@
|
|
1
|
-
import{jsx as jsx$1,Fragment,jsxs}from"react/jsx-runtime";import*as React from"react";import React__default,{createContext,useReducer,
|
1
|
+
import{jsx as jsx$1,Fragment,jsxs}from"react/jsx-runtime";import*as React from"react";import React__default,{createContext,useReducer,useEffect,useMemo,useContext,createElement,useRef,forwardRef,useState,useLayoutEffect,useCallback,useImperativeHandle,Component,Fragment as Fragment$1}from"react";import{t as getDefaultExportFromCjs,w as filter,x as omit,r as noop$2,u as useCollapsible,y as createPopper,z as uniqueId,A as get,B as offset$2,C as shift$2,E as flip$2,F as computePosition$1,G as arrow$3,H as createCoords$1,I as round$1,J as max$1,K as min$1,L as rectToClientRect$1,j as getAllIcons,v as commonjsGlobal,s as colors$1,M as highchartsTheme,N as merge,O as highchartsDarkTheme,Q as getAugmentedNamespace,S as typography,T as cloneDeep,m as isEmpty$1,U as isString}from"./lib-D7Va7yqa.js";import*as ReactDOM from"react-dom";import ReactDOM__default,{createPortal}from"react-dom";import{TrixEditor}from"react-trix";import Trix from"trix";import require$$0 from"react-is";const initialState={items:[],dragData:{id:"",initialGroup:""},isDragging:"",activeContainer:""};const reducer=(state,action)=>{switch(action.type){case"SET_ITEMS":return{...state,items:action.payload};case"SET_DRAG_DATA":return{...state,dragData:action.payload};case"SET_IS_DRAGGING":return{...state,isDragging:action.payload};case"SET_ACTIVE_CONTAINER":return{...state,activeContainer:action.payload};case"CHANGE_CATEGORY":return{...state,items:state.items.map((item=>item.id===action.payload.itemId?{...item,container:action.payload.container}:item))};case"REORDER_ITEMS":{const{dragId:dragId,targetId:targetId}=action.payload;const newItems=[...state.items];const draggedItem=newItems.find((item=>item.id===dragId));const draggedIndex=newItems.indexOf(draggedItem);const targetIndex=newItems.findIndex((item=>item.id===targetId));newItems.splice(draggedIndex,1);newItems.splice(targetIndex,0,draggedItem);return{...state,items:newItems}}default:return state}};const DragContext=createContext({});const DraggableContext=()=>useContext(DragContext);const DraggableProvider=({children:children,initialItems:initialItems,onReorder:onReorder,onDragStart:onDragStart,onDragEnter:onDragEnter,onDragEnd:onDragEnd,onDrop:onDrop,onDragOver:onDragOver,dropZone:dropZone={type:"ghost",color:"neutral",direction:"vertical"}})=>{const[state,dispatch]=useReducer(reducer,initialState);let dropZoneType="ghost";let dropZoneColor="neutral";let dropZoneDirection="vertical";if(typeof dropZone==="string"){dropZoneType=dropZone}else{dropZoneType=dropZone.type||"ghost";dropZoneColor=dropZone.type==="line"?dropZone.color||"primary":dropZone.color||"neutral";if(dropZoneType==="line"){dropZoneDirection=dropZone.direction||"vertical"}}useEffect((()=>{dispatch({type:"SET_ITEMS",payload:initialItems})}),[initialItems]);useEffect((()=>{onReorder(state.items)}),[state.items]);const handleDragStart=(id,container)=>{dispatch({type:"SET_DRAG_DATA",payload:{id:id,initialGroup:container}});dispatch({type:"SET_IS_DRAGGING",payload:id});if(onDragStart)onDragStart(id,container)};const handleDragEnter=(id,container)=>{if(state.dragData.id!==id){dispatch({type:"REORDER_ITEMS",payload:{dragId:state.dragData.id,targetId:id}});dispatch({type:"SET_DRAG_DATA",payload:{id:state.dragData.id,initialGroup:container}})}if(onDragEnter)onDragEnter(id,container)};const handleDragEnd=()=>{dispatch({type:"SET_IS_DRAGGING",payload:""});dispatch({type:"SET_ACTIVE_CONTAINER",payload:""});if(onDragEnd)onDragEnd()};const changeCategory=(itemId,container)=>{dispatch({type:"CHANGE_CATEGORY",payload:{itemId:itemId,container:container}})};const handleDrop=container=>{dispatch({type:"SET_IS_DRAGGING",payload:""});dispatch({type:"SET_ACTIVE_CONTAINER",payload:""});changeCategory(state.dragData.id,container);if(onDrop)onDrop(container)};const handleDragOver=(e,container)=>{e.preventDefault();dispatch({type:"SET_ACTIVE_CONTAINER",payload:container});if(onDragOver)onDragOver(e,container)};const contextValue=useMemo((()=>({items:state.items,dragData:state.dragData,isDragging:state.isDragging,activeContainer:state.activeContainer,dropZone:dropZoneType,dropZoneColor:dropZoneColor,...dropZoneType==="line"?{direction:dropZoneDirection}:{},handleDragStart:handleDragStart,handleDragEnter:handleDragEnter,handleDragEnd:handleDragEnd,handleDrop:handleDrop,handleDragOver:handleDragOver})),[state,dropZoneType,dropZoneColor,dropZoneDirection]);return jsx$1(DragContext.Provider,{value:contextValue,children:children})};var classnames$1={exports:{}};
|
2
2
|
/*!
|
3
3
|
Copyright (c) 2018 Jed Watson.
|
4
4
|
Licensed under the MIT License (MIT), see
|