playbook_ui 14.12.0 → 14.13.0.pre.alpha.PBNTR5596084
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 +1 -0
- data/app/pb_kits/playbook/pb_advanced_table/Components/CustomCell.tsx +1 -1
- data/app/pb_kits/playbook/pb_advanced_table/Components/TableHeaderCell.tsx +11 -4
- data/app/pb_kits/playbook/pb_advanced_table/Utilities/ActionBarAnimationHelper.ts +26 -0
- data/app/pb_kits/playbook/pb_advanced_table/_advanced_table.scss +71 -10
- data/app/pb_kits/playbook/pb_advanced_table/_advanced_table.tsx +37 -21
- data/app/pb_kits/playbook/pb_advanced_table/advanced_table.html.erb +3 -3
- data/app/pb_kits/playbook/pb_advanced_table/advanced_table.rb +3 -1
- data/app/pb_kits/playbook/pb_advanced_table/advanced_table.test.jsx +1 -1
- data/app/pb_kits/playbook/pb_advanced_table/docs/_advanced_table_loading.html.erb +33 -0
- data/app/pb_kits/playbook/pb_advanced_table/docs/_advanced_table_loading_rails.md +1 -0
- data/app/pb_kits/playbook/pb_advanced_table/docs/{_advanced_table_loading.md → _advanced_table_loading_react.md} +2 -2
- data/app/pb_kits/playbook/pb_advanced_table/docs/_advanced_table_responsive.html.erb +38 -0
- data/app/pb_kits/playbook/pb_advanced_table/docs/_advanced_table_table_props.jsx +1 -0
- data/app/pb_kits/playbook/pb_advanced_table/docs/_advanced_table_table_props_react.md +3 -1
- data/app/pb_kits/playbook/pb_advanced_table/docs/_advanced_table_table_props_sticky_header.jsx +55 -0
- data/app/pb_kits/playbook/pb_advanced_table/docs/_advanced_table_table_props_sticky_header_react.md +3 -0
- data/app/pb_kits/playbook/pb_advanced_table/docs/example.yml +3 -0
- data/app/pb_kits/playbook/pb_advanced_table/docs/index.js +2 -1
- data/app/pb_kits/playbook/pb_advanced_table/index.js +9 -6
- data/app/pb_kits/playbook/pb_advanced_table/table_body.rb +17 -3
- data/app/pb_kits/playbook/pb_advanced_table/table_header.html.erb +15 -11
- data/app/pb_kits/playbook/pb_advanced_table/table_header.rb +14 -3
- data/app/pb_kits/playbook/pb_advanced_table/table_row.html.erb +10 -7
- data/app/pb_kits/playbook/pb_advanced_table/table_row.rb +9 -1
- data/app/pb_kits/playbook/pb_advanced_table/table_subrow_header.html.erb +1 -1
- data/app/pb_kits/playbook/pb_advanced_table/table_subrow_header.rb +9 -0
- data/app/pb_kits/playbook/pb_avatar/_avatar.scss +14 -0
- data/app/pb_kits/playbook/pb_avatar/_avatar.tsx +11 -7
- data/app/pb_kits/playbook/pb_avatar/avatar.html.erb +6 -7
- data/app/pb_kits/playbook/pb_avatar/docs/_avatar_badge_component_overlay.jsx +9 -3
- data/app/pb_kits/playbook/pb_avatar/docs/_avatar_circle_icon_component_overlay.jsx +6 -2
- data/app/pb_kits/playbook/pb_button/button.rb +1 -1
- data/app/pb_kits/playbook/pb_card/card.html.erb +21 -2
- data/app/pb_kits/playbook/pb_card/card.rb +7 -0
- data/app/pb_kits/playbook/pb_copy_button/_copy_button.scss +4 -0
- data/app/pb_kits/playbook/pb_copy_button/_copy_button.tsx +92 -0
- data/app/pb_kits/playbook/pb_copy_button/copy_button.html.erb +15 -0
- data/app/pb_kits/playbook/pb_copy_button/copy_button.rb +28 -0
- data/app/pb_kits/playbook/pb_copy_button/copy_button.test.jsx +64 -0
- data/app/pb_kits/playbook/pb_copy_button/docs/_copy_button_default.html.erb +2 -0
- data/app/pb_kits/playbook/pb_copy_button/docs/_copy_button_default.jsx +21 -0
- data/app/pb_kits/playbook/pb_copy_button/docs/_copy_button_from.html.erb +5 -0
- data/app/pb_kits/playbook/pb_copy_button/docs/_copy_button_from.jsx +45 -0
- data/app/pb_kits/playbook/pb_copy_button/docs/_copy_button_from.md +1 -0
- data/app/pb_kits/playbook/pb_copy_button/docs/example.yml +8 -0
- data/app/pb_kits/playbook/pb_copy_button/docs/index.js +2 -0
- data/app/pb_kits/playbook/pb_copy_button/index.js +47 -0
- data/app/pb_kits/playbook/pb_date/_date.tsx +14 -4
- data/app/pb_kits/playbook/pb_date/docs/_date_default.jsx +2 -1
- data/app/pb_kits/playbook/pb_date/docs/_date_unstyled.jsx +13 -5
- data/app/pb_kits/playbook/pb_date_picker/_date_picker.tsx +3 -1
- data/app/pb_kits/playbook/pb_draggable/docs/_draggable_multiple_containers_rails.html.erb +99 -0
- data/app/pb_kits/playbook/pb_draggable/docs/_draggable_multiple_containers_rails.md +1 -0
- data/app/pb_kits/playbook/pb_draggable/docs/_draggable_with_cards_rails.html.erb +1 -3
- data/app/pb_kits/playbook/pb_draggable/docs/_draggable_with_cards_rails.md +7 -0
- data/app/pb_kits/playbook/pb_draggable/docs/_draggable_with_table.html.erb +61 -0
- data/app/pb_kits/playbook/pb_draggable/docs/_draggable_with_table.md +4 -0
- data/app/pb_kits/playbook/pb_draggable/docs/_draggable_with_table_react.jsx +90 -0
- data/app/pb_kits/playbook/pb_draggable/docs/_draggable_with_table_react.md +5 -0
- data/app/pb_kits/playbook/pb_draggable/docs/example.yml +4 -5
- data/app/pb_kits/playbook/pb_draggable/docs/index.js +2 -1
- data/app/pb_kits/playbook/pb_draggable/draggable_container.html.erb +2 -2
- data/app/pb_kits/playbook/pb_draggable/draggable_container.rb +5 -0
- data/app/pb_kits/playbook/pb_draggable/draggable_item.html.erb +1 -1
- data/app/pb_kits/playbook/pb_draggable/draggable_item.rb +4 -0
- data/app/pb_kits/playbook/pb_draggable/index.js +151 -15
- data/app/pb_kits/playbook/pb_draggable/subcomponents/DraggableContainer.tsx +7 -4
- data/app/pb_kits/playbook/pb_draggable/subcomponents/DraggableItem.tsx +6 -3
- data/app/pb_kits/playbook/pb_file_upload/file_upload.html.erb +1 -6
- data/app/pb_kits/playbook/pb_filter/filter.html.erb +1 -5
- data/app/pb_kits/playbook/pb_fixed_confirmation_toast/docs/_fixed_confirmation_toast_auto_close.html.erb +58 -0
- data/app/pb_kits/playbook/pb_fixed_confirmation_toast/docs/_fixed_confirmation_toast_auto_close_rails.md +3 -0
- data/app/pb_kits/playbook/pb_fixed_confirmation_toast/docs/example.yml +1 -0
- data/app/pb_kits/playbook/pb_fixed_confirmation_toast/index.js +7 -5
- data/app/pb_kits/playbook/pb_form_group/form_group.html.erb +1 -6
- data/app/pb_kits/playbook/pb_form_pill/form_pill.html.erb +1 -1
- data/app/pb_kits/playbook/pb_home_address_street/_home_address_street.tsx +11 -7
- data/app/pb_kits/playbook/pb_home_address_street/docs/_home_address_street_formatting.html.erb +11 -0
- data/app/pb_kits/playbook/pb_home_address_street/docs/_home_address_street_formatting.jsx +22 -0
- data/app/pb_kits/playbook/pb_home_address_street/docs/_home_address_street_formatting_rails.md +1 -0
- data/app/pb_kits/playbook/pb_home_address_street/docs/_home_address_street_formatting_react.md +1 -0
- data/app/pb_kits/playbook/pb_home_address_street/docs/example.yml +2 -0
- data/app/pb_kits/playbook/pb_home_address_street/docs/index.js +1 -0
- data/app/pb_kits/playbook/pb_home_address_street/home_address_street.rb +13 -2
- data/app/pb_kits/playbook/pb_icon/icon.html.erb +2 -6
- data/app/pb_kits/playbook/pb_icon_button/docs/_icon_button_default.html.erb +1 -2
- data/app/pb_kits/playbook/pb_icon_button/docs/_icon_button_sizes.html.erb +27 -0
- data/app/pb_kits/playbook/pb_icon_button/docs/example.yml +1 -3
- data/app/pb_kits/playbook/pb_icon_button/icon_button.html.erb +1 -1
- data/app/pb_kits/playbook/pb_icon_button/icon_button.rb +3 -0
- data/app/pb_kits/playbook/pb_layout/body.html.erb +1 -5
- data/app/pb_kits/playbook/pb_layout/footer.html.erb +1 -5
- data/app/pb_kits/playbook/pb_layout/header.html.erb +1 -5
- data/app/pb_kits/playbook/pb_layout/item.html.erb +1 -5
- data/app/pb_kits/playbook/pb_layout/layout.html.erb +1 -5
- data/app/pb_kits/playbook/pb_layout/sidebar.html.erb +1 -5
- data/app/pb_kits/playbook/pb_legend/legend.html.erb +1 -6
- data/app/pb_kits/playbook/pb_lightbox/lightbox.scss +7 -6
- data/app/pb_kits/playbook/pb_link/_link.tsx +18 -0
- data/app/pb_kits/playbook/pb_link/docs/_link_target.html.erb +15 -0
- data/app/pb_kits/playbook/pb_link/docs/_link_target.jsx +29 -0
- data/app/pb_kits/playbook/pb_link/docs/example.yml +5 -3
- data/app/pb_kits/playbook/pb_link/docs/index.js +2 -1
- data/app/pb_kits/playbook/pb_link/link.html.erb +1 -1
- data/app/pb_kits/playbook/pb_link/link.rb +6 -0
- data/app/pb_kits/playbook/pb_link/link.test.jsx +30 -0
- data/app/pb_kits/playbook/pb_message/message.html.erb +1 -6
- data/app/pb_kits/playbook/pb_message/message_mention.html.erb +1 -6
- data/app/pb_kits/playbook/pb_progress_step/docs/_progress_step_tooltip.html.erb +6 -6
- data/app/pb_kits/playbook/pb_table/docs/_table_with_background_kit.html.erb +6 -9
- data/app/pb_kits/playbook/pb_table/docs/_table_with_background_kit.jsx +6 -9
- data/app/pb_kits/playbook/pb_table/docs/_table_with_clickable_rows.html.erb +47 -0
- data/app/pb_kits/playbook/pb_table/docs/_table_with_clickable_rows.jsx +88 -0
- data/app/pb_kits/playbook/pb_table/docs/_table_with_clickable_rows.md +1 -0
- data/app/pb_kits/playbook/pb_table/docs/_table_with_collapsible_with_custom_content.jsx +12 -8
- data/app/pb_kits/playbook/pb_table/docs/_table_with_collapsible_with_custom_content_rails.html.erb +52 -0
- data/app/pb_kits/playbook/pb_table/docs/_table_with_collapsible_with_custom_content_rails.md +0 -0
- data/app/pb_kits/playbook/pb_table/docs/_table_with_collapsible_with_nested_rows_rails.html.erb +52 -0
- data/app/pb_kits/playbook/pb_table/docs/_table_with_collapsible_with_nested_rows_rails.md +3 -0
- data/app/pb_kits/playbook/pb_table/docs/_table_with_collapsible_with_nested_table_rails.html.erb +80 -0
- data/app/pb_kits/playbook/pb_table/docs/_table_with_collapsible_with_nested_table_rails.md +1 -0
- data/app/pb_kits/playbook/pb_table/docs/_table_with_selectable_rows.html.erb +96 -0
- data/app/pb_kits/playbook/pb_table/docs/_table_with_selectable_rows.jsx +101 -0
- data/app/pb_kits/playbook/pb_table/docs/_table_with_selectable_rows.md +1 -0
- data/app/pb_kits/playbook/pb_table/docs/example.yml +7 -0
- data/app/pb_kits/playbook/pb_table/docs/index.js +3 -1
- data/app/pb_kits/playbook/pb_table/styles/_desktop_collapse.scss +26 -0
- data/app/pb_kits/playbook/pb_table/styles/_mobile.scss +0 -1
- data/app/pb_kits/playbook/pb_table/styles/_mobile_collapse.scss +25 -0
- data/app/pb_kits/playbook/pb_table/styles/_tablet_collapse.scss +25 -0
- data/app/pb_kits/playbook/pb_table/subcomponents/_table_body.tsx +29 -2
- data/app/pb_kits/playbook/pb_table/subcomponents/_table_row.tsx +31 -3
- data/app/pb_kits/playbook/pb_table/table_body.html.erb +13 -7
- data/app/pb_kits/playbook/pb_table/table_body.rb +2 -0
- data/app/pb_kits/playbook/pb_table/table_row.html.erb +13 -7
- data/app/pb_kits/playbook/pb_table/table_row.rb +5 -1
- data/app/pb_kits/playbook/pb_text_input/docs/_text_input_mask.html.erb +1 -1
- data/app/pb_kits/playbook/pb_text_input/index.js +52 -83
- data/app/pb_kits/playbook/pb_tooltip/_tooltip.tsx +3 -1
- data/app/pb_kits/playbook/pb_tooltip/docs/_tooltip_default.html.erb +1 -1
- data/app/pb_kits/playbook/pb_tooltip/index.js +45 -27
- data/app/pb_kits/playbook/pb_tooltip/tooltip.rb +5 -1
- data/app/pb_kits/playbook/pb_user/_user.tsx +3 -0
- data/app/pb_kits/playbook/pb_user/docs/_user_light_weight.html.erb +42 -0
- data/app/pb_kits/playbook/pb_user/docs/_user_light_weight.jsx +59 -0
- data/app/pb_kits/playbook/pb_user/docs/_user_light_weight.md +2 -0
- data/app/pb_kits/playbook/pb_user/docs/example.yml +2 -0
- data/app/pb_kits/playbook/pb_user/docs/index.js +1 -0
- data/app/pb_kits/playbook/pb_user/user.html.erb +1 -1
- data/app/pb_kits/playbook/pb_user/user.rb +1 -0
- data/app/pb_kits/playbook/pb_user/user.test.js +14 -0
- data/dist/chunks/_typeahead-C_q1qAtC.js +36 -0
- data/dist/chunks/_weekday_stacked-DCeouuO3.js +45 -0
- data/dist/chunks/lazysizes-B7xYodB-.js +1 -0
- data/dist/chunks/{lib-kMuhBuU7.js → lib-WQEeEj3t.js} +2 -2
- data/dist/chunks/{pb_form_validation-DBJ0wZuS.js → pb_form_validation-Cq64l4zn.js} +1 -1
- data/dist/chunks/vendor.js +1 -1
- data/dist/menu.yml +6 -0
- 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/pb_forms_global_props_helper.rb +136 -0
- data/lib/playbook/pb_forms_helper.rb +13 -4
- data/lib/playbook/version.rb +2 -2
- metadata +59 -9
- data/dist/chunks/_typeahead-BWwaAo_0.js +0 -36
- data/dist/chunks/_weekday_stacked-DE8qVYG2.js +0 -45
- data/dist/chunks/lazysizes-DHz07jlL.js +0 -1
- /data/app/pb_kits/playbook/pb_fixed_confirmation_toast/docs/{_fixed_confirmation_toast_auto_close.md → _fixed_confirmation_toast_auto_close_react.md} +0 -0
@@ -0,0 +1,21 @@
|
|
1
|
+
import React from 'react'
|
2
|
+
import { CopyButton, Textarea } from 'playbook-ui'
|
3
|
+
|
4
|
+
const CopyButtonDefault = (props) => (
|
5
|
+
<div>
|
6
|
+
<CopyButton
|
7
|
+
{...props}
|
8
|
+
text="Copy Text"
|
9
|
+
tooltipPlacement="right"
|
10
|
+
tooltipText="Text copied!"
|
11
|
+
value="Playbook makes it easy to support bleeding edge, or legacy systems. Use Playbook’s 200+ components and end-to-end design language to create simple, intuitive and beautiful experiences with ease."
|
12
|
+
/>
|
13
|
+
|
14
|
+
<Textarea
|
15
|
+
{...props}
|
16
|
+
placeholder="Copy and paste here"
|
17
|
+
/>
|
18
|
+
</div>
|
19
|
+
)
|
20
|
+
|
21
|
+
export default CopyButtonDefault
|
@@ -0,0 +1,5 @@
|
|
1
|
+
<%= pb_rails("body", props: { id: "body", text: "Copy this body text!"}) %>
|
2
|
+
<%= pb_rails("copy_button", props: { text: "Copy Body text", from: "body", id: "copy-body-button" }) %>
|
3
|
+
<%= pb_rails("text_input", props: { margin_top: "xs", placeholder: "Copy and paste here" }) %>
|
4
|
+
<%= pb_rails("copy_button", props: { text: "Copy Text Input", from: "copy-input", id: "copy-input-button" }) %>
|
5
|
+
<%= pb_rails("text_input", props: { margin_top: "xs", id: "copy-input" , value: "Copy and paste here" }) %>
|
@@ -0,0 +1,45 @@
|
|
1
|
+
import React, { useState } from 'react'
|
2
|
+
import { CopyButton, Body, TextInput, Textarea } from 'playbook-ui'
|
3
|
+
|
4
|
+
const CopyButtonFrom = (props) => {
|
5
|
+
const [text, setText] = useState("Copy this text input text")
|
6
|
+
|
7
|
+
const handleChange = (event) => {
|
8
|
+
setText(event.target.value);
|
9
|
+
}
|
10
|
+
|
11
|
+
return (<div>
|
12
|
+
<Body id="body">Copy this body text!</Body>
|
13
|
+
<CopyButton
|
14
|
+
{...props}
|
15
|
+
from="body"
|
16
|
+
marginBottom="sm"
|
17
|
+
text="Copy Body text"
|
18
|
+
tooltipPlacement="right"
|
19
|
+
tooltipText="Body text copied!"
|
20
|
+
/>
|
21
|
+
|
22
|
+
<TextInput
|
23
|
+
{...props}
|
24
|
+
id="textinput"
|
25
|
+
onChange={handleChange}
|
26
|
+
value={text}
|
27
|
+
/>
|
28
|
+
<CopyButton
|
29
|
+
{...props}
|
30
|
+
from="textinput"
|
31
|
+
marginBottom="sm"
|
32
|
+
text="Copy Text Input"
|
33
|
+
tooltipPlacement="right"
|
34
|
+
tooltipText="Text input copied!"
|
35
|
+
/>
|
36
|
+
|
37
|
+
<Textarea
|
38
|
+
{...props}
|
39
|
+
placeholder="Copy and paste here"
|
40
|
+
/>
|
41
|
+
</div>
|
42
|
+
)
|
43
|
+
}
|
44
|
+
|
45
|
+
export default CopyButtonFrom
|
@@ -0,0 +1 @@
|
|
1
|
+
Provide an element's ID as the `from` parameter, and its text will be copied. If the element is an input, its `value` will be copied; otherwise, the `innerText` will be used. Additionally, if a `value` prop is provided, it will override the content from the `from` element and be copied instead.
|
@@ -0,0 +1,47 @@
|
|
1
|
+
import PbEnhancedElement from "../pb_enhanced_element"
|
2
|
+
|
3
|
+
export default class PbCopyButton extends PbEnhancedElement {
|
4
|
+
static get selector() {
|
5
|
+
return '.pb_copy_button_kit'
|
6
|
+
}
|
7
|
+
|
8
|
+
connect() {
|
9
|
+
this.handleClick = this.handleClick.bind(this)
|
10
|
+
this.button = this.element.querySelector('button')
|
11
|
+
if (this.button) {
|
12
|
+
this.button.addEventListener('click', this.handleClick)
|
13
|
+
}
|
14
|
+
}
|
15
|
+
|
16
|
+
disconnect() {
|
17
|
+
if (this.button) {
|
18
|
+
this.button.removeEventListener('click', this.handleClick)
|
19
|
+
}
|
20
|
+
}
|
21
|
+
|
22
|
+
handleClick() {
|
23
|
+
const fromId = this.element.getAttribute('data-from')
|
24
|
+
if (fromId) {
|
25
|
+
const fromElement = document.querySelector(`#${fromId}`)
|
26
|
+
if (fromElement) {
|
27
|
+
let contentToCopy = ''
|
28
|
+
if (fromElement.tagName.toLowerCase() === 'input') {
|
29
|
+
contentToCopy = fromElement.value
|
30
|
+
} else {
|
31
|
+
contentToCopy = fromElement.innerText
|
32
|
+
}
|
33
|
+
navigator.clipboard.writeText(contentToCopy)
|
34
|
+
.catch(err => console.error('Failed to copy text', err))
|
35
|
+
return
|
36
|
+
}
|
37
|
+
}
|
38
|
+
|
39
|
+
const textToCopy = this.element.getAttribute('data-copy-value')
|
40
|
+
if (textToCopy) {
|
41
|
+
navigator.clipboard.writeText(textToCopy)
|
42
|
+
.catch(err => console.error('Failed to copy text', err))
|
43
|
+
} else {
|
44
|
+
console.warn('No data-copy-value attribute found or data-from element')
|
45
|
+
}
|
46
|
+
}
|
47
|
+
}
|
@@ -14,6 +14,7 @@ type PbDateProps = {
|
|
14
14
|
alignment?: "left" | "center" | "right";
|
15
15
|
aria?: { [key: string]: string };
|
16
16
|
className?: string;
|
17
|
+
dark?: boolean;
|
17
18
|
data?: { [key: string]: string };
|
18
19
|
htmlOptions?: { [key: string]: string | number | boolean | (() => void) };
|
19
20
|
id?: string;
|
@@ -29,6 +30,7 @@ const PbDate = (props: PbDateProps): React.ReactElement => {
|
|
29
30
|
aria = {},
|
30
31
|
alignment = "left",
|
31
32
|
className,
|
33
|
+
dark = false,
|
32
34
|
data = {},
|
33
35
|
htmlOptions = {},
|
34
36
|
id,
|
@@ -56,7 +58,7 @@ const PbDate = (props: PbDateProps): React.ReactElement => {
|
|
56
58
|
);
|
57
59
|
|
58
60
|
return (
|
59
|
-
<div
|
61
|
+
<div
|
60
62
|
{...ariaProps}
|
61
63
|
{...dataProps}
|
62
64
|
{...htmlProps}
|
@@ -93,7 +95,9 @@ const PbDate = (props: PbDateProps): React.ReactElement => {
|
|
93
95
|
</>
|
94
96
|
: size == "md" || size == "lg"
|
95
97
|
? (
|
96
|
-
<Title
|
98
|
+
<Title
|
99
|
+
dark={dark}
|
100
|
+
size={4}
|
97
101
|
tag="h4"
|
98
102
|
>
|
99
103
|
{showIcon && (
|
@@ -127,6 +131,7 @@ const PbDate = (props: PbDateProps): React.ReactElement => {
|
|
127
131
|
<>
|
128
132
|
{showIcon && (
|
129
133
|
<Caption className="pb_icon_kit_container"
|
134
|
+
dark={dark}
|
130
135
|
tag="span"
|
131
136
|
>
|
132
137
|
<Icon fixedWidth
|
@@ -138,15 +143,20 @@ const PbDate = (props: PbDateProps): React.ReactElement => {
|
|
138
143
|
|
139
144
|
{showDayOfWeek && (
|
140
145
|
<>
|
141
|
-
<Caption
|
146
|
+
<Caption dark={dark}
|
147
|
+
tag="div">
|
148
|
+
{weekday}
|
149
|
+
</Caption>
|
142
150
|
<Caption color="light"
|
151
|
+
dark={dark}
|
143
152
|
tag="div"
|
144
153
|
text=" • "
|
145
154
|
/>
|
146
155
|
</>
|
147
156
|
)}
|
148
157
|
|
149
|
-
<Caption
|
158
|
+
<Caption dark={dark}
|
159
|
+
tag="span">
|
150
160
|
{month} {day}
|
151
161
|
{currentYear != year && <>{`, ${year}`}</>}
|
152
162
|
</Caption>
|
@@ -18,7 +18,7 @@ const DateDefault = (props) => {
|
|
18
18
|
value={"2012-08-03"}
|
19
19
|
{...props}
|
20
20
|
/>
|
21
|
-
<Caption>{"(Hyphenated Date)"}</Caption>
|
21
|
+
<Caption {...props}>{"(Hyphenated Date)"}</Caption>
|
22
22
|
</div>
|
23
23
|
|
24
24
|
<br />
|
@@ -56,6 +56,7 @@ const DateDefault = (props) => {
|
|
56
56
|
<Title
|
57
57
|
size={4}
|
58
58
|
text={"(Hyphenated Date)"}
|
59
|
+
{...props}
|
59
60
|
/>
|
60
61
|
</div>
|
61
62
|
|
@@ -4,7 +4,8 @@ import { Caption, Date as FormattedDate, Title } from 'playbook-ui'
|
|
4
4
|
const DateUnstyled = (props) => {
|
5
5
|
return (
|
6
6
|
<>
|
7
|
-
<Caption
|
7
|
+
<Caption {...props}
|
8
|
+
size="xs"
|
8
9
|
text="Basic unstyled example"
|
9
10
|
/>
|
10
11
|
<FormattedDate
|
@@ -15,10 +16,14 @@ const DateUnstyled = (props) => {
|
|
15
16
|
|
16
17
|
<br />
|
17
18
|
|
18
|
-
<Caption
|
19
|
+
<Caption {...props}
|
20
|
+
|
21
|
+
size="xs"
|
19
22
|
text="Example with wrapping typography kit"
|
20
23
|
/>
|
21
|
-
<Title
|
24
|
+
<Title {...props}
|
25
|
+
size={1}
|
26
|
+
>
|
22
27
|
<FormattedDate
|
23
28
|
unstyled
|
24
29
|
value={new Date('25 Dec 1995')}
|
@@ -28,10 +33,13 @@ const DateUnstyled = (props) => {
|
|
28
33
|
|
29
34
|
<br />
|
30
35
|
|
31
|
-
<Caption
|
36
|
+
<Caption {...props}
|
37
|
+
size="xs"
|
32
38
|
text="Example with icon + subcaption"
|
33
39
|
/>
|
34
|
-
<Caption
|
40
|
+
<Caption {...props}
|
41
|
+
size="xs"
|
42
|
+
>
|
35
43
|
<FormattedDate
|
36
44
|
showDayOfWeek
|
37
45
|
showIcon
|
@@ -29,6 +29,7 @@ type DatePickerProps = {
|
|
29
29
|
hideLabel?: boolean,
|
30
30
|
htmlOptions?: {[key: string]: string | number | boolean | (() => void)},
|
31
31
|
id?: string,
|
32
|
+
initializeOnce?: boolean,
|
32
33
|
inLine?: boolean,
|
33
34
|
inputAria?: { [key: string]: string },
|
34
35
|
inputData?: { [key: string]: string },
|
@@ -73,6 +74,7 @@ const DatePicker = (props: DatePickerProps): React.ReactElement => {
|
|
73
74
|
hideLabel = false,
|
74
75
|
htmlOptions = {},
|
75
76
|
id,
|
77
|
+
initializeOnce = false,
|
76
78
|
inLine = false,
|
77
79
|
inputAria = {},
|
78
80
|
inputData = {},
|
@@ -134,7 +136,7 @@ useEffect(() => {
|
|
134
136
|
yearRange,
|
135
137
|
required: false,
|
136
138
|
}, scrollContainer)
|
137
|
-
})
|
139
|
+
}, initializeOnce ? [] : undefined)
|
138
140
|
const filteredProps = {...props}
|
139
141
|
if (filteredProps.marginBottom === undefined) {
|
140
142
|
filteredProps.marginBottom = "sm"
|
@@ -0,0 +1,99 @@
|
|
1
|
+
<% containers = [
|
2
|
+
"To Do",
|
3
|
+
"In Progress",
|
4
|
+
"Done"
|
5
|
+
] %>
|
6
|
+
|
7
|
+
<% items_data = [
|
8
|
+
{
|
9
|
+
id: "11",
|
10
|
+
container: "To Do",
|
11
|
+
title: "Task 1",
|
12
|
+
description: "Bug fixes",
|
13
|
+
assignee_name: "Terry Miles",
|
14
|
+
assignee_img: "https://randomuser.me/api/portraits/men/44.jpg",
|
15
|
+
},
|
16
|
+
{
|
17
|
+
id: "12",
|
18
|
+
container: "To Do",
|
19
|
+
title: "Task 2",
|
20
|
+
description: "Documentation",
|
21
|
+
assignee_name: "Sophia Miles",
|
22
|
+
assignee_img: "https://randomuser.me/api/portraits/women/8.jpg",
|
23
|
+
},
|
24
|
+
{
|
25
|
+
id: "13",
|
26
|
+
container: "In Progress",
|
27
|
+
title: "Task 3",
|
28
|
+
description: "Add a variant",
|
29
|
+
assignee_name: "Alice Jones",
|
30
|
+
assignee_img: "https://randomuser.me/api/portraits/women/10.jpg",
|
31
|
+
},
|
32
|
+
{
|
33
|
+
id: "14",
|
34
|
+
container: "To Do",
|
35
|
+
title: "Task 4",
|
36
|
+
description: "Add jest tests",
|
37
|
+
assignee_name: "Mike James",
|
38
|
+
assignee_img: "https://randomuser.me/api/portraits/men/8.jpg",
|
39
|
+
},
|
40
|
+
{
|
41
|
+
id: "15",
|
42
|
+
container: "Done",
|
43
|
+
title: "Task 5",
|
44
|
+
description: "Alpha testing",
|
45
|
+
assignee_name: "James Guy",
|
46
|
+
assignee_img: "https://randomuser.me/api/portraits/men/18.jpg",
|
47
|
+
},
|
48
|
+
{
|
49
|
+
id: "16",
|
50
|
+
container: "In Progress",
|
51
|
+
title: "Task 6",
|
52
|
+
description: "Release",
|
53
|
+
assignee_name: "Sally Jones",
|
54
|
+
assignee_img: "https://randomuser.me/api/portraits/women/28.jpg",
|
55
|
+
},
|
56
|
+
] %>
|
57
|
+
|
58
|
+
<%= pb_rails("draggable", props: { initial_items: items_data }) do %>
|
59
|
+
<%= pb_rails("flex", props: { justify_content: "center" }) do %>
|
60
|
+
<% containers.each do |container| %>
|
61
|
+
<%= pb_rails("draggable/draggable_container", props: {
|
62
|
+
container: container,
|
63
|
+
width: "xs",
|
64
|
+
padding: "sm",
|
65
|
+
data: { container: container }
|
66
|
+
}) do %>
|
67
|
+
<%= pb_rails("caption", props: { text_align: "center" }) do %><%= container %><% end %>
|
68
|
+
<%= pb_rails("flex", props: {align_items: "stretch", orientation: "column"}) do %>
|
69
|
+
<% items_data.select { |item| item[:container] == container }.each do |item| %>
|
70
|
+
<%= pb_rails("draggable/draggable_item", props: {
|
71
|
+
container: container,
|
72
|
+
drag_id: item[:id]
|
73
|
+
}) do %>
|
74
|
+
<%= pb_rails("card", props: { margin_bottom: "sm", padding: "sm"}) do %>
|
75
|
+
<%= pb_rails("flex", props: { justify: "between" }) do %>
|
76
|
+
<%= pb_rails("flex/flex_item") do %>
|
77
|
+
<%= pb_rails("flex") do %>
|
78
|
+
<%= pb_rails("avatar", props: {
|
79
|
+
image_url: item[:assignee_img],
|
80
|
+
name: item[:assignee_name],
|
81
|
+
size: "xxs"
|
82
|
+
}) %>
|
83
|
+
<%= pb_rails("title", props: {
|
84
|
+
padding_left: "xs",
|
85
|
+
size: 4,
|
86
|
+
text: item[:title]
|
87
|
+
}) %>
|
88
|
+
<% end %>
|
89
|
+
<% end %>
|
90
|
+
<% end %>
|
91
|
+
<%= pb_rails("body", props: { padding_top: "xs", text: item[:description] }) %>
|
92
|
+
<% end %>
|
93
|
+
<% end %>
|
94
|
+
<% end %>
|
95
|
+
<% end %>
|
96
|
+
<% end %>
|
97
|
+
<% end %>
|
98
|
+
<% end %>
|
99
|
+
<% end %>
|
@@ -0,0 +1 @@
|
|
1
|
+
The Draggable kit can also be used to achieve more complex, multiple container functionality as shown here. This complex usage requires the full subcomponent structure.
|
@@ -7,8 +7,7 @@
|
|
7
7
|
<%= pb_rails("draggable", props: {initial_items: initial_items}) do %>
|
8
8
|
<%= pb_rails("draggable/draggable_container") do %>
|
9
9
|
<% initial_items.each do |item| %>
|
10
|
-
|
11
|
-
<%= pb_rails("card", props: {highlight: {position: "side", color:"primary"}, margin_bottom: "xs", padding: "xs"}) do %>
|
10
|
+
<%= pb_rails("card", props: {highlight: {position: "side", color:"primary"}, margin_bottom: "xs", padding: "xs", drag_id: item[:id], draggable_item: true }) do %>
|
12
11
|
<%= pb_rails("flex", props:{align_items: "stretch", flex_direction:"column"}) do %>
|
13
12
|
<%= pb_rails("flex", props:{gap: "xs"}) do %>
|
14
13
|
<%= pb_rails("title", props: { text: item[:name], tag: "h4", size: 4 }) %>
|
@@ -32,7 +31,6 @@
|
|
32
31
|
<% end %>
|
33
32
|
<% end %>
|
34
33
|
<% end %>
|
35
|
-
<% end %>
|
36
34
|
<% end %>
|
37
35
|
<% end %>
|
38
36
|
<% end %>
|
@@ -0,0 +1,7 @@
|
|
1
|
+
For a simplified version of the Draggable API for the Card kit, you can do the following:
|
2
|
+
|
3
|
+
Use the `draggable` kit and manage state as shown.
|
4
|
+
|
5
|
+
`draggable/draggable_container` kit creates the container within which the cards can be dragged and dropped.
|
6
|
+
|
7
|
+
The Card kit is optimized to work with the draggable kit. To enable drag, use the `draggable_item` and `drag_id` props on the Card kit as shown. An additional optional boolean prop (set to true by default) of `drag_handle` is also available to show the drag handle icon.
|
@@ -0,0 +1,61 @@
|
|
1
|
+
<% initial_items = [
|
2
|
+
{
|
3
|
+
id: "1",
|
4
|
+
title: "Task 1",
|
5
|
+
assignee_name: "Terry Miles",
|
6
|
+
assignee_img: "https://randomuser.me/api/portraits/men/44.jpg",
|
7
|
+
},
|
8
|
+
{
|
9
|
+
id: "2",
|
10
|
+
title: "Task 2",
|
11
|
+
assignee_name: "Sophia Miles",
|
12
|
+
assignee_img: "https://randomuser.me/api/portraits/women/8.jpg",
|
13
|
+
},
|
14
|
+
{
|
15
|
+
id: "3",
|
16
|
+
title: "Task 3",
|
17
|
+
assignee_name: "Alice Jones",
|
18
|
+
assignee_img: "https://randomuser.me/api/portraits/women/10.jpg",
|
19
|
+
},
|
20
|
+
{
|
21
|
+
id: "4",
|
22
|
+
title: "Task 4",
|
23
|
+
assignee_name: "Mike James",
|
24
|
+
assignee_img: "https://randomuser.me/api/portraits/men/8.jpg",
|
25
|
+
},
|
26
|
+
{
|
27
|
+
id: "5",
|
28
|
+
title: "Task 5",
|
29
|
+
assignee_name: "James Guy",
|
30
|
+
assignee_img: "https://randomuser.me/api/portraits/men/18.jpg",
|
31
|
+
}
|
32
|
+
] %>
|
33
|
+
|
34
|
+
|
35
|
+
|
36
|
+
<%= pb_rails("draggable", props: {initial_items: initial_items}) do %>
|
37
|
+
<%= pb_rails("table", props: { size: "sm", responsive:"none" }) do %>
|
38
|
+
<%= pb_rails("table/table_head") do %>
|
39
|
+
<%= pb_rails("table/table_row") do %>
|
40
|
+
<%= pb_rails("table/table_header", props: { text: "id"}) %>
|
41
|
+
<%= pb_rails("table/table_header", props: { text: "name"}) %>
|
42
|
+
<%= pb_rails("table/table_header", props: { text: "task number"}) %>
|
43
|
+
<% end %>
|
44
|
+
<% end %>
|
45
|
+
|
46
|
+
<%= pb_rails("table/table_body", props: {draggable_container: true}) do %>
|
47
|
+
<% initial_items.each do |item| %>
|
48
|
+
<%= pb_rails("table/table_row", props:{drag_id: item[:id], draggable_item: true}) do %>
|
49
|
+
<%= pb_rails("table/table_cell", props: { text: item[:id]}) %>
|
50
|
+
<%= pb_rails("table/table_cell") do %>
|
51
|
+
<%= pb_rails("flex", props:{align:"center"}) do %>
|
52
|
+
<%= pb_rails("avatar", props: {size: "xs", image_url: item[:assignee_img]}) %>
|
53
|
+
<%= pb_rails("body", props: {text: item[:assignee_name], padding_left:"sm"}) %>
|
54
|
+
<% end %>
|
55
|
+
<% end %>
|
56
|
+
<%= pb_rails("table/table_cell", props: { text: item[:title]}) %>
|
57
|
+
<% end %>
|
58
|
+
<% end %>
|
59
|
+
<% end %>
|
60
|
+
<% end %>
|
61
|
+
<% end %>
|
@@ -0,0 +1,4 @@
|
|
1
|
+
The draggable kit can also be used in conjunction with the table kit to create draggable table rows. To do this:
|
2
|
+
|
3
|
+
- use the `draggable_container` prop on the table/table_body to designate it as the Draggable Container
|
4
|
+
- use the `draggable_item` prop on the table/table_row to designate it as the Draggable Item. Make sure to also pass id to the `drag_id` prop here.
|
@@ -0,0 +1,90 @@
|
|
1
|
+
import React, { useState } from "react";
|
2
|
+
import { Flex, Table, Body, Avatar, DraggableProvider } from "playbook-ui";
|
3
|
+
|
4
|
+
// Initial items to be dragged
|
5
|
+
const data = [
|
6
|
+
{
|
7
|
+
id: "1",
|
8
|
+
task: "Task 1",
|
9
|
+
assignee_name: "Terry Miles",
|
10
|
+
assignee_img: "https://randomuser.me/api/portraits/men/44.jpg",
|
11
|
+
},
|
12
|
+
{
|
13
|
+
id: "2",
|
14
|
+
task: "Task 2",
|
15
|
+
assignee_name: "Sophia Miles",
|
16
|
+
assignee_img: "https://randomuser.me/api/portraits/women/8.jpg",
|
17
|
+
},
|
18
|
+
{
|
19
|
+
id: "3",
|
20
|
+
task: "Task 3",
|
21
|
+
assignee_name: "Alice Jones",
|
22
|
+
assignee_img: "https://randomuser.me/api/portraits/women/10.jpg",
|
23
|
+
},
|
24
|
+
{
|
25
|
+
id: "4",
|
26
|
+
task: "Task 4",
|
27
|
+
assignee_name: "Mike James",
|
28
|
+
assignee_img: "https://randomuser.me/api/portraits/men/8.jpg",
|
29
|
+
},
|
30
|
+
{
|
31
|
+
id: "5",
|
32
|
+
task: "Task 5",
|
33
|
+
assignee_name: "James Guy",
|
34
|
+
assignee_img: "https://randomuser.me/api/portraits/men/18.jpg",
|
35
|
+
}
|
36
|
+
];
|
37
|
+
|
38
|
+
const DraggableWithTableReact = (props) => {
|
39
|
+
const [initialState, setInitialState] = useState(data);
|
40
|
+
|
41
|
+
return (
|
42
|
+
<>
|
43
|
+
<DraggableProvider initialItems={data}
|
44
|
+
onReorder={(items) => setInitialState(items)}
|
45
|
+
>
|
46
|
+
<Table
|
47
|
+
responsive="none"
|
48
|
+
size="sm"
|
49
|
+
{...props}
|
50
|
+
>
|
51
|
+
<Table.Head>
|
52
|
+
<Table.Row>
|
53
|
+
<Table.Header>{"id"}</Table.Header>
|
54
|
+
<Table.Header>{"name"}</Table.Header>
|
55
|
+
<Table.Header>{"task number"}</Table.Header>
|
56
|
+
</Table.Row>
|
57
|
+
</Table.Head>
|
58
|
+
<Table.Body draggableContainer>
|
59
|
+
{initialState.map(({ id, task, assignee_name, assignee_img }) => (
|
60
|
+
<Table.Row
|
61
|
+
dragId={id}
|
62
|
+
draggableItem
|
63
|
+
key={id}
|
64
|
+
>
|
65
|
+
<Table.Cell>{id}</Table.Cell>
|
66
|
+
<Table.Cell>
|
67
|
+
<Flex align="center">
|
68
|
+
<Avatar
|
69
|
+
imageUrl={assignee_img}
|
70
|
+
size="xs"
|
71
|
+
/>
|
72
|
+
<Body
|
73
|
+
paddingLeft="xxs"
|
74
|
+
text={assignee_name}
|
75
|
+
{...props}
|
76
|
+
/>
|
77
|
+
</Flex>
|
78
|
+
</Table.Cell>
|
79
|
+
<Table.Cell>{task}</Table.Cell>
|
80
|
+
</Table.Row>
|
81
|
+
))}
|
82
|
+
</Table.Body>
|
83
|
+
</Table>
|
84
|
+
</DraggableProvider>
|
85
|
+
</>
|
86
|
+
|
87
|
+
);
|
88
|
+
};
|
89
|
+
|
90
|
+
export default DraggableWithTableReact;
|
@@ -0,0 +1,5 @@
|
|
1
|
+
The draggable kit can also be used in conjunction with the table kit to create draggable table rows. To do this:
|
2
|
+
|
3
|
+
- Wrap the Table with the `DraggableProvider` and manage state as shown.
|
4
|
+
- use the `draggableContainer` prop on the Table.Body to designate it as the Draggable Container
|
5
|
+
- use the `draggableItem` prop on the Table.Row to designate it as the Draggable Item. Make sure to also pass id to the `dragId` prop here.
|
@@ -1,18 +1,17 @@
|
|
1
1
|
examples:
|
2
|
-
|
3
|
-
|
4
2
|
react:
|
5
3
|
- draggable_default: Default
|
6
4
|
- draggable_with_list: Draggable with List Kit
|
7
5
|
- draggable_with_selectable_list: Draggable with SelectableList Kit
|
8
6
|
- draggable_with_cards: Draggable with Cards
|
7
|
+
- draggable_with_table_react: Draggable with Table
|
9
8
|
- draggable_multiple_containers: Dragging Across Multiple Containers
|
10
|
-
|
9
|
+
|
11
10
|
rails:
|
12
11
|
- draggable_default_rails: Default
|
13
12
|
- draggable_with_list_rails: Draggable with List Kit
|
14
13
|
- draggable_with_selectable_list_rails: Draggable with SelectableList Kit
|
15
14
|
- draggable_with_cards_rails: Draggable with Cards
|
15
|
+
- draggable_with_table: Draggable with Table
|
16
|
+
- draggable_multiple_containers_rails: Dragging Across Multiple Containers
|
16
17
|
|
17
|
-
|
18
|
-
|
@@ -2,4 +2,5 @@ export { default as DraggableDefault } from './_draggable_default.jsx'
|
|
2
2
|
export { default as DraggableWithCards } from './_draggable_with_cards.jsx'
|
3
3
|
export { default as DraggableWithList } from './_draggable_with_list.jsx'
|
4
4
|
export { default as DraggableWithSelectableList } from './_draggable_with_selectable_list.jsx'
|
5
|
-
export { default as DraggableMultipleContainers } from './_draggable_multiple_containers.jsx'
|
5
|
+
export { default as DraggableMultipleContainers } from './_draggable_multiple_containers.jsx'
|
6
|
+
export { default as DraggableWithTableReact } from './_draggable_with_table_react.jsx'
|
@@ -1,3 +1,3 @@
|
|
1
|
-
<%= pb_content_tag do %>
|
1
|
+
<%= pb_content_tag(object.tag) do %>
|
2
2
|
<%= content.presence %>
|
3
|
-
<% end %>
|
3
|
+
<% end %>
|
@@ -3,6 +3,11 @@
|
|
3
3
|
module Playbook
|
4
4
|
module PbDraggable
|
5
5
|
class DraggableContainer < ::Playbook::KitBase
|
6
|
+
prop :tag, type: Playbook::Props::String,
|
7
|
+
default: "div"
|
8
|
+
prop :container, type: Playbook::Props::String,
|
9
|
+
default: ""
|
10
|
+
|
6
11
|
def data
|
7
12
|
Hash(prop(:data)).merge(pb_draggable_container: true)
|
8
13
|
end
|
@@ -5,6 +5,10 @@ module Playbook
|
|
5
5
|
class DraggableItem < ::Playbook::KitBase
|
6
6
|
prop :drag_id, type: Playbook::Props::String,
|
7
7
|
default: ""
|
8
|
+
prop :tag, type: Playbook::Props::String,
|
9
|
+
default: "div"
|
10
|
+
prop :container, type: Playbook::Props::String,
|
11
|
+
default: ""
|
8
12
|
|
9
13
|
def data
|
10
14
|
Hash(prop(:data)).merge(pb_draggable_item: true)
|