playbook_ui 11.16.0 → 11.17.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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: ed9c5868b671e135987a4e3c391d8cdfa925217d8134552596aab8beb6dde627
4
- data.tar.gz: ffb9b388c45c05caf25b28c88f665525c24ceca2e7f52adf71bb5b70104dba73
3
+ metadata.gz: e30317c6abf3a057219669c5c7adab53460641afbbff126d729e4f0d1c6d3d87
4
+ data.tar.gz: d4c0d860a57a34ef50fdd7df5dca5f04b7634ee4298ddbb22f821b1ee4f13781
5
5
  SHA512:
6
- metadata.gz: aa935a21ba75a2fbaba40c7dd0c77554d12a5af159e0624ce965f7e81b8edca76922925b011cc3b1960db3fd6414de61f17c4b35f862105c55e0f48423e28d93
7
- data.tar.gz: 6b72e6f7857aecfd8030f75ac6e07de05c2f30ab38ab84274762e34e06bb81441c4520ad2fb4c82c37fcde314827bf5b149b9a6c79fb799381c7cf2481758b4a
6
+ metadata.gz: d9a433cbb717a4f6c08aac8c75ef0a6ab4b68c23e3c36c7ab0ee06887ada621855b7721697b094820cd6485115fc2b8f04c1b3e9338a5807e0010734c8c6d963
7
+ data.tar.gz: 194614449c6010f2d43b323440bd822c68ac37a171cbbecc1c20fc8ee6e24eba02c017568c77890f5b141afe1957776d9891cb5f58f7ddd01dfb0f174900e524
@@ -1,19 +1,25 @@
1
+ /* eslint-disable react/no-multi-comp */
1
2
  // @flow
2
3
 
3
- import React from 'react'
4
- import ReactDOM from 'react-dom'
4
+ import React, {useEffect} from "react";
5
+ import ReactDOM from "react-dom";
5
6
 
6
7
  import {
7
8
  Popper,
8
9
  Manager as PopperManager,
9
10
  PopperProps,
10
11
  Reference as PopperReference,
11
- } from 'react-popper'
12
+ } from "react-popper";
12
13
 
13
- import { buildAriaProps, buildCss, buildDataProps, noop } from '../utilities/props'
14
+ import {
15
+ buildAriaProps,
16
+ buildCss,
17
+ buildDataProps,
18
+ noop,
19
+ } from "../utilities/props";
14
20
 
15
- import classnames from 'classnames'
16
- import { globalProps } from '../utilities/globalProps'
21
+ import classnames from "classnames";
22
+ import { globalProps } from "../utilities/globalProps";
17
23
 
18
24
  type PbPopoverProps = {
19
25
  aria?: object,
@@ -25,7 +31,7 @@ type PbPopoverProps = {
25
31
  reference: PopperReference,
26
32
  show?: boolean,
27
33
  shouldClosePopover?: () => boolean,
28
- } & PopperProps
34
+ } & PopperProps;
29
35
 
30
36
  // Prop enabled default modifiers here
31
37
  // https://popper.js.org/docs/v2/modifiers
@@ -34,17 +40,17 @@ const POPOVER_MODIFIERS = {
34
40
  offset: {
35
41
  //https://popper.js.org/docs/v2/modifiers/offset/
36
42
  enabled: true,
37
- name: 'offset',
43
+ name: "offset",
38
44
  options: {
39
45
  offset: [0, 20],
40
46
  },
41
- phase: 'main',
47
+ phase: "main",
42
48
  },
43
- }
49
+ };
44
50
 
45
51
  const popoverModifiers = ({ modifiers, offset }) => {
46
- return offset ? modifiers.concat([POPOVER_MODIFIERS.offset]) : modifiers
47
- }
52
+ return offset ? modifiers.concat([POPOVER_MODIFIERS.offset]) : modifiers;
53
+ };
48
54
 
49
55
  const Popover = (props: PbPopoverProps) => {
50
56
  const {
@@ -62,11 +68,14 @@ const Popover = (props: PbPopoverProps) => {
62
68
  maxWidth,
63
69
  minHeight,
64
70
  minWidth,
65
- } = props
66
-
67
- const popoverSpacing = globalProps(props).includes('dark') || !globalProps(props) ? 'p_sm' : globalProps(props)
68
- const overflowHandling = maxHeight || maxWidth ? 'overflow_handling' : ''
69
- const zIndexStyle = zIndex ? { zIndex: zIndex } : {}
71
+ } = props;
72
+
73
+ const popoverSpacing =
74
+ globalProps(props).includes("dark") || !globalProps(props)
75
+ ? "p_sm"
76
+ : globalProps(props);
77
+ const overflowHandling = maxHeight || maxWidth ? "overflow_handling" : "";
78
+ const zIndexStyle = zIndex ? { zIndex: zIndex } : {};
70
79
  const widthHeightStyles = () => {
71
80
  return Object.assign(
72
81
  {},
@@ -74,15 +83,15 @@ const Popover = (props: PbPopoverProps) => {
74
83
  maxWidth ? { maxWidth: maxWidth } : {},
75
84
  minHeight ? { minHeight: minHeight } : {},
76
85
  minWidth ? { minWidth: minWidth } : {}
77
- )
78
- }
79
- const ariaProps = buildAriaProps(aria)
80
- const dataProps = buildDataProps(data)
86
+ );
87
+ };
88
+ const ariaProps = buildAriaProps(aria);
89
+ const dataProps = buildDataProps(data);
81
90
  const classes = classnames(
82
- buildCss('pb_popover_kit'),
91
+ buildCss("pb_popover_kit"),
83
92
  globalProps(props),
84
93
  className
85
- )
94
+ );
86
95
 
87
96
  return (
88
97
  <Popper
@@ -99,20 +108,14 @@ const Popover = (props: PbPopoverProps) => {
99
108
  data-placement={placement}
100
109
  id={id}
101
110
  ref={ref}
102
- style={Object.assign(
103
- {},
104
- style,
105
- zIndexStyle
106
- )}
111
+ style={Object.assign({}, style, zIndexStyle)}
107
112
  >
108
113
  <div
109
- className={classnames(
110
- `${buildCss('pb_popover_tooltip')} show`
111
- )}
114
+ className={classnames(`${buildCss("pb_popover_tooltip")} show`)}
112
115
  >
113
116
  <div
114
117
  className={classnames(
115
- 'pb_popover_body',
118
+ "pb_popover_body",
116
119
  popoverSpacing,
117
120
  overflowHandling
118
121
  )}
@@ -122,25 +125,33 @@ const Popover = (props: PbPopoverProps) => {
122
125
  </div>
123
126
  </div>
124
127
  </div>
125
- )
128
+ );
126
129
  }}
127
130
  </Popper>
128
- )
129
- }
130
-
131
- export default class PbReactPopover extends React.Component<PbPopoverProps> {
132
- static defaultProps = {
133
- modifiers: [],
134
- offset: false,
135
- placement: 'left',
136
- portal: 'body',
137
- show: false,
138
- shouldClosePopover: noop,
139
- usePortal: true,
140
- }
141
-
142
- componentDidMount() {
143
- const { closeOnClick, shouldClosePopover } = this.props
131
+ );
132
+ };
133
+
134
+ const PbReactPopover = (props: PbPopoverProps) => {
135
+ const {
136
+ className,
137
+ children,
138
+ modifiers = [],
139
+ offset = false,
140
+ placement = "left",
141
+ portal = "body",
142
+ reference,
143
+ referenceElement,
144
+ show = false,
145
+ usePortal = true,
146
+ zIndex,
147
+ maxHeight,
148
+ maxWidth,
149
+ minHeight,
150
+ minWidth,
151
+ } = props;
152
+
153
+ useEffect(() => {
154
+ const { closeOnClick, shouldClosePopover = noop } = props
144
155
 
145
156
  if (!closeOnClick) return
146
157
 
@@ -151,87 +162,66 @@ export default class PbReactPopover extends React.Component<PbPopoverProps> {
151
162
  target.closest('.pb_popover_reference_wrapper') !== null
152
163
 
153
164
  switch (closeOnClick) {
154
- case 'outside':
155
- if (!targetIsPopover || targetIsReference) {
156
- shouldClosePopover(true)
157
- }
158
- break
159
- case 'inside':
160
- if (targetIsPopover || targetIsReference) {
165
+ case 'outside':
166
+ if (!targetIsPopover || targetIsReference) {
167
+ shouldClosePopover(true)
168
+ }
169
+ break
170
+ case 'inside':
171
+ if (targetIsPopover || targetIsReference) {
172
+ shouldClosePopover(true)
173
+ }
174
+ break
175
+ case 'any':
161
176
  shouldClosePopover(true)
162
- }
163
- break
164
- case 'any':
165
- shouldClosePopover(true)
166
- break
177
+ break
167
178
  }
168
- })
169
- }
170
-
171
- props: PbPopoverProps
172
-
173
- render() {
174
- const {
175
- className,
176
- children,
177
- modifiers,
178
- offset,
179
- placement,
180
- portal,
181
- reference,
182
- referenceElement,
183
- show,
184
- usePortal,
185
- zIndex,
186
- maxHeight,
187
- maxWidth,
188
- minHeight,
189
- minWidth,
190
- } = this.props
191
-
192
- const popoverComponent = (
193
- <Popover
194
- {...this.props}
195
- className={className}
196
- maxHeight={maxHeight}
197
- maxWidth={maxWidth}
198
- minHeight={minHeight}
199
- minWidth={minWidth}
200
- modifiers={modifiers}
201
- offset={offset}
202
- placement={placement}
203
- referenceElement={referenceElement}
204
- zIndex={zIndex}
205
- >
206
- {children}
207
- </Popover>
208
- )
209
-
210
- return (
211
- <PopperManager>
212
- <If condition={reference && !referenceElement}>
213
- <PopperReference>
214
- {({ ref }) => (
215
- <span
216
- className="pb_popover_reference_wrapper"
217
- ref={ref}
218
- >
219
- <reference.type {...reference.props} />
220
- </span>
221
- )}
222
- </PopperReference>
223
- </If>
224
- <If condition={show}>
225
- <If condition={usePortal}>
226
- {ReactDOM.createPortal(
227
- popoverComponent,
228
- document.querySelector(portal)
229
- )}
230
- <Else />
231
- {popoverComponent}
232
- </If>
179
+ }, { capture: true })
180
+ }, [])
181
+
182
+ const popoverComponent = (
183
+ <Popover
184
+ className={className}
185
+ maxHeight={maxHeight}
186
+ maxWidth={maxWidth}
187
+ minHeight={minHeight}
188
+ minWidth={minWidth}
189
+ modifiers={modifiers}
190
+ offset={offset}
191
+ placement={placement}
192
+ referenceElement={referenceElement}
193
+ zIndex={zIndex}
194
+ {...props}
195
+ >
196
+ {children}
197
+ </Popover>
198
+ );
199
+
200
+ return (
201
+ <PopperManager>
202
+ <If condition={reference && !referenceElement}>
203
+ <PopperReference>
204
+ {({ ref }) => (
205
+ <span className="pb_popover_reference_wrapper"
206
+ ref={ref}
207
+ >
208
+ <reference.type {...reference.props} />
209
+ </span>
210
+ )}
211
+ </PopperReference>
212
+ </If>
213
+ <If condition={show}>
214
+ <If condition={usePortal}>
215
+ {ReactDOM.createPortal(
216
+ popoverComponent,
217
+ document.querySelector(portal)
218
+ )}
219
+ <Else />
220
+ {popoverComponent}
233
221
  </If>
234
- </PopperManager>
235
- )
236
- }
237
- }
222
+ </If>
223
+ </PopperManager>
224
+ );
225
+ };
226
+
227
+ export default PbReactPopover;
@@ -31,7 +31,7 @@ const PopoverClose = (props) => {
31
31
  }
32
32
 
33
33
  const handleAnyTogglePopover = () => {
34
- setAnyShowPopover(!showOutsidePopover)
34
+ setAnyShowPopover(!showAnyPopover)
35
35
  }
36
36
 
37
37
  const insidePopoverTrigger = (
@@ -1,6 +1,6 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Playbook
4
- PREVIOUS_VERSION = "11.15.0"
5
- VERSION = "11.16.0"
4
+ PREVIOUS_VERSION = "11.16.0"
5
+ VERSION = "11.17.0"
6
6
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: playbook_ui
3
3
  version: !ruby/object:Gem::Version
4
- version: 11.16.0
4
+ version: 11.17.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Power UX
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2023-01-03 00:00:00.000000000 Z
12
+ date: 2023-01-06 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: actionpack