@planningcenter/tapestry-react 2.0.0 → 2.1.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.
Files changed (157) hide show
  1. package/dist/cjs/Avatar/Avatar.js +3 -1
  2. package/dist/cjs/Box/Box.js +2 -2
  3. package/dist/cjs/Button/Button.js +2 -2
  4. package/dist/cjs/Calendar/Day.js +1 -0
  5. package/dist/cjs/Card/Card.js +14 -24
  6. package/dist/cjs/Card/Section.js +28 -0
  7. package/dist/cjs/Checkbox/Checkbox.js +1 -1
  8. package/dist/cjs/Collapse/Collapse.js +10 -9
  9. package/dist/cjs/Collapse/Collapse.test.js +56 -0
  10. package/dist/cjs/DataTable/components/Icon.js +4 -4
  11. package/dist/cjs/DragDrop/DragDrop.js +1 -1
  12. package/dist/cjs/GridView/GridView.js +2 -2
  13. package/dist/cjs/HelperDrawer/HelperDrawer.js +8 -8
  14. package/dist/cjs/Icon/Path.js +1 -0
  15. package/dist/cjs/Icon/Status.js +24 -17
  16. package/dist/cjs/Pagination/Pagination.js +99 -83
  17. package/dist/cjs/Scrim/Scrim.js +1 -1
  18. package/dist/cjs/Select/Inline.js +1 -0
  19. package/dist/cjs/Select/Option.js +1 -1
  20. package/dist/cjs/Select/OptionGroup.js +1 -3
  21. package/dist/cjs/Select/Value.js +1 -0
  22. package/dist/cjs/Select/constants.js +2 -2
  23. package/dist/cjs/Sidebar/Sidebar.js +5 -5
  24. package/dist/cjs/Spinner/Spinner.js +3 -3
  25. package/dist/cjs/StackView/StackView.js +2 -2
  26. package/dist/cjs/Table/Table.js +2 -2
  27. package/dist/cjs/Text/Text.js +2 -2
  28. package/dist/cjs/ThemeProvider/ThemeProvider.js +4 -18
  29. package/dist/cjs/TileView/TileView.js +2 -2
  30. package/dist/cjs/system/box-sizes.js +6 -3
  31. package/dist/cjs/system/use-css.js +2 -2
  32. package/dist/cjs/system/utils.js +2 -2
  33. package/dist/esm/Avatar/Avatar.js +3 -3
  34. package/dist/esm/Box/Box.js +1 -1
  35. package/dist/esm/Button/Button.js +2 -2
  36. package/dist/esm/Calendar/Day.js +1 -0
  37. package/dist/esm/Card/Card.js +12 -22
  38. package/dist/esm/Card/Section.js +15 -0
  39. package/dist/esm/Checkbox/Checkbox.js +1 -1
  40. package/dist/esm/Collapse/Collapse.js +3 -2
  41. package/dist/esm/Collapse/Collapse.test.js +53 -0
  42. package/dist/esm/DataTable/components/Icon.js +1 -1
  43. package/dist/esm/DragDrop/DragDrop.js +1 -1
  44. package/dist/esm/GridView/GridView.js +1 -1
  45. package/dist/esm/HelperDrawer/HelperDrawer.js +1 -1
  46. package/dist/esm/Icon/Path.js +1 -0
  47. package/dist/esm/Icon/Status.js +24 -17
  48. package/dist/esm/Pagination/Pagination.js +96 -78
  49. package/dist/esm/Scrim/Scrim.js +1 -1
  50. package/dist/esm/Select/Inline.js +1 -0
  51. package/dist/esm/Select/Option.js +1 -1
  52. package/dist/esm/Select/OptionGroup.js +1 -2
  53. package/dist/esm/Select/Value.js +1 -0
  54. package/dist/esm/Select/constants.js +2 -2
  55. package/dist/esm/Sidebar/Sidebar.js +1 -1
  56. package/dist/esm/Spinner/Spinner.js +1 -1
  57. package/dist/esm/StackView/StackView.js +1 -1
  58. package/dist/esm/Table/Table.js +1 -1
  59. package/dist/esm/Text/Text.js +1 -1
  60. package/dist/esm/ThemeProvider/ThemeProvider.js +3 -15
  61. package/dist/esm/TileView/TileView.js +1 -1
  62. package/dist/esm/system/box-sizes.js +6 -3
  63. package/dist/esm/system/use-css.js +1 -1
  64. package/dist/esm/system/utils.js +1 -1
  65. package/dist/types/Avatar/Avatar.d.ts +19 -0
  66. package/dist/types/Box/Box.d.ts +5 -2
  67. package/dist/types/Button/Button.d.ts +22 -14
  68. package/dist/types/Button/Input.d.ts +1 -1
  69. package/dist/types/Card/Card.d.ts +2 -8
  70. package/dist/types/Card/Section.d.ts +11 -0
  71. package/dist/types/ChurchCenterStatus/ChurchCenterStatus.d.ts +0 -1
  72. package/dist/types/Collapse/Collapse.test.d.ts +1 -0
  73. package/dist/types/Divider/Divider.d.ts +0 -1
  74. package/dist/types/FilterLayout/FilterLayout.d.ts +0 -1
  75. package/dist/types/GridView/GridView.d.ts +4 -1
  76. package/dist/types/Pagination/Pagination.d.ts +23 -0
  77. package/dist/types/Popover/Popover.d.ts +3 -3
  78. package/dist/types/Portal/Portal.d.ts +4 -3
  79. package/dist/types/Spinner/Spinner.d.ts +0 -1
  80. package/dist/types/StackView/StackView.d.ts +4 -1
  81. package/dist/types/Tab/Tab.d.ts +0 -1
  82. package/dist/types/Text/Text.d.ts +4 -1
  83. package/dist/types/TileView/TileView.d.ts +4 -1
  84. package/package.json +12 -15
  85. package/src/Avatar/Avatar.mdx +2 -2
  86. package/src/Avatar/{Avatar.js → Avatar.tsx} +10 -5
  87. package/src/Badge/Badge.mdx +2 -0
  88. package/src/Badge/Status.mdx +1 -0
  89. package/src/Box/Box.tsx +2 -1
  90. package/src/Button/Button.mdx +1 -0
  91. package/src/Button/Button.tsx +13 -5
  92. package/src/Button/Input.mdx +1 -0
  93. package/src/Calendar/Calendar.mdx +1 -0
  94. package/src/Calendar/Day.js +42 -2
  95. package/src/Calendar/Day.mdx +6 -0
  96. package/src/Card/Card.mdx +1 -10
  97. package/src/Card/Card.tsx +8 -16
  98. package/src/Card/Section.mdx +19 -0
  99. package/src/Card/Section.tsx +25 -0
  100. package/src/Checkbox/Checkbox.js +1 -1
  101. package/src/Collapse/Collapse.js +5 -2
  102. package/src/Collapse/Collapse.test.tsx +42 -0
  103. package/src/Combobox/Combobox.mdx +1 -1
  104. package/src/DataTable/components/Icon.js +1 -1
  105. package/src/DragDrop/DragDrop.js +1 -1
  106. package/src/Drawer/Drawer.mdx +1 -0
  107. package/src/EditActions/EditActions.mdx +1 -0
  108. package/src/FieldSet/FieldSet.mdx +1 -0
  109. package/src/GridView/GridView.tsx +1 -1
  110. package/src/HeadingUppercase/HeadingUppercase.mdx +1 -0
  111. package/src/HelperDrawer/HelperDrawer.js +1 -1
  112. package/src/Highlight/Highlight.mdx +1 -0
  113. package/src/Icon/Icon.mdx +65 -35
  114. package/src/Icon/Path.js +2 -0
  115. package/src/Icon/Path.mdx +34 -0
  116. package/src/Icon/Status.js +23 -14
  117. package/src/Icon/Status.mdx +17 -0
  118. package/src/Input/Inline.mdx +1 -0
  119. package/src/Input/Input.mdx +1 -0
  120. package/src/Input/InputBox.mdx +1 -0
  121. package/src/Input/InputField.mdx +1 -0
  122. package/src/Input/InputLabel.mdx +1 -0
  123. package/src/PagerView/PagerView.mdx +1 -1
  124. package/src/Pagination/Pagination.mdx +0 -1
  125. package/src/Pagination/Pagination.tsx +163 -0
  126. package/src/Popover/Popover.tsx +1 -1
  127. package/src/Portal/Portal.tsx +2 -0
  128. package/src/Progress/Progress.mdx +1 -0
  129. package/src/RangeSlider/RangeSlider.mdx +1 -0
  130. package/src/Scrim/Scrim.tsx +1 -1
  131. package/src/Section/Section.mdx +1 -0
  132. package/src/Select/Inline.js +21 -1
  133. package/src/Select/Inline.mdx +27 -0
  134. package/src/Select/Option.js +1 -1
  135. package/src/Select/Option.mdx +30 -0
  136. package/src/Select/OptionGroup.js +9 -3
  137. package/src/Select/OptionGroup.mdx +25 -0
  138. package/src/Select/Select.mdx +2 -99
  139. package/src/Select/Value.js +2 -0
  140. package/src/Select/Value.mdx +67 -0
  141. package/src/Select/constants.js +2 -2
  142. package/src/Sidebar/Sidebar.js +1 -1
  143. package/src/Spinner/Spinner.mdx +1 -0
  144. package/src/Spinner/Spinner.tsx +1 -1
  145. package/src/StackView/StackView.tsx +1 -1
  146. package/src/StepperField/StepperField.mdx +1 -0
  147. package/src/StepperProgress/StepperProgress.mdx +1 -0
  148. package/src/Table/Table.js +1 -1
  149. package/src/Text/Text.mdx +1 -0
  150. package/src/Text/Text.tsx +1 -1
  151. package/src/ThemeProvider/ThemeProvider.tsx +2 -13
  152. package/src/TileView/TileView.tsx +1 -1
  153. package/src/system/README.md +1 -1
  154. package/src/system/box-sizes.js +6 -3
  155. package/src/system/use-css.js +1 -1
  156. package/src/system/utils.js +1 -1
  157. package/src/Pagination/Pagination.js +0 -145
@@ -5,9 +5,21 @@ import Icon from './Icon'
5
5
  import Path from './Path'
6
6
 
7
7
  const STATUS_VARIANTS = {
8
- confirmed: ['general.outlinedCircleCheck', 'success'],
9
- unconfirmed: ['general.outlinedQuestionCircle', 'warning'],
10
- declined: ['general.outlinedXCircle', 'error'],
8
+ confirmed: {
9
+ iconColor: 'success',
10
+ iconFilled: 'general.checkCircle',
11
+ iconOutlined: 'general.outlinedCircleCheck',
12
+ },
13
+ unconfirmed: {
14
+ iconColor: 'warning',
15
+ iconFilled: 'general.questionCircle',
16
+ iconOutlined: 'general.outlinedQuestionCircle',
17
+ },
18
+ declined: {
19
+ iconColor: 'error',
20
+ iconFilled: 'general.xCircle',
21
+ iconOutlined: 'general.outlinedXCircle',
22
+ },
11
23
  }
12
24
 
13
25
  export type Props = {
@@ -21,21 +33,18 @@ export type Props = {
21
33
 
22
34
  function Status(props: Props) {
23
35
  const { color, variant, variantFilled, ...restProps } = props
24
- let variantName
25
- let variantColor
26
- Object.keys(STATUS_VARIANTS).some((key) => {
27
- return variant === key
28
- ? ([variantName, variantColor] = STATUS_VARIANTS[key])
29
- : false
30
- })
31
- if (variantName && variantFilled) {
32
- variantName += '-filled'
33
- }
36
+ const { iconOutlined, iconFilled, iconColor } = STATUS_VARIANTS[variant]
37
+
38
+ const variantColor = color || iconColor
39
+ const variantIcon = variantFilled ? iconFilled : iconOutlined
40
+
34
41
  return (
35
- <Icon name={variantName} color={color || variantColor} {...restProps}>
42
+ <Icon name={variantIcon} color={variantColor} {...restProps}>
36
43
  <Path name="tapestry.radio0" color={color} />
37
44
  </Icon>
38
45
  )
39
46
  }
40
47
 
48
+ Status.displayName = 'Icon.Status'
49
+
41
50
  export default Status
@@ -0,0 +1,17 @@
1
+ ---
2
+ title: Icon.Status
3
+ category: Primitives
4
+ summary: This wraps the [Icon](/icon) component and can render 3 different statuses.
5
+ propsSummary: Accepts [Icon](/icon) props.
6
+ parent: Icon
7
+ ---
8
+
9
+ ```jsx live
10
+ render(
11
+ <StackView axis="horizontal" spacing={3}>
12
+ <Icon.Status variant="confirmed" size="xl" />
13
+ <Icon.Status variant="unconfirmed" size="xl" />
14
+ <Icon.Status variant="declined" size="xl" />
15
+ </StackView>
16
+ )
17
+ ```
@@ -3,6 +3,7 @@ title: Input.Inline
3
3
  category: Forms
4
4
  summary: Composes [Input.InputField](/input.inputfield) with minimal styling.
5
5
  propsSummary: Accepts props for [Input.InputField](/input.inputfield).
6
+ parent: Input
6
7
  ---
7
8
 
8
9
  ```jsx live
@@ -3,6 +3,7 @@ title: Input
3
3
  category: Forms
4
4
  summary: Composes [Input.InputBox](/input.inputbox) and [Input.InputField](/input.inputfield).
5
5
  propsSummary: Accepts props for [Input.InputBox](/input.inputbox) _and_ [Input.InputField](/input.inputfield), remaining props are forwarded to `Input.InputBox`.
6
+ isParent: true
6
7
  ---
7
8
 
8
9
  ```jsx live
@@ -3,6 +3,7 @@ title: Input.InputBox
3
3
  category: Forms
4
4
  summary: A base component used in Input as well as [SegmentedControl](/segmentedcontrol), [Select](/select), and [TokenInput](/tokeninput).
5
5
  propsSummary: Accepts [StackView](/stackview) props.
6
+ parent: Input
6
7
  ---
7
8
 
8
9
  ```jsx live
@@ -3,6 +3,7 @@ title: Input.InputField
3
3
  category: Forms
4
4
  summary: The base component used in Input as well as Input.Inline and Combobox.Input. Provides a clean input base to build on top of.
5
5
  propsSummary: Accepts [Box](/box) props.
6
+ parent: Input
6
7
  ---
7
8
 
8
9
  ```jsx live
@@ -3,6 +3,7 @@ title: Input.InputLabel
3
3
  category: Forms
4
4
  summary: Provides accessibility as well as usability improvements for mouse users by allowing the user to click the <InputLabel/> component to focus the respective control. This mimics the browsers native label tag, but allows use with custom components like <Select/>.
5
5
  propsSummary: Accepts [Text](/text) props.
6
+ parent: Input
6
7
  ---
7
8
 
8
9
  ```jsx live
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  title: PagerView
3
3
  category: Layout
4
- summary: Allows paging between views. Use with the [useRovingIndex](https://github.com/ministrycentered/tapestry-react/blob/next/packages/tapestry-react/src/hooks/use-roving-index.js) hook to control the [activeViewIndex](#activeViewIndex).
4
+ summary: Allows paging between views. Use with the [useRovingIndex](https://github.com/planningcenter/tapestry-react/blob/next/packages/tapestry-react/src/hooks/use-roving-index.js) hook to control the [activeViewIndex](#activeViewIndex).
5
5
  propsSummary: Accepts [StackView](/stackview) props.
6
6
  ---
7
7
 
@@ -12,7 +12,6 @@ render(() => {
12
12
  currentPage={value}
13
13
  onPageChange={(value) => setValue(value)}
14
14
  totalPages={100}
15
- visiblePages={10}
16
15
  />
17
16
  )
18
17
  })
@@ -0,0 +1,163 @@
1
+ import React from 'react'
2
+
3
+ import Box from '../Box'
4
+ import Button from '../Button'
5
+ import Group from '../Group'
6
+ import StackView from '../StackView'
7
+ import { range } from '../utils'
8
+ import { useWindowWidth } from '@react-hook/window-size'
9
+ import { useThemeValue } from '../system'
10
+
11
+ function getVisiblePages(currentPage, totalPages, visiblePages) {
12
+ const start = Math.max(
13
+ 1,
14
+ Math.min(
15
+ totalPages - visiblePages + 1,
16
+ Math.floor(currentPage - visiblePages / 2 + 1)
17
+ )
18
+ )
19
+ const stop = Math.min(totalPages, start + visiblePages - 1)
20
+ const primaryWindow = range(start, stop + 1)
21
+ const showFirstPage = start > 1
22
+ const showLastPage = stop < totalPages
23
+
24
+ if (showFirstPage) {
25
+ primaryWindow.shift()
26
+ primaryWindow.shift()
27
+ }
28
+ if (showLastPage) {
29
+ primaryWindow.pop()
30
+ primaryWindow.pop()
31
+ }
32
+
33
+ const first = showFirstPage ? [1, '...'] : []
34
+ const last = showLastPage ? ['...', totalPages] : []
35
+ return first.concat(primaryWindow).concat(last)
36
+ }
37
+
38
+ export type PaginationProps = {
39
+ /**
40
+ * Change the color of the active page
41
+ */
42
+ activeColor: string,
43
+
44
+ /**
45
+ * Current visible page number
46
+ */
47
+ currentPage: number,
48
+
49
+ /**
50
+ * Callback when new page is requested
51
+ */
52
+ onPageChange: (nextPage: number) => undefined,
53
+
54
+ /**
55
+ * Total available pages
56
+ */
57
+ totalPages: number,
58
+
59
+ /**
60
+ * Amount of visible pages
61
+ */
62
+ visiblePages?: number,
63
+ }
64
+
65
+ const NavButton = ({ disabled, iconName, ...props }) => {
66
+ return (
67
+ <Button
68
+ backgroundColor={disabled ? '#f7f7f7' : '#f2f2f2'}
69
+ disabled={disabled}
70
+ icon={{
71
+ color: disabled ? '#cfcfcf' : undefined,
72
+ name: iconName,
73
+ size: 'xs',
74
+ }}
75
+ opacity={1}
76
+ shrink={0}
77
+ square
78
+ variant="fill"
79
+ {...props}
80
+ />
81
+ )
82
+ }
83
+
84
+ export default function Pagination({
85
+ activeColor = '#5b8bf7',
86
+ currentPage,
87
+ onPageChange = () => null,
88
+ visiblePages,
89
+ totalPages = 0,
90
+ ...restProps
91
+ }: PaginationProps) {
92
+ const { xs: xsBreakpoint } = useThemeValue('breakpoints')
93
+
94
+ const currentWidth = useWindowWidth()
95
+
96
+ function renderGap(key) {
97
+ return <Box key={key} userSelect="none" cursor="default" children="…" />
98
+ }
99
+
100
+ function renderPageLink(number) {
101
+ const isActive = currentPage === number
102
+
103
+ const outlineStyle = { border: '1px solid #5b8bf7', color: '#5b8bf7' }
104
+
105
+ return (
106
+ <Button
107
+ key={number}
108
+ focus={{ backgroundColor: '#f4f8fd', ...outlineStyle }}
109
+ fontWeight={500}
110
+ hover={{ backgroundColor: '#ffffff', ...outlineStyle }}
111
+ onClick={onPageChange.bind(null, number)}
112
+ shrink={0}
113
+ square
114
+ title={number}
115
+ variant={isActive ? 'fill' : 'naked'}
116
+ {...(isActive && { backgroundColor: '#5b8bf7', color: 'white' })}
117
+ />
118
+ )
119
+ }
120
+
121
+ function renderPageLinks() {
122
+ const visiblePagesToShow =
123
+ currentWidth <= xsBreakpoint ? visiblePages || 5 : visiblePages || 7
124
+ const pages = getVisiblePages(currentPage, totalPages, visiblePagesToShow)
125
+ return pages.map((page, index) =>
126
+ page === '...' ? renderGap(page + index) : renderPageLink(page)
127
+ )
128
+ }
129
+
130
+ if (totalPages <= 1) {
131
+ return null
132
+ } else {
133
+ return (
134
+ <StackView
135
+ alignment="center"
136
+ axis="horizontal"
137
+ distribution="center"
138
+ overflow="auto"
139
+ paddingVertical={1}
140
+ shrink={0}
141
+ spacing={0.5}
142
+ width="100%"
143
+ {...restProps}
144
+ >
145
+ <Group spacing={0.5}>
146
+ <NavButton
147
+ disabled={currentPage === 1}
148
+ iconName="general.leftChevron"
149
+ onClick={onPageChange.bind(null, currentPage - 1)}
150
+ tooltip={{ title: 'Previous Page' }}
151
+ />
152
+ <NavButton
153
+ disabled={currentPage === totalPages}
154
+ iconName="general.rightChevron"
155
+ onClick={onPageChange.bind(null, currentPage + 1)}
156
+ tooltip={{ title: 'Next Page' }}
157
+ />
158
+ </Group>
159
+ {renderPageLinks()}
160
+ </StackView>
161
+ )
162
+ }
163
+ }
@@ -17,7 +17,7 @@ export type PopoverProps = {
17
17
  /**
18
18
  * Controls the default component or tag being rendered.
19
19
  */
20
- as?: React.ReactNode
20
+ as?: any
21
21
 
22
22
  /**
23
23
  * The element to attach the popover to. Clones the element's ref to calculate
@@ -2,6 +2,8 @@ import * as React from 'react'
2
2
  import { createPortal } from 'react-dom'
3
3
 
4
4
  export type PortalProps = {
5
+ children: any
6
+
5
7
  /** Styles to apply to the portal root element. */
6
8
  style?: React.CSSProperties
7
9
 
@@ -3,6 +3,7 @@ title: Progress
3
3
  category: Indicators
4
4
  summary: Display progress towards the completion of a task. Composes [Box](/box).
5
5
  propsSummary: Accepts [Box](/box) props.
6
+ themeKey: progress
6
7
  ---
7
8
 
8
9
  ```jsx live
@@ -3,6 +3,7 @@ title: RangeSlider
3
3
  category: Forms
4
4
  summary: Allow the user to specify a numeric value which must be no less than a minimum value and no more than a maximum value. Composes [Box](/box).
5
5
  propsSummary: Accepts [Box](/box) props.
6
+ themeKey: rangeSlider
6
7
  ---
7
8
 
8
9
  ```jsx live
@@ -8,7 +8,7 @@ type ScrimProps = {
8
8
  children?: any,
9
9
  }
10
10
 
11
- const Scrim = React.forwardRef(function (props: ScrimProps,) {
11
+ const Scrim = React.forwardRef(function (props: ScrimProps, _ref: any) {
12
12
  React.useLayoutEffect(() => {
13
13
  document.body.style.overflow = 'hidden'
14
14
  return () => {
@@ -3,6 +3,7 @@ title: Section
3
3
  category: General
4
4
  summary: Sections are used within `Page` components to break up content into sections that always display a `Toolbar` at the top.
5
5
  propsSummary: Accepts [StackView](/stackview) props.
6
+ themeKey: section
6
7
  ---
7
8
 
8
9
  ```jsx live
@@ -1,8 +1,26 @@
1
+ // @flow
1
2
  import React from 'react'
2
3
 
3
4
  import Select from './Select'
4
5
 
5
- function Inline({ light, hover, focus, readOnly, ...restProps }) {
6
+ type Props = {
7
+ /**
8
+ * Changes the background and text color values
9
+ */
10
+ light?: boolean,
11
+ /**
12
+ * Accepts hover styles.
13
+ */
14
+ hover?: object,
15
+
16
+ /**
17
+ * Accepts focus styles.
18
+ */
19
+ focus?: object,
20
+ readOnly?: boolean,
21
+ }
22
+
23
+ function Inline({ light, hover, focus, readOnly, ...restProps }: Props) {
6
24
  const pseudoStyles = readOnly
7
25
  ? {}
8
26
  : { backgroundColor: light ? 'light-0' : 'highlight' }
@@ -29,4 +47,6 @@ function Inline({ light, hover, focus, readOnly, ...restProps }) {
29
47
  )
30
48
  }
31
49
 
50
+ Inline.displayName = 'Select.Inline'
51
+
32
52
  export default Inline
@@ -0,0 +1,27 @@
1
+ ---
2
+ title: Select.Inline
3
+ category: Forms
4
+ summary: A base component that composes [Select](/select) and provides transparent styles.
5
+ propsSummary: Accepts [Select](/select) props.
6
+ parent: Select
7
+ ---
8
+
9
+ ```jsx live
10
+ render(
11
+ <Box padding={2} backgroundColor="primary">
12
+ <Select.Inline light>
13
+ {generateRange(100).map((number) => (
14
+ <Select.Option key={number} value={number}>
15
+ {number}
16
+ </Select.Option>
17
+ ))}
18
+ </Select.Inline>
19
+ <Input.Inline
20
+ size="xl"
21
+ fontSize={0}
22
+ light
23
+ defaultValue="Editable Heading"
24
+ />
25
+ </Box>
26
+ )
27
+ ```
@@ -20,7 +20,7 @@ type Props = {
20
20
  }
21
21
 
22
22
  class Option extends Component<Props> {
23
- static displayName = OPTION_DISPLAY_NAME
23
+ static displayName = 'Select.Option'
24
24
 
25
25
  render() {
26
26
  const { children, disabled, index, text, value, ...restProps } = this.props
@@ -0,0 +1,30 @@
1
+ ---
2
+ title: Select.Option
3
+ category: Forms
4
+ summary: Holds values that will interact with [Select](/select) and can be wrapped by [Select.OptionGroup](/select.optiongroup)
5
+ parent: Select
6
+ ---
7
+
8
+ ```jsx live
9
+ render(
10
+ <Select
11
+ emptyValue="Select a fruit"
12
+ tooltip={{ title: 'Select a fruit' }}
13
+ onChange={(e) => console.log(e)}
14
+ >
15
+ <Select.Option value="apple">Apple</Select.Option>
16
+ <Select.Option value="orange">Orange</Select.Option>
17
+ <Select.Option value="banana">Banana</Select.Option>
18
+ <Select.Option value="mango">Mango</Select.Option>
19
+ <Select.Option value="kiwi" disabled>
20
+ Kiwi (Out of stock)
21
+ </Select.Option>
22
+ <Select.Option value="strawberry">Strawberry</Select.Option>
23
+ <Divider margin={0.5} />
24
+ <Menu.Item distribution="fill" spacing={1}>
25
+ <Button title="Action 1" size="sm" />
26
+ <Button title="Action 2" size="sm" />
27
+ </Menu.Item>
28
+ </Select>
29
+ )
30
+ ```
@@ -1,9 +1,15 @@
1
+ // @flow
1
2
  import { Component } from 'react'
2
3
 
3
- import { OPTIONGROUP_DISPLAY_NAME } from './constants'
4
+ type Props = {
5
+ /**
6
+ * Provide a title to a grouping of options.
7
+ */
8
+ title?: string,
9
+ }
4
10
 
5
- class OptionGroup extends Component {
6
- static displayName = OPTIONGROUP_DISPLAY_NAME
11
+ class OptionGroup extends Component<Props> {
12
+ static displayName = 'Select.OptionGroup'
7
13
 
8
14
  render() {
9
15
  return null
@@ -0,0 +1,25 @@
1
+ ---
2
+ title: Select.OptionGroup
3
+ category: Forms
4
+ summary: Groups and provides a title to a related set of [Select.Option](/select.option) components.
5
+ parent: Select
6
+ ---
7
+
8
+ ```jsx live
9
+ render(
10
+ <Box>
11
+ <Select multiple>
12
+ <Select.OptionGroup title="Group 1">
13
+ <Select.Option value="1">One</Select.Option>
14
+ <Select.Option value="2">Two</Select.Option>
15
+ <Select.Option value="3">Three</Select.Option>
16
+ </Select.OptionGroup>
17
+ <Select.OptionGroup title="Group 2">
18
+ <Select.Option value="4">Four</Select.Option>
19
+ <Select.Option value="5">Five</Select.Option>
20
+ <Select.Option value="6">Six</Select.Option>
21
+ </Select.OptionGroup>
22
+ </Select>
23
+ </Box>
24
+ )
25
+ ```
@@ -1,8 +1,9 @@
1
1
  ---
2
2
  title: Select
3
3
  category: Forms
4
- summary: Provide a list of options that can be selected. Replaces native select menus by using aria roles to enhance accessibility while allowing full customization of the options and what is used in the select popover. Composes [InputBox](/inputbox) and [Popover](/popover).
4
+ summary: Provide a list of options that can be selected. Replaces native select menus by using aria roles to enhance accessibility while allowing full customization of the options and what is used in the select popover. Composes [InputBox](/input.inputbox) and [Popover](/popover).
5
5
  propsSummary: Accepts [InputBox](/input.inputbox) props.
6
+ isParent: true
6
7
  ---
7
8
 
8
9
  ```jsx live
@@ -78,101 +79,3 @@ render(() => {
78
79
  )
79
80
  })
80
81
  ```
81
-
82
- ```jsx live
83
- const options = [
84
- {
85
- title: 'Arrangement Files',
86
- options: [
87
- {
88
- label: 'Chord Chart + → Lyrics & Chords',
89
- type: 'TXT',
90
- },
91
- {
92
- label: 'Lead Sheet',
93
- type: 'PDF',
94
- },
95
- ],
96
- },
97
- {
98
- title: 'E (Most Common)',
99
- options: [
100
- {
101
- label: 'E Chord Chart +',
102
- type: 'PDF',
103
- },
104
- ],
105
- },
106
- {
107
- title: 'Ab',
108
- options: [
109
- {
110
- label: 'Ab Chord Chart +',
111
- type: 'PDF',
112
- },
113
- ],
114
- },
115
- ]
116
- render(
117
- <Select
118
- multiple
119
- renderValue={(selectedOptions) => (
120
- <Select.Value>
121
- {selectedOptions.map((option) => option.value).join(', ')}
122
- </Select.Value>
123
- )}
124
- >
125
- {options.map((optgroup) => (
126
- <Select.OptionGroup key={optgroup.title} title={optgroup.title}>
127
- {optgroup.options.map((option) => (
128
- <Select.Option key={option.label} value={option.label}>
129
- <Text marginRight={2}>{option.label}</Text>
130
- <Badge size="xs" marginLeft="auto">
131
- {option.type}
132
- </Badge>
133
- </Select.Option>
134
- ))}
135
- </Select.OptionGroup>
136
- ))}
137
- </Select>
138
- )
139
- ```
140
-
141
- ```jsx live
142
- render(
143
- <Box>
144
- <Select multiple>
145
- <Select.OptionGroup title="Group 1">
146
- <Select.Option value="1">One</Select.Option>
147
- <Select.Option value="2">Two</Select.Option>
148
- <Select.Option value="3">Three</Select.Option>
149
- </Select.OptionGroup>
150
- <Select.OptionGroup title="Group 2">
151
- <Select.Option value="4">Four</Select.Option>
152
- <Select.Option value="5">Five</Select.Option>
153
- <Select.Option value="6">Six</Select.Option>
154
- </Select.OptionGroup>
155
- </Select>
156
- </Box>
157
- )
158
- ```
159
-
160
- ```jsx live
161
- render(
162
- <Box padding={2} backgroundColor="primary">
163
- <Select.Inline light>
164
- {generateRange(100).map((number) => (
165
- <Select.Option key={number} value={number}>
166
- {number}
167
- </Select.Option>
168
- ))}
169
- </Select.Inline>
170
- <Input.Inline
171
- size="xl"
172
- fontSize={0}
173
- light
174
- defaultValue="Editable Heading"
175
- />
176
- </Box>
177
- )
178
- ```
@@ -17,4 +17,6 @@ function Value(props) {
17
17
  )
18
18
  }
19
19
 
20
+ Value.displayName = 'Select.Value'
21
+
20
22
  export default Value