playbook_ui 14.22.0.pre.alpha.PLAY2254datepickerdefaultdatenullvalueturbo8533 → 14.22.0.pre.alpha.PLAY22588587
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/SubRowHeaderRow.tsx +32 -11
- data/app/pb_kits/playbook/pb_advanced_table/_advanced_table.tsx +6 -0
- data/app/pb_kits/playbook/pb_advanced_table/docs/_advanced_table_custom_sort.jsx +65 -0
- data/app/pb_kits/playbook/pb_advanced_table/docs/_advanced_table_custom_sort.md +5 -0
- data/app/pb_kits/playbook/pb_advanced_table/docs/example.yml +3 -2
- data/app/pb_kits/playbook/pb_advanced_table/docs/index.js +1 -0
- data/app/pb_kits/playbook/pb_date_picker/date_picker_helper.ts +1 -1
- data/dist/chunks/{_typeahead-BszXPiWi.js → _typeahead-B7FRYVtS.js} +1 -1
- data/dist/chunks/_weekday_stacked-D1TcPO8F.js +45 -0
- data/dist/chunks/{lib-BUnAetLK.js → lib-Carqm8Ip.js} +1 -1
- data/dist/chunks/{pb_form_validation-C0_FS7e9.js → pb_form_validation-DqRmTS8m.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/lib/playbook/version.rb +1 -1
- metadata +8 -6
- data/dist/chunks/_weekday_stacked-BOI-NAUo.js +0 -45
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 911865c34980d9a3e4456c6d6261d2c78bcc4be2295b4250f639415c020c6557
|
4
|
+
data.tar.gz: ffbc96ad87820c2ecedb124a431d654e168ce906b0dff718ca65af44017c2bf0
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 439099c3f2922db547ad9f6b41a9424b07da3cdd25f97c0c881ab41b727858d3e81bac0ace6737a96dfb98b02c70e4014f199f40f5c9941d45fef77aeb01a60d
|
7
|
+
data.tar.gz: 31ce0f8177eb5fe6e5a4752ddd67f59abf21c91255d2d9deee8af886b2fcc23dbab7b7df1a8fc964cab98aadbdaf7abf85b15f344fa566ec35ed64056220d29b
|
@@ -7,6 +7,7 @@ import { GlobalProps } from "../../utilities/globalProps"
|
|
7
7
|
|
8
8
|
import Flex from "../../pb_flex/_flex"
|
9
9
|
import Caption from "../../pb_caption/_caption"
|
10
|
+
import Icon from "../../pb_icon/_icon"
|
10
11
|
|
11
12
|
import { ToggleIconButton } from "./ToggleIconButton"
|
12
13
|
import { renderCollapsibleTrail } from "./CollapsibleTrail"
|
@@ -32,17 +33,19 @@ export const SubRowHeaderRow = ({
|
|
32
33
|
subRowHeaders,
|
33
34
|
table,
|
34
35
|
}: SubRowHeaderRowProps & GlobalProps) => {
|
35
|
-
const { inlineRowLoading } = useContext(AdvancedTableContext)
|
36
|
+
const { inlineRowLoading, customSort, onCustomSortClick } = useContext(AdvancedTableContext)
|
36
37
|
|
37
38
|
const numberOfColumns = table.getAllFlatColumns().length
|
38
39
|
const rowHasChildren = row.original.children ? true : false
|
39
40
|
const canExpand = inlineRowLoading ? rowHasChildren : row.getCanExpand()
|
41
|
+
const hasSubrowsToSort = row.getParentRow()?.subRows
|
42
|
+
|
40
43
|
|
41
44
|
return (
|
42
45
|
<tr className="custom-row bg-silver">
|
43
46
|
<td
|
44
47
|
className={`custom-row-first-column ${
|
45
|
-
|
48
|
+
isChrome() ? "chrome-styles" : ""
|
46
49
|
}`}
|
47
50
|
colSpan={1}
|
48
51
|
>
|
@@ -50,21 +53,39 @@ export const SubRowHeaderRow = ({
|
|
50
53
|
<div style={{ paddingLeft: `${row.depth * 1.25}em` }}>
|
51
54
|
<Flex align="center"
|
52
55
|
columnGap="xs"
|
56
|
+
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
57
|
+
//@ts-ignore
|
58
|
+
justifyContent={customSort && hasSubrowsToSort && hasSubrowsToSort.length > 1 ? "between" : undefined}
|
53
59
|
>
|
54
|
-
|
55
|
-
|
56
|
-
|
60
|
+
<Flex columnGap="xs">
|
61
|
+
{enableToggleExpansion === "all" && canExpand ? (
|
62
|
+
<ToggleIconButton onClick={onClick}
|
63
|
+
row={row}
|
64
|
+
/>
|
65
|
+
) : null}
|
66
|
+
<Caption
|
67
|
+
marginLeft={canExpand ? "none" : "xs"}
|
68
|
+
text={subRowHeaders[row.depth - 1]}
|
57
69
|
/>
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
70
|
+
</Flex>
|
71
|
+
{customSort && hasSubrowsToSort && hasSubrowsToSort.length > 1 && (
|
72
|
+
<button
|
73
|
+
aria-label="Sort this group"
|
74
|
+
className="sort-button-icon gray-icon"
|
75
|
+
onClick={() => { onCustomSortClick && onCustomSortClick(row.getParentRow()?.subRows)}}
|
76
|
+
>
|
77
|
+
<Icon
|
78
|
+
cursor="pointer"
|
79
|
+
fixedWidth
|
80
|
+
icon="sort"
|
81
|
+
/>
|
82
|
+
</button>
|
83
|
+
)}
|
63
84
|
</Flex>
|
64
85
|
</div>
|
65
86
|
</td>
|
66
87
|
|
67
88
|
<td colSpan={numberOfColumns - 1} />
|
68
89
|
</tr>
|
69
|
-
)
|
90
|
+
);
|
70
91
|
}
|
@@ -36,6 +36,7 @@ type AdvancedTableProps = {
|
|
36
36
|
columnDefinitions: GenericObject[]
|
37
37
|
columnGroupBorderColor?: "text_lt_default" | "text_lt_light" | "text_lt_lighter" | "text_dk_default" | "text_dk_light" | "text_dk_lighter"
|
38
38
|
columnVisibilityControl?: GenericObject
|
39
|
+
customSort?:boolean;
|
39
40
|
dark?: boolean
|
40
41
|
data?: { [key: string]: string }
|
41
42
|
enableToggleExpansion?: "all" | "header" | "none"
|
@@ -67,6 +68,7 @@ type AdvancedTableProps = {
|
|
67
68
|
tableProps?: GenericObject
|
68
69
|
toggleExpansionIcon?: string | string[]
|
69
70
|
onRowSelectionChange?: (arg: RowSelectionState) => void
|
71
|
+
onCustomSortClick?: (arg: GenericObject[]) => void
|
70
72
|
virtualizedRows?: boolean
|
71
73
|
allowFullScreen?: boolean
|
72
74
|
fullScreenControl?: (controls: FullscreenControls) => void
|
@@ -81,6 +83,7 @@ const AdvancedTable = (props: AdvancedTableProps) => {
|
|
81
83
|
columnDefinitions,
|
82
84
|
columnGroupBorderColor,
|
83
85
|
columnVisibilityControl,
|
86
|
+
customSort,
|
84
87
|
dark = false,
|
85
88
|
data = {},
|
86
89
|
enableToggleExpansion = "header",
|
@@ -95,6 +98,7 @@ const AdvancedTable = (props: AdvancedTableProps) => {
|
|
95
98
|
maxHeight,
|
96
99
|
onRowToggleClick,
|
97
100
|
onToggleExpansionClick,
|
101
|
+
onCustomSortClick,
|
98
102
|
pagination = false,
|
99
103
|
paginationProps,
|
100
104
|
pinnedRows,
|
@@ -325,6 +329,7 @@ const AdvancedTable = (props: AdvancedTableProps) => {
|
|
325
329
|
columnDefinitions={columnDefinitions}
|
326
330
|
columnGroupBorderColor={columnGroupBorderColor}
|
327
331
|
columnVisibilityControl={columnVisibilityControl}
|
332
|
+
customSort={customSort}
|
328
333
|
enableToggleExpansion={enableToggleExpansion}
|
329
334
|
enableVirtualization={virtualizedRows}
|
330
335
|
expandByDepth={expandByDepth}
|
@@ -336,6 +341,7 @@ const AdvancedTable = (props: AdvancedTableProps) => {
|
|
336
341
|
isActionBarVisible={isActionBarVisible}
|
337
342
|
isFullscreen={isFullscreen}
|
338
343
|
loading={loading}
|
344
|
+
onCustomSortClick={onCustomSortClick}
|
339
345
|
onExpandByDepthClick={onExpandByDepthClick}
|
340
346
|
pinnedRows={pinnedRows}
|
341
347
|
responsive={responsive}
|
@@ -0,0 +1,65 @@
|
|
1
|
+
import React from "react"
|
2
|
+
import AdvancedTable from '../../pb_advanced_table/_advanced_table'
|
3
|
+
import MOCK_DATA from "./advanced_table_mock_data.json"
|
4
|
+
|
5
|
+
const AdvancedTableCustomSort = (props) => {
|
6
|
+
const columnDefinitions = [
|
7
|
+
{
|
8
|
+
accessor: "year",
|
9
|
+
label: "Year",
|
10
|
+
id: "year",
|
11
|
+
cellAccessors: ["quarter", "month", "day"],
|
12
|
+
},
|
13
|
+
{
|
14
|
+
accessor: "newEnrollments",
|
15
|
+
id: "newEnrollments",
|
16
|
+
label: "New Enrollments",
|
17
|
+
},
|
18
|
+
{
|
19
|
+
accessor: "scheduledMeetings",
|
20
|
+
id: "scheduledMeetings",
|
21
|
+
label: "Scheduled Meetings",
|
22
|
+
},
|
23
|
+
{
|
24
|
+
accessor: "attendanceRate",
|
25
|
+
id: "attendanceRate",
|
26
|
+
label: "Attendance Rate",
|
27
|
+
},
|
28
|
+
{
|
29
|
+
accessor: "completedClasses",
|
30
|
+
id: "completedClasses",
|
31
|
+
label: "Completed Classes",
|
32
|
+
},
|
33
|
+
{
|
34
|
+
accessor: "classCompletionRate",
|
35
|
+
id: "classCompletionRate",
|
36
|
+
label: "Class Completion Rate",
|
37
|
+
},
|
38
|
+
{
|
39
|
+
accessor: "graduatedStudents",
|
40
|
+
id: "graduatedStudents",
|
41
|
+
label: "Graduated Students",
|
42
|
+
},
|
43
|
+
]
|
44
|
+
|
45
|
+
//Render the subRow header rows
|
46
|
+
const subRowHeaders = ["Quarter", "Month", "Day"]
|
47
|
+
|
48
|
+
return (
|
49
|
+
<div>
|
50
|
+
<AdvancedTable
|
51
|
+
columnDefinitions={columnDefinitions}
|
52
|
+
customSort
|
53
|
+
enableToggleExpansion="all"
|
54
|
+
onCustomSortClick={(subrows)=>{console.log("Custom sort clicked", subrows)}}
|
55
|
+
tableData={MOCK_DATA}
|
56
|
+
{...props}
|
57
|
+
>
|
58
|
+
<AdvancedTable.Header enableSorting />
|
59
|
+
<AdvancedTable.Body subRowHeaders={subRowHeaders} />
|
60
|
+
</AdvancedTable>
|
61
|
+
</div>
|
62
|
+
)
|
63
|
+
}
|
64
|
+
|
65
|
+
export default AdvancedTableCustomSort
|
@@ -0,0 +1,5 @@
|
|
1
|
+
The optional `customSort` prop can be used to add a sort button within a subrow header. The button will only appear if that subrowheader has more than one subrow nested within it. This button comes with a callback function called `onCustomSortClick`.
|
2
|
+
|
3
|
+
The `onCustomSortClick` provides as an argument an array of all the subrows nested within that level of the table.
|
4
|
+
|
5
|
+
__NOTE__: `customSort` must be used in conjunction with the `subRowHeaders` prop. The `customSort` DOES NOT handle the sort logic, this must be handled on the frontend using the callback provided.
|
@@ -19,14 +19,15 @@ examples:
|
|
19
19
|
- advanced_table_selectable_rows_actions_rails: Selectable Rows (With Actions)
|
20
20
|
- advanced_table_selectable_rows_header_rails: Selectable Rows (No Actions Bar)
|
21
21
|
- advanced_table_scrollbar_none: Advanced Table Scrollbar None
|
22
|
-
|
23
|
-
|
22
|
+
- advanced_table_column_styling_rails: Column Styling
|
23
|
+
- advanced_table_column_styling_column_headers_rails: Column Styling with Multiple Headers
|
24
24
|
|
25
25
|
react:
|
26
26
|
- advanced_table_default: Default (Required Props)
|
27
27
|
- advanced_table_loading: Loading State
|
28
28
|
- advanced_table_sort: Enable Sorting
|
29
29
|
- advanced_table_sort_control: Sort Control
|
30
|
+
- advanced_table_custom_sort: Custom Sort
|
30
31
|
- advanced_table_expanded_control: Expanded Control
|
31
32
|
- advanced_table_expand_by_depth: Expand by Depth
|
32
33
|
- advanced_table_subrow_headers: SubRow Headers
|
@@ -38,3 +38,4 @@ export { default as AdvancedTableRowStyling } from './_advanced_table_row_stylin
|
|
38
38
|
export { default as AdvancedTableColumnStyling } from './_advanced_table_column_styling.jsx'
|
39
39
|
export { default as AdvancedTableColumnStylingColumnHeaders } from './_advanced_table_column_styling_column_headers.jsx'
|
40
40
|
export { default as AdvancedTableInfiniteScroll} from './_advanced_table_infinite_scroll.jsx'
|
41
|
+
export { default as AdvancedTableCustomSort } from './_advanced_table_custom_sort.jsx'
|
@@ -275,7 +275,7 @@ const datePickerHelper = (config: DatePickerConfig, scrollContainer: string | HT
|
|
275
275
|
picker.monthsDropdownContainer.value = picker.currentMonth
|
276
276
|
|
277
277
|
/* Reset date picker to default value on form.reset() */
|
278
|
-
if (defaultDate
|
278
|
+
if (defaultDate){
|
279
279
|
picker.setDate(defaultDate)
|
280
280
|
yearChangeHook(picker)
|
281
281
|
}
|
@@ -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,useEffect,useMemo,useContext,createElement,useRef,forwardRef,useState,useLayoutEffect,useCallback,useImperativeHandle,Component,Fragment as Fragment$1}from"react";import{g as getDefaultExportFromCjs,v as filter,w as omit,s as noop$2,u as useCollapsible,x as createPopper,y as uniqueId,z as get,A as flip$2,B as offset$2,C as shift$2,E as arrow$3,F as computePosition$1,G as createCoords$1,H as round$1,I as max$1,J as min$1,K as rectToClientRect$1,k as getAllIcons,t as colors$1,L as highchartsTheme,M as merge,N as highchartsDarkTheme,O as getAugmentedNamespace,Q as typography,S as cloneDeep,n as isEmpty$1,T as isString}from"./lib-
|
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{g as getDefaultExportFromCjs,v as filter,w as omit,s as noop$2,u as useCollapsible,x as createPopper,y as uniqueId,z as get,A as flip$2,B as offset$2,C as shift$2,E as arrow$3,F as computePosition$1,G as createCoords$1,H as round$1,I as max$1,J as min$1,K as rectToClientRect$1,k as getAllIcons,t as colors$1,L as highchartsTheme,M as merge,N as highchartsDarkTheme,O as getAugmentedNamespace,Q as typography,S as cloneDeep,n as isEmpty$1,T as isString}from"./lib-Carqm8Ip.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
|