playbook_ui 11.18.0.pre.alpha.pagutility1 → 11.19.0.pre.alpha.map1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (29) hide show
  1. checksums.yaml +4 -4
  2. data/app/pb_kits/playbook/_playbook.scss +2 -1
  3. data/app/pb_kits/playbook/data/menu.yml +1 -0
  4. data/app/pb_kits/playbook/index.js +3 -2
  5. data/app/pb_kits/playbook/pb_collapsible/child_kits/CollapsibleContent.tsx +8 -8
  6. data/app/pb_kits/playbook/pb_file_upload/_file_upload.tsx +10 -3
  7. data/app/pb_kits/playbook/pb_list/_list.tsx +97 -0
  8. data/app/pb_kits/playbook/pb_list/{_list_item.jsx → _list_item.tsx} +4 -6
  9. data/app/pb_kits/playbook/pb_map/_map.scss +6 -0
  10. data/app/pb_kits/playbook/pb_map/_map.tsx +39 -0
  11. data/app/pb_kits/playbook/pb_map/docs/_map_default.jsx +49 -0
  12. data/app/pb_kits/playbook/pb_map/docs/example.yml +6 -0
  13. data/app/pb_kits/playbook/pb_map/docs/index.js +1 -0
  14. data/app/pb_kits/playbook/pb_map/map.test.jsx +17 -0
  15. data/app/pb_kits/playbook/pb_popover/_popover.tsx +239 -0
  16. data/app/pb_kits/playbook/pb_popover/{index.js → index.ts} +10 -6
  17. data/app/pb_kits/playbook/pb_popover/popover.test.js +222 -0
  18. data/app/pb_kits/playbook/pb_typeahead/_typeahead.jsx +13 -2
  19. data/app/pb_kits/playbook/pb_typeahead/docs/_typeahead_with_highlight.jsx +98 -0
  20. data/app/pb_kits/playbook/pb_typeahead/docs/example.yml +1 -0
  21. data/app/pb_kits/playbook/pb_typeahead/docs/index.js +1 -0
  22. data/app/pb_kits/playbook/playbook-doc.js +2 -0
  23. data/lib/playbook/version.rb +2 -2
  24. data/lib/playbook.rb +0 -1
  25. metadata +14 -22
  26. data/app/pb_kits/playbook/pb_list/_list.jsx +0 -98
  27. data/app/pb_kits/playbook/pb_popover/_popover.jsx +0 -227
  28. data/app/pb_kits/playbook/utilities/_pagination.scss +0 -68
  29. data/lib/playbook/pagination_renderer.rb +0 -41
@@ -1,227 +0,0 @@
1
- /* eslint-disable react/no-multi-comp */
2
- // @flow
3
-
4
- import React, {useEffect} from "react";
5
- import ReactDOM from "react-dom";
6
-
7
- import {
8
- Popper,
9
- Manager as PopperManager,
10
- PopperProps,
11
- Reference as PopperReference,
12
- } from "react-popper";
13
-
14
- import {
15
- buildAriaProps,
16
- buildCss,
17
- buildDataProps,
18
- noop,
19
- } from "../utilities/props";
20
-
21
- import classnames from "classnames";
22
- import { globalProps } from "../utilities/globalProps";
23
-
24
- type PbPopoverProps = {
25
- aria?: object,
26
- className?: string,
27
- closeOnClick?: "outside" | "inside",
28
- data?: object,
29
- id?: String,
30
- offset?: boolean,
31
- reference: PopperReference,
32
- show?: boolean,
33
- shouldClosePopover?: () => boolean,
34
- } & PopperProps;
35
-
36
- // Prop enabled default modifiers here
37
- // https://popper.js.org/docs/v2/modifiers
38
-
39
- const POPOVER_MODIFIERS = {
40
- offset: {
41
- //https://popper.js.org/docs/v2/modifiers/offset/
42
- enabled: true,
43
- name: "offset",
44
- options: {
45
- offset: [0, 20],
46
- },
47
- phase: "main",
48
- },
49
- };
50
-
51
- const popoverModifiers = ({ modifiers, offset }) => {
52
- return offset ? modifiers.concat([POPOVER_MODIFIERS.offset]) : modifiers;
53
- };
54
-
55
- const Popover = (props: PbPopoverProps) => {
56
- const {
57
- aria = {},
58
- className,
59
- children,
60
- data = {},
61
- id,
62
- modifiers,
63
- offset,
64
- placement,
65
- referenceElement,
66
- zIndex,
67
- maxHeight,
68
- maxWidth,
69
- minHeight,
70
- minWidth,
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 } : {};
79
- const widthHeightStyles = () => {
80
- return Object.assign(
81
- {},
82
- maxHeight ? { maxHeight: maxHeight } : {},
83
- maxWidth ? { maxWidth: maxWidth } : {},
84
- minHeight ? { minHeight: minHeight } : {},
85
- minWidth ? { minWidth: minWidth } : {}
86
- );
87
- };
88
- const ariaProps = buildAriaProps(aria);
89
- const dataProps = buildDataProps(data);
90
- const classes = classnames(
91
- buildCss("pb_popover_kit"),
92
- globalProps(props),
93
- className
94
- );
95
-
96
- return (
97
- <Popper
98
- modifiers={popoverModifiers({ modifiers, offset })}
99
- placement={placement}
100
- referenceElement={referenceElement}
101
- >
102
- {({ placement, ref, style }) => {
103
- return (
104
- <div
105
- {...ariaProps}
106
- {...dataProps}
107
- className={classes}
108
- data-placement={placement}
109
- id={id}
110
- ref={ref}
111
- style={Object.assign({}, style, zIndexStyle)}
112
- >
113
- <div
114
- className={classnames(`${buildCss("pb_popover_tooltip")} show`)}
115
- >
116
- <div
117
- className={classnames(
118
- "pb_popover_body",
119
- popoverSpacing,
120
- overflowHandling
121
- )}
122
- style={widthHeightStyles()}
123
- >
124
- {children}
125
- </div>
126
- </div>
127
- </div>
128
- );
129
- }}
130
- </Popper>
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
155
-
156
- if (!closeOnClick) return
157
-
158
- document.body.addEventListener('click', ({ target }) => {
159
- const targetIsPopover =
160
- target.closest('[class^=pb_popover_tooltip]') !== null
161
- const targetIsReference =
162
- target.closest('.pb_popover_reference_wrapper') !== null
163
-
164
- switch (closeOnClick) {
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':
176
- shouldClosePopover(true)
177
- break
178
- }
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}
221
- </If>
222
- </If>
223
- </PopperManager>
224
- );
225
- };
226
-
227
- export default PbReactPopover;
@@ -1,68 +0,0 @@
1
- @import "../tokens/colors";
2
- @import "../tokens/typography";
3
- @import "../tokens/border_radius";
4
- @import "../tokens/shadows";
5
-
6
- .pb_pagination {
7
- display: inline-block;
8
- border-radius: $border_rad_light;
9
- border: 1px solid $border_light;
10
- background-color: $white;
11
- padding: 3px 0px 3.6px 0px;
12
- li {
13
- display: inline;
14
- > a, li > span {
15
- padding: 7px 13px;
16
- text-decoration: none;
17
- margin-left: -1px;
18
- border: 0 !important;
19
- }}
20
- li:first-child > a, li:first-child > span {
21
- padding: 7px 13px;
22
- margin-left: .5px;
23
- border-right: 1px solid $border_light !important;
24
- z-index: 2;
25
- }
26
- li:last-child > a, li:last-child > span {
27
- padding: 7px 13px;
28
- margin-right: .5px;
29
- border-left: 1px solid $border_light !important;
30
- z-index: 2;
31
- }
32
- a {
33
- color: $text_lt_default !important;
34
- font-size: $text_small;
35
- font-weight: $regular;
36
- border: none;
37
-
38
- &:hover {
39
- background-color: $active_light;
40
- color: $primary !important;
41
- border-radius: $border_rad_light;
42
- }
43
-
44
- &:focus {
45
- outline: 1px solid $primary !important;
46
- border-radius: $border_rad_light;
47
- outline-offset: -1px;
48
- }
49
- }
50
- .active > span {
51
- background-color: $primary !important;
52
- border-radius: $border_rad_light;
53
- color: #fff;
54
- padding: 7px 10px;
55
- border: 0 !important;
56
- text-decoration: none;
57
- font-weight: $bold;
58
- font-size: $text_small;
59
-
60
- &:hover {
61
- box-shadow: $shadow_deeper;
62
- }
63
- }
64
- .disabled > span {
65
- padding: 7px 10px;
66
- font-size: $text_small;
67
- }
68
- }
@@ -1,41 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- require "will_paginate/view_helpers/action_view"
4
-
5
- module Playbook
6
- module Pagination
7
- class Rails < WillPaginate::ActionView::LinkRenderer
8
- def container_attributes
9
- { class: "pb_pagination" }
10
- end
11
-
12
- def page_number(page)
13
- if page == current_page
14
- tag("li", tag("span", page), class: "active")
15
- else
16
- tag("li", link(page, page, rel: rel_value(page)))
17
- end
18
- end
19
-
20
- def previous_or_next_page(page, text, classname)
21
- if page
22
- tag("li", link(text, page), class: classname)
23
- else
24
- tag("li", tag("span", text), class: "%s disabled")
25
- end
26
- end
27
-
28
- def gap; end
29
-
30
- def previous_page
31
- num = @collection.current_page > 1 && @collection.current_page - 1
32
- previous_or_next_page(num, "<i class='far fa-chevron-left fa-xs'></i>", "prev")
33
- end
34
-
35
- def next_page
36
- num = @collection.current_page < @collection.total_pages && @collection.current_page + 1
37
- previous_or_next_page(num, "<i class='far fa-chevron-right fa-xs'></i>", "next")
38
- end
39
- end
40
- end
41
- end