@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.
- package/dist/cjs/Avatar/Avatar.js +3 -1
- package/dist/cjs/Box/Box.js +2 -2
- package/dist/cjs/Button/Button.js +2 -2
- package/dist/cjs/Calendar/Day.js +1 -0
- package/dist/cjs/Card/Card.js +14 -24
- package/dist/cjs/Card/Section.js +28 -0
- package/dist/cjs/Checkbox/Checkbox.js +1 -1
- package/dist/cjs/Collapse/Collapse.js +10 -9
- package/dist/cjs/Collapse/Collapse.test.js +56 -0
- package/dist/cjs/DataTable/components/Icon.js +4 -4
- package/dist/cjs/DragDrop/DragDrop.js +1 -1
- package/dist/cjs/GridView/GridView.js +2 -2
- package/dist/cjs/HelperDrawer/HelperDrawer.js +8 -8
- package/dist/cjs/Icon/Path.js +1 -0
- package/dist/cjs/Icon/Status.js +24 -17
- package/dist/cjs/Pagination/Pagination.js +99 -83
- package/dist/cjs/Scrim/Scrim.js +1 -1
- package/dist/cjs/Select/Inline.js +1 -0
- package/dist/cjs/Select/Option.js +1 -1
- package/dist/cjs/Select/OptionGroup.js +1 -3
- package/dist/cjs/Select/Value.js +1 -0
- package/dist/cjs/Select/constants.js +2 -2
- package/dist/cjs/Sidebar/Sidebar.js +5 -5
- package/dist/cjs/Spinner/Spinner.js +3 -3
- package/dist/cjs/StackView/StackView.js +2 -2
- package/dist/cjs/Table/Table.js +2 -2
- package/dist/cjs/Text/Text.js +2 -2
- package/dist/cjs/ThemeProvider/ThemeProvider.js +4 -18
- package/dist/cjs/TileView/TileView.js +2 -2
- package/dist/cjs/system/box-sizes.js +6 -3
- package/dist/cjs/system/use-css.js +2 -2
- package/dist/cjs/system/utils.js +2 -2
- package/dist/esm/Avatar/Avatar.js +3 -3
- package/dist/esm/Box/Box.js +1 -1
- package/dist/esm/Button/Button.js +2 -2
- package/dist/esm/Calendar/Day.js +1 -0
- package/dist/esm/Card/Card.js +12 -22
- package/dist/esm/Card/Section.js +15 -0
- package/dist/esm/Checkbox/Checkbox.js +1 -1
- package/dist/esm/Collapse/Collapse.js +3 -2
- package/dist/esm/Collapse/Collapse.test.js +53 -0
- package/dist/esm/DataTable/components/Icon.js +1 -1
- package/dist/esm/DragDrop/DragDrop.js +1 -1
- package/dist/esm/GridView/GridView.js +1 -1
- package/dist/esm/HelperDrawer/HelperDrawer.js +1 -1
- package/dist/esm/Icon/Path.js +1 -0
- package/dist/esm/Icon/Status.js +24 -17
- package/dist/esm/Pagination/Pagination.js +96 -78
- package/dist/esm/Scrim/Scrim.js +1 -1
- package/dist/esm/Select/Inline.js +1 -0
- package/dist/esm/Select/Option.js +1 -1
- package/dist/esm/Select/OptionGroup.js +1 -2
- package/dist/esm/Select/Value.js +1 -0
- package/dist/esm/Select/constants.js +2 -2
- package/dist/esm/Sidebar/Sidebar.js +1 -1
- package/dist/esm/Spinner/Spinner.js +1 -1
- package/dist/esm/StackView/StackView.js +1 -1
- package/dist/esm/Table/Table.js +1 -1
- package/dist/esm/Text/Text.js +1 -1
- package/dist/esm/ThemeProvider/ThemeProvider.js +3 -15
- package/dist/esm/TileView/TileView.js +1 -1
- package/dist/esm/system/box-sizes.js +6 -3
- package/dist/esm/system/use-css.js +1 -1
- package/dist/esm/system/utils.js +1 -1
- package/dist/types/Avatar/Avatar.d.ts +19 -0
- package/dist/types/Box/Box.d.ts +5 -2
- package/dist/types/Button/Button.d.ts +22 -14
- package/dist/types/Button/Input.d.ts +1 -1
- package/dist/types/Card/Card.d.ts +2 -8
- package/dist/types/Card/Section.d.ts +11 -0
- package/dist/types/ChurchCenterStatus/ChurchCenterStatus.d.ts +0 -1
- package/dist/types/Collapse/Collapse.test.d.ts +1 -0
- package/dist/types/Divider/Divider.d.ts +0 -1
- package/dist/types/FilterLayout/FilterLayout.d.ts +0 -1
- package/dist/types/GridView/GridView.d.ts +4 -1
- package/dist/types/Pagination/Pagination.d.ts +23 -0
- package/dist/types/Popover/Popover.d.ts +3 -3
- package/dist/types/Portal/Portal.d.ts +4 -3
- package/dist/types/Spinner/Spinner.d.ts +0 -1
- package/dist/types/StackView/StackView.d.ts +4 -1
- package/dist/types/Tab/Tab.d.ts +0 -1
- package/dist/types/Text/Text.d.ts +4 -1
- package/dist/types/TileView/TileView.d.ts +4 -1
- package/package.json +12 -15
- package/src/Avatar/Avatar.mdx +2 -2
- package/src/Avatar/{Avatar.js → Avatar.tsx} +10 -5
- package/src/Badge/Badge.mdx +2 -0
- package/src/Badge/Status.mdx +1 -0
- package/src/Box/Box.tsx +2 -1
- package/src/Button/Button.mdx +1 -0
- package/src/Button/Button.tsx +13 -5
- package/src/Button/Input.mdx +1 -0
- package/src/Calendar/Calendar.mdx +1 -0
- package/src/Calendar/Day.js +42 -2
- package/src/Calendar/Day.mdx +6 -0
- package/src/Card/Card.mdx +1 -10
- package/src/Card/Card.tsx +8 -16
- package/src/Card/Section.mdx +19 -0
- package/src/Card/Section.tsx +25 -0
- package/src/Checkbox/Checkbox.js +1 -1
- package/src/Collapse/Collapse.js +5 -2
- package/src/Collapse/Collapse.test.tsx +42 -0
- package/src/Combobox/Combobox.mdx +1 -1
- package/src/DataTable/components/Icon.js +1 -1
- package/src/DragDrop/DragDrop.js +1 -1
- package/src/Drawer/Drawer.mdx +1 -0
- package/src/EditActions/EditActions.mdx +1 -0
- package/src/FieldSet/FieldSet.mdx +1 -0
- package/src/GridView/GridView.tsx +1 -1
- package/src/HeadingUppercase/HeadingUppercase.mdx +1 -0
- package/src/HelperDrawer/HelperDrawer.js +1 -1
- package/src/Highlight/Highlight.mdx +1 -0
- package/src/Icon/Icon.mdx +65 -35
- package/src/Icon/Path.js +2 -0
- package/src/Icon/Path.mdx +34 -0
- package/src/Icon/Status.js +23 -14
- package/src/Icon/Status.mdx +17 -0
- package/src/Input/Inline.mdx +1 -0
- package/src/Input/Input.mdx +1 -0
- package/src/Input/InputBox.mdx +1 -0
- package/src/Input/InputField.mdx +1 -0
- package/src/Input/InputLabel.mdx +1 -0
- package/src/PagerView/PagerView.mdx +1 -1
- package/src/Pagination/Pagination.mdx +0 -1
- package/src/Pagination/Pagination.tsx +163 -0
- package/src/Popover/Popover.tsx +1 -1
- package/src/Portal/Portal.tsx +2 -0
- package/src/Progress/Progress.mdx +1 -0
- package/src/RangeSlider/RangeSlider.mdx +1 -0
- package/src/Scrim/Scrim.tsx +1 -1
- package/src/Section/Section.mdx +1 -0
- package/src/Select/Inline.js +21 -1
- package/src/Select/Inline.mdx +27 -0
- package/src/Select/Option.js +1 -1
- package/src/Select/Option.mdx +30 -0
- package/src/Select/OptionGroup.js +9 -3
- package/src/Select/OptionGroup.mdx +25 -0
- package/src/Select/Select.mdx +2 -99
- package/src/Select/Value.js +2 -0
- package/src/Select/Value.mdx +67 -0
- package/src/Select/constants.js +2 -2
- package/src/Sidebar/Sidebar.js +1 -1
- package/src/Spinner/Spinner.mdx +1 -0
- package/src/Spinner/Spinner.tsx +1 -1
- package/src/StackView/StackView.tsx +1 -1
- package/src/StepperField/StepperField.mdx +1 -0
- package/src/StepperProgress/StepperProgress.mdx +1 -0
- package/src/Table/Table.js +1 -1
- package/src/Text/Text.mdx +1 -0
- package/src/Text/Text.tsx +1 -1
- package/src/ThemeProvider/ThemeProvider.tsx +2 -13
- package/src/TileView/TileView.tsx +1 -1
- package/src/system/README.md +1 -1
- package/src/system/box-sizes.js +6 -3
- package/src/system/use-css.js +1 -1
- package/src/system/utils.js +1 -1
- package/src/Pagination/Pagination.js +0 -145
package/src/Icon/Status.js
CHANGED
|
@@ -5,9 +5,21 @@ import Icon from './Icon'
|
|
|
5
5
|
import Path from './Path'
|
|
6
6
|
|
|
7
7
|
const STATUS_VARIANTS = {
|
|
8
|
-
confirmed:
|
|
9
|
-
|
|
10
|
-
|
|
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
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
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={
|
|
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
|
+
```
|
package/src/Input/Inline.mdx
CHANGED
package/src/Input/Input.mdx
CHANGED
|
@@ -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
|
package/src/Input/InputBox.mdx
CHANGED
|
@@ -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
|
package/src/Input/InputField.mdx
CHANGED
package/src/Input/InputLabel.mdx
CHANGED
|
@@ -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/
|
|
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
|
|
|
@@ -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
|
+
}
|
package/src/Popover/Popover.tsx
CHANGED
package/src/Portal/Portal.tsx
CHANGED
|
@@ -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
|
package/src/Scrim/Scrim.tsx
CHANGED
|
@@ -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 () => {
|
package/src/Section/Section.mdx
CHANGED
package/src/Select/Inline.js
CHANGED
|
@@ -1,8 +1,26 @@
|
|
|
1
|
+
// @flow
|
|
1
2
|
import React from 'react'
|
|
2
3
|
|
|
3
4
|
import Select from './Select'
|
|
4
5
|
|
|
5
|
-
|
|
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
|
+
```
|
package/src/Select/Option.js
CHANGED
|
@@ -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
|
-
|
|
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 =
|
|
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
|
+
```
|
package/src/Select/Select.mdx
CHANGED
|
@@ -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
|
-
```
|