playbook_ui 11.18.0 → 11.19.0.pre.alpha.pagpassthrough1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/app/pb_kits/playbook/_playbook.scss +2 -0
- data/app/pb_kits/playbook/data/menu.yml +1 -0
- data/app/pb_kits/playbook/pb_collapsible/child_kits/CollapsibleContent.tsx +8 -8
- data/app/pb_kits/playbook/pb_file_upload/_file_upload.tsx +10 -3
- data/app/pb_kits/playbook/pb_list/_list.tsx +97 -0
- data/app/pb_kits/playbook/pb_list/{_list_item.jsx → _list_item.tsx} +4 -6
- data/app/pb_kits/playbook/pb_paginate/_paginate.scss +3 -0
- data/app/pb_kits/playbook/pb_paginate/docs/_paginate_default.html.erb +19 -0
- data/app/pb_kits/playbook/pb_paginate/docs/example.yml +6 -0
- data/app/pb_kits/playbook/pb_paginate/paginate.html.erb +5 -0
- data/app/pb_kits/playbook/pb_paginate/paginate.rb +14 -0
- data/app/pb_kits/playbook/pb_popover/_popover.tsx +239 -0
- data/app/pb_kits/playbook/pb_popover/{index.js → index.ts} +10 -6
- data/app/pb_kits/playbook/pb_popover/popover.test.js +222 -0
- data/app/pb_kits/playbook/pb_typeahead/_typeahead.jsx +13 -2
- data/app/pb_kits/playbook/pb_typeahead/docs/_typeahead_with_highlight.jsx +98 -0
- data/app/pb_kits/playbook/pb_typeahead/docs/example.yml +1 -0
- data/app/pb_kits/playbook/pb_typeahead/docs/index.js +1 -0
- data/app/pb_kits/playbook/utilities/_pagination.scss +69 -0
- data/lib/playbook/pagination_renderer.rb +41 -0
- data/lib/playbook/version.rb +2 -2
- data/lib/playbook.rb +2 -0
- metadata +31 -8
- data/app/pb_kits/playbook/pb_list/_list.jsx +0 -98
- data/app/pb_kits/playbook/pb_popover/_popover.jsx +0 -227
@@ -1,98 +0,0 @@
|
|
1
|
-
/* @flow */
|
2
|
-
|
3
|
-
import React, { type Node } from 'react'
|
4
|
-
import classnames from 'classnames'
|
5
|
-
import { buildAriaProps, buildCss, buildDataProps } from '../utilities/props'
|
6
|
-
import { globalProps } from '../utilities/globalProps'
|
7
|
-
|
8
|
-
type ListProps = {
|
9
|
-
aria?: object,
|
10
|
-
borderless: boolean,
|
11
|
-
className?: string,
|
12
|
-
children: array<Node> | Node,
|
13
|
-
dark: boolean,
|
14
|
-
data?: object,
|
15
|
-
id?: string,
|
16
|
-
layout: "" | "left" | "right",
|
17
|
-
ordered: boolean,
|
18
|
-
role?: string,
|
19
|
-
tabIndex?: string,
|
20
|
-
text?: string,
|
21
|
-
size?: string,
|
22
|
-
variant?: string,
|
23
|
-
xpadding: boolean,
|
24
|
-
}
|
25
|
-
|
26
|
-
const List = (props: ListProps) => {
|
27
|
-
const {
|
28
|
-
aria = {},
|
29
|
-
borderless = false,
|
30
|
-
children,
|
31
|
-
className,
|
32
|
-
dark = false,
|
33
|
-
data = {},
|
34
|
-
id,
|
35
|
-
layout = '',
|
36
|
-
ordered = false,
|
37
|
-
role,
|
38
|
-
size = '',
|
39
|
-
tabIndex,
|
40
|
-
xpadding = false,
|
41
|
-
variant,
|
42
|
-
text,
|
43
|
-
} = props
|
44
|
-
|
45
|
-
const layoutClass = {
|
46
|
-
left: 'layout_left',
|
47
|
-
right: 'layout_right',
|
48
|
-
default: '',
|
49
|
-
}
|
50
|
-
|
51
|
-
const childrenWithProps = React.Children.map(children, (child) => {
|
52
|
-
return React.cloneElement(child, { text, variant })
|
53
|
-
})
|
54
|
-
const ariaProps = buildAriaProps(aria)
|
55
|
-
const dataProps = buildDataProps(data)
|
56
|
-
const classes = classnames(
|
57
|
-
buildCss('pb_list_kit', layoutClass[layout], size, {
|
58
|
-
dark: dark,
|
59
|
-
borderless: borderless,
|
60
|
-
ordered: ordered,
|
61
|
-
xpadding: xpadding,
|
62
|
-
}),
|
63
|
-
globalProps(props),
|
64
|
-
className
|
65
|
-
)
|
66
|
-
|
67
|
-
return (
|
68
|
-
<div
|
69
|
-
className={classes}
|
70
|
-
>
|
71
|
-
<If condition={ordered}>
|
72
|
-
<ol
|
73
|
-
{...ariaProps}
|
74
|
-
{...dataProps}
|
75
|
-
className={className}
|
76
|
-
id={id}
|
77
|
-
role={role}
|
78
|
-
tabIndex={tabIndex}
|
79
|
-
>
|
80
|
-
{childrenWithProps}
|
81
|
-
</ol>
|
82
|
-
<Else />
|
83
|
-
<ul
|
84
|
-
{...ariaProps}
|
85
|
-
{...dataProps}
|
86
|
-
className={className}
|
87
|
-
id={id}
|
88
|
-
role={role}
|
89
|
-
tabIndex={tabIndex}
|
90
|
-
>
|
91
|
-
{childrenWithProps}
|
92
|
-
</ul>
|
93
|
-
</If>
|
94
|
-
</div>
|
95
|
-
)
|
96
|
-
}
|
97
|
-
|
98
|
-
export default List
|
@@ -1,227 +0,0 @@
|
|
1
|
-
/* eslint-disable react/no-multi-comp */
|
2
|
-
// @flow
|
3
|
-
|
4
|
-
import React, {useEffect} from "react";
|
5
|
-
import ReactDOM from "react-dom";
|
6
|
-
|
7
|
-
import {
|
8
|
-
Popper,
|
9
|
-
Manager as PopperManager,
|
10
|
-
PopperProps,
|
11
|
-
Reference as PopperReference,
|
12
|
-
} from "react-popper";
|
13
|
-
|
14
|
-
import {
|
15
|
-
buildAriaProps,
|
16
|
-
buildCss,
|
17
|
-
buildDataProps,
|
18
|
-
noop,
|
19
|
-
} from "../utilities/props";
|
20
|
-
|
21
|
-
import classnames from "classnames";
|
22
|
-
import { globalProps } from "../utilities/globalProps";
|
23
|
-
|
24
|
-
type PbPopoverProps = {
|
25
|
-
aria?: object,
|
26
|
-
className?: string,
|
27
|
-
closeOnClick?: "outside" | "inside",
|
28
|
-
data?: object,
|
29
|
-
id?: String,
|
30
|
-
offset?: boolean,
|
31
|
-
reference: PopperReference,
|
32
|
-
show?: boolean,
|
33
|
-
shouldClosePopover?: () => boolean,
|
34
|
-
} & PopperProps;
|
35
|
-
|
36
|
-
// Prop enabled default modifiers here
|
37
|
-
// https://popper.js.org/docs/v2/modifiers
|
38
|
-
|
39
|
-
const POPOVER_MODIFIERS = {
|
40
|
-
offset: {
|
41
|
-
//https://popper.js.org/docs/v2/modifiers/offset/
|
42
|
-
enabled: true,
|
43
|
-
name: "offset",
|
44
|
-
options: {
|
45
|
-
offset: [0, 20],
|
46
|
-
},
|
47
|
-
phase: "main",
|
48
|
-
},
|
49
|
-
};
|
50
|
-
|
51
|
-
const popoverModifiers = ({ modifiers, offset }) => {
|
52
|
-
return offset ? modifiers.concat([POPOVER_MODIFIERS.offset]) : modifiers;
|
53
|
-
};
|
54
|
-
|
55
|
-
const Popover = (props: PbPopoverProps) => {
|
56
|
-
const {
|
57
|
-
aria = {},
|
58
|
-
className,
|
59
|
-
children,
|
60
|
-
data = {},
|
61
|
-
id,
|
62
|
-
modifiers,
|
63
|
-
offset,
|
64
|
-
placement,
|
65
|
-
referenceElement,
|
66
|
-
zIndex,
|
67
|
-
maxHeight,
|
68
|
-
maxWidth,
|
69
|
-
minHeight,
|
70
|
-
minWidth,
|
71
|
-
} = props;
|
72
|
-
|
73
|
-
const popoverSpacing =
|
74
|
-
globalProps(props).includes("dark") || !globalProps(props)
|
75
|
-
? "p_sm"
|
76
|
-
: globalProps(props);
|
77
|
-
const overflowHandling = maxHeight || maxWidth ? "overflow_handling" : "";
|
78
|
-
const zIndexStyle = zIndex ? { zIndex: zIndex } : {};
|
79
|
-
const widthHeightStyles = () => {
|
80
|
-
return Object.assign(
|
81
|
-
{},
|
82
|
-
maxHeight ? { maxHeight: maxHeight } : {},
|
83
|
-
maxWidth ? { maxWidth: maxWidth } : {},
|
84
|
-
minHeight ? { minHeight: minHeight } : {},
|
85
|
-
minWidth ? { minWidth: minWidth } : {}
|
86
|
-
);
|
87
|
-
};
|
88
|
-
const ariaProps = buildAriaProps(aria);
|
89
|
-
const dataProps = buildDataProps(data);
|
90
|
-
const classes = classnames(
|
91
|
-
buildCss("pb_popover_kit"),
|
92
|
-
globalProps(props),
|
93
|
-
className
|
94
|
-
);
|
95
|
-
|
96
|
-
return (
|
97
|
-
<Popper
|
98
|
-
modifiers={popoverModifiers({ modifiers, offset })}
|
99
|
-
placement={placement}
|
100
|
-
referenceElement={referenceElement}
|
101
|
-
>
|
102
|
-
{({ placement, ref, style }) => {
|
103
|
-
return (
|
104
|
-
<div
|
105
|
-
{...ariaProps}
|
106
|
-
{...dataProps}
|
107
|
-
className={classes}
|
108
|
-
data-placement={placement}
|
109
|
-
id={id}
|
110
|
-
ref={ref}
|
111
|
-
style={Object.assign({}, style, zIndexStyle)}
|
112
|
-
>
|
113
|
-
<div
|
114
|
-
className={classnames(`${buildCss("pb_popover_tooltip")} show`)}
|
115
|
-
>
|
116
|
-
<div
|
117
|
-
className={classnames(
|
118
|
-
"pb_popover_body",
|
119
|
-
popoverSpacing,
|
120
|
-
overflowHandling
|
121
|
-
)}
|
122
|
-
style={widthHeightStyles()}
|
123
|
-
>
|
124
|
-
{children}
|
125
|
-
</div>
|
126
|
-
</div>
|
127
|
-
</div>
|
128
|
-
);
|
129
|
-
}}
|
130
|
-
</Popper>
|
131
|
-
);
|
132
|
-
};
|
133
|
-
|
134
|
-
const PbReactPopover = (props: PbPopoverProps) => {
|
135
|
-
const {
|
136
|
-
className,
|
137
|
-
children,
|
138
|
-
modifiers = [],
|
139
|
-
offset = false,
|
140
|
-
placement = "left",
|
141
|
-
portal = "body",
|
142
|
-
reference,
|
143
|
-
referenceElement,
|
144
|
-
show = false,
|
145
|
-
usePortal = true,
|
146
|
-
zIndex,
|
147
|
-
maxHeight,
|
148
|
-
maxWidth,
|
149
|
-
minHeight,
|
150
|
-
minWidth,
|
151
|
-
} = props;
|
152
|
-
|
153
|
-
useEffect(() => {
|
154
|
-
const { closeOnClick, shouldClosePopover = noop } = props
|
155
|
-
|
156
|
-
if (!closeOnClick) return
|
157
|
-
|
158
|
-
document.body.addEventListener('click', ({ target }) => {
|
159
|
-
const targetIsPopover =
|
160
|
-
target.closest('[class^=pb_popover_tooltip]') !== null
|
161
|
-
const targetIsReference =
|
162
|
-
target.closest('.pb_popover_reference_wrapper') !== null
|
163
|
-
|
164
|
-
switch (closeOnClick) {
|
165
|
-
case 'outside':
|
166
|
-
if (!targetIsPopover || targetIsReference) {
|
167
|
-
shouldClosePopover(true)
|
168
|
-
}
|
169
|
-
break
|
170
|
-
case 'inside':
|
171
|
-
if (targetIsPopover || targetIsReference) {
|
172
|
-
shouldClosePopover(true)
|
173
|
-
}
|
174
|
-
break
|
175
|
-
case 'any':
|
176
|
-
shouldClosePopover(true)
|
177
|
-
break
|
178
|
-
}
|
179
|
-
}, { capture: true })
|
180
|
-
}, [])
|
181
|
-
|
182
|
-
const popoverComponent = (
|
183
|
-
<Popover
|
184
|
-
className={className}
|
185
|
-
maxHeight={maxHeight}
|
186
|
-
maxWidth={maxWidth}
|
187
|
-
minHeight={minHeight}
|
188
|
-
minWidth={minWidth}
|
189
|
-
modifiers={modifiers}
|
190
|
-
offset={offset}
|
191
|
-
placement={placement}
|
192
|
-
referenceElement={referenceElement}
|
193
|
-
zIndex={zIndex}
|
194
|
-
{...props}
|
195
|
-
>
|
196
|
-
{children}
|
197
|
-
</Popover>
|
198
|
-
);
|
199
|
-
|
200
|
-
return (
|
201
|
-
<PopperManager>
|
202
|
-
<If condition={reference && !referenceElement}>
|
203
|
-
<PopperReference>
|
204
|
-
{({ ref }) => (
|
205
|
-
<span className="pb_popover_reference_wrapper"
|
206
|
-
ref={ref}
|
207
|
-
>
|
208
|
-
<reference.type {...reference.props} />
|
209
|
-
</span>
|
210
|
-
)}
|
211
|
-
</PopperReference>
|
212
|
-
</If>
|
213
|
-
<If condition={show}>
|
214
|
-
<If condition={usePortal}>
|
215
|
-
{ReactDOM.createPortal(
|
216
|
-
popoverComponent,
|
217
|
-
document.querySelector(portal)
|
218
|
-
)}
|
219
|
-
<Else />
|
220
|
-
{popoverComponent}
|
221
|
-
</If>
|
222
|
-
</If>
|
223
|
-
</PopperManager>
|
224
|
-
);
|
225
|
-
};
|
226
|
-
|
227
|
-
export default PbReactPopover;
|