playbook_ui 14.12.0.pre.alpha.PBNTR779railsdraggablecrosscontainer5863 → 14.12.0.pre.alpha.PBNTR834advtablemaxHeightstickyheader5932

Sign up to get free protection for your applications and to get access to all the features.
Files changed (58) hide show
  1. checksums.yaml +4 -4
  2. data/app/pb_kits/playbook/pb_advanced_table/Components/TableHeaderCell.tsx +10 -3
  3. data/app/pb_kits/playbook/pb_advanced_table/Utilities/ActionBarAnimationHelper.ts +26 -0
  4. data/app/pb_kits/playbook/pb_advanced_table/_advanced_table.scss +58 -7
  5. data/app/pb_kits/playbook/pb_advanced_table/_advanced_table.tsx +37 -21
  6. data/app/pb_kits/playbook/pb_advanced_table/docs/_advanced_table_table_props.jsx +1 -0
  7. data/app/pb_kits/playbook/pb_advanced_table/docs/_advanced_table_table_props_react.md +3 -1
  8. data/app/pb_kits/playbook/pb_advanced_table/docs/_advanced_table_table_props_sticky_header.jsx +55 -0
  9. data/app/pb_kits/playbook/pb_advanced_table/docs/_advanced_table_table_props_sticky_header_react.md +3 -0
  10. data/app/pb_kits/playbook/pb_advanced_table/docs/example.yml +1 -0
  11. data/app/pb_kits/playbook/pb_advanced_table/docs/index.js +2 -1
  12. data/app/pb_kits/playbook/pb_copy_button/_copy_button.scss +2 -1
  13. data/app/pb_kits/playbook/pb_copy_button/copy_button.html.erb +15 -0
  14. data/app/pb_kits/playbook/pb_copy_button/copy_button.rb +28 -0
  15. data/app/pb_kits/playbook/pb_copy_button/docs/_copy_button_default.html.erb +2 -0
  16. data/app/pb_kits/playbook/pb_copy_button/docs/_copy_button_from.html.erb +5 -0
  17. data/app/pb_kits/playbook/pb_copy_button/docs/example.yml +3 -3
  18. data/app/pb_kits/playbook/pb_copy_button/index.js +47 -0
  19. data/app/pb_kits/playbook/pb_draggable/docs/example.yml +5 -1
  20. data/app/pb_kits/playbook/pb_draggable/draggable_container.html.erb +2 -2
  21. data/app/pb_kits/playbook/pb_draggable/draggable_container.rb +0 -3
  22. data/app/pb_kits/playbook/pb_draggable/draggable_item.rb +0 -2
  23. data/app/pb_kits/playbook/pb_draggable/index.js +16 -88
  24. data/app/pb_kits/playbook/pb_home_address_street/_home_address_street.tsx +7 -11
  25. data/app/pb_kits/playbook/pb_home_address_street/docs/example.yml +0 -2
  26. data/app/pb_kits/playbook/pb_home_address_street/docs/index.js +0 -1
  27. data/app/pb_kits/playbook/pb_home_address_street/home_address_street.rb +2 -11
  28. data/app/pb_kits/playbook/pb_link/_link.tsx +18 -0
  29. data/app/pb_kits/playbook/pb_link/docs/_link_target.html.erb +15 -0
  30. data/app/pb_kits/playbook/pb_link/docs/_link_target.jsx +29 -0
  31. data/app/pb_kits/playbook/pb_link/docs/example.yml +5 -3
  32. data/app/pb_kits/playbook/pb_link/docs/index.js +2 -1
  33. data/app/pb_kits/playbook/pb_link/link.html.erb +1 -1
  34. data/app/pb_kits/playbook/pb_link/link.rb +6 -0
  35. data/app/pb_kits/playbook/pb_link/link.test.jsx +30 -0
  36. data/app/pb_kits/playbook/pb_progress_step/docs/_progress_step_tooltip.html.erb +6 -6
  37. data/app/pb_kits/playbook/pb_tooltip/docs/_tooltip_default.html.erb +1 -1
  38. data/app/pb_kits/playbook/pb_tooltip/index.js +45 -27
  39. data/app/pb_kits/playbook/pb_tooltip/tooltip.rb +5 -1
  40. data/dist/chunks/{_typeahead-W0hatdPs.js → _typeahead-CkemExmL.js} +1 -1
  41. data/dist/chunks/_weekday_stacked-DiNLeUtf.js +45 -0
  42. data/dist/chunks/{lib-kMuhBuU7.js → lib-DjpLC8uO.js} +1 -1
  43. data/dist/chunks/{pb_form_validation-DBJ0wZuS.js → pb_form_validation-S56UaHZl.js} +1 -1
  44. data/dist/chunks/vendor.js +1 -1
  45. data/dist/menu.yml +2 -2
  46. data/dist/playbook-doc.js +1 -1
  47. data/dist/playbook-rails-react-bindings.js +1 -1
  48. data/dist/playbook-rails.js +1 -1
  49. data/dist/playbook.css +1 -1
  50. data/lib/playbook/version.rb +1 -1
  51. metadata +16 -12
  52. data/app/pb_kits/playbook/pb_draggable/docs/_draggable_multiple_containers_rails.html.erb +0 -193
  53. data/app/pb_kits/playbook/pb_draggable/docs/_draggable_multiple_containers_rails.md +0 -1
  54. data/app/pb_kits/playbook/pb_home_address_street/docs/_home_address_street_formatting.html.erb +0 -11
  55. data/app/pb_kits/playbook/pb_home_address_street/docs/_home_address_street_formatting.jsx +0 -22
  56. data/app/pb_kits/playbook/pb_home_address_street/docs/_home_address_street_formatting_rails.md +0 -1
  57. data/app/pb_kits/playbook/pb_home_address_street/docs/_home_address_street_formatting_react.md +0 -1
  58. data/dist/chunks/_weekday_stacked-C98LOqgG.js +0 -45
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 765d089ccf2865b636f00f2731f259d3251554090ba8cf345d1b96c887af523a
4
- data.tar.gz: d2027d84bedb2da3000a272b5c85e8c108dbf4fac0c612653a8ce7f943924f51
3
+ metadata.gz: 10481065914978d6f6adca5acfd5c5837487d2540b84d3f9213dd9ba2cec8a8d
4
+ data.tar.gz: 442feb90a9b0b9aaf12e0aa8c20a628372c40939bf9a19cb84a7a157178c19b5
5
5
  SHA512:
6
- metadata.gz: 5927b36c0974b0d951da24d21a0afbae2f1e4949ec0e73e299491f7bb33e378b6be3eb573c0e090edc94efb924753b9117a310d12c6ff43da62c79cd21edbc17
7
- data.tar.gz: 123324d5d23872521397b16043be4df25028beb28731e8cf7e2a79ff4c49058aa4a902a1908677d0533163256ea5860861d2cdb629971be3599a61b55192c95d
6
+ metadata.gz: 8443b9866c2d121714a98c73c6d46f8b767c6def1b25f9523a9a1d1206c1caffdae81aca44c60cde13d0bbaba3630775a6c008ec7db33122bb7a21b835bc5742
7
+ data.tar.gz: 630de57b02e052633faeacee73b06b6eacfa77563b6a9aaef953854ae869640620b149c6acf2a1357a0ab6649f88e755941c3658c4ae61bd5198f5930389f328
@@ -39,8 +39,15 @@ export const TableHeaderCell = ({
39
39
  sortIcon,
40
40
  table
41
41
  }: TableHeaderCellProps) => {
42
- const { sortControl, responsive, selectableRows, hasAnySubRows, showActionsBar, inlineRowLoading } =
43
- useContext(AdvancedTableContext);
42
+ const {
43
+ sortControl,
44
+ responsive,
45
+ selectableRows,
46
+ hasAnySubRows,
47
+ showActionsBar,
48
+ inlineRowLoading,
49
+ isActionBarVisible,
50
+ } = useContext(AdvancedTableContext);
44
51
 
45
52
  type justifyTypes = "none" | "center" | "start" | "end" | "between" | "around" | "evenly"
46
53
 
@@ -65,7 +72,7 @@ export const TableHeaderCell = ({
65
72
 
66
73
  const cellClassName = classnames(
67
74
  "table-header-cells",
68
- `${showActionsBar && "header-cells-with-actions"}`,
75
+ `${showActionsBar && isActionBarVisible && "header-cells-with-actions"}`,
69
76
  `${isChrome() ? "chrome-styles" : ""}`,
70
77
  `${enableSorting ? "table-header-cells-active" : ""}`,
71
78
  { "pinned-left": responsive === "scroll" && isPinnedLeft },
@@ -0,0 +1,26 @@
1
+ export const showActionBar = (elem: HTMLElement) => {
2
+ elem.style.display = "block";
3
+ const height = elem.scrollHeight + "px";
4
+ elem.style.height = height;
5
+ elem.classList.add("is-visible");
6
+ elem.style.overflow = "hidden";
7
+
8
+ window.setTimeout(() => {
9
+ if (elem.classList.contains("is-visible")) {
10
+ elem.style.height = "";
11
+ elem.style.overflow = "visible";
12
+ }
13
+ }, 300);
14
+ };
15
+
16
+ export const hideActionBar = (elem: HTMLElement) => {
17
+ elem.style.height = elem.scrollHeight + "px";
18
+ elem.offsetHeight;
19
+ window.setTimeout(() => {
20
+ elem.style.height = "0";
21
+ elem.style.overflow = "hidden";
22
+ }, 10);
23
+ window.setTimeout(() => {
24
+ elem.classList.remove("is-visible");
25
+ }, 300);
26
+ };
@@ -31,12 +31,12 @@
31
31
  width: 100%;
32
32
  }
33
33
 
34
- .row-selection-actions-card {
35
- border-bottom-right-radius: 0px !important;
36
- border-bottom-left-radius: 0px !important;
37
- border-bottom-color: transparent;
38
- }
39
-
34
+ .row-selection-actions-card {
35
+ border-bottom-right-radius: 0px !important;
36
+ border-bottom-left-radius: 0px !important;
37
+ border-bottom-color: transparent;
38
+ transition: height 300ms ease;
39
+ }
40
40
  .table-header-cells:first-child {
41
41
  min-width: 180px;
42
42
  }
@@ -93,6 +93,43 @@
93
93
  color: $primary !important;
94
94
  }
95
95
 
96
+ // Sticky Header
97
+ .sticky-header {
98
+ thead {
99
+ z-index: 3 !important;
100
+ }
101
+ }
102
+
103
+ // Max height overflow - the below prevents expansion from overflowing container at full screen for responsive and nonresponsive tables
104
+ &.advanced-table-max-height-xs {
105
+ max-height: 320px;
106
+ overflow-y: auto;
107
+ }
108
+ &.advanced-table-max-height-sm {
109
+ max-height: 480px;
110
+ overflow-y: auto;
111
+ }
112
+ &.advanced-table-max-height-md {
113
+ max-height: 768px;
114
+ overflow-y: auto;
115
+ }
116
+ &.advanced-table-max-height-lg {
117
+ max-height: 1024px;
118
+ overflow-y: auto;
119
+ }
120
+ &.advanced-table-max-height-xl {
121
+ max-height: 1280px;
122
+ overflow-y: auto;
123
+ }
124
+ &.advanced-table-max-height-xxl {
125
+ max-height: 1440px;
126
+ overflow-y: auto;
127
+ }
128
+ &.advanced-table-max-height-xxxl {
129
+ max-height: 1920px;
130
+ overflow-y: auto;
131
+ }
132
+
96
133
  // Icons
97
134
  .button-icon {
98
135
  display: flex;
@@ -214,7 +251,13 @@
214
251
  .bg-white td:first-child {
215
252
  background-color: $white;
216
253
  }
217
-
254
+ .sticky-header {
255
+ thead {
256
+ th:first-child {
257
+ box-shadow: 1px 0 10px -2px $border_light !important;
258
+ }
259
+ }
260
+ }
218
261
  }
219
262
  }
220
263
  @media only screen and (min-width: $screen-xl-min) {
@@ -302,6 +345,14 @@
302
345
  .bg-white td:first-child {
303
346
  background-color: $bg_dark_card;
304
347
  }
348
+ .sticky-header {
349
+ thead {
350
+ th:first-child {
351
+ background: $bg_dark;
352
+ box-shadow: 1px 0 10px -2px $border_dark !important;
353
+ }
354
+ }
355
+ }
305
356
  }
306
357
  }
307
358
  }
@@ -1,4 +1,4 @@
1
- import React, { useState, useEffect, useCallback } from "react"
1
+ import React, { useState, useEffect, useCallback, useRef } from "react"
2
2
  import classnames from "classnames"
3
3
 
4
4
  import { GenericObject } from "../types"
@@ -27,6 +27,7 @@ import FlexItem from "../pb_flex/_flex_item"
27
27
  import AdvancedTableContext from "./Context/AdvancedTableContext"
28
28
 
29
29
  import { updateExpandAndCollapseState } from "./Utilities/ExpansionControlHelpers"
30
+ import { showActionBar, hideActionBar } from "./Utilities/ActionBarAnimationHelper"
30
31
 
31
32
  import { CustomCell } from "./Components/CustomCell"
32
33
  import { TableHeader } from "./SubKits/TableHeader"
@@ -48,6 +49,7 @@ type AdvancedTableProps = {
48
49
  initialLoadingRowsCount?: number
49
50
  inlineRowLoading?: boolean
50
51
  loading?: boolean | string
52
+ maxHeight?: "auto" | "xs" | "sm" | "md" | "lg" | "xl" | "xxl" | "xxxl"
51
53
  onRowToggleClick?: (arg: Row<GenericObject>) => void
52
54
  onToggleExpansionClick?: (arg: Row<GenericObject>) => void
53
55
  pagination?: boolean,
@@ -79,6 +81,7 @@ const AdvancedTable = (props: AdvancedTableProps) => {
79
81
  initialLoadingRowsCount = 10,
80
82
  inlineRowLoading = false,
81
83
  loading,
84
+ maxHeight,
82
85
  onRowToggleClick,
83
86
  onToggleExpansionClick,
84
87
  pagination = false,
@@ -288,6 +291,7 @@ const AdvancedTable = (props: AdvancedTableProps) => {
288
291
  const classes = classnames(
289
292
  buildCss("pb_advanced_table"),
290
293
  `advanced-table-responsive-${responsive}`,
294
+ maxHeight ? `advanced-table-max-height-${maxHeight}` : '', // max height as kit prop not global prop to control overflow-y
291
295
  globalProps(props),
292
296
  className
293
297
  )
@@ -295,6 +299,20 @@ const AdvancedTable = (props: AdvancedTableProps) => {
295
299
  const onPageChange = (page: number) => {
296
300
  table.setPageIndex(page - 1)
297
301
  }
302
+ //When to show the actions bar as a whole
303
+ const isActionBarVisible = selectableRows && showActionsBar && selectedRowsLength > 0
304
+
305
+ //Ref and useEffect for animating the actions bar
306
+ const cardRef = useRef(null);
307
+ useEffect(() => {
308
+ if (cardRef.current) {
309
+ if (isActionBarVisible) {
310
+ showActionBar(cardRef.current);
311
+ } else {
312
+ hideActionBar(cardRef.current);
313
+ }
314
+ }
315
+ }, [isActionBarVisible]);
298
316
 
299
317
  return (
300
318
  <div {...ariaProps}
@@ -311,6 +329,7 @@ const AdvancedTable = (props: AdvancedTableProps) => {
311
329
  expandedControl,
312
330
  handleExpandOrCollapse,
313
331
  inlineRowLoading,
332
+ isActionBarVisible,
314
333
  loading,
315
334
  responsive,
316
335
  setExpanded,
@@ -333,27 +352,24 @@ const AdvancedTable = (props: AdvancedTableProps) => {
333
352
  total={table.getPageCount()}
334
353
  />
335
354
  }
336
- {
337
- selectableRows && showActionsBar && (
338
- <Card className="row-selection-actions-card"
339
- padding="xs"
355
+ <Card
356
+ borderNone={!isActionBarVisible}
357
+ className={`${isActionBarVisible && "show-action-card row-selection-actions-card"}`}
358
+ htmlOptions={{ ref: cardRef as any }}
359
+ padding={`${isActionBarVisible ? "xs" : "none"}`}
360
+ >
361
+ <Flex alignItems="center"
362
+ justify="between"
363
+ >
364
+ <Caption color="light"
365
+ paddingLeft="xs"
366
+ size="xs"
340
367
  >
341
- <Flex alignItems="center"
342
- justify="between"
343
- >
344
- <Caption color="light"
345
- paddingLeft="xs"
346
- size="xs"
347
- >
348
- {selectedRowsLength} Selected
349
- </Caption>
350
- <FlexItem>
351
- {actions}
352
- </FlexItem>
353
- </Flex>
354
- </Card>
355
- )
356
- }
368
+ {selectedRowsLength} Selected
369
+ </Caption>
370
+ <FlexItem>{actions}</FlexItem>
371
+ </Flex>
372
+ </Card>
357
373
  <Table
358
374
  className={`${loading ? "content-loading" : ""}`}
359
375
  dark={dark}
@@ -44,6 +44,7 @@ const AdvancedTableTableProps = (props) => {
44
44
  <div>
45
45
  <AdvancedTable
46
46
  columnDefinitions={columnDefinitions}
47
+ responsive="none"
47
48
  tableData={MOCK_DATA}
48
49
  tableProps={tableProps}
49
50
  {...props}
@@ -1 +1,3 @@
1
- This kit uses the [Table kit](https://playbook.powerapp.cloud/kits/table/react) under the hood which comes with it's own set of props. If you want to apply certain Table props to that underlying kit, you can do so by using the optional `tableProps` prop. This prop must be an object that contains valid Table props. For a full list of Table props, see [here](https://playbook.powerapp.cloud/kits/table/react).
1
+ This kit uses the [Table kit](https://playbook.powerapp.cloud/kits/table/react) under the hood which comes with it's own set of props. If you want to apply certain Table props to that underlying kit, you can do so by using the optional `tableProps` prop. This prop must be an object that contains valid Table props. For a full list of Table props, see [here](https://playbook.powerapp.cloud/kits/table/react).
2
+
3
+ This doc example showcases how to set a sticky header for a nonresponsive table. To achieve sticky header AND responsive functionality, see the ["Table Props Sticky Header"](https://playbook.powerapp.cloud/kits/advanced_table/react#table-props-sticky-header) doc example below.
@@ -0,0 +1,55 @@
1
+ import React from "react"
2
+ import { AdvancedTable } from "playbook-ui"
3
+ import MOCK_DATA from "./advanced_table_mock_data.json"
4
+
5
+ const AdvancedTableTablePropsStickyHeader = (props) => {
6
+ const columnDefinitions = [
7
+ {
8
+ accessor: "year",
9
+ label: "Year",
10
+ cellAccessors: ["quarter", "month", "day"],
11
+ },
12
+ {
13
+ accessor: "newEnrollments",
14
+ label: "New Enrollments",
15
+ },
16
+ {
17
+ accessor: "scheduledMeetings",
18
+ label: "Scheduled Meetings",
19
+ },
20
+ {
21
+ accessor: "attendanceRate",
22
+ label: "Attendance Rate",
23
+ },
24
+ {
25
+ accessor: "completedClasses",
26
+ label: "Completed Classes",
27
+ },
28
+ {
29
+ accessor: "classCompletionRate",
30
+ label: "Class Completion Rate",
31
+ },
32
+ {
33
+ accessor: "graduatedStudents",
34
+ label: "Graduated Students",
35
+ },
36
+ ]
37
+
38
+ const tableProps = {
39
+ sticky: true
40
+ }
41
+
42
+ return (
43
+ <div>
44
+ <AdvancedTable
45
+ columnDefinitions={columnDefinitions}
46
+ maxHeight="xs"
47
+ tableData={MOCK_DATA}
48
+ tableProps={tableProps}
49
+ {...props}
50
+ />
51
+ </div>
52
+ )
53
+ }
54
+
55
+ export default AdvancedTableTablePropsStickyHeader
@@ -0,0 +1,3 @@
1
+ Create a sticky header that works for responsive Advanced Tables by setting `sticky: true` via `tableProps` and giving the AdvancedTable a `maxHeight` using our [Max Height](https://playbook.powerapp.cloud/visual_guidelines/max_height) global prop. This behavior requires a `maxHeight` to work. The header is sticky within the table container, allowing for it to work along with the first column stickiness of a responsive table on smaller screen sizes.
2
+
3
+ A sticky header on a nonresponsive table is demonstrated in the ["Table Props"](https://playbook.powerapp.cloud/kits/advanced_table/react#table-props) doc example above.
@@ -22,6 +22,7 @@ examples:
22
22
  - advanced_table_collapsible_trail: Collapsible Trail
23
23
  - advanced_table_table_options: Table Options
24
24
  - advanced_table_table_props: Table Props
25
+ - advanced_table_table_props_sticky_header: Table Props Sticky Header
25
26
  - advanced_table_inline_row_loading: Inline Row Loading
26
27
  - advanced_table_responsive: Responsive Tables
27
28
  - advanced_table_custom_cell: Custom Components for Cells
@@ -18,4 +18,5 @@ export { default as AdvancedTableSelectableRows } from './_advanced_table_select
18
18
  export { default as AdvancedTableSelectableRowsNoSubrows } from './_advanced_table_selectable_rows_no_subrows.jsx'
19
19
  export { default as AdvancedTableNoSubrows } from './_advanced_table_no_subrows.jsx'
20
20
  export { default as AdvancedTableSelectableRowsHeader } from './_advanced_table_selectable_rows_header.jsx'
21
- export { default as AdvancedTableSelectableRowsActions } from './_advanced_table_selectable_rows_actions.jsx'
21
+ export { default as AdvancedTableSelectableRowsActions } from './_advanced_table_selectable_rows_actions.jsx'
22
+ export { default as AdvancedTableTablePropsStickyHeader } from './_advanced_table_table_props_sticky_header.jsx'
@@ -1,3 +1,4 @@
1
1
  .pb_copy_button_kit {
2
-
2
+ width: fit-content;
3
+ height: fit-content;
3
4
  }
@@ -0,0 +1,15 @@
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 %>
@@ -0,0 +1,28 @@
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
@@ -0,0 +1,2 @@
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" }) %>
@@ -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" }) %>
@@ -1,8 +1,8 @@
1
1
  examples:
2
-
2
+ rails:
3
+ - copy_button_default: Default
4
+ - copy_button_from: Copy From
3
5
 
4
6
  react:
5
7
  - copy_button_default: Default
6
8
  - copy_button_from: Copy From
7
-
8
-
@@ -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
+ }
@@ -1,14 +1,18 @@
1
1
  examples:
2
+
3
+
2
4
  react:
3
5
  - draggable_default: Default
4
6
  - draggable_with_list: Draggable with List Kit
5
7
  - draggable_with_selectable_list: Draggable with SelectableList Kit
6
8
  - draggable_with_cards: Draggable with Cards
7
9
  - draggable_multiple_containers: Dragging Across Multiple Containers
10
+
8
11
  rails:
9
12
  - draggable_default_rails: Default
10
13
  - draggable_with_list_rails: Draggable with List Kit
11
14
  - draggable_with_selectable_list_rails: Draggable with SelectableList Kit
12
15
  - draggable_with_cards_rails: Draggable with Cards
13
- - draggable_multiple_containers_rails: Dragging Across Multiple Containers
14
16
 
17
+
18
+
@@ -1,3 +1,3 @@
1
1
  <%= pb_content_tag do %>
2
- <%= content.presence %>
3
- <% end %>
2
+ <%= content.presence %>
3
+ <% end %>
@@ -3,9 +3,6 @@
3
3
  module Playbook
4
4
  module PbDraggable
5
5
  class DraggableContainer < ::Playbook::KitBase
6
- prop :container, type: Playbook::Props::String,
7
- default: ""
8
-
9
6
  def data
10
7
  Hash(prop(:data)).merge(pb_draggable_container: true)
11
8
  end
@@ -5,8 +5,6 @@ module Playbook
5
5
  class DraggableItem < ::Playbook::KitBase
6
6
  prop :drag_id, type: Playbook::Props::String,
7
7
  default: ""
8
- prop :container, type: Playbook::Props::String,
9
- default: ""
10
8
 
11
9
  def data
12
10
  Hash(prop(:data)).merge(pb_draggable_item: true)