playbook_ui 11.18.0 → 11.19.0.pre.alpha.map1

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: 39519a8938c7fb8a9489e3be29b15fc9ace9caa5c6686328ca2e4b9e551aba91
4
- data.tar.gz: 6534fa189af42de89d9a3f4df359ac402e1c0228ab675449cdf76d5dac001dbb
3
+ metadata.gz: acd29c105dfbace7771313774060bc89a0486a03679b639541eb9fa9dc7d6913
4
+ data.tar.gz: 841b861b8177704106fb9d5946dd98a20a419d964e21dffd680ad8cf67dc91f1
5
5
  SHA512:
6
- metadata.gz: e85a07433af032820340c4f5e8e29ac807637c994350df2ef518afad3fe0c9cb09955aa10dcea2429242863af4f906fea5bf89d011fd0dfc2244ab4056a53a42
7
- data.tar.gz: 0e1c3a2e97f4a36db0caf31debc8f04aa9434b0dc2627a99ff22ebfe67fe91a3be577bb91f2412dde9081874bc34995365721a09e4bf1eba1110bca1a31fe373
6
+ metadata.gz: 7faa135348c5d7ec1734b1a094ac8693bf8f158986d685275c324ac61f386b7fe344e52aa633522c2c88e59a1b5da2cc5ad1073adf6da243d9175f66db37c5ec
7
+ data.tar.gz: 9b6b86e11f484407bf3b8bb206308e67bff415a383723978ffa805a860559ce6e8a26c11dcb67a21e02464a1d710aeaa948e741b05dc900a80c384ea4d57ae4d
@@ -103,3 +103,5 @@
103
103
  @import './utilities/line_height';
104
104
  @import './utilities/display';
105
105
  @import './utilities/flexbox';
106
+
107
+ @import 'pb_map/map';
@@ -55,6 +55,7 @@ kits:
55
55
  - lightbox
56
56
  - list
57
57
  - loading_inline
58
+ - map
58
59
  - nav
59
60
  - tags:
60
61
  - badge
@@ -10,8 +10,8 @@ export { default as Background } from './pb_background/_background'
10
10
  export { default as Badge } from './pb_badge/_badge'
11
11
  export { default as BarGraph } from './pb_bar_graph/_bar_graph'
12
12
  export { default as Body } from './pb_body/_body'
13
- export { default as BreadCrumbs } from './pb_bread_crumbs/_bread_crumbs'
14
13
  export { default as BreadCrumbItem } from './pb_bread_crumbs/_bread_crumb_item'
14
+ export { default as BreadCrumbs } from './pb_bread_crumbs/_bread_crumbs'
15
15
  export { default as Button } from './pb_button/_button'
16
16
  export { default as ButtonToolbar } from './pb_button_toolbar/_button_toolbar'
17
17
  export { default as Caption } from './pb_caption/_caption'
@@ -53,11 +53,12 @@ export { default as LabelPill } from './pb_label_pill/_label_pill'
53
53
  export { default as LabelValue } from './pb_label_value/_label_value'
54
54
  export { default as Layout } from './pb_layout/_layout'
55
55
  export { default as Legend } from './pb_legend/_legend'
56
+ export { default as Lightbox } from './pb_lightbox/_lightbox'
56
57
  export { default as LineGraph } from './pb_line_graph/_line_graph'
57
58
  export { default as List } from './pb_list/_list'
58
- export { default as Lightbox } from './pb_lightbox/_lightbox'
59
59
  export { default as ListItem } from './pb_list/_list_item'
60
60
  export { default as LoadingInline } from './pb_loading_inline/_loading_inline'
61
+ export { default as Map} from './pb_map/_map'
61
62
  export { default as Message } from './pb_message/_message'
62
63
  export { default as MultipleUsers } from './pb_multiple_users/_multiple_users'
63
64
  export { default as MultipleUsersStacked } from './pb_multiple_users_stacked/_multiple_users_stacked'
@@ -23,15 +23,15 @@ const CollapsibleContent = ({
23
23
  const contentSpacing = globalProps(props, { padding })
24
24
 
25
25
  return (
26
- <div className={classnames(contentCSS, className, contentSpacing)}>
27
- <AnimateHeight
28
- duration={300}
29
- height={context.collapsed ? 0 : 'auto'}
30
- id="bottom-section"
31
- >
26
+ <AnimateHeight
27
+ duration={400}
28
+ height={context.collapsed ? 0 : 'auto'}
29
+ id="bottom-section"
30
+ >
31
+ <div className={classnames(contentCSS, className, contentSpacing)}>
32
32
  {children}
33
- </AnimateHeight>
34
- </div>
33
+ </div>
34
+ </AnimateHeight>
35
35
  )
36
36
  }
37
37
 
@@ -1,5 +1,5 @@
1
1
  import React, { useEffect, useCallback, useRef } from 'react'
2
- import { useDropzone } from 'react-dropzone'
2
+ import { useDropzone, DropzoneInputProps, DropzoneRootProps } from 'react-dropzone'
3
3
  import classnames from 'classnames'
4
4
 
5
5
  import { buildCss, buildDataProps, noop } from '../utilities/props'
@@ -38,13 +38,20 @@ const FileUpload = (props: FileUploadProps): React.ReactElement => {
38
38
  onFilesAccepted(files)
39
39
  }, [onFilesAccepted])
40
40
 
41
- const { getRootProps, getInputProps, isDragActive, rejectedFiles } = useDropzone({
41
+ type DropZoneProps = {
42
+ getRootProps: () => DropzoneRootProps & any;
43
+ getInputProps: () => DropzoneInputProps & any;
44
+ isDragActive: boolean;
45
+ rejectedFiles: File[];
46
+ }
47
+
48
+ const { getRootProps, getInputProps, isDragActive, rejectedFiles }: DropZoneProps = useDropzone({
42
49
  accept,
43
50
  maxSize,
44
51
  onDrop,
45
52
  })
46
53
 
47
- const prevRejected: any = useRef();
54
+ const prevRejected = useRef<File[] | null>(null);
48
55
 
49
56
  const maxFileSizeText = `Max file size is ${getFormattedFileSize(maxSize)}.`
50
57
 
@@ -0,0 +1,97 @@
1
+ import React from "react";
2
+ import classnames from "classnames";
3
+ import { buildAriaProps, buildCss, buildDataProps } from "../utilities/props";
4
+ import { globalProps } from "../utilities/globalProps";
5
+
6
+ type ListProps = {
7
+ aria?: { [key: string]: string };
8
+ borderless?: boolean;
9
+ className?: string;
10
+ children: React.ReactNode[] | React.ReactNode;
11
+ dark?: boolean;
12
+ data?: object;
13
+ id?: string;
14
+ layout: "" | "left" | "right";
15
+ ordered?: boolean;
16
+ role?: string;
17
+ tabIndex?: number;
18
+ text?: string;
19
+ size?: string;
20
+ variant?: string;
21
+ xpadding: boolean;
22
+ };
23
+
24
+ const List = (props: ListProps) => {
25
+ const {
26
+ aria = {},
27
+ borderless = false,
28
+ children,
29
+ className,
30
+ dark = false,
31
+ data = {},
32
+ id,
33
+ layout = "",
34
+ ordered = false,
35
+ role,
36
+ size = "",
37
+ tabIndex,
38
+ xpadding = false,
39
+ variant,
40
+ text,
41
+ } = props;
42
+
43
+ const layoutClass: { [key: string]: string } = {
44
+ left: "layout_left",
45
+ right: "layout_right",
46
+ default: "",
47
+ };
48
+
49
+ const childrenWithProps = React.Children.map(
50
+ children,
51
+ (child: React.ReactElement) => {
52
+ return React.cloneElement(child, { text, variant });
53
+ }
54
+ );
55
+ const ariaProps = buildAriaProps(aria);
56
+ const dataProps = buildDataProps(data);
57
+ const classes = classnames(
58
+ buildCss("pb_list_kit", layoutClass[layout], size, {
59
+ dark: dark,
60
+ borderless: borderless,
61
+ ordered: ordered,
62
+ xpadding: xpadding,
63
+ }),
64
+ globalProps(props),
65
+ className
66
+ );
67
+
68
+ return (
69
+ <div className={classes}>
70
+ {ordered ? (
71
+ <ol
72
+ {...ariaProps}
73
+ {...dataProps}
74
+ className={className}
75
+ id={id}
76
+ role={role}
77
+ tabIndex={tabIndex}
78
+ >
79
+ {childrenWithProps}
80
+ </ol>
81
+ ) : (
82
+ <ul
83
+ {...ariaProps}
84
+ {...dataProps}
85
+ className={className}
86
+ id={id}
87
+ role={role}
88
+ tabIndex={tabIndex}
89
+ >
90
+ {childrenWithProps}
91
+ </ul>
92
+ )}
93
+ </div>
94
+ );
95
+ };
96
+
97
+ export default List;
@@ -1,17 +1,15 @@
1
- /* @flow */
2
-
3
- import React, { type Node } from 'react'
1
+ import React from 'react'
4
2
  import classnames from 'classnames'
5
3
  import { buildAriaProps, buildCss, buildDataProps } from '../utilities/props'
6
4
  import { globalProps } from '../utilities/globalProps'
7
5
 
8
6
  type ListItemProps = {
9
- aria?: object,
10
- children: array<Node> | Node,
7
+ aria?: { [key: string]: string },
8
+ children: React.ReactNode[] | React.ReactNode,
11
9
  className?: string,
12
10
  data?: object,
13
11
  id?: string,
14
- tabIndex?: string,
12
+ tabIndex?: number,
15
13
  }
16
14
 
17
15
  const ListItem = (props: ListItemProps) => {
@@ -0,0 +1,6 @@
1
+ @import "../tokens/typography";
2
+
3
+ .pb_map {
4
+ font-family: $font_family_base;
5
+
6
+ }
@@ -0,0 +1,39 @@
1
+ import React from 'react'
2
+ import classnames from 'classnames'
3
+ import { buildAriaProps, buildCss, buildDataProps } from '../utilities/props'
4
+ import { globalProps } from '../utilities/globalProps'
5
+
6
+ type MapProps = {
7
+ aria?: { [key: string]: string },
8
+ children?: React.ReactChild[] | React.ReactNode,
9
+ className?: string,
10
+ data?: { [key: string]: string },
11
+ id?: string,
12
+ }
13
+
14
+ const Map = (props: MapProps) => {
15
+ const {
16
+ aria = {},
17
+ children,
18
+ className,
19
+ data = {},
20
+ id,
21
+ } = props
22
+
23
+ const ariaProps = buildAriaProps(aria)
24
+ const dataProps = buildDataProps(data)
25
+ const classes = classnames(buildCss('pb_map'), globalProps(props), className)
26
+
27
+ return (
28
+ <div
29
+ {...ariaProps}
30
+ {...dataProps}
31
+ className={classes}
32
+ id={id}
33
+ >
34
+ {children}
35
+ </div>
36
+ )
37
+ }
38
+
39
+ export default Map
@@ -0,0 +1,49 @@
1
+ import React, { useRef, useEffect } from 'react'
2
+ import Map from '../_map'
3
+
4
+ import maplibregl from 'maplibre-gl'
5
+
6
+ const MapDefault = () => {
7
+
8
+ const mapContainerRef = useRef(null)
9
+
10
+ useEffect(() => {
11
+ if (!maplibregl.supported()) {
12
+ alert('Your browser does not support MapLibre GL');
13
+ } else {
14
+ const map = new maplibregl.Map({
15
+ container: mapContainerRef.current,
16
+ style: 'https://api.maptiler.com/maps/positron/style.json?key=g8IQm57iZcbJ6Ky1HmG4',
17
+ center: [-75.379143, 39.831200],
18
+ zoom: 13,
19
+ })
20
+ //set marker/pin
21
+ /* eslint-disable-next-line */
22
+ const marker = new maplibregl.Marker({
23
+ color: "#0056CF",
24
+ }).setLngLat([-75.379143, 39.831200])
25
+ .setPopup(new maplibregl.Popup({className: 'map_popup'}).setHTML(`<h4 class="pb_title_kit_size_4">Hello World!</h4>`)) // add popup
26
+ .addTo(map);
27
+
28
+ //add controls
29
+ map.addControl(new maplibregl.NavigationControl())
30
+
31
+ }
32
+ }, [])
33
+ return (
34
+ <Map>
35
+ <div
36
+ ref={mapContainerRef}
37
+ style={{
38
+ position: 'absolute',
39
+ left: 0,
40
+ right: 0,
41
+ top: 0,
42
+ bottom: 0,
43
+ }}
44
+ />
45
+ </Map>
46
+ )
47
+ }
48
+
49
+ export default MapDefault
@@ -0,0 +1,6 @@
1
+ examples:
2
+
3
+
4
+ react:
5
+ - map_default: Default
6
+
@@ -0,0 +1 @@
1
+ export { default as MapDefault } from './_map_default.jsx'
@@ -0,0 +1,17 @@
1
+ import { renderKit } from '../utilities/test-utils'
2
+
3
+ import { Map } from '../'
4
+
5
+ /* See these resources for more testing info:
6
+ - https://github.com/testing-library/jest-dom#usage for useage and examples
7
+ - https://jestjs.io/docs/en/using-matchers
8
+ */
9
+
10
+ test('generated scaffold test - update me', () => {
11
+ const props = {
12
+ data: { testid: 'default' }
13
+ }
14
+
15
+ const kit = renderKit(Map , props)
16
+ expect(kit).toBeInTheDocument()
17
+ })
@@ -0,0 +1,239 @@
1
+ import React, { useEffect } from "react";
2
+ import ReactDOM from "react-dom";
3
+
4
+ import {
5
+ Popper,
6
+ Manager as PopperManager,
7
+ Modifier,
8
+ PopperProps,
9
+ Reference as PopperReference,
10
+ } from "react-popper";
11
+
12
+ import {
13
+ buildAriaProps,
14
+ buildCss,
15
+ buildDataProps,
16
+ noop,
17
+ } from "../utilities/props";
18
+
19
+ import classnames from "classnames";
20
+ import { globalProps, GlobalProps } from "../utilities/globalProps";
21
+
22
+ type PbPopoverProps = {
23
+ aria?: { [key: string]: string };
24
+ className?: string;
25
+ closeOnClick?: "outside" | "inside" | "any";
26
+ data?: object;
27
+ id?: string;
28
+ offset?: boolean;
29
+ reference: PopperReference & any;
30
+ show?: boolean;
31
+ shouldClosePopover?: (arg0: boolean) => boolean | boolean;
32
+ } & GlobalProps &
33
+ PopperProps<any>;
34
+
35
+ // Prop enabled default modifiers here
36
+ // https://popper.js.org/docs/v2/modifiers
37
+
38
+ const POPOVER_MODIFIERS = {
39
+ offset: {
40
+ //https://popper.js.org/docs/v2/modifiers/offset/
41
+ enabled: true,
42
+ name: "offset",
43
+ options: {
44
+ offset: [0, 20],
45
+ },
46
+ phase: "main",
47
+ },
48
+ };
49
+
50
+ const popoverModifiers = ({
51
+ modifiers,
52
+ offset,
53
+ }: {
54
+ modifiers: Modifier<any> & any;
55
+ offset: {};
56
+ }) => {
57
+ return offset ? modifiers.concat([POPOVER_MODIFIERS.offset]) : modifiers;
58
+ };
59
+
60
+ const Popover = (props: PbPopoverProps) => {
61
+ const {
62
+ aria = {},
63
+ className,
64
+ children,
65
+ data = {},
66
+ id,
67
+ modifiers,
68
+ offset,
69
+ placement,
70
+ referenceElement,
71
+ zIndex,
72
+ maxHeight,
73
+ maxWidth,
74
+ minHeight,
75
+ minWidth,
76
+ } = props;
77
+
78
+ const popoverSpacing =
79
+ globalProps(props).includes("dark") || !globalProps(props)
80
+ ? "p_sm"
81
+ : globalProps(props);
82
+ const overflowHandling = maxHeight || maxWidth ? "overflow_handling" : "";
83
+ const zIndexStyle = zIndex ? { zIndex: zIndex } : {};
84
+ const widthHeightStyles = () => {
85
+ return Object.assign(
86
+ {},
87
+ maxHeight ? { maxHeight: maxHeight } : {},
88
+ maxWidth ? { maxWidth: maxWidth } : {},
89
+ minHeight ? { minHeight: minHeight } : {},
90
+ minWidth ? { minWidth: minWidth } : {}
91
+ );
92
+ };
93
+ const ariaProps = buildAriaProps(aria);
94
+ const dataProps = buildDataProps(data);
95
+ const classes = classnames(
96
+ buildCss("pb_popover_kit"),
97
+ globalProps(props),
98
+ className
99
+ );
100
+
101
+ return (
102
+ <Popper
103
+ modifiers={popoverModifiers({ modifiers, offset })}
104
+ placement={placement}
105
+ referenceElement={referenceElement}
106
+ >
107
+ {({ placement, ref, style }) => {
108
+ return (
109
+ <div
110
+ {...ariaProps}
111
+ {...dataProps}
112
+ className={classes}
113
+ data-placement={placement}
114
+ id={id}
115
+ ref={ref}
116
+ style={Object.assign({}, style, zIndexStyle)}
117
+ >
118
+ <div
119
+ className={classnames(`${buildCss("pb_popover_tooltip")} show`)}
120
+ >
121
+ <div
122
+ className={classnames(
123
+ "pb_popover_body",
124
+ popoverSpacing,
125
+ overflowHandling
126
+ )}
127
+ style={widthHeightStyles()}
128
+ >
129
+ {children}
130
+ </div>
131
+ </div>
132
+ </div>
133
+ );
134
+ }}
135
+ </Popper>
136
+ );
137
+ };
138
+
139
+ const PbReactPopover = (props: PbPopoverProps) => {
140
+ const {
141
+ className,
142
+ children,
143
+ modifiers = [],
144
+ offset = false,
145
+ placement = "left",
146
+ portal = "body",
147
+ reference,
148
+ referenceElement,
149
+ show = false,
150
+ usePortal = true,
151
+ zIndex,
152
+ maxHeight,
153
+ maxWidth,
154
+ minHeight,
155
+ minWidth,
156
+ } = props;
157
+
158
+ useEffect(() => {
159
+ const { closeOnClick, shouldClosePopover = noop } = props;
160
+
161
+ if (!closeOnClick) return;
162
+
163
+ document.body.addEventListener(
164
+ "click",
165
+ ({ target }) => {
166
+ const targetIsPopover =
167
+ (target as HTMLElement).closest("[class^=pb_popover_tooltip]") !==
168
+ null;
169
+ const targetIsReference =
170
+ (target as HTMLElement).closest(".pb_popover_reference_wrapper") !==
171
+ null;
172
+
173
+ switch (closeOnClick) {
174
+ case "outside":
175
+ if (!targetIsPopover || targetIsReference) {
176
+ shouldClosePopover(true);
177
+ }
178
+ break;
179
+ case "inside":
180
+ if (targetIsPopover || targetIsReference) {
181
+ shouldClosePopover(true);
182
+ }
183
+ break;
184
+ case "any":
185
+ shouldClosePopover(true);
186
+ break;
187
+ }
188
+ },
189
+ { capture: true }
190
+ );
191
+ }, []);
192
+
193
+ const popoverComponent = (
194
+ <Popover
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
+ {...props}
206
+ >
207
+ {children}
208
+ </Popover>
209
+ );
210
+
211
+ return (
212
+ <PopperManager>
213
+ <>
214
+ {reference && !referenceElement && (
215
+ <PopperReference>
216
+ {({ ref }) => (
217
+ <span className="pb_popover_reference_wrapper" ref={ref}>
218
+ <reference.type {...reference.props} />
219
+ </span>
220
+ )}
221
+ </PopperReference>
222
+ )}
223
+ {show &&
224
+ (usePortal ? (
225
+ <>
226
+ {ReactDOM.createPortal(
227
+ popoverComponent,
228
+ document.querySelector(portal)
229
+ )}
230
+ </>
231
+ ) : (
232
+ { popoverComponent }
233
+ ))}
234
+ </>
235
+ </PopperManager>
236
+ );
237
+ };
238
+
239
+ export default PbReactPopover;
@@ -1,9 +1,13 @@
1
1
  import PbEnhancedElement from '../pb_enhanced_element'
2
- import { createPopper } from '@popperjs/core'
2
+ import { createPopper, Instance, Placement } from '@popperjs/core'
3
3
 
4
4
  const POPOVER_OFFSET_Y = [0, 20]
5
5
 
6
6
  export default class PbPopover extends PbEnhancedElement {
7
+ popper: Instance
8
+ _triggerElement: HTMLElement
9
+ _tooltip: HTMLElement
10
+ element: HTMLElement
7
11
  static get selector() {
8
12
  return '[data-pb-popover-kit]'
9
13
  }
@@ -14,8 +18,8 @@ export default class PbPopover extends PbEnhancedElement {
14
18
 
15
19
  connect() {
16
20
  this.moveTooltip()
17
- this.popper = createPopper(this.triggerElement, this.tooltip, {
18
- placement: this.position,
21
+ this.popper = createPopper (this.triggerElement, this.tooltip, {
22
+ placement: this.position as Placement,
19
23
  strategy: 'fixed',
20
24
  modifiers: [
21
25
  {
@@ -27,7 +31,7 @@ export default class PbPopover extends PbEnhancedElement {
27
31
  ],
28
32
  })
29
33
 
30
- this.triggerElement.addEventListener('click', (event) => {
34
+ this.triggerElement.addEventListener('click', (event: Event) => {
31
35
  event.preventDefault()
32
36
  event.stopPropagation()
33
37
 
@@ -43,8 +47,8 @@ export default class PbPopover extends PbEnhancedElement {
43
47
  }
44
48
 
45
49
  checkCloseTooltip() {
46
- document.querySelector('body').addEventListener('click', ({ target }) => {
47
- const isTooltipElement = target.closest(`#${this.tooltipId}`) !== null
50
+ document.querySelector('body').addEventListener('click', ({ target } ) => {
51
+ const isTooltipElement = (target as HTMLElement).closest(`#${this.tooltipId}`) !== null
48
52
 
49
53
  switch (this.closeOnClick) {
50
54
  case 'any':