playbook_ui 14.4.0.pre.alpha.PLAY1547reactzoompanpinchlightbox3613893 → 14.4.0.pre.alpha.PLAY1562highchartsbump3819
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/app/pb_kits/playbook/pb_advanced_table/Components/SortIconButton.tsx +4 -23
- data/app/pb_kits/playbook/pb_contact/_contact.tsx +5 -17
- data/app/pb_kits/playbook/pb_contact/contact.html.erb +6 -14
- data/app/pb_kits/playbook/pb_contact/contact.rb +0 -4
- data/app/pb_kits/playbook/pb_contact/contact.test.js +1 -1
- data/app/pb_kits/playbook/pb_date_picker/_date_picker.tsx +3 -4
- data/app/pb_kits/playbook/pb_date_picker/date_picker.html.erb +1 -1
- data/app/pb_kits/playbook/pb_date_picker/date_picker.rb +0 -4
- data/app/pb_kits/playbook/pb_date_picker/date_picker_helper.ts +3 -6
- data/app/pb_kits/playbook/pb_date_picker/docs/_date_picker_inline.html.erb +1 -1
- data/app/pb_kits/playbook/pb_date_picker/sass_partials/_header_styles.scss +2 -6
- data/app/pb_kits/playbook/pb_dialog/_dialog.scss +0 -2
- data/app/pb_kits/playbook/pb_dialog/dialog_header.html.erb +1 -1
- data/app/pb_kits/playbook/pb_map/_map_controls.tsx +1 -7
- data/app/pb_kits/playbook/pb_multi_level_select/_multi_level_select.tsx +4 -15
- data/app/pb_kits/playbook/pb_pagination/docs/_pagination_page_change.jsx +1 -12
- data/app/pb_kits/playbook/pb_pagination/docs/_pagination_page_change_react.md +1 -3
- data/app/pb_kits/playbook/pb_passphrase/_passphrase.tsx +2 -10
- data/app/pb_kits/playbook/pb_radio/_radio.tsx +33 -92
- data/app/pb_kits/playbook/pb_radio/docs/example.yml +0 -1
- data/app/pb_kits/playbook/pb_radio/docs/index.js +0 -1
- data/app/pb_kits/playbook/pb_rich_text_editor/TipTap/ToolbarDropdown.tsx +5 -12
- data/app/pb_kits/playbook/pb_select/_select.tsx +2 -5
- data/app/pb_kits/playbook/pb_select/select.html.erb +1 -1
- data/app/pb_kits/playbook/pb_select/select.rb +0 -4
- data/app/pb_kits/playbook/pb_text_input/_text_input.scss +1 -0
- data/app/pb_kits/playbook/pb_typeahead/_typeahead.scss +1 -0
- data/app/pb_kits/playbook/pb_typeahead/_typeahead.test.jsx +0 -14
- data/app/pb_kits/playbook/pb_typeahead/_typeahead.tsx +0 -3
- data/app/pb_kits/playbook/pb_typeahead/components/Control.tsx +5 -6
- data/app/pb_kits/playbook/pb_typeahead/docs/example.yml +0 -2
- data/app/pb_kits/playbook/pb_typeahead/docs/index.js +0 -1
- data/app/pb_kits/playbook/pb_typeahead/typeahead.html.erb +1 -2
- data/app/pb_kits/playbook/pb_typeahead/typeahead.rb +1 -6
- data/app/pb_kits/playbook/utilities/icons/allicons.tsx +0 -123
- data/dist/chunks/_typeahead-D7A7UtDj.js +22 -0
- data/dist/chunks/_weekday_stacked-cRBjVQjA.js +45 -0
- data/dist/chunks/lib-D2U4I1U6.js +16 -0
- data/dist/chunks/{pb_form_validation-D9zkwt2b.js → pb_form_validation-zV9OpdSt.js} +1 -1
- data/dist/chunks/vendor.js +1 -1
- data/dist/playbook-doc.js +1 -1
- data/dist/playbook-rails-react-bindings.js +1 -1
- data/dist/playbook-rails.js +1 -1
- data/dist/playbook.css +1 -1
- data/lib/playbook/version.rb +1 -1
- metadata +6 -11
- data/app/pb_kits/playbook/pb_radio/docs/_radio_custom_children.jsx +0 -59
- data/app/pb_kits/playbook/pb_typeahead/docs/_typeahead_margin_bottom.html.erb +0 -88
- data/app/pb_kits/playbook/pb_typeahead/docs/_typeahead_margin_bottom.jsx +0 -60
- data/app/pb_kits/playbook/utilities/icons/angle-down.svg +0 -3
- data/app/pb_kits/playbook/utilities/icons/envelope.svg +0 -3
- data/dist/chunks/_typeahead-C7ICra83.js +0 -22
- data/dist/chunks/_weekday_stacked-BNuGWnXO.js +0 -45
- data/dist/chunks/lib-CEpcaI8y.js +0 -29
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 97228845b448a163135025419bb6c223b4c4b0f37f4aad4cf239f9d3bf21639a
|
4
|
+
data.tar.gz: cbb30004b258be8f9bf2cc04e0f4d594bc90f94d89aeb97b57e8927c590d4daf
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: a95c812b64ce4a792bbb8f5b433cef7cb74b20b4224ae8e81ba83d6379c60f839f2c089afc077f9ca189a2ba9e074a9e5943318cd6e54c66df71080fe401294d
|
7
|
+
data.tar.gz: 10edc2d87a52fab3c7de13169df6606146410f83fd47e3bc2c0497856166dd9283444b44c5119e4978c2c30dbaf2884375a16f7122f336f623733da1c6a6b243
|
@@ -4,7 +4,6 @@ import { Header } from "@tanstack/react-table"
|
|
4
4
|
import { GenericObject } from "../../types"
|
5
5
|
|
6
6
|
import Icon from "../../pb_icon/_icon"
|
7
|
-
import { getAllIcons } from "../../utilities/icons/allicons"
|
8
7
|
|
9
8
|
import { displayIcon } from "../Utilities/IconHelpers"
|
10
9
|
|
@@ -12,39 +11,21 @@ type SortIconButtonProps = {
|
|
12
11
|
header: Header<GenericObject, unknown>
|
13
12
|
sortIcon?: string | string[]
|
14
13
|
}
|
15
|
-
|
16
14
|
export const SortIconButton = ({ header, sortIcon }: SortIconButtonProps) => {
|
17
15
|
|
18
|
-
const firstIcon = displayIcon(sortIcon)[0]
|
19
|
-
const secondIcon = displayIcon(sortIcon)[1]
|
20
|
-
const upIcon = getAllIcons()["arrowUpShortWide"].icon as unknown as { [key: string]: SVGElement }
|
21
|
-
const downIcon = getAllIcons()["arrowDownShortWide"].icon as unknown as { [key: string]: SVGElement }
|
22
|
-
|
23
16
|
return (
|
24
17
|
<>
|
25
18
|
{header.column.getIsSorted() === "desc" ? (
|
26
19
|
<div className="sort-button-icon"
|
27
|
-
key={
|
20
|
+
key={displayIcon(sortIcon)[0]}
|
28
21
|
>
|
29
|
-
|
30
|
-
<Icon
|
31
|
-
className="svg-inline--fa"
|
32
|
-
customIcon={upIcon}
|
33
|
-
/> ) : (
|
34
|
-
<Icon icon={firstIcon} />
|
35
|
-
)}
|
22
|
+
<Icon icon={displayIcon(sortIcon)[0]} />
|
36
23
|
</div>
|
37
24
|
) : (
|
38
25
|
<div className="sort-button-icon"
|
39
|
-
key={
|
26
|
+
key={displayIcon(sortIcon)[1]}
|
40
27
|
>
|
41
|
-
|
42
|
-
<Icon
|
43
|
-
className="svg-inline--fa"
|
44
|
-
customIcon={downIcon}
|
45
|
-
/> ) : (
|
46
|
-
<Icon icon={secondIcon} />
|
47
|
-
)}
|
28
|
+
<Icon icon={displayIcon(sortIcon)[1]} />
|
48
29
|
</div>
|
49
30
|
)}
|
50
31
|
</>
|
@@ -7,7 +7,6 @@ import { globalProps } from '../utilities/globalProps'
|
|
7
7
|
import Body from '../pb_body/_body'
|
8
8
|
import Caption from '../pb_caption/_caption'
|
9
9
|
import Icon from '../pb_icon/_icon'
|
10
|
-
import { getAllIcons } from "../utilities/icons/allicons"
|
11
10
|
|
12
11
|
const contactTypeMap: { [key: string]: string } = {
|
13
12
|
'cell': 'mobile',
|
@@ -19,8 +18,6 @@ const contactTypeMap: { [key: string]: string } = {
|
|
19
18
|
'wrong-phone': 'phone-slash',
|
20
19
|
}
|
21
20
|
|
22
|
-
const envelopeIcon = getAllIcons()["envelope"].icon as unknown as { [key: string]: SVGElement }
|
23
|
-
|
24
21
|
const formatContact = (contactString: string, contactType: string) => {
|
25
22
|
if (contactType === 'email') return contactString
|
26
23
|
|
@@ -94,20 +91,11 @@ const Contact = (props: ContactProps): React.ReactElement => {
|
|
94
91
|
dark={dark}
|
95
92
|
tag="span"
|
96
93
|
>
|
97
|
-
|
98
|
-
|
99
|
-
|
100
|
-
|
101
|
-
|
102
|
-
fixedWidth
|
103
|
-
/>
|
104
|
-
) : (
|
105
|
-
<Icon
|
106
|
-
dark={dark}
|
107
|
-
fixedWidth
|
108
|
-
icon={contactTypeMap[contactType] || 'phone'}
|
109
|
-
/>
|
110
|
-
)}
|
94
|
+
<Icon
|
95
|
+
dark={dark}
|
96
|
+
fixedWidth
|
97
|
+
icon={contactTypeMap[contactType] || 'phone'}
|
98
|
+
/>
|
111
99
|
{` ${formatContact(contactValue, contactType)} `}
|
112
100
|
{contactDetail && (
|
113
101
|
<Caption
|
@@ -4,20 +4,12 @@
|
|
4
4
|
classname: "pb_contact_kit",
|
5
5
|
color: "light",
|
6
6
|
dark: object.dark
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
}) %>
|
14
|
-
<% else %>
|
15
|
-
<%= pb_rails("icon", props: {
|
16
|
-
icon: object.contact_icon,
|
17
|
-
fixed_width: true,
|
18
|
-
dark: object.dark
|
19
|
-
}) %>
|
20
|
-
<% end %>
|
7
|
+
}) do %>
|
8
|
+
<%= pb_rails("icon", props: {
|
9
|
+
icon: object.contact_icon,
|
10
|
+
fixed_width: true,
|
11
|
+
dark: object.dark
|
12
|
+
}) %>
|
21
13
|
<%= object.formatted_contact_value if object.contact_value %>
|
22
14
|
|
23
15
|
<%= pb_rails("caption", props: {
|
@@ -79,7 +79,7 @@ test('returns correct icon', () => {
|
|
79
79
|
expect(screen.getByTestId('test-home').querySelector('.pb_icon_kit')).toHaveClass('fa-phone')
|
80
80
|
expect(screen.getByTestId('test-work').querySelector('.pb_icon_kit')).toHaveClass('fa-phone-office')
|
81
81
|
expect(screen.getByTestId('test-work-cell').querySelector('.pb_icon_kit')).toHaveClass('fa-phone-laptop')
|
82
|
-
expect(screen.getByTestId('test-email').querySelector('.
|
82
|
+
expect(screen.getByTestId('test-email').querySelector('.pb_icon_kit')).toHaveClass('fa-envelope')
|
83
83
|
expect(screen.getByTestId('test-wrong-phone').querySelector('.pb_icon_kit')).toHaveClass('fa-phone-slash')
|
84
84
|
expect(screen.getByTestId('test-wrong-type').querySelector('.pb_icon_kit')).toHaveClass('fa-phone')
|
85
85
|
expect(screen.getByTestId('test-extension').querySelector('.pb_icon_kit')).toHaveClass('fa-phone-plus')
|
@@ -3,7 +3,6 @@ import classnames from 'classnames'
|
|
3
3
|
|
4
4
|
import { buildAriaProps, buildCss, buildDataProps, buildHtmlProps } from '../utilities/props'
|
5
5
|
import { deprecatedProps, globalProps, GlobalProps } from '../utilities/globalProps'
|
6
|
-
import { getAllIcons } from "../utilities/icons/allicons"
|
7
6
|
|
8
7
|
import datePickerHelper from './date_picker_helper'
|
9
8
|
import Icon from '../pb_icon/_icon'
|
@@ -162,7 +161,7 @@ useEffect(() => {
|
|
162
161
|
}
|
163
162
|
return base
|
164
163
|
}
|
165
|
-
|
164
|
+
|
166
165
|
|
167
166
|
return (
|
168
167
|
<div
|
@@ -232,8 +231,8 @@ useEffect(() => {
|
|
232
231
|
id={`${pickerId}-angle-down`}
|
233
232
|
>
|
234
233
|
<Icon
|
235
|
-
className="angle_down_icon
|
236
|
-
|
234
|
+
className="angle_down_icon"
|
235
|
+
icon="angle-down"
|
237
236
|
/>
|
238
237
|
</div>
|
239
238
|
</div>
|
@@ -5,9 +5,6 @@ import monthSelectPlugin from 'flatpickr/dist/plugins/monthSelect'
|
|
5
5
|
import weekSelect from "flatpickr/dist/plugins/weekSelect/weekSelect"
|
6
6
|
import timeSelectPlugin from './plugins/timeSelect'
|
7
7
|
import quickPickPlugin from './plugins/quickPick'
|
8
|
-
import { getAllIcons } from '../utilities/icons/allicons';
|
9
|
-
|
10
|
-
const angleDown = getAllIcons().angleDown.string
|
11
8
|
|
12
9
|
const getPositionElement = (element: string | Element) => {
|
13
10
|
return (typeof element === 'string') ? document.querySelectorAll(element)[0] : element
|
@@ -259,10 +256,10 @@ const datePickerHelper = (config: DatePickerConfig, scrollContainer: string | HT
|
|
259
256
|
})
|
260
257
|
}
|
261
258
|
|
262
|
-
// Adding dropdown icons to year and month
|
263
|
-
dropdown.insertAdjacentHTML('afterend',
|
259
|
+
// Adding dropdown icons to year and month selects
|
260
|
+
dropdown.insertAdjacentHTML('afterend', '<i class="far fa-angle-down year-dropdown-icon" id="test-id"></i>')
|
264
261
|
if (picker.monthElements[0].parentElement) {
|
265
|
-
return picker.monthElements[0].insertAdjacentHTML('afterend',
|
262
|
+
return picker.monthElements[0].insertAdjacentHTML('afterend', '<i class="far fa-angle-down month-dropdown-icon"></i>')}
|
266
263
|
// if (picker.weekElements[0].parentElement){
|
267
264
|
// return picker.weekElements[0].insertAdjacentHTML('afterend', '<i class="far fa-angle-down year-dropdown-icon" id="test-id"></i>')
|
268
265
|
// }
|
@@ -76,11 +76,7 @@
|
|
76
76
|
pointer-events: none;
|
77
77
|
color: $text_lt_light;
|
78
78
|
}
|
79
|
-
|
80
|
-
width: 16px;
|
81
|
-
margin-top: 6px;
|
82
|
-
margin-left: -2px;
|
83
|
-
}
|
79
|
+
|
84
80
|
// Left - Right Arrow Styling
|
85
81
|
.flatpickr-prev-month {
|
86
82
|
display: flex;
|
@@ -117,4 +113,4 @@
|
|
117
113
|
}
|
118
114
|
}
|
119
115
|
}
|
120
|
-
}
|
116
|
+
}
|
@@ -2,7 +2,7 @@
|
|
2
2
|
<%= pb_rails("flex", props: {classname:object.classname, spacing:"between", padding:"sm", align:"center"}) do %>
|
3
3
|
<%= content.presence || object.title %>
|
4
4
|
|
5
|
-
<button class="dialog-button-class
|
5
|
+
<button class="dialog-button-class" type="button" data-close-dialog= <%= object.id %> >
|
6
6
|
<%= pb_rails("icon", props: { custom_icon: Playbook::Engine::root.join(times_icon) }) %>
|
7
7
|
</button>
|
8
8
|
<% end %>
|
@@ -2,7 +2,6 @@ import React from "react";
|
|
2
2
|
import Button from "../pb_button/_button";
|
3
3
|
import Icon from "../pb_icon/_icon";
|
4
4
|
import Flex from "../pb_flex/_flex";
|
5
|
-
import { getAllIcons } from "../utilities/icons/allicons"
|
6
5
|
|
7
6
|
type MapControlTypes = {
|
8
7
|
zoomBtns?: boolean,
|
@@ -13,8 +12,6 @@ type MapControlTypes = {
|
|
13
12
|
children?: React.ReactNode | React.ReactNode[]
|
14
13
|
}
|
15
14
|
|
16
|
-
const eyeIcon = getAllIcons()["eye"]
|
17
|
-
|
18
15
|
const MapControls = ({
|
19
16
|
zoomBtns,
|
20
17
|
zoomInClick,
|
@@ -45,10 +42,7 @@ const MapControls = ({
|
|
45
42
|
<Button className="map-flyto-button"
|
46
43
|
onClick={flyToClick}
|
47
44
|
>
|
48
|
-
<Icon
|
49
|
-
className="svg-inline--fa"
|
50
|
-
customIcon={eyeIcon.icon as unknown as { [key: string]: SVGElement }}
|
51
|
-
/>
|
45
|
+
<Icon icon="eye" />
|
52
46
|
</Button>
|
53
47
|
) : null}
|
54
48
|
</>
|
@@ -88,9 +88,6 @@ const MultiLevelSelect = (props: MultiLevelSelectProps) => {
|
|
88
88
|
item: []
|
89
89
|
})
|
90
90
|
|
91
|
-
const arrowDownElementId = `arrow_down_${id}`
|
92
|
-
const arrowUpElementId = `arrow_up_${id}`
|
93
|
-
|
94
91
|
const modifyRecursive = (tree: { [key: string]: any }[], check: boolean) => {
|
95
92
|
if (!Array.isArray(tree)) {
|
96
93
|
return
|
@@ -176,12 +173,7 @@ const MultiLevelSelect = (props: MultiLevelSelectProps) => {
|
|
176
173
|
useEffect(() => {
|
177
174
|
// Function to handle clicks outside the dropdown
|
178
175
|
const handleClickOutside = (event: any) => {
|
179
|
-
if (
|
180
|
-
dropdownRef.current &&
|
181
|
-
!dropdownRef.current.contains(event.target) &&
|
182
|
-
event.target.id !== arrowDownElementId &&
|
183
|
-
event.target.id !== arrowUpElementId
|
184
|
-
) {
|
176
|
+
if (dropdownRef.current && !dropdownRef.current.contains(event.target)) {
|
185
177
|
setIsDropdownClosed(true)
|
186
178
|
}
|
187
179
|
}
|
@@ -268,6 +260,7 @@ const MultiLevelSelect = (props: MultiLevelSelectProps) => {
|
|
268
260
|
|
269
261
|
// Handle click on input wrapper(entire div with pills, typeahead, etc) so it doesn't close when input or form pill is clicked
|
270
262
|
const handleInputWrapperClick = (e: any) => {
|
263
|
+
e.stopPropagation()
|
271
264
|
if (
|
272
265
|
e.target.id === "multiselect_input" ||
|
273
266
|
e.target.classList.contains("pb_form_pill_tag")
|
@@ -525,20 +518,16 @@ const MultiLevelSelect = (props: MultiLevelSelectProps) => {
|
|
525
518
|
</div>
|
526
519
|
|
527
520
|
{isDropdownClosed ? (
|
528
|
-
<div
|
529
|
-
key="chevron-down">
|
521
|
+
<div key="chevron-down">
|
530
522
|
<Icon
|
531
523
|
icon="chevron-down"
|
532
|
-
id={arrowDownElementId}
|
533
524
|
size="xs"
|
534
525
|
/>
|
535
526
|
</div>
|
536
527
|
) : (
|
537
|
-
<div
|
538
|
-
key="chevron-up">
|
528
|
+
<div key="chevron-up">
|
539
529
|
<Icon
|
540
530
|
icon="chevron-up"
|
541
|
-
id={arrowUpElementId}
|
542
531
|
size="xs"
|
543
532
|
/>
|
544
533
|
</div>
|
@@ -22,16 +22,6 @@ const PaginationPageChange = (props) => {
|
|
22
22
|
|
23
23
|
return (
|
24
24
|
<div className="App">
|
25
|
-
<Pagination
|
26
|
-
current={activePage}
|
27
|
-
key={`pagination-top-${activePage}`}
|
28
|
-
marginBottom="xs"
|
29
|
-
onChange={onPageChange}
|
30
|
-
range={5}
|
31
|
-
total={totalPages}
|
32
|
-
{...props}
|
33
|
-
/>
|
34
|
-
|
35
25
|
<Table
|
36
26
|
marginBottom="xs"
|
37
27
|
responsive="none"
|
@@ -59,8 +49,7 @@ const PaginationPageChange = (props) => {
|
|
59
49
|
</Table>
|
60
50
|
|
61
51
|
<Pagination
|
62
|
-
current={
|
63
|
-
key={`pagination-bottom-${activePage}`}
|
52
|
+
current={1}
|
64
53
|
onChange={onPageChange}
|
65
54
|
range={5}
|
66
55
|
total={totalPages}
|
@@ -1,3 +1 @@
|
|
1
|
-
You can use the `onChange` prop to control the data of your table. This prop is callback function that will allow you control the state.
|
2
|
-
|
3
|
-
To ensure synchronization between multiple pagination components on a single page, use unique, dynamic keys for each pagination instance. Each Pagination component should have its own dynamic key that reflects the current active page: this example uses `pagination-top-${activePage}` and `pagination-bottom-${activePage}`.
|
1
|
+
You can use the `onChange` prop to control the data of your table. This prop is callback function that will allow you control the state.
|
@@ -12,7 +12,6 @@ import Icon from '../pb_icon/_icon'
|
|
12
12
|
import PbReactPopover from '../pb_popover/_popover'
|
13
13
|
import TextInput from '../pb_text_input/_text_input'
|
14
14
|
import { GenericObject } from "../types"
|
15
|
-
import { getAllIcons } from "../utilities/icons/allicons"
|
16
15
|
|
17
16
|
type PassphraseProps = {
|
18
17
|
aria?: { [key: string]: string },
|
@@ -97,9 +96,6 @@ const Passphrase = (props: PassphraseProps): React.ReactElement => {
|
|
97
96
|
/>
|
98
97
|
)
|
99
98
|
|
100
|
-
const shieldIcon = getAllIcons()["shieldCheck"]
|
101
|
-
const eyeIcon = getAllIcons()["eye"]
|
102
|
-
|
103
99
|
return (
|
104
100
|
<div
|
105
101
|
{...ariaProps}
|
@@ -139,8 +135,7 @@ const Passphrase = (props: PassphraseProps): React.ReactElement => {
|
|
139
135
|
size="xs"
|
140
136
|
>
|
141
137
|
<Icon
|
142
|
-
|
143
|
-
customIcon={shieldIcon.icon as unknown as { [key: string]: SVGElement }}
|
138
|
+
icon="shield-check"
|
144
139
|
marginRight="xs"
|
145
140
|
/>
|
146
141
|
{tip}
|
@@ -178,10 +173,7 @@ const Passphrase = (props: PassphraseProps): React.ReactElement => {
|
|
178
173
|
color="light"
|
179
174
|
dark={dark}
|
180
175
|
>
|
181
|
-
|
182
|
-
className="svg-inline--fa"
|
183
|
-
customIcon={eyeIcon.icon as unknown as { [key: string]: SVGElement }}
|
184
|
-
/>
|
176
|
+
<Icon icon="eye" />
|
185
177
|
</Body>
|
186
178
|
</span>
|
187
179
|
</div>
|
@@ -1,30 +1,28 @@
|
|
1
|
-
/*eslint-disable react/no-multi-comp */
|
1
|
+
/*eslint-disable react/no-multi-comp, flowtype/space-before-type-colon */
|
2
2
|
|
3
|
-
import React, { forwardRef
|
3
|
+
import React, { forwardRef } from 'react'
|
4
4
|
import Body from '../pb_body/_body'
|
5
|
-
import Flex from '../pb_flex/_flex'
|
6
5
|
import classnames from 'classnames'
|
7
6
|
import { buildAriaProps, buildCss, buildDataProps, buildHtmlProps } from '../utilities/props'
|
8
7
|
import { globalProps, GlobalProps } from '../utilities/globalProps'
|
9
8
|
|
10
9
|
type RadioProps = {
|
11
|
-
aria?: {
|
10
|
+
aria?: {[key: string]: string},
|
12
11
|
alignment?: string,
|
13
12
|
checked?: boolean,
|
14
13
|
children?: React.ReactChild[] | React.ReactChild,
|
15
|
-
customChildren?: boolean,
|
16
14
|
className?: string,
|
17
15
|
dark?: boolean,
|
18
|
-
data?: {
|
16
|
+
data?: {[key: string]: string},
|
19
17
|
disabled?: boolean,
|
20
18
|
error?: boolean,
|
21
|
-
htmlOptions?: {
|
19
|
+
htmlOptions?: {[key: string]: string | number | boolean | (() => void)},
|
22
20
|
id?: string,
|
23
21
|
label: string,
|
24
22
|
name?: string,
|
25
23
|
value?: string,
|
26
24
|
text?: string,
|
27
|
-
onChange: (event: React.FormEvent<HTMLInputElement> | null)
|
25
|
+
onChange: (event: React.FormEvent<HTMLInputElement> | null)=>void,
|
28
26
|
} & GlobalProps
|
29
27
|
|
30
28
|
const Radio = ({
|
@@ -32,11 +30,10 @@ const Radio = ({
|
|
32
30
|
alignment,
|
33
31
|
children,
|
34
32
|
className,
|
35
|
-
customChildren = false,
|
36
33
|
dark = false,
|
34
|
+
data = {},
|
37
35
|
disabled = false,
|
38
36
|
error = false,
|
39
|
-
data = {},
|
40
37
|
htmlOptions = {},
|
41
38
|
id,
|
42
39
|
label,
|
@@ -46,28 +43,17 @@ const Radio = ({
|
|
46
43
|
onChange = () => { void 0 },
|
47
44
|
...props
|
48
45
|
}: RadioProps, ref: any) => {
|
49
|
-
const
|
50
|
-
|
51
|
-
const
|
52
|
-
const dataProps = buildDataProps(data);
|
53
|
-
const htmlProps = buildHtmlProps(htmlOptions);
|
46
|
+
const ariaProps = buildAriaProps(aria)
|
47
|
+
const dataProps = buildDataProps(data)
|
48
|
+
const htmlProps = buildHtmlProps(htmlOptions)
|
54
49
|
const classes = classnames(
|
55
|
-
buildCss('pb_radio_kit', alignment),
|
56
|
-
dark ? 'dark' : null,
|
57
|
-
error ? 'error' : null,
|
50
|
+
buildCss('pb_radio_kit', alignment ),
|
51
|
+
dark ? 'dark': null, error ? 'error': null,
|
58
52
|
globalProps(props),
|
59
|
-
className
|
60
|
-
);
|
61
|
-
|
62
|
-
const classesCustom = classnames(
|
63
|
-
dark ? 'dark' : null,
|
64
|
-
error ? 'error' : null,
|
65
|
-
globalProps(props),
|
66
|
-
className
|
67
|
-
);
|
53
|
+
className)
|
68
54
|
|
69
55
|
const displayRadio = (props: RadioProps & any) => {
|
70
|
-
if (children
|
56
|
+
if (children)
|
71
57
|
return (children)
|
72
58
|
else
|
73
59
|
return (
|
@@ -84,69 +70,24 @@ const Radio = ({
|
|
84
70
|
/>
|
85
71
|
)}
|
86
72
|
|
87
|
-
const handleContainerClick = (event: React.MouseEvent<HTMLDivElement, MouseEvent> | undefined) => {
|
88
|
-
if (event) {
|
89
|
-
const target = event.target as HTMLElement;
|
90
|
-
if (
|
91
|
-
target.id === 'pb-radio-children-wrapper' ||
|
92
|
-
target.closest('#pb-radio-children-wrapper')
|
93
|
-
) {
|
94
|
-
radioRef.current?.click();
|
95
|
-
}
|
96
|
-
}
|
97
|
-
};
|
98
|
-
|
99
73
|
return (
|
100
|
-
|
101
|
-
|
102
|
-
|
103
|
-
|
104
|
-
|
105
|
-
|
106
|
-
|
107
|
-
|
108
|
-
|
109
|
-
|
110
|
-
|
111
|
-
|
112
|
-
|
113
|
-
|
114
|
-
|
115
|
-
|
116
|
-
|
117
|
-
|
118
|
-
disabled={disabled}
|
119
|
-
id={id}
|
120
|
-
name={name}
|
121
|
-
onChange={onChange}
|
122
|
-
ref={radioRef}
|
123
|
-
type="radio"
|
124
|
-
value={value}
|
125
|
-
{...props}
|
126
|
-
/>
|
127
|
-
<span className="pb_radio_button" />
|
128
|
-
</label>
|
129
|
-
<div id="pb-radio-children-wrapper"> {children} </div>
|
130
|
-
</Flex>
|
131
|
-
) : (
|
132
|
-
<label
|
133
|
-
{...ariaProps}
|
134
|
-
{...dataProps}
|
135
|
-
{...htmlProps}
|
136
|
-
className={classes}
|
137
|
-
htmlFor={id}
|
138
|
-
>
|
139
|
-
<>{displayRadio(props)}</>
|
140
|
-
<span className="pb_radio_button" />
|
141
|
-
<Body
|
142
|
-
dark={dark}
|
143
|
-
status={error ? 'negative' : null}
|
144
|
-
text={label}
|
145
|
-
variant={null}
|
146
|
-
/>
|
147
|
-
</label>
|
148
|
-
)
|
149
|
-
);
|
150
|
-
};
|
74
|
+
<label
|
75
|
+
{...ariaProps}
|
76
|
+
{...dataProps}
|
77
|
+
{...htmlProps}
|
78
|
+
className={classes}
|
79
|
+
htmlFor={id}
|
80
|
+
>
|
81
|
+
<>{displayRadio(props)}</>
|
82
|
+
<span className="pb_radio_button" />
|
83
|
+
<Body
|
84
|
+
dark={dark}
|
85
|
+
status={error ? 'negative' : null}
|
86
|
+
text={label}
|
87
|
+
variant={null}
|
88
|
+
/>
|
89
|
+
</label>
|
90
|
+
)
|
91
|
+
}
|
151
92
|
|
152
|
-
export default forwardRef(Radio)
|
93
|
+
export default forwardRef(Radio)
|
@@ -3,4 +3,3 @@ export { default as RadioCustom } from './_radio_custom.jsx'
|
|
3
3
|
export { default as RadioError } from './_radio_error.jsx'
|
4
4
|
export { default as RadioAlignment } from './_radio_alignment.jsx'
|
5
5
|
export { default as RadioDisabled } from './_radio_disabled.jsx'
|
6
|
-
export { default as RadioCustomChildren } from './_radio_custom_children.jsx'
|