playbook_ui 14.22.0.pre.alpha.PLAY2207preservesearchinputrails8526 → 14.22.0.pre.alpha.PLAY2248railstooltipclicktoopen8667
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/CustomCell.tsx +6 -7
- data/app/pb_kits/playbook/pb_advanced_table/Components/SubRowHeaderRow.tsx +32 -11
- data/app/pb_kits/playbook/pb_advanced_table/Hooks/useTableState.ts +2 -2
- data/app/pb_kits/playbook/pb_advanced_table/_advanced_table.scss +5 -0
- 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/_advanced_table_with_custom_header.jsx +69 -0
- data/app/pb_kits/playbook/pb_advanced_table/docs/_advanced_table_with_custom_header.md +1 -0
- data/app/pb_kits/playbook/pb_advanced_table/docs/example.yml +4 -2
- data/app/pb_kits/playbook/pb_advanced_table/docs/index.js +2 -0
- data/app/pb_kits/playbook/pb_advanced_table/table_row.html.erb +2 -2
- data/app/pb_kits/playbook/pb_table/_table.tsx +4 -4
- data/app/pb_kits/playbook/pb_table/docs/_table_sticky_columns.jsx +8 -8
- data/app/pb_kits/playbook/pb_table/docs/_table_sticky_columns_react.md +1 -1
- data/app/pb_kits/playbook/pb_table/docs/_table_sticky_left_columns.jsx +12 -12
- data/app/pb_kits/playbook/pb_table/docs/_table_sticky_left_columns_react.md +3 -3
- data/app/pb_kits/playbook/pb_table/docs/_table_sticky_right_columns.jsx +12 -12
- data/app/pb_kits/playbook/pb_table/docs/_table_sticky_right_columns_react.md +3 -3
- data/app/pb_kits/playbook/pb_tooltip/docs/_tooltip_click_open.html.erb +14 -0
- data/app/pb_kits/playbook/pb_tooltip/docs/_tooltip_click_open_rails.md +1 -0
- data/app/pb_kits/playbook/pb_tooltip/docs/example.yml +1 -0
- data/app/pb_kits/playbook/pb_tooltip/index.js +59 -36
- data/app/pb_kits/playbook/pb_tooltip/tooltip.rb +9 -2
- data/app/pb_kits/playbook/pb_typeahead/docs/_typeahead_preserve_input.html.erb +1 -0
- data/dist/chunks/{_typeahead-B7FRYVtS.js → _typeahead-CJa1XdQQ.js} +1 -1
- data/dist/chunks/_weekday_stacked-DEFOs-MK.js +45 -0
- data/dist/chunks/{lib-Carqm8Ip.js → lib-LHsP11gB.js} +1 -1
- data/dist/chunks/{pb_form_validation-DqRmTS8m.js → pb_form_validation-BHrTZlH7.js} +1 -1
- data/dist/chunks/vendor.js +1 -1
- data/dist/playbook-doc.js +2 -2
- 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 -7
- data/dist/chunks/_weekday_stacked-B0oaGhTW.js +0 -45
- /data/app/pb_kits/playbook/pb_tooltip/docs/{_tooltip_click_open.md → _tooltip_click_open_react.md} +0 -0
@@ -19,60 +19,75 @@ export default class PbTooltip extends PbEnhancedElement {
|
|
19
19
|
}
|
20
20
|
|
21
21
|
this.triggerElements.forEach((trigger) => {
|
22
|
-
const method = this.
|
22
|
+
const method = this.effectiveTriggerMethod
|
23
23
|
const interactionEnabled = this.tooltipInteraction
|
24
24
|
|
25
25
|
if (method === 'click') {
|
26
|
-
trigger.addEventListener('click', () => {
|
27
|
-
this.
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
this.currentTrigger = trigger
|
34
|
-
const delayOpen = this.delayOpen ? parseInt(this.delayOpen) : TOOLTIP_TIMEOUT
|
35
|
-
this.mouseenterTimeout = setTimeout(() => {
|
36
|
-
this.showTooltip(trigger)
|
37
|
-
if (interactionEnabled) {
|
38
|
-
this.checkCloseTooltip(trigger)
|
26
|
+
trigger.addEventListener('click', (e) => {
|
27
|
+
if (this.useClickToOpen) {
|
28
|
+
e.preventDefault()
|
29
|
+
if (this.isTooltipVisible()) {
|
30
|
+
this.hideTooltip()
|
31
|
+
} else {
|
32
|
+
this.showTooltip(trigger)
|
39
33
|
}
|
40
|
-
}
|
34
|
+
} else {
|
35
|
+
this.showTooltip(trigger)
|
36
|
+
}
|
41
37
|
})
|
38
|
+
} else {
|
39
|
+
if (!this.useClickToOpen) {
|
40
|
+
trigger.addEventListener('mouseenter', () => {
|
41
|
+
clearSafeZoneListener(this)
|
42
|
+
clearTimeout(this.mouseleaveTimeout)
|
43
|
+
this.currentTrigger = trigger
|
44
|
+
const delayOpen = this.delayOpen ? parseInt(this.delayOpen) : TOOLTIP_TIMEOUT
|
45
|
+
this.mouseenterTimeout = setTimeout(() => {
|
46
|
+
this.showTooltip(trigger)
|
47
|
+
if (interactionEnabled) {
|
48
|
+
this.checkCloseTooltip(trigger)
|
49
|
+
}
|
50
|
+
}, delayOpen)
|
51
|
+
})
|
42
52
|
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
53
|
+
trigger.addEventListener('mouseleave', () => {
|
54
|
+
clearTimeout(this.mouseenterTimeout)
|
55
|
+
if (this.delayClose) {
|
56
|
+
const delayClose = parseInt(this.delayClose)
|
57
|
+
this.mouseleaveTimeout = setTimeout(() => {
|
58
|
+
if (interactionEnabled) {
|
59
|
+
this.attachSafeZoneListener()
|
60
|
+
} else {
|
61
|
+
this.hideTooltip()
|
62
|
+
}
|
63
|
+
}, delayClose)
|
64
|
+
} else {
|
48
65
|
if (interactionEnabled) {
|
49
66
|
this.attachSafeZoneListener()
|
50
67
|
} else {
|
51
68
|
this.hideTooltip()
|
52
69
|
}
|
53
|
-
}, delayClose)
|
54
|
-
} else {
|
55
|
-
if (interactionEnabled) {
|
56
|
-
this.attachSafeZoneListener()
|
57
|
-
} else {
|
58
|
-
this.hideTooltip()
|
59
70
|
}
|
60
|
-
}
|
61
|
-
})
|
62
|
-
|
63
|
-
if (interactionEnabled) {
|
64
|
-
this.tooltip.addEventListener('mouseenter', () => {
|
65
|
-
clearSafeZoneListener(this)
|
66
71
|
})
|
67
72
|
|
68
|
-
|
69
|
-
this.
|
70
|
-
|
73
|
+
if (interactionEnabled) {
|
74
|
+
this.tooltip.addEventListener('mouseenter', () => {
|
75
|
+
clearSafeZoneListener(this)
|
76
|
+
})
|
77
|
+
|
78
|
+
this.tooltip.addEventListener('mouseleave', () => {
|
79
|
+
this.attachSafeZoneListener()
|
80
|
+
})
|
81
|
+
}
|
71
82
|
}
|
72
83
|
}
|
73
84
|
})
|
74
85
|
}
|
75
86
|
|
87
|
+
isTooltipVisible() {
|
88
|
+
return this.tooltip && this.tooltip.classList.contains('show')
|
89
|
+
}
|
90
|
+
|
76
91
|
attachSafeZoneListener() {
|
77
92
|
clearSafeZoneListener(this)
|
78
93
|
this.safeZoneHandler = (e) => {
|
@@ -145,7 +160,7 @@ export default class PbTooltip extends PbEnhancedElement {
|
|
145
160
|
|
146
161
|
this.tooltip.classList.add('show')
|
147
162
|
|
148
|
-
if (this.
|
163
|
+
if (this.effectiveTriggerMethod === 'click' && !this.useClickToOpen) {
|
149
164
|
clearTimeout(this.autoHideTimeout)
|
150
165
|
this.autoHideTimeout = setTimeout(() => {
|
151
166
|
this.hideTooltip()
|
@@ -224,6 +239,14 @@ export default class PbTooltip extends PbEnhancedElement {
|
|
224
239
|
return this.element.dataset.pbTooltipTriggerMethod || 'hover'
|
225
240
|
}
|
226
241
|
|
242
|
+
get useClickToOpen() {
|
243
|
+
return this.element.dataset.pbTooltipUseClickToOpen === 'true'
|
244
|
+
}
|
245
|
+
|
246
|
+
get effectiveTriggerMethod() {
|
247
|
+
return this.useClickToOpen ? 'click' : this.triggerMethod
|
248
|
+
}
|
249
|
+
|
227
250
|
get tooltipInteraction() {
|
228
251
|
return this.element.dataset.pbTooltipInteraction === 'true'
|
229
252
|
}
|
@@ -21,6 +21,8 @@ module Playbook
|
|
21
21
|
prop :trigger_method, type: Playbook::Props::Enum,
|
22
22
|
values: %w[hover click],
|
23
23
|
default: "hover"
|
24
|
+
prop :use_click_to_open, type: Playbook::Props::Boolean,
|
25
|
+
default: false
|
24
26
|
prop :width
|
25
27
|
|
26
28
|
def classname
|
@@ -46,6 +48,10 @@ module Playbook
|
|
46
48
|
out
|
47
49
|
end
|
48
50
|
|
51
|
+
def effective_trigger_method
|
52
|
+
use_click_to_open ? "click" : (trigger_method || "hover")
|
53
|
+
end
|
54
|
+
|
49
55
|
def data
|
50
56
|
data = Hash(values[:data]).merge(
|
51
57
|
pb_tooltip_kit: true,
|
@@ -54,8 +60,9 @@ module Playbook
|
|
54
60
|
pb_tooltip_trigger_element_id: trigger_element_id,
|
55
61
|
pb_tooltip_tooltip_id: tooltip_id,
|
56
62
|
pb_tooltip_show_tooltip: true,
|
57
|
-
pb_tooltip_trigger_method:
|
58
|
-
pb_tooltip_interaction: interaction
|
63
|
+
pb_tooltip_trigger_method: effective_trigger_method,
|
64
|
+
pb_tooltip_interaction: interaction,
|
65
|
+
pb_tooltip_use_click_to_open: use_click_to_open
|
59
66
|
)
|
60
67
|
data = data.merge(pb_tooltip_delay_open: delay_open) if delay_open
|
61
68
|
data = data.merge(pb_tooltip_delay_close: delay_close) if delay_close
|
@@ -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-LHsP11gB.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
|