playbook_ui 14.13.0.pre.alpha.rails8compatible6232 → 14.13.0.pre.rc.0
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/_playbook.scss +1 -1
- data/app/pb_kits/playbook/pb_advanced_table/Components/CustomCell.tsx +1 -1
- data/app/pb_kits/playbook/pb_advanced_table/Components/TableHeaderCell.tsx +4 -11
- data/app/pb_kits/playbook/pb_advanced_table/_advanced_table.scss +10 -74
- data/app/pb_kits/playbook/pb_advanced_table/_advanced_table.tsx +26 -43
- data/app/pb_kits/playbook/pb_advanced_table/advanced_table.rb +1 -8
- data/app/pb_kits/playbook/pb_advanced_table/docs/_advanced_table_table_props.html.erb +1 -1
- data/app/pb_kits/playbook/pb_advanced_table/docs/_advanced_table_table_props.jsx +0 -1
- data/app/pb_kits/playbook/pb_advanced_table/docs/_advanced_table_table_props_rails.md +1 -3
- data/app/pb_kits/playbook/pb_advanced_table/docs/_advanced_table_table_props_react.md +1 -3
- data/app/pb_kits/playbook/pb_advanced_table/docs/example.yml +0 -3
- data/app/pb_kits/playbook/pb_advanced_table/docs/index.js +1 -3
- data/app/pb_kits/playbook/pb_advanced_table/index.js +6 -9
- data/app/pb_kits/playbook/pb_advanced_table/table_row.html.erb +5 -8
- data/app/pb_kits/playbook/pb_avatar/_avatar.scss +0 -9
- data/app/pb_kits/playbook/pb_avatar/_avatar.tsx +7 -11
- data/app/pb_kits/playbook/pb_avatar/avatar.html.erb +7 -6
- data/app/pb_kits/playbook/pb_avatar/docs/_avatar_badge_component_overlay.jsx +3 -9
- data/app/pb_kits/playbook/pb_avatar/docs/_avatar_circle_icon_component_overlay.jsx +2 -6
- data/app/pb_kits/playbook/pb_avatar_action_button/_avatar_action_button.scss +66 -0
- data/app/pb_kits/playbook/pb_avatar_action_button/_avatar_action_button.tsx +98 -0
- data/app/pb_kits/playbook/pb_avatar_action_button/avatar_action_button.html.erb +28 -0
- data/app/pb_kits/playbook/pb_avatar_action_button/avatar_action_button.rb +42 -0
- data/app/pb_kits/playbook/pb_avatar_action_button/docs/_avatar_action_button_actions.html.erb +19 -0
- data/app/pb_kits/playbook/pb_avatar_action_button/docs/_avatar_action_button_actions.jsx +26 -0
- data/app/pb_kits/playbook/pb_avatar_action_button/docs/_avatar_action_button_default.html.erb +10 -0
- data/app/pb_kits/playbook/pb_avatar_action_button/docs/_avatar_action_button_default.jsx +17 -0
- data/app/pb_kits/playbook/pb_avatar_action_button/docs/_avatar_action_button_on_click.jsx +19 -0
- data/app/pb_kits/playbook/pb_avatar_action_button/docs/_avatar_action_button_onclick.html.erb +16 -0
- data/app/pb_kits/playbook/pb_avatar_action_button/docs/_avatar_action_button_placement.html.erb +35 -0
- data/app/pb_kits/playbook/pb_avatar_action_button/docs/_avatar_action_button_placement.jsx +42 -0
- data/app/pb_kits/playbook/pb_avatar_action_button/docs/_avatar_action_button_tooltip.html.erb +13 -0
- data/app/pb_kits/playbook/pb_avatar_action_button/docs/example.yml +15 -0
- data/app/pb_kits/playbook/pb_avatar_action_button/docs/index.js +4 -0
- data/app/pb_kits/playbook/pb_avatar_action_button/pb_avatar_action_button.test.js +31 -0
- data/app/pb_kits/playbook/pb_bar_graph/docs/example.yml +0 -1
- data/app/pb_kits/playbook/pb_bar_graph/docs/index.js +0 -1
- data/app/pb_kits/playbook/pb_button/button.rb +1 -1
- data/app/pb_kits/playbook/pb_checkbox/_checkbox.tsx +8 -17
- data/app/pb_kits/playbook/pb_checkbox/checkbox.test.js +0 -16
- data/app/pb_kits/playbook/pb_checkbox/docs/example.yml +1 -2
- data/app/pb_kits/playbook/pb_checkbox/docs/index.js +0 -1
- data/app/pb_kits/playbook/pb_date/_date.tsx +4 -14
- data/app/pb_kits/playbook/pb_date/docs/_date_default.jsx +1 -2
- data/app/pb_kits/playbook/pb_date/docs/_date_unstyled.jsx +5 -13
- data/app/pb_kits/playbook/pb_date_picker/_date_picker.tsx +1 -3
- data/app/pb_kits/playbook/pb_draggable/docs/example.yml +5 -4
- data/app/pb_kits/playbook/pb_draggable/docs/index.js +1 -2
- data/app/pb_kits/playbook/pb_draggable/draggable_container.html.erb +2 -2
- data/app/pb_kits/playbook/pb_draggable/draggable_container.rb +0 -5
- data/app/pb_kits/playbook/pb_draggable/draggable_item.html.erb +1 -1
- data/app/pb_kits/playbook/pb_draggable/draggable_item.rb +0 -4
- data/app/pb_kits/playbook/pb_draggable/index.js +15 -151
- data/app/pb_kits/playbook/pb_draggable/subcomponents/DraggableContainer.tsx +4 -7
- data/app/pb_kits/playbook/pb_draggable/subcomponents/DraggableItem.tsx +3 -6
- data/app/pb_kits/playbook/pb_file_upload/file_upload.html.erb +6 -1
- data/app/pb_kits/playbook/pb_filter/filter.html.erb +5 -1
- data/app/pb_kits/playbook/pb_fixed_confirmation_toast/docs/example.yml +0 -1
- data/app/pb_kits/playbook/pb_fixed_confirmation_toast/index.js +5 -7
- data/app/pb_kits/playbook/pb_form_group/form_group.html.erb +6 -1
- 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 +7 -11
- data/app/pb_kits/playbook/pb_home_address_street/docs/example.yml +0 -2
- data/app/pb_kits/playbook/pb_home_address_street/docs/index.js +0 -1
- data/app/pb_kits/playbook/pb_home_address_street/home_address_street.rb +2 -13
- data/app/pb_kits/playbook/pb_icon/icon.html.erb +6 -2
- data/app/pb_kits/playbook/pb_icon_button/docs/_icon_button_default.html.erb +2 -1
- data/app/pb_kits/playbook/pb_icon_button/docs/example.yml +3 -1
- 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 +0 -3
- data/app/pb_kits/playbook/pb_layout/body.html.erb +5 -1
- data/app/pb_kits/playbook/pb_layout/footer.html.erb +5 -1
- data/app/pb_kits/playbook/pb_layout/header.html.erb +5 -1
- data/app/pb_kits/playbook/pb_layout/item.html.erb +5 -1
- data/app/pb_kits/playbook/pb_layout/layout.html.erb +5 -1
- data/app/pb_kits/playbook/pb_layout/sidebar.html.erb +5 -1
- data/app/pb_kits/playbook/pb_legend/legend.html.erb +6 -1
- data/app/pb_kits/playbook/pb_lightbox/lightbox.scss +6 -7
- data/app/pb_kits/playbook/pb_link/_link.tsx +0 -18
- data/app/pb_kits/playbook/pb_link/docs/example.yml +3 -5
- data/app/pb_kits/playbook/pb_link/docs/index.js +1 -2
- data/app/pb_kits/playbook/pb_link/link.html.erb +1 -1
- data/app/pb_kits/playbook/pb_link/link.rb +0 -6
- data/app/pb_kits/playbook/pb_link/link.test.jsx +0 -30
- data/app/pb_kits/playbook/pb_message/message.html.erb +6 -1
- data/app/pb_kits/playbook/pb_message/message_mention.html.erb +6 -1
- data/app/pb_kits/playbook/pb_multi_level_select/multi_level_select.html.erb +6 -1
- data/app/pb_kits/playbook/pb_nav/item.html.erb +19 -7
- data/app/pb_kits/playbook/pb_nav/nav.html.erb +8 -3
- data/app/pb_kits/playbook/pb_online_status/online_status.html.erb +6 -1
- data/app/pb_kits/playbook/pb_overlay/_overlay.tsx +0 -4
- data/app/pb_kits/playbook/pb_overlay/docs/example.yml +0 -1
- data/app/pb_kits/playbook/pb_overlay/docs/index.js +0 -1
- data/app/pb_kits/playbook/pb_overlay/subcomponents/_overlay_token.tsx +10 -48
- data/app/pb_kits/playbook/pb_popover/popover.html.erb +6 -1
- data/app/pb_kits/playbook/pb_progress_pills/_progress_pills.scss +1 -6
- data/app/pb_kits/playbook/pb_progress_pills/_progress_pills.tsx +5 -7
- data/app/pb_kits/playbook/pb_progress_pills/docs/_progress_pills_default.html.erb +0 -1
- data/app/pb_kits/playbook/pb_progress_pills/docs/_progress_pills_default.jsx +0 -7
- data/app/pb_kits/playbook/pb_progress_pills/docs/example.yml +0 -2
- data/app/pb_kits/playbook/pb_progress_pills/docs/index.js +0 -1
- data/app/pb_kits/playbook/pb_progress_pills/progress_pills.html.erb +7 -2
- data/app/pb_kits/playbook/pb_progress_pills/progress_pills.rb +0 -6
- data/app/pb_kits/playbook/pb_progress_pills/progress_pills.test.js +1 -26
- data/app/pb_kits/playbook/pb_progress_simple/progress_simple.html.erb +5 -1
- data/app/pb_kits/playbook/pb_progress_step/docs/_progress_step_tooltip.html.erb +6 -6
- data/app/pb_kits/playbook/pb_progress_step/progress_step.html.erb +5 -1
- data/app/pb_kits/playbook/pb_progress_step/progress_step_item.html.erb +5 -1
- data/app/pb_kits/playbook/pb_radio/radio.html.erb +11 -6
- data/app/pb_kits/playbook/pb_table/docs/_table_with_background_kit.html.erb +9 -6
- data/app/pb_kits/playbook/pb_table/docs/_table_with_background_kit.jsx +9 -6
- data/app/pb_kits/playbook/pb_table/docs/_table_with_collapsible.jsx +1 -1
- data/app/pb_kits/playbook/pb_table/docs/example.yml +0 -5
- data/app/pb_kits/playbook/pb_table/docs/index.js +1 -3
- data/app/pb_kits/playbook/pb_table/index.ts +9 -41
- data/app/pb_kits/playbook/pb_table/styles/_collapsible.scss +0 -4
- data/app/pb_kits/playbook/pb_table/styles/_desktop_collapse.scss +0 -26
- data/app/pb_kits/playbook/pb_table/styles/_mobile.scss +1 -0
- data/app/pb_kits/playbook/pb_table/styles/_mobile_collapse.scss +0 -25
- data/app/pb_kits/playbook/pb_table/styles/_tablet_collapse.scss +0 -25
- data/app/pb_kits/playbook/pb_table/subcomponents/_table_body.tsx +2 -29
- data/app/pb_kits/playbook/pb_table/subcomponents/_table_row.tsx +3 -31
- data/app/pb_kits/playbook/pb_table/table_body.html.erb +7 -13
- data/app/pb_kits/playbook/pb_table/table_body.rb +0 -2
- data/app/pb_kits/playbook/pb_table/table_row.html.erb +7 -14
- data/app/pb_kits/playbook/pb_table/table_row.rb +1 -14
- data/app/pb_kits/playbook/pb_text_input/docs/_text_input_mask.html.erb +1 -15
- data/app/pb_kits/playbook/pb_text_input/index.js +82 -60
- data/app/pb_kits/playbook/pb_text_input/text_input.rb +2 -5
- data/app/pb_kits/playbook/pb_tooltip/_tooltip.tsx +1 -3
- data/app/pb_kits/playbook/pb_tooltip/docs/_tooltip_default.html.erb +1 -1
- data/app/pb_kits/playbook/pb_tooltip/index.js +27 -45
- data/app/pb_kits/playbook/pb_tooltip/tooltip.rb +1 -5
- data/app/pb_kits/playbook/pb_user/_user.tsx +0 -3
- data/app/pb_kits/playbook/pb_user/docs/example.yml +0 -2
- data/app/pb_kits/playbook/pb_user/docs/index.js +0 -1
- data/app/pb_kits/playbook/pb_user/user.html.erb +1 -1
- data/app/pb_kits/playbook/pb_user/user.rb +0 -1
- data/app/pb_kits/playbook/pb_user/user.test.js +0 -14
- data/dist/chunks/_typeahead-BWwaAo_0.js +36 -0
- data/dist/chunks/_weekday_stacked-zyBCd1s8.js +45 -0
- data/dist/chunks/{lib-D3us1bGD.js → lib-kMuhBuU7.js} +2 -2
- data/dist/chunks/{pb_form_validation-BpihMSOQ.js → pb_form_validation-DBJ0wZuS.js} +1 -1
- data/dist/chunks/vendor.js +1 -1
- data/dist/menu.yml +7 -6
- 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 +2 -2
- metadata +38 -79
- data/app/pb_kits/playbook/pb_advanced_table/Utilities/ActionBarAnimationHelper.ts +0 -26
- data/app/pb_kits/playbook/pb_advanced_table/docs/_advanced_table_column_headers_custom_cell.jsx +0 -75
- data/app/pb_kits/playbook/pb_advanced_table/docs/_advanced_table_table_props_sticky_header.html.erb +0 -33
- data/app/pb_kits/playbook/pb_advanced_table/docs/_advanced_table_table_props_sticky_header.jsx +0 -55
- data/app/pb_kits/playbook/pb_advanced_table/docs/_advanced_table_table_props_sticky_header_rails.md +0 -3
- data/app/pb_kits/playbook/pb_advanced_table/docs/_advanced_table_table_props_sticky_header_react.md +0 -3
- data/app/pb_kits/playbook/pb_bar_graph/BarGraphStyles.scss +0 -58
- data/app/pb_kits/playbook/pb_bar_graph/docs/_bar_graph_pb_styles.jsx +0 -64
- data/app/pb_kits/playbook/pb_bar_graph/docs/_bar_graph_pb_styles.md +0 -1
- data/app/pb_kits/playbook/pb_checkbox/docs/_checkbox_react_hook.jsx +0 -69
- data/app/pb_kits/playbook/pb_checkbox/docs/_checkbox_react_hook.md +0 -1
- data/app/pb_kits/playbook/pb_copy_button/_copy_button.scss +0 -4
- data/app/pb_kits/playbook/pb_copy_button/_copy_button.tsx +0 -92
- data/app/pb_kits/playbook/pb_copy_button/copy_button.html.erb +0 -15
- data/app/pb_kits/playbook/pb_copy_button/copy_button.rb +0 -28
- data/app/pb_kits/playbook/pb_copy_button/copy_button.test.jsx +0 -64
- data/app/pb_kits/playbook/pb_copy_button/docs/_copy_button_default.html.erb +0 -2
- data/app/pb_kits/playbook/pb_copy_button/docs/_copy_button_default.jsx +0 -21
- data/app/pb_kits/playbook/pb_copy_button/docs/_copy_button_from.html.erb +0 -5
- data/app/pb_kits/playbook/pb_copy_button/docs/_copy_button_from.jsx +0 -45
- data/app/pb_kits/playbook/pb_copy_button/docs/_copy_button_from.md +0 -1
- data/app/pb_kits/playbook/pb_copy_button/docs/example.yml +0 -8
- data/app/pb_kits/playbook/pb_copy_button/docs/index.js +0 -2
- data/app/pb_kits/playbook/pb_copy_button/index.js +0 -47
- data/app/pb_kits/playbook/pb_draggable/docs/_draggable_multiple_containers_rails.html.erb +0 -99
- data/app/pb_kits/playbook/pb_draggable/docs/_draggable_multiple_containers_rails.md +0 -1
- data/app/pb_kits/playbook/pb_draggable/docs/_draggable_with_table.html.erb +0 -61
- data/app/pb_kits/playbook/pb_draggable/docs/_draggable_with_table.md +0 -4
- data/app/pb_kits/playbook/pb_draggable/docs/_draggable_with_table_react.jsx +0 -90
- data/app/pb_kits/playbook/pb_draggable/docs/_draggable_with_table_react.md +0 -5
- data/app/pb_kits/playbook/pb_fixed_confirmation_toast/docs/_fixed_confirmation_toast_auto_close.html.erb +0 -58
- data/app/pb_kits/playbook/pb_fixed_confirmation_toast/docs/_fixed_confirmation_toast_auto_close_rails.md +0 -3
- data/app/pb_kits/playbook/pb_home_address_street/docs/_home_address_street_formatting.html.erb +0 -11
- data/app/pb_kits/playbook/pb_home_address_street/docs/_home_address_street_formatting.jsx +0 -22
- data/app/pb_kits/playbook/pb_home_address_street/docs/_home_address_street_formatting_rails.md +0 -1
- data/app/pb_kits/playbook/pb_home_address_street/docs/_home_address_street_formatting_react.md +0 -1
- data/app/pb_kits/playbook/pb_icon_button/docs/_icon_button_sizes.html.erb +0 -27
- data/app/pb_kits/playbook/pb_link/docs/_link_target.html.erb +0 -15
- data/app/pb_kits/playbook/pb_link/docs/_link_target.jsx +0 -29
- data/app/pb_kits/playbook/pb_overlay/docs/_overlay_vertical_dynamic_multi_directional.jsx +0 -37
- data/app/pb_kits/playbook/pb_overlay/docs/_overlay_vertical_dynamic_multi_directional_react.md +0 -1
- data/app/pb_kits/playbook/pb_progress_pills/docs/_progress_pills_default.md +0 -1
- data/app/pb_kits/playbook/pb_progress_pills/docs/_progress_pills_full_width.html.erb +0 -1
- data/app/pb_kits/playbook/pb_progress_pills/docs/_progress_pills_full_width.jsx +0 -18
- data/app/pb_kits/playbook/pb_progress_pills/docs/_progress_pills_full_width_rails.md +0 -1
- data/app/pb_kits/playbook/pb_progress_pills/docs/_progress_pills_full_width_react.md +0 -1
- data/app/pb_kits/playbook/pb_table/docs/_table_with_clickable_rows.html.erb +0 -47
- data/app/pb_kits/playbook/pb_table/docs/_table_with_clickable_rows.jsx +0 -88
- data/app/pb_kits/playbook/pb_table/docs/_table_with_clickable_rows.md +0 -1
- data/app/pb_kits/playbook/pb_table/docs/_table_with_collapsible_with_custom_click.html.erb +0 -51
- data/app/pb_kits/playbook/pb_table/docs/_table_with_collapsible_with_custom_click_rails.md +0 -2
- data/app/pb_kits/playbook/pb_table/docs/_table_with_selectable_rows.html.erb +0 -96
- data/app/pb_kits/playbook/pb_table/docs/_table_with_selectable_rows.jsx +0 -101
- data/app/pb_kits/playbook/pb_table/docs/_table_with_selectable_rows.md +0 -1
- data/app/pb_kits/playbook/pb_user/docs/_user_light_weight.html.erb +0 -42
- data/app/pb_kits/playbook/pb_user/docs/_user_light_weight.jsx +0 -59
- data/app/pb_kits/playbook/pb_user/docs/_user_light_weight.md +0 -2
- data/dist/chunks/_typeahead-PqkcDf1H.js +0 -36
- data/dist/chunks/_weekday_stacked-C7J0S4f7.js +0 -45
- /data/app/pb_kits/playbook/pb_fixed_confirmation_toast/docs/{_fixed_confirmation_toast_auto_close_react.md → _fixed_confirmation_toast_auto_close.md} +0 -0
- /data/app/pb_kits/playbook/pb_table/docs/{_table_with_collapsible_with_custom_click_react.md → _table_with_collapsible_with_custom_click.md} +0 -0
@@ -1,69 +0,0 @@
|
|
1
|
-
import React, { useState } from "react"
|
2
|
-
import { useForm } from "react-hook-form"
|
3
|
-
import { Button, Checkbox, Flex, Body } from "playbook-ui"
|
4
|
-
|
5
|
-
const CheckboxReactHook = () => {
|
6
|
-
const { register, handleSubmit } = useForm({
|
7
|
-
defaultValues: {
|
8
|
-
Small: false,
|
9
|
-
Medium: false,
|
10
|
-
Large: false,
|
11
|
-
},
|
12
|
-
})
|
13
|
-
|
14
|
-
const [submittedData, setSubmittedData] = useState({
|
15
|
-
Small: false,
|
16
|
-
Medium: false,
|
17
|
-
Large: false,
|
18
|
-
})
|
19
|
-
|
20
|
-
const onSubmit = (data) => {
|
21
|
-
setSubmittedData(data)
|
22
|
-
}
|
23
|
-
|
24
|
-
return (
|
25
|
-
<Flex orientation="row">
|
26
|
-
<Flex align="start"
|
27
|
-
orientation="column"
|
28
|
-
paddingRight="lg"
|
29
|
-
>
|
30
|
-
<form onSubmit={handleSubmit(onSubmit)}>
|
31
|
-
<Checkbox padding="xs"
|
32
|
-
text="Small"
|
33
|
-
{...register("Small")}
|
34
|
-
/>
|
35
|
-
<br />
|
36
|
-
<Checkbox padding="xs"
|
37
|
-
text="Medium"
|
38
|
-
{...register("Medium")}
|
39
|
-
/>
|
40
|
-
<br />
|
41
|
-
<Checkbox padding="xs"
|
42
|
-
text="Large"
|
43
|
-
{...register("Large")}
|
44
|
-
/>
|
45
|
-
<br />
|
46
|
-
<Button htmlType="submit"
|
47
|
-
marginTop="sm"
|
48
|
-
text="submit"
|
49
|
-
/>
|
50
|
-
</form>
|
51
|
-
</Flex>
|
52
|
-
<Flex align="start"
|
53
|
-
orientation="column"
|
54
|
-
>
|
55
|
-
<Body padding="xs"
|
56
|
-
text={`Small: ${submittedData.Small ? "true" : "false"}`}
|
57
|
-
/>
|
58
|
-
<Body padding="xs"
|
59
|
-
text={`Medium: ${submittedData.Medium ? "true" : "false"}`}
|
60
|
-
/>
|
61
|
-
<Body padding="xs"
|
62
|
-
text={`Large: ${submittedData.Large ? "true" : "false"}`}
|
63
|
-
/>
|
64
|
-
</Flex>
|
65
|
-
</Flex>
|
66
|
-
)
|
67
|
-
}
|
68
|
-
|
69
|
-
export default CheckboxReactHook
|
@@ -1 +0,0 @@
|
|
1
|
-
You can pass react hook props to the checkbox kit.
|
@@ -1,92 +0,0 @@
|
|
1
|
-
|
2
|
-
import React, { useState } from 'react'
|
3
|
-
import classnames from 'classnames'
|
4
|
-
import { buildAriaProps, buildCss, buildDataProps } from '../utilities/props'
|
5
|
-
import { globalProps } from '../utilities/globalProps'
|
6
|
-
|
7
|
-
import Button from '../pb_button/_button'
|
8
|
-
import Tooltip from '../pb_tooltip/_tooltip'
|
9
|
-
|
10
|
-
type CopyButtonProps = {
|
11
|
-
aria?: { [key: string]: string },
|
12
|
-
className?: string,
|
13
|
-
data?: { [key: string]: string },
|
14
|
-
id?: string,
|
15
|
-
from?: string,
|
16
|
-
text?: string,
|
17
|
-
tooltipPlacement?: "top" | "right" | "bottom" | "left",
|
18
|
-
tooltipText?: string,
|
19
|
-
value?: string,
|
20
|
-
}
|
21
|
-
|
22
|
-
const CopyButton = (props: CopyButtonProps) => {
|
23
|
-
const {
|
24
|
-
aria = {},
|
25
|
-
className,
|
26
|
-
data = {},
|
27
|
-
from = '',
|
28
|
-
id,
|
29
|
-
text= 'Copy',
|
30
|
-
tooltipPlacement= 'bottom',
|
31
|
-
tooltipText = 'Copied!',
|
32
|
-
value = '',
|
33
|
-
} = props
|
34
|
-
|
35
|
-
const [copied, setCopied] = useState(false)
|
36
|
-
|
37
|
-
const ariaProps = buildAriaProps(aria)
|
38
|
-
const dataProps = buildDataProps(data)
|
39
|
-
const classes = classnames(buildCss('pb_copy_button_kit'), globalProps(props), className)
|
40
|
-
|
41
|
-
const copy = () => {
|
42
|
-
if (!from && !value) {
|
43
|
-
return
|
44
|
-
}
|
45
|
-
|
46
|
-
if (value) {
|
47
|
-
navigator.clipboard.writeText(value)
|
48
|
-
} else if (from) {
|
49
|
-
const copyElement = document.getElementById(from);
|
50
|
-
let copyText = copyElement?.innerText
|
51
|
-
|
52
|
-
if (copyElement instanceof HTMLTextAreaElement || copyElement instanceof HTMLInputElement) {
|
53
|
-
copyText = copyElement.value;
|
54
|
-
}
|
55
|
-
|
56
|
-
if (copyText) {
|
57
|
-
navigator.clipboard.writeText(copyText)
|
58
|
-
}
|
59
|
-
}
|
60
|
-
|
61
|
-
setCopied(true)
|
62
|
-
|
63
|
-
setTimeout(() => {
|
64
|
-
setCopied(false)
|
65
|
-
}, 1000);
|
66
|
-
}
|
67
|
-
|
68
|
-
return (
|
69
|
-
<div
|
70
|
-
{...ariaProps}
|
71
|
-
{...dataProps}
|
72
|
-
className={classes}
|
73
|
-
id={id}
|
74
|
-
>
|
75
|
-
<Tooltip
|
76
|
-
forceOpenTooltip={copied}
|
77
|
-
placement={tooltipPlacement}
|
78
|
-
showTooltip={false}
|
79
|
-
text={tooltipText}
|
80
|
-
>
|
81
|
-
<Button
|
82
|
-
icon='copy'
|
83
|
-
onClick={copy}
|
84
|
-
>
|
85
|
-
{ text }
|
86
|
-
</Button>
|
87
|
-
</Tooltip>
|
88
|
-
</div>
|
89
|
-
)
|
90
|
-
}
|
91
|
-
|
92
|
-
export default CopyButton
|
@@ -1,15 +0,0 @@
|
|
1
|
-
<%= pb_content_tag do %>
|
2
|
-
<%= pb_rails("button", props: { icon: "copy" }) do %>
|
3
|
-
<%= object.text %>
|
4
|
-
<% end %>
|
5
|
-
<% if object.id %>
|
6
|
-
<%= pb_rails("tooltip", props: {
|
7
|
-
trigger_element_selector: "##{object.id}",
|
8
|
-
position: object.tooltip_position,
|
9
|
-
tooltip_id: "#{object.id}_tooltip",
|
10
|
-
trigger_method: "click"
|
11
|
-
}) do %>
|
12
|
-
<%= object.tooltip_text %>
|
13
|
-
<% end %>
|
14
|
-
<% end %>
|
15
|
-
<% end %>
|
@@ -1,28 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
module Playbook
|
4
|
-
module PbCopyButton
|
5
|
-
class CopyButton < ::Playbook::KitBase
|
6
|
-
prop :text
|
7
|
-
prop :tooltip_position,
|
8
|
-
type: Playbook::Props::Enum,
|
9
|
-
values: %w[top right bottom left],
|
10
|
-
default: "top"
|
11
|
-
prop :tooltip_text, type: Playbook::Props::String,
|
12
|
-
default: "Copied!"
|
13
|
-
prop :value
|
14
|
-
prop :from
|
15
|
-
|
16
|
-
def classname
|
17
|
-
generate_classname("pb_copy_button_kit")
|
18
|
-
end
|
19
|
-
|
20
|
-
def data
|
21
|
-
Hash(values[:data]).merge(
|
22
|
-
"copy-value": value,
|
23
|
-
"from": from
|
24
|
-
)
|
25
|
-
end
|
26
|
-
end
|
27
|
-
end
|
28
|
-
end
|
@@ -1,64 +0,0 @@
|
|
1
|
-
import React from 'react';
|
2
|
-
import { CopyButton } from 'playbook-ui'
|
3
|
-
import { ensureAccessible, renderKit, render, fireEvent, screen } from '../utilities/test-utils'
|
4
|
-
|
5
|
-
const props = {
|
6
|
-
data: { testid: 'default', value: 'copy' }
|
7
|
-
}
|
8
|
-
|
9
|
-
test('returns namespaced class name', () => {
|
10
|
-
const kit = renderKit(CopyButton, props)
|
11
|
-
expect(kit).toBeInTheDocument()
|
12
|
-
expect(kit).toHaveClass('pb_copy_button_kit')
|
13
|
-
})
|
14
|
-
|
15
|
-
it('should be accessible', async () => {
|
16
|
-
ensureAccessible(CopyButton, props)
|
17
|
-
})
|
18
|
-
|
19
|
-
// It's difficult to actually use navigator.clipboard.readText, so we mock
|
20
|
-
it('copies the value to clipboard and pastes it into an input', async () => {
|
21
|
-
Object.defineProperty(global, 'navigator', {
|
22
|
-
value: {
|
23
|
-
clipboard: {
|
24
|
-
writeText: jest.fn().mockResolvedValueOnce(undefined),
|
25
|
-
},
|
26
|
-
},
|
27
|
-
writable: true,
|
28
|
-
})
|
29
|
-
|
30
|
-
render(<CopyButton {...props} />)
|
31
|
-
|
32
|
-
const copyButton = screen.getByTestId('default')
|
33
|
-
fireEvent.click(copyButton)
|
34
|
-
|
35
|
-
await navigator.clipboard.writeText('copy')
|
36
|
-
|
37
|
-
expect(navigator.clipboard.writeText).toHaveBeenCalledWith("copy");
|
38
|
-
})
|
39
|
-
|
40
|
-
test('passes text and tooltip props to button', () => {
|
41
|
-
render(
|
42
|
-
<CopyButton
|
43
|
-
data={{ testid: 'text-test' }}
|
44
|
-
text={"text"}
|
45
|
-
tooltipPlacement="right"
|
46
|
-
tooltipText="Text copied!"
|
47
|
-
value="copy"
|
48
|
-
/>
|
49
|
-
)
|
50
|
-
|
51
|
-
const content = screen.getByText("text")
|
52
|
-
expect(content).toHaveTextContent("text")
|
53
|
-
|
54
|
-
const kit = screen.getByTestId('text-test')
|
55
|
-
const button = kit.querySelector('.pb_button_kit_primary_inline_enabled')
|
56
|
-
expect(button).toBeInTheDocument()
|
57
|
-
|
58
|
-
fireEvent.click(button)
|
59
|
-
const tooltipContent = screen.getByText("Text copied!")
|
60
|
-
expect(tooltipContent).toHaveTextContent("Text copied!")
|
61
|
-
|
62
|
-
const tooltip = kit.querySelector('.pb_tooltip_kit')
|
63
|
-
expect(tooltip).toBeInTheDocument()
|
64
|
-
})
|
@@ -1,2 +0,0 @@
|
|
1
|
-
<%= pb_rails("copy_button", props: { id: "default-copy-button", text: "Copy Text", 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." } ) %>
|
2
|
-
<%= pb_rails("textarea", props: { margin_top: "xs", placeholder: "Copy and paste here" }) %>
|
@@ -1,21 +0,0 @@
|
|
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
|
@@ -1,5 +0,0 @@
|
|
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" }) %>
|
@@ -1,45 +0,0 @@
|
|
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
|
@@ -1 +0,0 @@
|
|
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.
|
@@ -1,47 +0,0 @@
|
|
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
|
-
}
|
@@ -1,99 +0,0 @@
|
|
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 %>
|
@@ -1 +0,0 @@
|
|
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.
|
@@ -1,61 +0,0 @@
|
|
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 %>
|
@@ -1,4 +0,0 @@
|
|
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.
|