playbook_ui 14.16.0.pre.alpha.PBNTR881advancedtablefullscreen6934 → 14.16.0.pre.alpha.PBNTR933reactdraggablebugdragbtwnexamples7021
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/_advanced_table.scss +2 -2
- data/app/pb_kits/playbook/pb_advanced_table/_advanced_table.tsx +1 -1
- data/app/pb_kits/playbook/pb_draggable/context/index.tsx +58 -17
- data/app/pb_kits/playbook/pb_dropdown/docs/_dropdown_with_autocomplete.jsx +6 -6
- data/app/pb_kits/playbook/pb_dropdown/docs/_dropdown_with_autocomplete_and_custom_display.jsx +6 -6
- data/app/pb_kits/playbook/pb_dropdown/docs/_dropdown_with_custom_display.jsx +6 -6
- data/app/pb_kits/playbook/pb_dropdown/docs/_dropdown_with_custom_display_rails.html.erb +8 -8
- data/app/pb_kits/playbook/pb_layout/_layout.scss +58 -0
- data/app/pb_kits/playbook/pb_layout/_layout.tsx +20 -7
- data/app/pb_kits/playbook/pb_layout/docs/_layout_bracket.jsx +190 -0
- data/app/pb_kits/playbook/pb_layout/docs/_layout_bracket.md +5 -0
- data/app/pb_kits/playbook/pb_layout/docs/example.yml +1 -0
- data/app/pb_kits/playbook/pb_layout/docs/index.js +1 -0
- data/app/pb_kits/playbook/pb_layout/layout.test.js +4 -0
- data/app/pb_kits/playbook/pb_layout/subcomponents/_game.tsx +90 -0
- data/app/pb_kits/playbook/pb_layout/subcomponents/_round.tsx +57 -0
- data/app/pb_kits/playbook/pb_table/styles/_striped.scss +3 -3
- data/app/pb_kits/playbook/pb_typeahead/docs/_typeahead_with_highlight.jsx +4 -4
- data/dist/chunks/{_typeahead-Djo6qCne.js → _typeahead-7W5Ha5Td.js} +1 -1
- data/dist/chunks/_weekday_stacked-DSKatW3m.js +45 -0
- 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/dist/playbook.css +1 -1
- data/lib/playbook/version.rb +1 -1
- metadata +8 -4
- data/dist/chunks/_weekday_stacked-CON3AkXi.js +0 -45
@@ -7,4 +7,5 @@ export { default as LayoutKanbanResponsive } from './_layout_kanban_responsive.j
|
|
7
7
|
export { default as LayoutCollectionDetail } from './_layout_collection_detail.jsx'
|
8
8
|
export { default as LayoutContent } from './_layout_content.jsx'
|
9
9
|
export { default as LayoutMasonry } from './_layout_masonry.jsx'
|
10
|
+
export { default as LayoutBracket } from './_layout_bracket.jsx'
|
10
11
|
|
@@ -82,6 +82,10 @@ test("render all layout variants", () => {
|
|
82
82
|
layout: "masonry",
|
83
83
|
expected: "pb_layout_kit_masonry_size_md_left_light",
|
84
84
|
},
|
85
|
+
{
|
86
|
+
layout: "bracket",
|
87
|
+
expected: "pb_layout_kit_bracket",
|
88
|
+
},
|
85
89
|
]
|
86
90
|
|
87
91
|
testValues.forEach(({ layout, expected }) => {
|
@@ -0,0 +1,90 @@
|
|
1
|
+
import React from 'react'
|
2
|
+
import classnames from 'classnames'
|
3
|
+
|
4
|
+
import { GlobalProps, globalProps, globalInlineProps } from '../../utilities/globalProps'
|
5
|
+
|
6
|
+
import Card from '../../pb_card/_card'
|
7
|
+
import SectionSeparator from '../../pb_section_separator/_section_separator'
|
8
|
+
|
9
|
+
type LayoutGameProps = {
|
10
|
+
children: React.ReactNode[] | React.ReactNode,
|
11
|
+
className?: string,
|
12
|
+
numberOfRounds: number,
|
13
|
+
numberOfGames: number,
|
14
|
+
isOdd: boolean,
|
15
|
+
} & GlobalProps
|
16
|
+
|
17
|
+
// Game component (modeled after Item)
|
18
|
+
const Game = (props: LayoutGameProps) => {
|
19
|
+
const { children, className, numberOfRounds, numberOfGames, isOdd } = props
|
20
|
+
const dynamicInlineProps = globalInlineProps(props)
|
21
|
+
|
22
|
+
const numberOfChildren = Array.isArray(children) ? children.length : 0
|
23
|
+
|
24
|
+
const isMultiple = Array.isArray(children)
|
25
|
+
|
26
|
+
let ratio = 0
|
27
|
+
let exponent
|
28
|
+
if (numberOfGames > 1) {
|
29
|
+
exponent = (numberOfRounds) - Math.log2(numberOfGames) - 1
|
30
|
+
ratio = 2 ** exponent
|
31
|
+
}
|
32
|
+
|
33
|
+
if (numberOfChildren === 2) {
|
34
|
+
const [firstChild, secondChild] = React.Children.toArray(children)
|
35
|
+
|
36
|
+
if (React.isValidElement(firstChild) && React.isValidElement(secondChild)) {
|
37
|
+
return (
|
38
|
+
<div
|
39
|
+
className={classnames('layout_game', globalProps(props), className)}
|
40
|
+
style={dynamicInlineProps}
|
41
|
+
>
|
42
|
+
<Card
|
43
|
+
marginY="xs"
|
44
|
+
padding="none"
|
45
|
+
shadow="deep"
|
46
|
+
>
|
47
|
+
<Card.Body padding="xs">{firstChild}</Card.Body>
|
48
|
+
<SectionSeparator />
|
49
|
+
<Card.Body padding="xs">{secondChild}</Card.Body>
|
50
|
+
</Card>
|
51
|
+
{isOdd && numberOfGames > 1 &&
|
52
|
+
<div
|
53
|
+
className="half_box"
|
54
|
+
style={{ height: `calc(${ratio} * 100% + 4px)` }}
|
55
|
+
/>
|
56
|
+
}
|
57
|
+
</div>
|
58
|
+
)
|
59
|
+
}
|
60
|
+
}
|
61
|
+
|
62
|
+
return (
|
63
|
+
<div
|
64
|
+
className={classnames('layout_game', globalProps(props), className)}
|
65
|
+
style={dynamicInlineProps}
|
66
|
+
>
|
67
|
+
{((!isMultiple && children) || numberOfChildren >= 1 )? (
|
68
|
+
children
|
69
|
+
) : (
|
70
|
+
<Card
|
71
|
+
marginY="xs"
|
72
|
+
padding="none"
|
73
|
+
shadow="deep"
|
74
|
+
>
|
75
|
+
<Card.Body padding="xs">To be determined...</Card.Body>
|
76
|
+
<SectionSeparator />
|
77
|
+
<Card.Body padding="xs">To be determined...</Card.Body>
|
78
|
+
</Card>
|
79
|
+
)}
|
80
|
+
{isOdd && numberOfGames > 1 &&
|
81
|
+
<div
|
82
|
+
className="half_box"
|
83
|
+
style={{ height: `calc(${ratio} * 100% + 4px)` }}
|
84
|
+
/>
|
85
|
+
}
|
86
|
+
</div>
|
87
|
+
)
|
88
|
+
}
|
89
|
+
|
90
|
+
export default Game
|
@@ -0,0 +1,57 @@
|
|
1
|
+
import React from 'react'
|
2
|
+
import classnames from 'classnames'
|
3
|
+
|
4
|
+
import { GlobalProps, globalProps, globalInlineProps } from '../../utilities/globalProps'
|
5
|
+
|
6
|
+
type LayoutRoundLabelProps = {
|
7
|
+
children: React.ReactNode[] | React.ReactNode,
|
8
|
+
className?: string,
|
9
|
+
} & GlobalProps
|
10
|
+
|
11
|
+
export const RoundLabel = (props: LayoutRoundLabelProps) => {
|
12
|
+
const { children, className } = props
|
13
|
+
const dynamicInlineProps = globalInlineProps(props)
|
14
|
+
return (
|
15
|
+
<div
|
16
|
+
className={classnames('layout_round_label', className)}
|
17
|
+
style={dynamicInlineProps}
|
18
|
+
>
|
19
|
+
{children}
|
20
|
+
</div>
|
21
|
+
)
|
22
|
+
}
|
23
|
+
|
24
|
+
type LayoutRoundProps = {
|
25
|
+
children: React.ReactNode[] | React.ReactNode,
|
26
|
+
className?: string,
|
27
|
+
numberOfRounds: number,
|
28
|
+
} & GlobalProps
|
29
|
+
|
30
|
+
export const Round = (props: LayoutRoundProps) => {
|
31
|
+
const { children, className, numberOfRounds } = props
|
32
|
+
const dynamicInlineProps = globalInlineProps(props)
|
33
|
+
const numberOfChildren = Array.isArray(children) ? children.length : 0
|
34
|
+
|
35
|
+
const childrenWithProps = Array.isArray(children) ? children.map((child, index) =>
|
36
|
+
React.isValidElement(child) ? React.cloneElement(child, { numberOfRounds, numberOfGames: numberOfChildren, isOdd: index % 2 === 0, key: `child_${index}` }) : child
|
37
|
+
) : children
|
38
|
+
|
39
|
+
const rightConnectors = Array.from({ length: numberOfChildren / 2 }, (_, index) => (
|
40
|
+
<div
|
41
|
+
className="right_connector"
|
42
|
+
key={`right_connector_${index}`}
|
43
|
+
/>
|
44
|
+
))
|
45
|
+
|
46
|
+
return (
|
47
|
+
<>
|
48
|
+
<div
|
49
|
+
className={classnames('layout_round', globalProps(props), className)}
|
50
|
+
style={dynamicInlineProps}
|
51
|
+
>
|
52
|
+
{childrenWithProps}
|
53
|
+
</div>
|
54
|
+
<div className="connector_container">{rightConnectors}</div>
|
55
|
+
</>
|
56
|
+
)
|
57
|
+
}
|
@@ -1,7 +1,7 @@
|
|
1
|
-
[class^=pb_table] {
|
1
|
+
[class^=pb_table]:not(:has(colgroup)) {
|
2
2
|
&.striped {
|
3
3
|
tbody, .pb_table_tbody {
|
4
|
-
tr:nth-child(odd), .pb_table_tr:nth-child(odd) {
|
4
|
+
tr:nth-child(odd):not(.pb_background_kit), .pb_table_tr:nth-child(odd):not(.pb_background_kit) {
|
5
5
|
background-color: $bg_light;
|
6
6
|
}
|
7
7
|
}
|
@@ -10,7 +10,7 @@
|
|
10
10
|
&.dark {
|
11
11
|
&.striped {
|
12
12
|
tbody, .pb_table_tbody {
|
13
|
-
tr:nth-child(odd), .pb_table_tr:nth-child(odd) {
|
13
|
+
tr:nth-child(odd):not(.pb_background_kit), .pb_table_tr:nth-child(odd):not(.pb_background_kit) {
|
14
14
|
background-color: $bg_dark;
|
15
15
|
}
|
16
16
|
}
|
@@ -18,18 +18,18 @@ const USERS = [
|
|
18
18
|
territory: "PHL",
|
19
19
|
},
|
20
20
|
{
|
21
|
-
name: "
|
22
|
-
title: "
|
21
|
+
name: "Carlos Lima",
|
22
|
+
title: "Nitro Developer",
|
23
23
|
territory: "PHL",
|
24
24
|
},
|
25
25
|
{
|
26
26
|
name: "Stephen Marshall",
|
27
|
-
title: "Senior
|
27
|
+
title: "Senior Nitro Developer",
|
28
28
|
territory: "PHL",
|
29
29
|
},
|
30
30
|
{
|
31
31
|
name: "Jasper Furniss",
|
32
|
-
title: "
|
32
|
+
title: "Lead User Experience Engineer",
|
33
33
|
territory: "PHL",
|
34
34
|
},
|
35
35
|
];
|
@@ -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,
|
1
|
+
import{jsx as jsx$1,Fragment,jsxs}from"react/jsx-runtime";import*as React from"react";import React__default,{createContext,useReducer,useRef,useState,useEffect,useMemo,useContext,createElement,forwardRef,useLayoutEffect,useCallback,useImperativeHandle,Component,Fragment as Fragment$1}from"react";import{r as getDefaultExportFromCjs,x as filter,y as omit,u as useCollapsible,z as get,j as getAllIcons,q as commonjsGlobal,w as colors$1,t as highchartsTheme,A as merge,s as highchartsDarkTheme,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,M as getAugmentedNamespace,N as createPopper,O as uniqueId,Q as typography,S as cloneDeep,l as isEmpty$1,T as isString}from"./lib-BGzBzFZX.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 targetItem=newItems.find((item=>item.id===targetId));if(!draggedItem||!targetItem||draggedItem.container!==targetItem.container){return state}if(dragId===targetId){return state}const draggedIndex=newItems.findIndex((item=>item.id===dragId));const targetIndex=newItems.findIndex((item=>item.id===targetId));if(draggedIndex===-1||targetIndex===-1){return state}newItems.splice(draggedIndex,1);newItems.splice(targetIndex,0,draggedItem);return{...state,items:newItems}}default:return state}};const DragContext=createContext({});const DraggableContext=()=>{const context=useContext(DragContext);if(context===void 0){throw new Error("DraggableContext must be used within a DraggableProvider")}return context};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);const initialItemsRef=useRef(initialItems);const[isDragging,setIsDragging]=useState(false);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});initialItemsRef.current=initialItems}),[initialItems]);useEffect((()=>{if(onReorder){onReorder(state.items)}}),[state.items,onReorder]);const handleDragStart=(id,container)=>{setIsDragging(true);dispatch({type:"SET_DRAG_DATA",payload:{id:id,initialGroup:container}});dispatch({type:"SET_IS_DRAGGING",payload:id});dispatch({type:"SET_ACTIVE_CONTAINER",payload:container});if(onDragStart)onDragStart(id,container)};const handleDragEnter=(id,container)=>{if(!isDragging||container!==state.activeContainer)return;if(state.dragData.id===id)return;const draggedItem=state.items.find((item=>item.id===state.dragData.id));const targetItem=state.items.find((item=>item.id===id));if(!draggedItem||!targetItem||draggedItem.container!==targetItem.container){return}dispatch({type:"REORDER_ITEMS",payload:{dragId:state.dragData.id,targetId:id}});if(onDragEnter)onDragEnter(id,container)};const handleDragEnd=()=>{setIsDragging(false);dispatch({type:"SET_IS_DRAGGING",payload:""});dispatch({type:"SET_ACTIVE_CONTAINER",payload:""});if(onDragEnd)onDragEnd()};const handleDrop=container=>{const draggedItem=state.items.find((item=>item.id===state.dragData.id));if(draggedItem&&draggedItem.container!==container){dispatch({type:"CHANGE_CATEGORY",payload:{itemId:state.dragData.id,container:container}})}dispatch({type:"SET_IS_DRAGGING",payload:""});dispatch({type:"SET_ACTIVE_CONTAINER",payload:""});setIsDragging(false);if(onDrop)onDrop(container)};const handleDragOver=(e,container)=>{e.preventDefault();e.stopPropagation();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,handleDragStart,handleDragEnter,handleDragEnd,handleDrop,handleDragOver]);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
|