playbook_ui 14.14.0.pre.alpha.PBNTR890typeahead6394 → 14.14.0.pre.alpha.PBNTR892dialogenhancedelement6476

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 85ec8319ef8383dcbd45605b1c431293afbf510fc625b115b815c820a0f74597
4
- data.tar.gz: c2a828a83f9bf40c4eb691d765dfc4319bbffbbbbad2a2c8b28e3d22b4dc3797
3
+ metadata.gz: 87dde43f2e80f2fb326bea47771b1b44f66dc0745458a22d6fdc2da372eaf197
4
+ data.tar.gz: 8434f9863bd44e9ee69f1be53a770e87de0df3002aa69666df787bfd9d2db202
5
5
  SHA512:
6
- metadata.gz: ae4c18ecdc0fad76efba409c039b5c8ecc55f50ce0cf9041a3ce1285683abf50cec01ae9687331d104a2b4fd0d508adeeef0d55996e71ff8038d4c951f55d6de
7
- data.tar.gz: f9fa664003f3b446c12e4a4eb6763a0c163068230954422c10cf03747ed2c303c4ef6cde080df056c707c17dbe462fb0bc0958ddd4a7cf56dfe08ab130e25017
6
+ metadata.gz: fffef961e834a62003bc28a6ce270f916e63d6e27c306db563b4a3f7a6054dd1f8161cc76799a9056b0efabbebf65943748eca172da7a984697a903027779b62
7
+ data.tar.gz: 3cf6e726483df0b00d9436cb81d4c243e54f95c5be40ce39245a01793f6c266ad34f9e416282ce08991536b78e0c6cf9999e2466ee8c1840b549f348e65e78fc
@@ -1,4 +1,8 @@
1
- <div class="pb_dialog_wrapper_rails <%= object.full_height_style %>" data-overlay-click= <%= object.overlay_close %> >
1
+ <div
2
+ class="pb_dialog_wrapper_rails <%= object.full_height_style %>"
3
+ data-pb-dialog-wrapper="true"
4
+ data-overlay-click= <%= object.overlay_close %>
5
+ >
2
6
  <%= pb_content_tag(:dialog) do %>
3
7
  <% if object.status === "" && object.title %>
4
8
  <%= pb_rails("dialog/dialog_header", props: { title: object.title, id: object.id }) %>
@@ -33,8 +37,3 @@
33
37
  <%= content %>
34
38
  <% end %>
35
39
  </div>
36
-
37
- <%= javascript_tag do %>
38
- window.addEventListener("DOMContentLoaded", () => dialogHelper())
39
- window.addEventListener("turbo:frame-load", () => dialogHelper())
40
- <% end %>
@@ -1,3 +1,5 @@
1
+ // Three places in Nitro depend on this function inside the window scope.
2
+ // Because of this, we will keep this file until we remove this dependency from Nitro.
1
3
  const dialogHelper = () => {
2
4
  const openTrigger = document.querySelectorAll("[data-open-dialog]");
3
5
  const closeTrigger = document.querySelectorAll("[data-close-dialog]");
@@ -0,0 +1,75 @@
1
+ import PbEnhancedElement from "../pb_enhanced_element";
2
+
3
+ const DIALOG_WRAPPER_SELECTOR = "[data-pb-dialog-wrapper]";
4
+
5
+ export default class PbDialog extends PbEnhancedElement {
6
+ static get selector() {
7
+ return DIALOG_WRAPPER_SELECTOR;
8
+ }
9
+
10
+ connect() {
11
+ window.addEventListener("DOMContentLoaded", () => this.setupDialog())
12
+ window.addEventListener("turbo:frame-load", () => this.setupDialog())
13
+ }
14
+
15
+ setupDialog() {
16
+ const openTrigger = document.querySelectorAll("[data-open-dialog]");
17
+ const closeTrigger = document.querySelectorAll("[data-close-dialog]");
18
+ const dialogs = document.querySelectorAll(".pb_dialog_rails")
19
+
20
+ const loadingButton = document.querySelector('[data-disable-with="Loading"]');
21
+ if (loadingButton) {
22
+ loadingButton.addEventListener("click", function () {
23
+ const okayLoadingButton = document.querySelector('[data-disable-with="Loading"]');
24
+ const cancelButton = document.querySelector('[data-disable-cancel-with="Loading"]');
25
+ let currentClass = okayLoadingButton.className;
26
+ let cancelClass = cancelButton ? cancelButton.className : "";
27
+
28
+ let newClass = currentClass.replace("_enabled", "_disabled_loading");
29
+ let newCancelClass = cancelClass.replace("_enabled", "_disabled");
30
+
31
+ // Disable the buttons
32
+ okayLoadingButton.disabled = true;
33
+ if (cancelButton) cancelButton.disabled = true;
34
+
35
+ okayLoadingButton.className = newClass;
36
+ if (cancelButton) cancelButton.className = newCancelClass;
37
+ });
38
+ }
39
+
40
+ openTrigger.forEach((open) => {
41
+ open.addEventListener("click", () => {
42
+ var openTriggerData = open.dataset.openDialog;
43
+ var targetDialog = document.getElementById(openTriggerData)
44
+ if (targetDialog.open) return;
45
+ targetDialog.showModal();
46
+ });
47
+ });
48
+
49
+ closeTrigger.forEach((close) => {
50
+ close.addEventListener("click", () => {
51
+ var closeTriggerData = close.dataset.closeDialog;
52
+ document.getElementById(closeTriggerData).close();
53
+ });
54
+ });
55
+
56
+ // Close dialog box on outside click
57
+ dialogs.forEach((dialogElement) => {
58
+ dialogElement.addEventListener("mousedown", (event) => {
59
+ const dialogParentDataset = dialogElement.parentElement.dataset
60
+ if (dialogParentDataset.overlayClick === "overlay_close") return
61
+
62
+ const dialogModal = event.target.getBoundingClientRect()
63
+ const clickedOutsideDialogModal = event.clientX < dialogModal.left ||
64
+ event.clientX > dialogModal.right ||
65
+ event.clientY < dialogModal.top ||
66
+ event.clientY > dialogModal.bottom
67
+
68
+ if (clickedOutsideDialogModal) {
69
+ dialogElement.close()
70
+ event.stopPropagation()
71
+ }
72
+ })
73
+ })
74
+ }
75
+ }
@@ -69,4 +69,17 @@ $overlay_colors: (
69
69
  pointer-events: none;
70
70
  z-index: 1;
71
71
  }
72
+
73
+ &.overlay-hide-scrollbar {
74
+ & [class*="overflow_x_auto"],
75
+ & [class*="overflow_y_auto"],
76
+ & [class*="overflow_auto"] {
77
+ &::-webkit-scrollbar {
78
+ display: none !important;
79
+ }
80
+
81
+ -ms-overflow-style: none !important;
82
+ scrollbar-width: none !important;
83
+ }
84
+ }
72
85
  }
@@ -11,6 +11,7 @@ export type OverlayChildrenProps = {
11
11
  dynamic?: boolean,
12
12
  position: string,
13
13
  size: string,
14
+ scrollBarNone?: boolean,
14
15
  }
15
16
 
16
17
  type OverlayProps = {
@@ -23,6 +24,8 @@ type OverlayProps = {
23
24
  htmlOptions?: { [key: string]: string | number | boolean | (() => void) },
24
25
  id?: string,
25
26
  layout: { [key: string]: string },
27
+ scrollBarNone?: boolean,
28
+
26
29
  }
27
30
 
28
31
  const Overlay = (props: OverlayProps) => {
@@ -36,11 +39,12 @@ const Overlay = (props: OverlayProps) => {
36
39
  htmlOptions = {},
37
40
  id,
38
41
  layout = { "bottom": "full" },
42
+ scrollBarNone = false,
39
43
  } = props
40
44
 
41
45
  const ariaProps = buildAriaProps(aria)
42
46
  const dataProps = buildDataProps(data)
43
- const classes = classnames(buildCss('pb_overlay'), globalProps(props), className)
47
+ const classes = classnames(buildCss('pb_overlay'), { 'overlay-hide-scrollbar': scrollBarNone }, globalProps(props), className )
44
48
  const htmlProps = buildHtmlProps(htmlOptions)
45
49
  const dynamicInlineProps = globalInlineProps(props)
46
50
 
@@ -68,12 +72,14 @@ const Overlay = (props: OverlayProps) => {
68
72
  children,
69
73
  color,
70
74
  position: getPosition(),
75
+ scrollBarNone,
71
76
  size: getSize()
72
77
  }) : OverlayToken({
73
78
  children,
74
79
  color,
75
80
  dynamic: dynamic,
76
81
  position: getPosition(),
82
+ scrollBarNone,
77
83
  size: getSize()
78
84
  })
79
85
  }
@@ -0,0 +1,11 @@
1
+ <%= pb_rails("overlay", props: { layout: { "x": "xl" }, color: "card_light", scroll_bar_none: true }) do %>
2
+ <%= pb_rails("flex", props: { column_gap: "lg", orientation: "row", overflow_x: "auto" }) do %>
3
+ <% 15.times do %>
4
+ <%= pb_rails("flex/flex_item") do %>
5
+ <%= pb_rails("card") do %>
6
+ Card content
7
+ <% end %>
8
+ <% end %>
9
+ <% end %>
10
+ <% end %>
11
+ <% end %>
@@ -0,0 +1,37 @@
1
+ import React from 'react'
2
+ import {
3
+ Overlay,
4
+ Card,
5
+ Flex,
6
+ FlexItem,
7
+ } from 'playbook-ui'
8
+
9
+ const InlineCardsExample = () => {
10
+ return (
11
+ <Flex
12
+ columnGap="lg"
13
+ orientation="row"
14
+ overflowX="auto"
15
+ >
16
+ {Array.from({ length: 15 }, (_, index) => (
17
+ <FlexItem key={index}>
18
+ <Card>{"Card Content"}</Card>
19
+ </FlexItem>
20
+ ))}
21
+ </Flex>
22
+ )
23
+ }
24
+
25
+ const OverlayHideScrollBar = () => (
26
+ <>
27
+ <Overlay
28
+ color="card_light"
29
+ layout={{"x": "xl"}}
30
+ scrollBarNone
31
+ >
32
+ <InlineCardsExample />
33
+ </Overlay>
34
+ </>
35
+ )
36
+
37
+ export default OverlayHideScrollBar
@@ -0,0 +1 @@
1
+ Pass the `scroll_bar_none` prop to hide the scrollbar from view. This is particularly helpful for small containers where the scrollbar may occupy too much space.
@@ -0,0 +1 @@
1
+ Pass the `scrollBarNone` prop to hide the scrollbar from view. This is particularly helpful for small containers where the scrollbar may occupy too much space.
@@ -4,9 +4,11 @@ examples:
4
4
  - overlay_multi_directional: Multi-directional
5
5
  - overlay_vertical_dynamic_multi_directional: Vertical Dynamic Multi-directional
6
6
  - overlay_toggle: Toggle
7
+ - overlay_hide_scroll_bar: Hide Scroll Bar
7
8
 
8
9
  rails:
9
10
  - overlay_default: Default
10
11
  - overlay_multi_directional: Multi-directional
11
12
  - overlay_vertical_dynamic_multi_directional: Vertical Dynamic Multi-directional
12
13
  - overlay_toggle: Toggle
14
+ - overlay_hide_scroll_bar: Hide Scroll Bar
@@ -2,3 +2,4 @@ export { default as OverlayDefault } from './_overlay_default.jsx'
2
2
  export { default as OverlayMultiDirectional } from './_overlay_multi_directional.jsx'
3
3
  export { default as OverlayToggle } from './_overlay_toggle.jsx'
4
4
  export { default as OverlayVerticalDynamicMultiDirectional } from './_overlay_vertical_dynamic_multi_directional.jsx'
5
+ export { default as OverlayHideScrollBar } from './_overlay_hide_scroll_bar.jsx'
@@ -10,9 +10,11 @@ module Playbook
10
10
  default: { "bottom": "full" }
11
11
  prop :dynamic, type: Playbook::Props::Boolean,
12
12
  default: false
13
+ prop :scroll_bar_none, type: Playbook::Props::Boolean,
14
+ default: false
13
15
 
14
16
  def classname
15
- generate_classname("pb_overlay")
17
+ generate_classname("pb_overlay", hide_scroll_bar_class)
16
18
  end
17
19
 
18
20
  def position
@@ -114,6 +116,10 @@ module Playbook
114
116
  data.merge!("data-overlay-dynamic" => true) if dynamic
115
117
  data
116
118
  end
119
+
120
+ def hide_scroll_bar_class
121
+ scroll_bar_none ? " overlay-hide-scrollbar" : ""
122
+ end
117
123
  end
118
124
  end
119
125
  end
@@ -64,3 +64,15 @@ test('should render children', () => {
64
64
  const kit = screen.getByTestId(testId)
65
65
  expect(kit).toHaveTextContent(props.children)
66
66
  })
67
+
68
+ test('should add overlay-hide-scrollbar class when scrollBarNone is true', () => {
69
+ const props = {
70
+ children,
71
+ data: { testid: testId },
72
+ scrollBarNone: true
73
+ }
74
+
75
+ render(<Overlay {...props} />)
76
+ const kit = screen.getByTestId(testId)
77
+ expect(kit).toHaveClass('overlay-hide-scrollbar')
78
+ })