playbook_ui 15.6.0.pre.alpha.PLAY2686contactkittextonly13049 → 15.6.0.pre.alpha.draggableask12898
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_card/docs/_card_header.md +1 -1
- data/app/pb_kits/playbook/pb_card/docs/_card_highlight.md +1 -1
- data/app/pb_kits/playbook/pb_collapsible/__snapshots__/collapsible.test.js.snap +2 -2
- data/app/pb_kits/playbook/pb_collapsible/child_kits/CollapsibleIcon.tsx +8 -10
- data/app/pb_kits/playbook/pb_collapsible/docs/_collapsible_icons.jsx +1 -0
- data/app/pb_kits/playbook/pb_collapsible/docs/_collapsible_state.jsx +3 -0
- data/app/pb_kits/playbook/pb_contact/_contact.tsx +24 -51
- data/app/pb_kits/playbook/pb_contact/contact.html.erb +19 -53
- data/app/pb_kits/playbook/pb_contact/contact.rb +1 -11
- data/app/pb_kits/playbook/pb_contact/contact.test.js +0 -76
- data/app/pb_kits/playbook/pb_contact/docs/example.yml +0 -2
- data/app/pb_kits/playbook/pb_contact/docs/index.js +0 -1
- data/app/pb_kits/playbook/pb_date_picker/date_picker.test.js +0 -24
- data/app/pb_kits/playbook/pb_date_picker/date_picker_helper.ts +3 -181
- data/app/pb_kits/playbook/pb_distribution_bar/docs/_distribution_bar_custom_colors.md +1 -1
- data/app/pb_kits/playbook/pb_draggable/context/index.tsx +88 -91
- data/app/pb_kits/playbook/pb_draggable/context/types.ts +1 -1
- data/app/pb_kits/playbook/pb_filter/Filter/FilterBackground.tsx +3 -3
- data/app/pb_kits/playbook/pb_radio/docs/_radio_error.md +1 -1
- data/app/pb_kits/playbook/pb_select/_select.tsx +3 -8
- data/app/pb_kits/playbook/pb_select/docs/_select_error.md +1 -1
- data/app/pb_kits/playbook/pb_select/docs/example.yml +0 -2
- data/app/pb_kits/playbook/pb_select/docs/index.js +0 -1
- data/app/pb_kits/playbook/pb_select/select.html.erb +2 -2
- data/app/pb_kits/playbook/pb_select/select.rb +1 -3
- data/app/pb_kits/playbook/pb_select/select.test.js +0 -23
- data/app/pb_kits/playbook/pb_table/_table.tsx +33 -187
- data/app/pb_kits/playbook/pb_table/docs/example.yml +0 -4
- data/app/pb_kits/playbook/pb_table/docs/index.js +0 -2
- data/app/pb_kits/playbook/pb_table/table.html.erb +12 -68
- data/app/pb_kits/playbook/pb_table/table.rb +3 -22
- data/app/pb_kits/playbook/pb_table/table.test.js +0 -143
- data/app/pb_kits/playbook/pb_text_input/docs/_text_input_error.md +1 -1
- data/app/pb_kits/playbook/pb_textarea/docs/_textarea_error.md +1 -1
- data/app/pb_kits/playbook/pb_timeline/_item.tsx +0 -3
- data/app/pb_kits/playbook/pb_timeline/docs/_timeline_with_date.md +1 -1
- data/app/pb_kits/playbook/pb_timeline/docs/example.yml +0 -2
- data/app/pb_kits/playbook/pb_timeline/docs/index.js +0 -1
- data/app/pb_kits/playbook/pb_timeline/item.html.erb +1 -1
- data/app/pb_kits/playbook/pb_timeline/item.rb +0 -2
- data/app/pb_kits/playbook/pb_timeline/label.html.erb +1 -2
- data/app/pb_kits/playbook/pb_timeline/label.rb +0 -2
- data/app/pb_kits/playbook/pb_timeline/subcomponents/Label.tsx +0 -3
- data/app/pb_kits/playbook/pb_timeline/timeline.test.js +0 -51
- data/app/pb_kits/playbook/tokens/_colors.scss +1 -2
- data/dist/chunks/_typeahead-319r1pyq.js +6 -0
- data/dist/chunks/lib-CgpqUb6l.js +29 -0
- 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/collection_select_field.rb +1 -9
- data/lib/playbook/forms/builder/select_field.rb +1 -9
- data/lib/playbook/forms/builder/time_zone_select_field.rb +1 -9
- data/lib/playbook/pb_kit_helper.rb +0 -35
- data/lib/playbook/version.rb +1 -1
- metadata +4 -23
- data/app/pb_kits/playbook/pb_contact/docs/_contact_unstyled.html.erb +0 -33
- data/app/pb_kits/playbook/pb_contact/docs/_contact_unstyled.jsx +0 -46
- data/app/pb_kits/playbook/pb_contact/docs/_contact_unstyled_rails.md +0 -2
- data/app/pb_kits/playbook/pb_contact/docs/_contact_unstyled_react.md +0 -2
- data/app/pb_kits/playbook/pb_select/docs/_select_input_options.html.erb +0 -16
- data/app/pb_kits/playbook/pb_select/docs/_select_input_options.jsx +0 -30
- data/app/pb_kits/playbook/pb_select/docs/_select_input_options.md +0 -1
- data/app/pb_kits/playbook/pb_table/docs/_table_with_filter_variant.jsx +0 -134
- data/app/pb_kits/playbook/pb_table/docs/_table_with_filter_variant.md +0 -34
- data/app/pb_kits/playbook/pb_table/docs/_table_with_filter_variant_rails.html.erb +0 -101
- data/app/pb_kits/playbook/pb_table/docs/_table_with_filter_variant_rails.md +0 -33
- data/app/pb_kits/playbook/pb_table/docs/_table_with_filter_variant_with_pagination.jsx +0 -180
- data/app/pb_kits/playbook/pb_table/docs/_table_with_filter_variant_with_pagination.md +0 -3
- data/app/pb_kits/playbook/pb_table/docs/_table_with_filter_variant_with_pagination_rails.html.erb +0 -122
- data/app/pb_kits/playbook/pb_table/docs/_table_with_filter_variant_with_pagination_rails.md +0 -3
- data/app/pb_kits/playbook/pb_timeline/docs/_timeline_show_current_year.html.erb +0 -60
- data/app/pb_kits/playbook/pb_timeline/docs/_timeline_show_current_year.jsx +0 -118
- data/app/pb_kits/playbook/pb_timeline/docs/_timeline_show_current_year.md +0 -1
- data/app/pb_kits/playbook/utilities/deprecated.ts +0 -73
- data/dist/chunks/_typeahead-CHwm9MTE.js +0 -6
- data/dist/chunks/lib-Cugvy62C.js +0 -29
|
@@ -1 +1 @@
|
|
|
1
|
-
You can customize the order of the colors you would like to use by using the `colors` prop. Only the data and status colors will work for Playbook charts. See the [design page](https://playbook.powerapp.cloud/
|
|
1
|
+
You can customize the order of the colors you would like to use by using the `colors` prop. Only the data and status colors will work for Playbook charts. See the [design page](https://playbook.powerapp.cloud/token/colors) for reference.
|
|
@@ -92,32 +92,16 @@ const reducer = (state: InitialStateType, action: ActionType) => {
|
|
|
92
92
|
return { ...state, items: newItems };
|
|
93
93
|
}
|
|
94
94
|
|
|
95
|
-
// Reset item back to its original container
|
|
95
|
+
// Reset item back to its original container (e.g., when drag ends without valid drop)
|
|
96
96
|
case "RESET_DRAG_CONTAINER": {
|
|
97
|
-
const { itemId, originalContainer
|
|
98
|
-
const newItems = [...state.items];
|
|
99
|
-
const draggedItem = newItems.find(item => item && item.id === itemId);
|
|
100
|
-
|
|
101
|
-
if (!draggedItem) return state;
|
|
102
|
-
|
|
103
|
-
const currentIndex = newItems.indexOf(draggedItem);
|
|
104
|
-
|
|
105
|
-
// Remove from current position
|
|
106
|
-
newItems.splice(currentIndex, 1);
|
|
107
|
-
|
|
108
|
-
// Restore container property and insert at original index
|
|
109
|
-
const restoredItem = { ...draggedItem, container: originalContainer };
|
|
110
|
-
|
|
111
|
-
// Insert at original index, or at end if index is invalid
|
|
112
|
-
if (originalIndex !== undefined && originalIndex >= 0) {
|
|
113
|
-
newItems.splice(originalIndex, 0, restoredItem);
|
|
114
|
-
} else {
|
|
115
|
-
newItems.push(restoredItem);
|
|
116
|
-
}
|
|
117
|
-
|
|
97
|
+
const { itemId, originalContainer } = action.payload;
|
|
118
98
|
return {
|
|
119
99
|
...state,
|
|
120
|
-
items:
|
|
100
|
+
items: state.items.map(item =>
|
|
101
|
+
item.id === itemId
|
|
102
|
+
? { ...item, container: originalContainer }
|
|
103
|
+
: item
|
|
104
|
+
)
|
|
121
105
|
};
|
|
122
106
|
}
|
|
123
107
|
|
|
@@ -154,14 +138,12 @@ export const DraggableProvider = ({
|
|
|
154
138
|
isDragging: boolean;
|
|
155
139
|
draggedItemId: string;
|
|
156
140
|
originalContainer: string;
|
|
157
|
-
originalIndex: number;
|
|
158
141
|
currentContainer: string;
|
|
159
142
|
dropOccurred: boolean;
|
|
160
143
|
}>({
|
|
161
144
|
isDragging: false,
|
|
162
145
|
draggedItemId: '',
|
|
163
146
|
originalContainer: '',
|
|
164
|
-
originalIndex: -1,
|
|
165
147
|
currentContainer: '',
|
|
166
148
|
dropOccurred: false,
|
|
167
149
|
});
|
|
@@ -220,33 +202,87 @@ export const DraggableProvider = ({
|
|
|
220
202
|
|
|
221
203
|
e.preventDefault();
|
|
222
204
|
|
|
223
|
-
|
|
224
|
-
// (otherwise the container's handleDrop would have set dropOccurred = true)
|
|
225
|
-
// So we should ALWAYS reset to original container for invalid drops
|
|
226
|
-
const originalContainer = dragStateRef.current.originalContainer;
|
|
227
|
-
|
|
228
|
-
dispatch({
|
|
229
|
-
type: 'RESET_DRAG_CONTAINER',
|
|
230
|
-
payload: {
|
|
231
|
-
itemId: dragStateRef.current.draggedItemId,
|
|
232
|
-
originalContainer: originalContainer,
|
|
233
|
-
originalIndex: dragStateRef.current.originalIndex,
|
|
234
|
-
},
|
|
235
|
-
});
|
|
205
|
+
const currentContainer = dragStateRef.current.currentContainer;
|
|
236
206
|
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
207
|
+
// If item is in a different container than original, treat it as a successful drop
|
|
208
|
+
if (currentContainer && currentContainer !== dragStateRef.current.originalContainer) {
|
|
209
|
+
|
|
210
|
+
// Mark as dropped so other handlers know
|
|
211
|
+
dragStateRef.current.dropOccurred = true;
|
|
212
|
+
|
|
213
|
+
// Trigger onDrop callback with the current container
|
|
214
|
+
if (onDrop) {
|
|
215
|
+
const draggedItem = stateRef.current.items.find(item => item && item.id === dragStateRef.current.draggedItemId);
|
|
216
|
+
const updatedItem = draggedItem ? { ...draggedItem, container: currentContainer } : null;
|
|
217
|
+
const itemsInContainer = stateRef.current.items.filter(item => item && item.container === currentContainer);
|
|
218
|
+
const indexInContainer = itemsInContainer.findIndex(item => item && item.id === dragStateRef.current.draggedItemId);
|
|
219
|
+
const itemAbove = indexInContainer > 0 ? itemsInContainer[indexInContainer - 1] : null;
|
|
220
|
+
const itemBelow = indexInContainer < itemsInContainer.length - 1 ? itemsInContainer[indexInContainer + 1] : null;
|
|
221
|
+
|
|
222
|
+
onDrop(
|
|
223
|
+
dragStateRef.current.draggedItemId,
|
|
224
|
+
currentContainer,
|
|
225
|
+
dragStateRef.current.originalContainer,
|
|
226
|
+
updatedItem,
|
|
227
|
+
itemAbove,
|
|
228
|
+
itemBelow
|
|
229
|
+
);
|
|
230
|
+
}
|
|
231
|
+
|
|
232
|
+
// Trigger onDragEnd callback
|
|
233
|
+
if (onDragEnd) {
|
|
234
|
+
const itemsInContainer = stateRef.current.items.filter(item => item && item.container === currentContainer);
|
|
235
|
+
const indexInContainer = itemsInContainer.findIndex(item => item && item.id === dragStateRef.current.draggedItemId);
|
|
236
|
+
const itemAbove = indexInContainer > 0 ? itemsInContainer[indexInContainer - 1] : null;
|
|
237
|
+
const itemBelow = indexInContainer < itemsInContainer.length - 1 ? itemsInContainer[indexInContainer + 1] : null;
|
|
238
|
+
|
|
239
|
+
onDragEnd(
|
|
240
|
+
dragStateRef.current.draggedItemId,
|
|
241
|
+
currentContainer,
|
|
242
|
+
dragStateRef.current.originalContainer,
|
|
243
|
+
itemAbove,
|
|
244
|
+
itemBelow
|
|
245
|
+
);
|
|
246
|
+
}
|
|
247
|
+
|
|
248
|
+
dispatch({ type: 'SET_IS_DRAGGING', payload: "" });
|
|
249
|
+
dispatch({ type: 'SET_ACTIVE_CONTAINER', payload: "" });
|
|
250
|
+
dispatch({ type: 'SET_DRAG_DATA', payload: { id: "", initialGroup: "", originId: "" } });
|
|
251
|
+
} else {
|
|
252
|
+
// Reset to original container (item didn't move or dropped in invalid zone)
|
|
253
|
+
const originalContainer = dragStateRef.current.originalContainer;
|
|
254
|
+
|
|
255
|
+
dispatch({
|
|
256
|
+
type: 'RESET_DRAG_CONTAINER',
|
|
257
|
+
payload: {
|
|
258
|
+
itemId: dragStateRef.current.draggedItemId,
|
|
259
|
+
originalContainer: originalContainer,
|
|
260
|
+
},
|
|
261
|
+
});
|
|
262
|
+
|
|
263
|
+
// Call onDrop with original container info
|
|
264
|
+
if (onDrop) {
|
|
265
|
+
const draggedItem = stateRef.current.items.find(item => item && item.id === dragStateRef.current.draggedItemId);
|
|
266
|
+
const updatedItem = draggedItem ? { ...draggedItem, container: originalContainer } : null;
|
|
267
|
+
const itemsInContainer = stateRef.current.items.filter(item => item && item.container === originalContainer);
|
|
268
|
+
const indexInContainer = itemsInContainer.findIndex(item => item && item.id === dragStateRef.current.draggedItemId);
|
|
269
|
+
const itemAbove = indexInContainer > 0 ? itemsInContainer[indexInContainer - 1] : null;
|
|
270
|
+
const itemBelow = indexInContainer < itemsInContainer.length - 1 ? itemsInContainer[indexInContainer + 1] : null;
|
|
271
|
+
|
|
272
|
+
onDrop(
|
|
273
|
+
dragStateRef.current.draggedItemId,
|
|
274
|
+
originalContainer,
|
|
275
|
+
originalContainer,
|
|
276
|
+
updatedItem,
|
|
277
|
+
itemAbove,
|
|
278
|
+
itemBelow
|
|
279
|
+
);
|
|
280
|
+
}
|
|
281
|
+
|
|
282
|
+
dispatch({ type: 'SET_IS_DRAGGING', payload: "" });
|
|
283
|
+
dispatch({ type: 'SET_ACTIVE_CONTAINER', payload: "" });
|
|
284
|
+
dispatch({ type: 'SET_DRAG_DATA', payload: { id: "", initialGroup: "", originId: "" } });
|
|
285
|
+
}
|
|
250
286
|
};
|
|
251
287
|
|
|
252
288
|
const handleGlobalMouseUp = () => {
|
|
@@ -283,7 +319,6 @@ export const DraggableProvider = ({
|
|
|
283
319
|
payload: {
|
|
284
320
|
itemId: dragStateRef.current.draggedItemId,
|
|
285
321
|
originalContainer: dragStateRef.current.originalContainer,
|
|
286
|
-
originalIndex: dragStateRef.current.originalIndex,
|
|
287
322
|
},
|
|
288
323
|
});
|
|
289
324
|
}
|
|
@@ -296,7 +331,6 @@ export const DraggableProvider = ({
|
|
|
296
331
|
isDragging: false,
|
|
297
332
|
draggedItemId: '',
|
|
298
333
|
originalContainer: '',
|
|
299
|
-
originalIndex: -1,
|
|
300
334
|
currentContainer: '',
|
|
301
335
|
dropOccurred: false,
|
|
302
336
|
};
|
|
@@ -305,45 +339,14 @@ export const DraggableProvider = ({
|
|
|
305
339
|
}
|
|
306
340
|
};
|
|
307
341
|
|
|
308
|
-
// Detect when drag leaves document boundaries
|
|
309
|
-
const handleDragLeave = (e: DragEvent) => {
|
|
310
|
-
// Check if we're leaving the document (relatedTarget will be null)
|
|
311
|
-
if (!e.relatedTarget && dragStateRef.current.isDragging && !dragStateRef.current.dropOccurred) {
|
|
312
|
-
// Drag left the document: reset to original container immediately
|
|
313
|
-
dispatch({
|
|
314
|
-
type: 'RESET_DRAG_CONTAINER',
|
|
315
|
-
payload: {
|
|
316
|
-
itemId: dragStateRef.current.draggedItemId,
|
|
317
|
-
originalContainer: dragStateRef.current.originalContainer,
|
|
318
|
-
originalIndex: dragStateRef.current.originalIndex,
|
|
319
|
-
},
|
|
320
|
-
});
|
|
321
|
-
dispatch({ type: 'SET_IS_DRAGGING', payload: "" });
|
|
322
|
-
dispatch({ type: 'SET_ACTIVE_CONTAINER', payload: "" });
|
|
323
|
-
dispatch({ type: 'SET_DRAG_DATA', payload: { id: "", initialGroup: "", originId: "" } });
|
|
324
|
-
|
|
325
|
-
// Clear drag state
|
|
326
|
-
dragStateRef.current = {
|
|
327
|
-
isDragging: false,
|
|
328
|
-
draggedItemId: '',
|
|
329
|
-
originalContainer: '',
|
|
330
|
-
originalIndex: -1,
|
|
331
|
-
currentContainer: '',
|
|
332
|
-
dropOccurred: false,
|
|
333
|
-
};
|
|
334
|
-
}
|
|
335
|
-
};
|
|
336
|
-
|
|
337
342
|
document.addEventListener('dragover', handleGlobalDragOver);
|
|
338
343
|
document.addEventListener('drop', handleGlobalDrop);
|
|
339
|
-
document.addEventListener('dragleave', handleDragLeave);
|
|
340
344
|
document.addEventListener('mouseup', handleGlobalMouseUp);
|
|
341
345
|
document.addEventListener('pointerup', handleGlobalMouseUp);
|
|
342
346
|
|
|
343
347
|
return () => {
|
|
344
348
|
document.removeEventListener('dragover', handleGlobalDragOver);
|
|
345
349
|
document.removeEventListener('drop', handleGlobalDrop);
|
|
346
|
-
document.removeEventListener('dragleave', handleDragLeave);
|
|
347
350
|
document.removeEventListener('mouseup', handleGlobalMouseUp);
|
|
348
351
|
document.removeEventListener('pointerup', handleGlobalMouseUp);
|
|
349
352
|
};
|
|
@@ -368,7 +371,6 @@ export const DraggableProvider = ({
|
|
|
368
371
|
payload: {
|
|
369
372
|
itemId: dragStateRef.current.draggedItemId,
|
|
370
373
|
originalContainer: dragStateRef.current.originalContainer,
|
|
371
|
-
originalIndex: dragStateRef.current.originalIndex,
|
|
372
374
|
},
|
|
373
375
|
});
|
|
374
376
|
}
|
|
@@ -378,7 +380,6 @@ export const DraggableProvider = ({
|
|
|
378
380
|
isDragging: false,
|
|
379
381
|
draggedItemId: '',
|
|
380
382
|
originalContainer: '',
|
|
381
|
-
originalIndex: -1,
|
|
382
383
|
currentContainer: '',
|
|
383
384
|
dropOccurred: false,
|
|
384
385
|
};
|
|
@@ -390,14 +391,10 @@ export const DraggableProvider = ({
|
|
|
390
391
|
const handleDragStart = (id: string, container: string) => {
|
|
391
392
|
// Track drag in ref for global listener
|
|
392
393
|
if (enableCrossContainerPreview) {
|
|
393
|
-
// Find the original index of the item
|
|
394
|
-
const originalIndex = state.items.findIndex(item => item && item.id === id);
|
|
395
|
-
|
|
396
394
|
dragStateRef.current = {
|
|
397
395
|
isDragging: true,
|
|
398
396
|
draggedItemId: id,
|
|
399
397
|
originalContainer: container,
|
|
400
|
-
originalIndex: originalIndex,
|
|
401
398
|
currentContainer: container,
|
|
402
399
|
dropOccurred: false,
|
|
403
400
|
};
|
|
@@ -465,7 +462,7 @@ export const DraggableProvider = ({
|
|
|
465
462
|
|
|
466
463
|
// If enableCrossContainerPreview is true and no drop occurred, reset item to original container
|
|
467
464
|
if (enableCrossContainerPreview && !dragStateRef.current.dropOccurred && draggedItemId && originalContainer) {
|
|
468
|
-
dispatch({ type: 'RESET_DRAG_CONTAINER', payload: { itemId: draggedItemId, originalContainer
|
|
465
|
+
dispatch({ type: 'RESET_DRAG_CONTAINER', payload: { itemId: draggedItemId, originalContainer } });
|
|
469
466
|
}
|
|
470
467
|
|
|
471
468
|
dispatch({ type: 'SET_IS_DRAGGING', payload: "" });
|
|
@@ -23,7 +23,7 @@ export type ActionType =
|
|
|
23
23
|
| { type: 'REORDER_ITEMS'; payload: { dragId: string; targetId: string } }
|
|
24
24
|
| { type: 'REORDER_ITEMS_CROSS_CONTAINER'; payload: { dragId: string; targetId: string; newContainer: string } }
|
|
25
25
|
| { type: 'MOVE_TO_CONTAINER_END'; payload: { dragId: string; newContainer: string } }
|
|
26
|
-
| { type: 'RESET_DRAG_CONTAINER'; payload: { itemId: string; originalContainer: string
|
|
26
|
+
| { type: 'RESET_DRAG_CONTAINER'; payload: { itemId: string; originalContainer: string } };
|
|
27
27
|
|
|
28
28
|
export interface DropZoneConfig {
|
|
29
29
|
type?: 'ghost' | 'outline' | 'shadow' | 'line';
|
|
@@ -6,10 +6,10 @@ import { GlobalProps, globalProps } from '../../utilities/globalProps'
|
|
|
6
6
|
import Card from '../../pb_card/_card'
|
|
7
7
|
|
|
8
8
|
export type FilterBackgroundProps = {
|
|
9
|
-
background
|
|
10
|
-
className
|
|
9
|
+
background: boolean,
|
|
10
|
+
className: string,
|
|
11
11
|
children?: React.ReactChild[] | React.ReactChild,
|
|
12
|
-
dark
|
|
12
|
+
dark: boolean,
|
|
13
13
|
} & GlobalProps
|
|
14
14
|
|
|
15
15
|
const FilterBackground = (props: FilterBackgroundProps): React.ReactElement => {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
Error shows that the radio option must be selected or is invalid (
|
|
1
|
+
Error shows that the radio option must be selected or is invalid (ie when used in a form it signals a user to fix an error).
|
|
@@ -29,7 +29,6 @@ type SelectProps = {
|
|
|
29
29
|
id?: string,
|
|
30
30
|
includeBlank?: string,
|
|
31
31
|
inline?: boolean,
|
|
32
|
-
inputOptions?: {[key: string]: string | number | boolean | (() => void)},
|
|
33
32
|
label?: string,
|
|
34
33
|
margin: string,
|
|
35
34
|
marginBottom: string,
|
|
@@ -64,7 +63,6 @@ const Select = ({
|
|
|
64
63
|
label,
|
|
65
64
|
htmlOptions = {},
|
|
66
65
|
inline = false,
|
|
67
|
-
inputOptions = {},
|
|
68
66
|
multiple = false,
|
|
69
67
|
name,
|
|
70
68
|
onChange = () => undefined,
|
|
@@ -96,17 +94,14 @@ const Select = ({
|
|
|
96
94
|
const angleDown = getAllIcons()["angleDown"].icon as unknown as { [key: string]: SVGElement }
|
|
97
95
|
|
|
98
96
|
const selectWrapperClass = classnames(buildCss('pb_select_kit_wrapper'), { error }, className)
|
|
99
|
-
const selectId = (inputOptions?.id as string) || name
|
|
100
|
-
|
|
101
97
|
const selectBody =(() =>{
|
|
102
98
|
if (children) return children
|
|
103
99
|
return (
|
|
104
100
|
<select
|
|
105
101
|
{...htmlOptions}
|
|
106
102
|
{...domSafeProps(props)}
|
|
107
|
-
{...inputOptions}
|
|
108
103
|
disabled={disabled}
|
|
109
|
-
id={
|
|
104
|
+
id={name}
|
|
110
105
|
multiple={multiple}
|
|
111
106
|
name={name}
|
|
112
107
|
onChange={onChange}
|
|
@@ -130,7 +125,7 @@ const Select = ({
|
|
|
130
125
|
{label &&
|
|
131
126
|
<label
|
|
132
127
|
className="pb_select_kit_label"
|
|
133
|
-
htmlFor={
|
|
128
|
+
htmlFor={name}
|
|
134
129
|
>
|
|
135
130
|
<Caption
|
|
136
131
|
dark={props.dark}
|
|
@@ -140,7 +135,7 @@ const Select = ({
|
|
|
140
135
|
}
|
|
141
136
|
<label
|
|
142
137
|
className={selectWrapperClass}
|
|
143
|
-
htmlFor={
|
|
138
|
+
htmlFor={name}
|
|
144
139
|
>
|
|
145
140
|
{selectBody}
|
|
146
141
|
{ multiple !== true ?
|
|
@@ -1 +1 @@
|
|
|
1
|
-
Select w/ Error shows that
|
|
1
|
+
Select w/ Error shows that the radio option must be selected or is invalid (ie when used in a form it signals a user to fix an error).
|
|
@@ -15,7 +15,6 @@ examples:
|
|
|
15
15
|
- select_inline_compact: Select Inline Compact
|
|
16
16
|
- select_attributes: Select W/ Attributes
|
|
17
17
|
- select_multiple: Select Multiple
|
|
18
|
-
- select_input_options: Input Options
|
|
19
18
|
|
|
20
19
|
|
|
21
20
|
|
|
@@ -34,7 +33,6 @@ examples:
|
|
|
34
33
|
- select_inline_compact: Select Inline Compact
|
|
35
34
|
- select_multiple: Select Multiple
|
|
36
35
|
- select_react_hook: React Hook
|
|
37
|
-
- select_input_options: Input Options
|
|
38
36
|
|
|
39
37
|
swift:
|
|
40
38
|
- select_default_swift: Default
|
|
@@ -12,4 +12,3 @@ export { default as SelectInlineCompact } from './_select_inline_compact.jsx'
|
|
|
12
12
|
export { default as SelectMultiple } from './_select_multiple.jsx'
|
|
13
13
|
export { default as SelectReactHook } from './_select_react_hook.jsx'
|
|
14
14
|
export { default as SelectCustomSelectSubheaders } from './_select_custom_select_subheaders.jsx'
|
|
15
|
-
export { default as SelectInputOptions } from './_select_input_options.jsx'
|
|
@@ -2,11 +2,11 @@
|
|
|
2
2
|
id: nil,
|
|
3
3
|
class: object.classnames ) do %>
|
|
4
4
|
<% if object.label %>
|
|
5
|
-
<label class="pb_select_kit_label" for="<%= object.
|
|
5
|
+
<label class="pb_select_kit_label" for="<%= object.name %>">
|
|
6
6
|
<%= pb_rails("caption", props: { text: object.label, dark: object.dark }) %>
|
|
7
7
|
</label>
|
|
8
8
|
<% end %>
|
|
9
|
-
<label class="<%= object.select_wrapper_class %>" for="<%= object.
|
|
9
|
+
<label class="<%= object.select_wrapper_class %>" for="<%= object.name %>">
|
|
10
10
|
<% if content.present? %>
|
|
11
11
|
<%= content %>
|
|
12
12
|
<%= pb_rails("body", props: { status: "negative", text: object.error }) %>
|
|
@@ -14,8 +14,6 @@ module Playbook
|
|
|
14
14
|
prop :error
|
|
15
15
|
prop :include_blank
|
|
16
16
|
prop :inline, type: Playbook::Props::Boolean, default: false
|
|
17
|
-
prop :input_options, type: Playbook::Props::HashProp,
|
|
18
|
-
default: {}
|
|
19
17
|
prop :label
|
|
20
18
|
prop :multiple, type: Playbook::Props::Boolean, default: false
|
|
21
19
|
prop :name
|
|
@@ -40,7 +38,7 @@ module Playbook
|
|
|
40
38
|
multiple: multiple,
|
|
41
39
|
onchange: onchange,
|
|
42
40
|
include_blank: include_blank,
|
|
43
|
-
}.merge(attributes)
|
|
41
|
+
}.merge(attributes)
|
|
44
42
|
end
|
|
45
43
|
|
|
46
44
|
def classname
|
|
@@ -65,27 +65,4 @@ test('returns multiple variant', () => {
|
|
|
65
65
|
const selectElement = kit.querySelector('select');
|
|
66
66
|
|
|
67
67
|
expect(selectElement).toHaveAttribute('multiple', '');
|
|
68
|
-
});
|
|
69
|
-
|
|
70
|
-
test('inputOptions are passed to select element', () => {
|
|
71
|
-
render(
|
|
72
|
-
<Select
|
|
73
|
-
data={{ testid: testId }}
|
|
74
|
-
inputOptions={{
|
|
75
|
-
id: 'custom-select-id',
|
|
76
|
-
className: 'custom-select-class',
|
|
77
|
-
'aria-label': 'Custom aria label',
|
|
78
|
-
}}
|
|
79
|
-
label="Favorite Food"
|
|
80
|
-
name="food"
|
|
81
|
-
options={options}
|
|
82
|
-
/>
|
|
83
|
-
)
|
|
84
|
-
|
|
85
|
-
const kit = screen.getByTestId(testId)
|
|
86
|
-
const selectElement = kit.querySelector('select')
|
|
87
|
-
|
|
88
|
-
expect(selectElement).toHaveAttribute('id', 'custom-select-id')
|
|
89
|
-
expect(selectElement).toHaveClass('custom-select-class')
|
|
90
|
-
expect(selectElement).toHaveAttribute('aria-label', 'Custom aria label')
|
|
91
68
|
});
|