playbook_ui 11.0.0.pre.alpha.2 → 11.0.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (68) hide show
  1. checksums.yaml +4 -4
  2. data/app/pb_kits/playbook/pb_background/_background.scss +8 -1
  3. data/app/pb_kits/playbook/pb_background/_background.tsx +9 -1
  4. data/app/pb_kits/playbook/pb_background/background.rb +76 -16
  5. data/app/pb_kits/playbook/pb_background/docs/_background_status.html.erb +14 -2
  6. data/app/pb_kits/playbook/pb_background/docs/_background_status.jsx +43 -2
  7. data/app/pb_kits/playbook/pb_background/docs/_background_status.md +1 -1
  8. data/app/pb_kits/playbook/pb_badge/_badge.tsx +1 -2
  9. data/app/pb_kits/playbook/pb_body/_body.scss +4 -4
  10. data/app/pb_kits/playbook/pb_body/_body.tsx +5 -4
  11. data/app/pb_kits/playbook/pb_body/_body_mixins.scss +7 -3
  12. data/app/pb_kits/playbook/pb_body/body.rb +4 -3
  13. data/app/pb_kits/playbook/pb_body/body.test.js +12 -9
  14. data/app/pb_kits/playbook/pb_body/docs/_body_light.html.erb +4 -4
  15. data/app/pb_kits/playbook/pb_body/docs/_body_light.jsx +4 -4
  16. data/app/pb_kits/playbook/pb_body/docs/_description.md +2 -2
  17. data/app/pb_kits/playbook/pb_body/docs/_footer.md +1 -1
  18. data/app/pb_kits/playbook/pb_button/button.rb +5 -5
  19. data/app/pb_kits/playbook/pb_caption/_caption.tsx +1 -1
  20. data/app/pb_kits/playbook/pb_caption/_caption_mixin.scss +3 -1
  21. data/app/pb_kits/playbook/pb_caption/docs/_caption_colors.html.erb +2 -1
  22. data/app/pb_kits/playbook/pb_caption/docs/_caption_colors.jsx +5 -0
  23. data/app/pb_kits/playbook/pb_card/_card.tsx +5 -5
  24. data/app/pb_kits/playbook/pb_checkbox/{_checkbox.jsx → _checkbox.tsx} +33 -29
  25. data/app/pb_kits/playbook/pb_date_picker/_date_picker.jsx +30 -18
  26. data/app/pb_kits/playbook/pb_date_picker/_date_picker.scss +3 -0
  27. data/app/pb_kits/playbook/pb_date_picker/date_picker.rb +12 -1
  28. data/app/pb_kits/playbook/pb_date_picker/date_picker.test.js +160 -0
  29. data/app/pb_kits/playbook/pb_date_picker/date_picker_helper.js +37 -11
  30. data/app/pb_kits/playbook/pb_date_picker/docs/_date_picker_default.html.erb +1 -1
  31. data/app/pb_kits/playbook/pb_date_picker/docs/_date_picker_month_and_year.html.erb +2 -2
  32. data/app/pb_kits/playbook/pb_date_picker/docs/_date_picker_month_and_year.jsx +1 -1
  33. data/app/pb_kits/playbook/pb_date_picker/docs/_date_picker_month_and_year.md +1 -1
  34. data/app/pb_kits/playbook/pb_date_picker/docs/_date_picker_time.html.erb +6 -0
  35. data/app/pb_kits/playbook/pb_date_picker/docs/_date_picker_time.jsx +21 -0
  36. data/app/pb_kits/playbook/pb_date_picker/docs/_date_picker_time.md +1 -0
  37. data/app/pb_kits/playbook/pb_date_picker/docs/_date_picker_week.html.erb +5 -0
  38. data/app/pb_kits/playbook/pb_date_picker/docs/_date_picker_week.jsx +18 -0
  39. data/app/pb_kits/playbook/pb_date_picker/docs/_date_picker_week.md +1 -0
  40. data/app/pb_kits/playbook/pb_date_picker/docs/example.yml +4 -0
  41. data/app/pb_kits/playbook/pb_date_picker/docs/index.js +2 -0
  42. data/app/pb_kits/playbook/pb_date_picker/plugins/timeSelect.js +137 -0
  43. data/app/pb_kits/playbook/pb_date_picker/sass_partials/_day_styles.scss +27 -2
  44. data/app/pb_kits/playbook/pb_date_picker/sass_partials/_flatpickr_styles.scss +1 -5
  45. data/app/pb_kits/playbook/pb_date_picker/sass_partials/_time_selection_styles.scss +63 -0
  46. data/app/pb_kits/playbook/pb_date_picker/sass_partials/_week_styles.scss +127 -0
  47. data/app/pb_kits/playbook/pb_dialog/_dialog.jsx +60 -14
  48. data/app/pb_kits/playbook/pb_dialog/docs/_dialog_default.jsx +1 -1
  49. data/app/pb_kits/playbook/pb_dialog/docs/_dialog_stacked_alert.jsx +153 -0
  50. data/app/pb_kits/playbook/pb_dialog/docs/_dialog_stacked_alert.md +1 -0
  51. data/app/pb_kits/playbook/pb_dialog/docs/_dialog_status.jsx +130 -0
  52. data/app/pb_kits/playbook/pb_dialog/docs/_dialog_status.md +1 -0
  53. data/app/pb_kits/playbook/pb_dialog/docs/example.yml +2 -0
  54. data/app/pb_kits/playbook/pb_dialog/docs/index.js +2 -0
  55. data/app/pb_kits/playbook/pb_form_pill/{_form_pill.jsx → _form_pill.tsx} +16 -12
  56. data/app/pb_kits/playbook/pb_form_pill/docs/_form_pill_example.jsx +1 -1
  57. data/app/pb_kits/playbook/pb_form_pill/docs/_form_pill_size.jsx +1 -1
  58. data/app/pb_kits/playbook/pb_form_pill/docs/_form_pill_tag.jsx +1 -1
  59. data/app/pb_kits/playbook/pb_form_pill/docs/_form_pill_user.jsx +1 -1
  60. data/app/pb_kits/playbook/pb_hashtag/{_hashtag.jsx → _hashtag.tsx} +3 -4
  61. data/app/pb_kits/playbook/pb_radio/_radio.tsx +86 -0
  62. data/app/pb_kits/playbook/pb_select/{_select.jsx → _select.tsx} +34 -38
  63. data/app/pb_kits/playbook/pb_text_input/{_text_input.jsx → _text_input.tsx} +42 -43
  64. data/app/pb_kits/playbook/tokens/_colors.scss +17 -1
  65. data/app/pb_kits/playbook/utilities/props.ts +2 -2
  66. data/lib/playbook/version.rb +1 -1
  67. metadata +24 -10
  68. data/app/pb_kits/playbook/pb_radio/_radio.jsx +0 -78
@@ -0,0 +1,153 @@
1
+ /* eslint-disable react/jsx-handler-names */
2
+
3
+ import React, { useState } from "react"
4
+ import { Button, Dialog, Flex, FlexItem, SectionSeparator } from "../.."
5
+
6
+ const useDialog = (visible = false) => {
7
+ const [opened, setOpened] = useState(visible)
8
+ const toggle = () => setOpened(!opened)
9
+ return [opened, toggle]
10
+ }
11
+
12
+ const DialogStackedAlert = () => {
13
+ const [singleButtonOpen, toggleSingleButtonOpen] = useDialog()
14
+ const [stackedButtonOpen, toggleStackedButtonOpen] = useDialog()
15
+ const [singleLinkButtonOpen, toggleSingleLinkButtonOpen] = useDialog()
16
+ const [twoLinkButtonOpen, toggleTwoLinkButtonOpen] = useDialog()
17
+
18
+
19
+ const dialogs = [
20
+ {
21
+ status: "info",
22
+ text: "Text explaining why there is an alert",
23
+ title: "Are you sure?",
24
+ toggle: toggleSingleButtonOpen,
25
+ visible: singleButtonOpen,
26
+ confirmedButton:"Ok, Thanks",
27
+ },
28
+ {
29
+ status: "error",
30
+ text: "Text explaining the error",
31
+ title: "Error Message",
32
+ confirmedButton:"Yes, Action",
33
+ cancelledButton: "Ok, Cancel",
34
+ toggle: toggleStackedButtonOpen,
35
+ visible: stackedButtonOpen,
36
+ },
37
+ {
38
+ status: "caution",
39
+ text: "This is the action you will be taking",
40
+ title: "Are you sure?",
41
+ toggle: toggleSingleLinkButtonOpen,
42
+ visible: singleLinkButtonOpen,
43
+ linkConfirmedButton:"Ok, Thanks!"
44
+ },
45
+ {
46
+ status: "success",
47
+ text: "Text explaining what is successful",
48
+ title: "Success",
49
+ toggle: toggleTwoLinkButtonOpen,
50
+ visible: twoLinkButtonOpen,
51
+ linkConfirmedButton:"Ok",
52
+ linkCancelledButton: "Cancel"
53
+ }
54
+ ]
55
+
56
+ return (
57
+ <div>
58
+ <Flex>
59
+ <Button
60
+ marginX="md"
61
+ onClick={toggleSingleButtonOpen}
62
+ >
63
+ {"1 Button Information Status"}
64
+ </Button>
65
+ <Button
66
+ marginX="md"
67
+ onClick={toggleStackedButtonOpen}
68
+ >
69
+ {"2 Button Error Status"}
70
+ </Button>
71
+ <Button
72
+ marginX="md"
73
+ onClick={toggleSingleLinkButtonOpen}
74
+ >
75
+ {"1 Link Button Caution"}
76
+ </Button>
77
+ <Button
78
+ marginX="md"
79
+ onClick={toggleTwoLinkButtonOpen}
80
+ >
81
+ {"2 Link Button Success"}
82
+ </Button>
83
+ </Flex>
84
+ <Flex>
85
+ {dialogs.map((dialog) => (
86
+ <Dialog
87
+ alertStyle={dialog.alertStyle}
88
+ key={dialog.status}
89
+ onClose={dialog.toggle}
90
+ opened={dialog.visible}
91
+ size="sm"
92
+ status={dialog.status}
93
+ text={dialog.text}
94
+ title={dialog.title}
95
+ >
96
+ <If condition={dialog.cancelledButton || dialog.confirmedButton}>
97
+ <Dialog.Footer>
98
+ <Button
99
+ fullWidth
100
+ onClick={dialog.toggle}
101
+ >
102
+ {dialog.confirmedButton}
103
+ </Button>
104
+ </Dialog.Footer>
105
+ <If condition={dialog.cancelledButton}>
106
+ <Dialog.Footer paddingTop="none">
107
+ <Button
108
+ fullWidth
109
+ onClick={dialog.toggle}
110
+ variant="secondary"
111
+ >
112
+ {dialog.cancelledButton}
113
+ </Button>
114
+ </Dialog.Footer>
115
+ </If>
116
+ </If>
117
+ <If condition={dialog.linkCancelledButton || dialog.linkConfirmedButton} >
118
+ <SectionSeparator />
119
+ <Flex
120
+ inline="flex-container"
121
+ vertical="stretch"
122
+ >
123
+ <FlexItem flex={1} >
124
+ <Button
125
+ fullWidth
126
+ onClick={dialog.toggle}
127
+ variant="link"
128
+ >
129
+ {dialog.linkConfirmedButton}
130
+ </Button>
131
+ </FlexItem>
132
+ <If condition={dialog.linkCancelledButton}>
133
+ <SectionSeparator orientation="vertical"/>
134
+ <FlexItem flex={1}>
135
+ <Button
136
+ fullWidth
137
+ onClick={dialog.toggle}
138
+ variant="link"
139
+ >
140
+ {dialog.linkCancelledButton}
141
+ </Button>
142
+ </FlexItem>
143
+ </If>
144
+ </Flex>
145
+ </If>
146
+ </Dialog>
147
+ ))}
148
+ </Flex>
149
+ </div>
150
+ )
151
+ }
152
+
153
+ export default DialogStackedAlert
@@ -0,0 +1 @@
1
+ This is designed to show you how the buttons can stack with different alert styles. It also has a link style for the buttons for the mobile views.
@@ -0,0 +1,130 @@
1
+ /* eslint-disable react/jsx-handler-names */
2
+ /* @flow */
3
+
4
+ import React, { useState } from "react"
5
+ import { Button, Dialog, Flex } from "../.."
6
+
7
+ const useDialog = (visible = false) => {
8
+ const [opened, setOpened] = useState(visible)
9
+ const toggle = () => setOpened(!opened)
10
+ return [opened, toggle]
11
+
12
+ }
13
+
14
+ const DialogStatus = () => {
15
+ const [infoAlertOpened, toggleInfoAlert] = useDialog()
16
+ const [cautionAlertOpened, toggleCautionAlert] = useDialog()
17
+ const [successAlertOpened, toggleSuccessAlert] = useDialog()
18
+ const [errorAlertOpened, toggleErrorAlert] = useDialog()
19
+ const [deleteAlertOpened, toggleDeleteAlert] = useDialog()
20
+
21
+ const dialogs = [
22
+ {
23
+ status: "info",
24
+ text: "Text explaining why there is an alert",
25
+ title: "Are you Sure?",
26
+ toggle: toggleInfoAlert,
27
+ visible: infoAlertOpened,
28
+ buttonOneText:"No, Cancel",
29
+ buttonTwoText: "Yes, Action"
30
+ },
31
+ {
32
+ status: "caution",
33
+ text: "This is the action you will be taking",
34
+ title: "Are you Sure?",
35
+ toggle: toggleCautionAlert,
36
+ visible: cautionAlertOpened,
37
+ buttonOneText:"No, Cancel",
38
+ buttonTwoText: "Yes, Action"
39
+ },
40
+ {
41
+ status: "delete",
42
+ text: "You are about to delete ...",
43
+ title: "Delete",
44
+ toggle: toggleDeleteAlert,
45
+ visible: deleteAlertOpened,
46
+ buttonOneText:"No, Cancel",
47
+ buttonTwoText: "Yes, Delete"
48
+ },
49
+ {
50
+ status: "error",
51
+ text: "Text explaining the error",
52
+ title: "Error Message",
53
+ toggle: toggleErrorAlert,
54
+ visible: errorAlertOpened,
55
+ buttonOneText:"No, Cancel",
56
+ buttonTwoText: "Ok, Thanks"
57
+ },
58
+ {
59
+ status: "success",
60
+ text: "Text explaining what is successful",
61
+ title: "Success!",
62
+ toggle: toggleSuccessAlert,
63
+ visible: successAlertOpened,
64
+ buttonOneText:"No, Cancel",
65
+ buttonTwoText: "Ok, Thanks"
66
+ },
67
+ ]
68
+
69
+ return (
70
+ <div>
71
+ <Flex>
72
+ <Button
73
+ marginX="md"
74
+ onClick={toggleInfoAlert}
75
+ >
76
+ {"Information Status"}
77
+ </Button>
78
+ <Button
79
+ marginX="md"
80
+ onClick={toggleCautionAlert}
81
+ >
82
+ {"Caution Status"}
83
+ </Button>
84
+ <Button
85
+ marginX="md"
86
+ onClick={toggleSuccessAlert}
87
+ >
88
+ {"Success Status"}
89
+ </Button>
90
+ <Button onClick={toggleErrorAlert}>
91
+ {"Error Status"}
92
+ </Button>
93
+ <Button
94
+ marginX="md"
95
+ onClick={toggleDeleteAlert}
96
+ >
97
+ {"Delete Status"}
98
+ </Button>
99
+ </Flex>
100
+ <Flex>
101
+ {dialogs.map((dialog) => (
102
+ <Dialog
103
+ key={dialog.status}
104
+ onClose={dialog.toggle}
105
+ opened={dialog.visible}
106
+ status={dialog.status}
107
+ text={dialog.text}
108
+ title={dialog.title}
109
+ >
110
+ <Dialog.Footer>
111
+ <Button
112
+ onClick={dialog.toggle}
113
+ variant="secondary"
114
+ >
115
+ {dialog.buttonOneText}
116
+ </Button>
117
+ <Button
118
+ onClick={dialog.toggle}
119
+ >
120
+ {dialog.buttonTwoText}
121
+ </Button>
122
+ </Dialog.Footer>
123
+ </Dialog>
124
+ ))}
125
+ </Flex>
126
+ </div>
127
+ )
128
+ }
129
+
130
+ export default DialogStatus
@@ -0,0 +1 @@
1
+ This shows the different alert statuses that can be used for dialog boxes. These all have two buttons which is a default
@@ -8,3 +8,5 @@ examples:
8
8
  - dialog_sizes: Sizes
9
9
  - dialog_scrollable: Scrollable
10
10
  - dialog_should_close_on_overlay: Overlay Click
11
+ - dialog_status: Status Alert
12
+ - dialog_stacked_alert: Stacked Button Alert
@@ -4,3 +4,5 @@ export { default as DialogSizes } from './_dialog_sizes.jsx'
4
4
  export { default as DialogScrollable } from './_dialog_scrollable.jsx'
5
5
  export { default as DialogSeparators } from './_dialog_separators.jsx'
6
6
  export { default as DialogShouldCloseOnOverlay } from './_dialog_should_close_on_overlay.jsx'
7
+ export { default as DialogStatus } from './_dialog_status.jsx'
8
+ export { default as DialogStackedAlert } from './_dialog_stacked_alert.jsx'
@@ -4,24 +4,24 @@ import classnames from 'classnames'
4
4
  import Title from '../pb_title/_title'
5
5
  import Icon from '../pb_icon/_icon'
6
6
  import Avatar from '../pb_avatar/_avatar'
7
- import { globalProps } from '../utilities/globalProps'
7
+ import { globalProps, GlobalProps } from '../utilities/globalProps'
8
8
 
9
9
  type FormPillProps = {
10
10
  className?: string,
11
11
  id?: string,
12
12
  text: string,
13
13
  name: string,
14
- onClick?: EventHandler,
14
+ onClick?: React.MouseEventHandler<HTMLSpanElement>,
15
15
  avatar?: boolean,
16
16
  avatarUrl?: string,
17
17
  size?: string,
18
- textTransform?: "none" | "lowercase",
18
+ textTransform?: 'none' | 'lowercase',
19
19
  closeProps?: {
20
- onClick?: EventHandler,
21
- onMouseDown?: EventHandler,
22
- onTouchEnd?: EventHandler,
23
- },
24
- }
20
+ onClick?: React.MouseEventHandler<HTMLSpanElement>,
21
+ onMouseDown?: React.MouseEventHandler<HTMLSpanElement>,
22
+ onTouchEnd?: React.TouchEventHandler<HTMLSpanElement>,
23
+ },
24
+ } & GlobalProps
25
25
  const FormPill = (props: FormPillProps) => {
26
26
  const {
27
27
  className,
@@ -42,25 +42,29 @@ const FormPill = (props: FormPillProps) => {
42
42
  )
43
43
  return (
44
44
  <div className={css}>
45
- <If condition={name}>
45
+ {name &&
46
+ <>
46
47
  <Avatar
47
48
  imageUrl={avatarUrl}
48
49
  name={name}
49
50
  size="xs"
51
+ status={null}
50
52
  />
51
53
  <Title
52
54
  className="pb_form_pill_text"
53
55
  size={4}
54
56
  text={name}
55
57
  />
56
- </If>
57
- <If condition={text}>
58
+ </>
59
+ }
60
+
61
+ {text &&
58
62
  <Title
59
63
  className="pb_form_pill_tag"
60
64
  size={4}
61
65
  text={text}
62
66
  />
63
- </If>
67
+ }
64
68
  <div
65
69
  className="pb_form_pill_close"
66
70
  onClick={onClick}
@@ -1,5 +1,5 @@
1
1
  import React from 'react'
2
- import FormPill from '../_form_pill.jsx'
2
+ import FormPill from '../_form_pill'
3
3
 
4
4
  const FormPillExample = (props) => {
5
5
  return (
@@ -1,5 +1,5 @@
1
1
  import React from 'react'
2
- import FormPill from '../_form_pill.jsx'
2
+ import FormPill from '../_form_pill'
3
3
 
4
4
  const FormPillSize = (props) => {
5
5
  return (
@@ -1,5 +1,5 @@
1
1
  import React from 'react'
2
- import FormPill from '../_form_pill.jsx'
2
+ import FormPill from '../_form_pill'
3
3
 
4
4
  const FormPillDefault = (props) => {
5
5
  return (
@@ -1,5 +1,5 @@
1
1
  import React from 'react'
2
- import FormPill from '../_form_pill.jsx'
2
+ import FormPill from '../_form_pill'
3
3
 
4
4
  const FormPillDefault = (props) => {
5
5
  return (
@@ -1,16 +1,15 @@
1
- /* @flow */
2
1
  /* eslint-disable react/no-multi-comp, flowtype/space-before-type-colon */
3
2
 
4
3
  import React from 'react'
5
4
  import classnames from 'classnames'
6
5
 
7
6
  import { buildAriaProps, buildCss, buildDataProps } from '../utilities/props'
8
- import { globalProps } from '../utilities/globalProps'
7
+ import { globalProps, GlobalProps } from '../utilities/globalProps'
9
8
 
10
9
  import Badge from '../pb_badge/_badge'
11
10
 
12
11
  type HashtagProps = {
13
- aria?: object,
12
+ aria?: {[key: string]: string},
14
13
  className?: string,
15
14
  dark?: boolean,
16
15
  data?: string,
@@ -18,7 +17,7 @@ type HashtagProps = {
18
17
  text?: string,
19
18
  type: "default" | "home" | "project" | "appointment",
20
19
  url?: string,
21
- }
20
+ } & GlobalProps
22
21
 
23
22
  const typeMap = {
24
23
  home: 'H#',
@@ -0,0 +1,86 @@
1
+ /*eslint-disable react/no-multi-comp, flowtype/space-before-type-colon */
2
+
3
+ import React, { forwardRef } from 'react'
4
+ import Body from '../pb_body/_body'
5
+ import classnames from 'classnames'
6
+ import { buildAriaProps, buildCss, buildDataProps } from '../utilities/props'
7
+ import { globalProps, GlobalProps } from '../utilities/globalProps'
8
+
9
+ type RadioProps = {
10
+ aria?: {[key: string]: string},
11
+ alignment?: string,
12
+ checked?: boolean,
13
+ children?: Node,
14
+ className?: string,
15
+ dark?: boolean,
16
+ data?: {[key: string]: string},
17
+ error?: boolean,
18
+ id?: string,
19
+ label: string,
20
+ name: string,
21
+ value: string,
22
+ text: string,
23
+ onChange: (event: React.FormEvent<HTMLInputElement>)=>void,
24
+ } & GlobalProps
25
+
26
+ const Radio = ({
27
+ aria = {},
28
+ alignment,
29
+ children,
30
+ className,
31
+ dark = false,
32
+ data = {},
33
+ error = false,
34
+ id,
35
+ label,
36
+ name = 'radio_name',
37
+ text = 'Radio Text',
38
+ value = 'radio_text',
39
+ onChange = () => {},
40
+ ...props
41
+ }: RadioProps, ref: any) => {
42
+ const ariaProps = buildAriaProps(aria)
43
+ const dataProps = buildDataProps(data)
44
+ const classes = classnames(
45
+ buildCss('pb_radio_kit', alignment ),
46
+ dark ? 'dark': null, error ? 'error': null,
47
+ globalProps(props),
48
+ className)
49
+
50
+ const displayRadio = (props: RadioProps) => {
51
+ if (children)
52
+ return (children)
53
+ else
54
+ return (
55
+ <input
56
+ id={id}
57
+ name={name}
58
+ onChange={onChange}
59
+ ref={ref}
60
+ text={text}
61
+ type="radio"
62
+ value={value}
63
+ {...props}
64
+ />
65
+ )}
66
+
67
+ return (
68
+ <label
69
+ {...ariaProps}
70
+ {...dataProps}
71
+ className={classes}
72
+ htmlFor={id}
73
+ >
74
+ <>{displayRadio(null)}</>
75
+ <span className="pb_radio_button" />
76
+ <Body
77
+ dark={dark}
78
+ status={error ? 'negative' : null}
79
+ text={label}
80
+ variant={null}
81
+ />
82
+ </label>
83
+ )
84
+ }
85
+
86
+ export default forwardRef(Radio)
@@ -1,10 +1,8 @@
1
- /* @flow */
2
-
3
1
  import React, { forwardRef } from 'react'
4
2
  import classnames from 'classnames'
5
3
 
6
4
  import { buildAriaProps, buildCss, buildDataProps } from '../utilities/props'
7
- import { globalProps, domSafeProps } from '../utilities/globalProps'
5
+ import { globalProps, GlobalProps, domSafeProps } from '../utilities/globalProps'
8
6
  import type { InputCallback } from '../types'
9
7
 
10
8
  import Body from '../pb_body/_body'
@@ -18,16 +16,14 @@ type SelectOption = {
18
16
  }
19
17
 
20
18
  type SelectProps = {
21
- aria?: object,
19
+ aria?: { [key: string]: string },
22
20
  blankSelection?: string,
23
- children?: React.Node,
24
- compact?: boolean,
21
+ children?: Node,
25
22
  className?: string,
26
- data?: object,
23
+ compact?: boolean,
24
+ data?: { [key: string]: string },
27
25
  disabled?: boolean,
28
26
  error?: string,
29
- onChange: InputCallback<HTMLSelectElement>,
30
- options: SelectOption[],
31
27
  id?: string,
32
28
  includeBlank?: string,
33
29
  inline?: boolean,
@@ -36,9 +32,11 @@ type SelectProps = {
36
32
  marginBottom: string,
37
33
  multiple?: boolean,
38
34
  name?: string,
35
+ onChange: InputCallback<HTMLSelectElement>,
36
+ options: SelectOption[],
39
37
  required?: boolean,
40
38
  value?: string,
41
- }
39
+ } & GlobalProps
42
40
 
43
41
  const createOptions = (options: SelectOption[]) => options.map((option, index) => (
44
42
  <option
@@ -68,7 +66,7 @@ const Select = ({
68
66
  required = false,
69
67
  value,
70
68
  ...props
71
- }: SelectProps, ref: React.ElementRef<"select">) => {
69
+ }: SelectProps, ref: React.LegacyRef<HTMLSelectElement>) => {
72
70
  const ariaProps = buildAriaProps(aria)
73
71
  const dataProps = buildDataProps(data)
74
72
  const optionsList = createOptions(options)
@@ -87,6 +85,25 @@ const Select = ({
87
85
  )
88
86
 
89
87
  const selectWrapperClass = classnames(buildCss('pb_select_kit_wrapper'), { error }, className)
88
+ const selectBody =(() =>{
89
+ if (children) return children
90
+ return (
91
+ <select
92
+ {...domSafeProps(props)}
93
+ disabled={disabled}
94
+ id={name}
95
+ multiple={multiple}
96
+ name={name}
97
+ onChange={onChange}
98
+ ref={ref}
99
+ required={required}
100
+ value={value}
101
+ >
102
+ {blankSelection && <option value="">{blankSelection}</option>}
103
+ {optionsList}
104
+ </select>
105
+ )
106
+ })()
90
107
 
91
108
  return (
92
109
  <div
@@ -94,51 +111,30 @@ const Select = ({
94
111
  {...dataProps}
95
112
  className={classes}
96
113
  >
97
- <If condition={label}>
114
+ {label &&
98
115
  <label
99
116
  className="pb_select_kit_label"
100
117
  htmlFor={name}
101
118
  >
102
- <Caption
103
- text={label}
104
- />
119
+ <Caption text={label} />
105
120
  </label>
106
- </If>
121
+ }
107
122
  <label
108
123
  className={selectWrapperClass}
109
124
  htmlFor={name}
110
125
  >
111
- <If condition={children}>
112
- {children}
113
- <Else />
114
- <select
115
- {...domSafeProps(props)}
116
- disabled={disabled}
117
- id={name}
118
- multiple={multiple}
119
- name={name}
120
- onChange={onChange}
121
- ref={ref}
122
- required={required}
123
- value={value}
124
- >
125
- <If condition={blankSelection}>
126
- <option value="">{blankSelection}</option>
127
- </If>
128
- {optionsList}
129
- </select>
130
- </If>
126
+ {selectBody}
131
127
  <Icon
132
128
  className="pb_select_kit_caret"
133
129
  fixedWidth
134
130
  icon="angle-down"
135
131
  />
136
- <If condition={error}>
132
+ {error &&
137
133
  <Body
138
134
  status="negative"
139
135
  text={error}
140
136
  />
141
- </If>
137
+ }
142
138
  </label>
143
139
  </div>
144
140
  )