@instructure/ui-list 8.8.0 → 8.8.1-snapshot.63
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/LICENSE.md +27 -0
- package/es/InlineList/InlineListItem/index.js +5 -38
- package/es/InlineList/InlineListItem/props.js +56 -0
- package/es/InlineList/index.js +2 -25
- package/{src/InlineList/InlineListItem/types.ts → es/InlineList/props.js} +26 -20
- package/es/List/ListItem/index.js +4 -37
- package/es/List/ListItem/props.js +56 -0
- package/es/List/index.js +4 -41
- package/es/List/props.js +60 -0
- package/lib/InlineList/InlineListItem/index.js +5 -38
- package/lib/InlineList/InlineListItem/props.js +68 -0
- package/lib/InlineList/index.js +3 -28
- package/lib/InlineList/props.js +65 -0
- package/lib/List/ListItem/index.js +4 -37
- package/lib/List/ListItem/props.js +68 -0
- package/lib/List/index.js +4 -42
- package/lib/List/props.js +74 -0
- package/package.json +15 -14
- package/src/InlineList/InlineListItem/index.tsx +8 -46
- package/src/InlineList/InlineListItem/props.ts +105 -0
- package/src/InlineList/InlineListItem/styles.ts +1 -1
- package/src/InlineList/InlineListItem/theme.ts +1 -1
- package/src/InlineList/index.tsx +5 -35
- package/src/InlineList/props.ts +102 -0
- package/src/List/ListItem/index.tsx +7 -45
- package/src/List/ListItem/props.ts +105 -0
- package/src/List/ListItem/styles.ts +1 -1
- package/src/List/ListItem/theme.ts +1 -1
- package/src/List/index.tsx +7 -48
- package/src/List/props.ts +111 -0
- package/src/List/styles.ts +1 -1
- package/src/List/theme.ts +1 -1
- package/src/index.ts +4 -4
- package/types/InlineList/InlineListItem/index.d.ts +19 -30
- package/types/InlineList/InlineListItem/index.d.ts.map +1 -1
- package/types/InlineList/InlineListItem/props.d.ts +20 -0
- package/types/InlineList/InlineListItem/props.d.ts.map +1 -0
- package/types/InlineList/InlineListItem/styles.d.ts +1 -1
- package/types/InlineList/InlineListItem/theme.d.ts +1 -1
- package/types/InlineList/InlineListItem/theme.d.ts.map +1 -1
- package/types/InlineList/index.d.ts +27 -23
- package/types/InlineList/index.d.ts.map +1 -1
- package/types/InlineList/props.d.ts +20 -0
- package/types/InlineList/props.d.ts.map +1 -0
- package/types/List/ListItem/index.d.ts +19 -30
- package/types/List/ListItem/index.d.ts.map +1 -1
- package/types/List/ListItem/props.d.ts +20 -0
- package/types/List/ListItem/props.d.ts.map +1 -0
- package/types/List/ListItem/styles.d.ts +1 -1
- package/types/List/ListItem/theme.d.ts +1 -1
- package/types/List/ListItem/theme.d.ts.map +1 -1
- package/types/List/index.d.ts +21 -35
- package/types/List/index.d.ts.map +1 -1
- package/types/List/props.d.ts +21 -0
- package/types/List/props.d.ts.map +1 -0
- package/types/List/styles.d.ts +1 -1
- package/types/List/theme.d.ts +1 -1
- package/types/List/theme.d.ts.map +1 -1
- package/types/index.d.ts +4 -4
- package/es/InlineList/InlineListItem/types.js +0 -1
- package/es/InlineList/types.js +0 -1
- package/es/List/ListItem/types.js +0 -1
- package/es/List/types.js +0 -1
- package/lib/InlineList/InlineListItem/types.js +0 -1
- package/lib/InlineList/types.js +0 -1
- package/lib/List/ListItem/types.js +0 -1
- package/lib/List/types.js +0 -1
- package/src/InlineList/types.ts +0 -43
- package/src/List/ListItem/types.ts +0 -45
- package/src/List/types.ts +0 -46
- package/types/InlineList/InlineListItem/types.d.ts +0 -12
- package/types/InlineList/InlineListItem/types.d.ts.map +0 -1
- package/types/InlineList/types.d.ts +0 -10
- package/types/InlineList/types.d.ts.map +0 -1
- package/types/List/ListItem/types.d.ts +0 -12
- package/types/List/ListItem/types.d.ts.map +0 -1
- package/types/List/types.d.ts +0 -13
- package/types/List/types.d.ts.map +0 -1
|
@@ -0,0 +1,102 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* The MIT License (MIT)
|
|
3
|
+
*
|
|
4
|
+
* Copyright (c) 2015 - present Instructure, Inc.
|
|
5
|
+
*
|
|
6
|
+
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
7
|
+
* of this software and associated documentation files (the "Software"), to deal
|
|
8
|
+
* in the Software without restriction, including without limitation the rights
|
|
9
|
+
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
10
|
+
* copies of the Software, and to permit persons to whom the Software is
|
|
11
|
+
* furnished to do so, subject to the following conditions:
|
|
12
|
+
*
|
|
13
|
+
* The above copyright notice and this permission notice shall be included in all
|
|
14
|
+
* copies or substantial portions of the Software.
|
|
15
|
+
*
|
|
16
|
+
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
17
|
+
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
18
|
+
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
19
|
+
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
20
|
+
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
21
|
+
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
22
|
+
* SOFTWARE.
|
|
23
|
+
*/
|
|
24
|
+
|
|
25
|
+
import React from 'react'
|
|
26
|
+
import PropTypes from 'prop-types'
|
|
27
|
+
|
|
28
|
+
import { Children as ChildrenPropTypes } from '@instructure/ui-prop-types'
|
|
29
|
+
import { ThemeablePropTypes } from '@instructure/emotion'
|
|
30
|
+
import { InlineListItem } from './InlineListItem'
|
|
31
|
+
|
|
32
|
+
import type { Spacing } from '@instructure/emotion'
|
|
33
|
+
import type { PropValidators } from '@instructure/shared-types'
|
|
34
|
+
|
|
35
|
+
type InlineListOwnProps = {
|
|
36
|
+
children?: React.ReactNode // TODO: oneOf([InlineListItem])
|
|
37
|
+
as?: 'ul' | 'ol'
|
|
38
|
+
margin?: Spacing
|
|
39
|
+
size?: 'small' | 'medium' | 'large'
|
|
40
|
+
delimiter?: 'none' | 'pipe' | 'slash' | 'arrow'
|
|
41
|
+
itemSpacing?:
|
|
42
|
+
| 'none'
|
|
43
|
+
| 'xxx-small'
|
|
44
|
+
| 'xx-small'
|
|
45
|
+
| 'x-small'
|
|
46
|
+
| 'small'
|
|
47
|
+
| 'medium'
|
|
48
|
+
| 'large'
|
|
49
|
+
| 'x-large'
|
|
50
|
+
| 'xx-large'
|
|
51
|
+
elementRef?: (...args: any[]) => any
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
type PropKeys = keyof InlineListOwnProps
|
|
55
|
+
|
|
56
|
+
type AllowedPropKeys = Readonly<Array<PropKeys>>
|
|
57
|
+
|
|
58
|
+
type InlineListProps = InlineListOwnProps
|
|
59
|
+
|
|
60
|
+
const propTypes: PropValidators<PropKeys> = {
|
|
61
|
+
/**
|
|
62
|
+
* Only accepts `<InlineList.Item>` as a child
|
|
63
|
+
*/
|
|
64
|
+
children: ChildrenPropTypes.oneOf([InlineListItem]),
|
|
65
|
+
as: PropTypes.oneOf(['ul', 'ol']),
|
|
66
|
+
/**
|
|
67
|
+
* Valid values are `0`, `none`, `auto`, `xxx-small`, `xx-small`, `x-small`,
|
|
68
|
+
* `small`, `medium`, `large`, `x-large`, `xx-large`. Apply these values via
|
|
69
|
+
* familiar CSS-like shorthand. For example: `margin="small auto large"`.
|
|
70
|
+
*/
|
|
71
|
+
margin: ThemeablePropTypes.spacing,
|
|
72
|
+
size: PropTypes.oneOf(['small', 'medium', 'large']),
|
|
73
|
+
delimiter: PropTypes.oneOf(['none', 'pipe', 'slash', 'arrow']),
|
|
74
|
+
/**
|
|
75
|
+
* Sets the margin separating each ListItem.
|
|
76
|
+
*/
|
|
77
|
+
itemSpacing: PropTypes.oneOf([
|
|
78
|
+
'none',
|
|
79
|
+
'xxx-small',
|
|
80
|
+
'xx-small',
|
|
81
|
+
'x-small',
|
|
82
|
+
'small',
|
|
83
|
+
'medium',
|
|
84
|
+
'large',
|
|
85
|
+
'x-large',
|
|
86
|
+
'xx-large'
|
|
87
|
+
]),
|
|
88
|
+
elementRef: PropTypes.func
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
const allowedProps: AllowedPropKeys = [
|
|
92
|
+
'children',
|
|
93
|
+
'as',
|
|
94
|
+
'margin',
|
|
95
|
+
'size',
|
|
96
|
+
'delimiter',
|
|
97
|
+
'itemSpacing',
|
|
98
|
+
'elementRef'
|
|
99
|
+
]
|
|
100
|
+
|
|
101
|
+
export type { InlineListProps }
|
|
102
|
+
export { propTypes, allowedProps }
|
|
@@ -24,17 +24,18 @@
|
|
|
24
24
|
|
|
25
25
|
/** @jsx jsx */
|
|
26
26
|
import { Component } from 'react'
|
|
27
|
-
import PropTypes from 'prop-types'
|
|
28
27
|
|
|
29
28
|
import { View } from '@instructure/ui-view'
|
|
30
29
|
import { testable } from '@instructure/ui-testable'
|
|
31
30
|
import { passthroughProps } from '@instructure/ui-react-utils'
|
|
32
31
|
|
|
33
|
-
import { withStyle, jsx
|
|
32
|
+
import { withStyle, jsx } from '@instructure/emotion'
|
|
34
33
|
|
|
35
34
|
import generateStyle from './styles'
|
|
36
35
|
import generateComponentTheme from './theme'
|
|
37
|
-
|
|
36
|
+
|
|
37
|
+
import { propTypes, allowedProps } from './props'
|
|
38
|
+
import type { ListItemProps } from './props'
|
|
38
39
|
|
|
39
40
|
/**
|
|
40
41
|
---
|
|
@@ -47,49 +48,10 @@ id: List.Item
|
|
|
47
48
|
class ListItem extends Component<ListItemProps> {
|
|
48
49
|
static readonly componentId = 'List.Item'
|
|
49
50
|
|
|
50
|
-
static propTypes =
|
|
51
|
-
|
|
52
|
-
makeStyles: PropTypes.func,
|
|
53
|
-
// eslint-disable-next-line react/require-default-props
|
|
54
|
-
styles: PropTypes.object,
|
|
55
|
-
children: PropTypes.oneOfType([PropTypes.node, PropTypes.func]).isRequired,
|
|
56
|
-
/**
|
|
57
|
-
* Inherits delimiter from the parent List component.
|
|
58
|
-
*/
|
|
59
|
-
delimiter: PropTypes.oneOf(['none', 'dashed', 'solid']),
|
|
60
|
-
size: PropTypes.oneOf(['small', 'medium', 'large']),
|
|
61
|
-
/**
|
|
62
|
-
* Valid values are `0`, `none`, `auto`, `xxx-small`, `xx-small`, `x-small`,
|
|
63
|
-
* `small`, `medium`, `large`, `x-large`, `xx-large`. Apply these values via
|
|
64
|
-
* familiar CSS-like shorthand. For example: `margin="small auto large"`.
|
|
65
|
-
*/
|
|
66
|
-
margin: ThemeablePropTypes.spacing,
|
|
67
|
-
/**
|
|
68
|
-
* Valid values are `0`, `none`, `xxx-small`, `xx-small`, `x-small`,
|
|
69
|
-
* `small`, `medium`, `large`, `x-large`, `xx-large`. Apply these values via
|
|
70
|
-
* familiar CSS-like shorthand. For example: `padding="small x-large large"`.
|
|
71
|
-
*/
|
|
72
|
-
padding: ThemeablePropTypes.spacing,
|
|
73
|
-
/**
|
|
74
|
-
* Inherits itemSpacing from the parent List component
|
|
75
|
-
*/
|
|
76
|
-
spacing: PropTypes.oneOf([
|
|
77
|
-
'none',
|
|
78
|
-
'xxx-small',
|
|
79
|
-
'xx-small',
|
|
80
|
-
'x-small',
|
|
81
|
-
'small',
|
|
82
|
-
'medium',
|
|
83
|
-
'large',
|
|
84
|
-
'x-large',
|
|
85
|
-
'xx-large'
|
|
86
|
-
]),
|
|
87
|
-
elementRef: PropTypes.func
|
|
88
|
-
}
|
|
89
|
-
|
|
51
|
+
static propTypes = propTypes
|
|
52
|
+
static allowedProps = allowedProps
|
|
90
53
|
static defaultProps = {
|
|
91
54
|
padding: 'none',
|
|
92
|
-
margin: undefined,
|
|
93
55
|
spacing: 'none',
|
|
94
56
|
delimiter: 'none',
|
|
95
57
|
size: 'medium',
|
|
@@ -124,7 +86,7 @@ class ListItem extends Component<ListItemProps> {
|
|
|
124
86
|
return (
|
|
125
87
|
<View
|
|
126
88
|
{...passthroughProps(rest)}
|
|
127
|
-
css={styles
|
|
89
|
+
css={styles?.listItem}
|
|
128
90
|
as="li"
|
|
129
91
|
margin={margin}
|
|
130
92
|
padding={padding}
|
|
@@ -0,0 +1,105 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* The MIT License (MIT)
|
|
3
|
+
*
|
|
4
|
+
* Copyright (c) 2015 - present Instructure, Inc.
|
|
5
|
+
*
|
|
6
|
+
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
7
|
+
* of this software and associated documentation files (the "Software"), to deal
|
|
8
|
+
* in the Software without restriction, including without limitation the rights
|
|
9
|
+
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
10
|
+
* copies of the Software, and to permit persons to whom the Software is
|
|
11
|
+
* furnished to do so, subject to the following conditions:
|
|
12
|
+
*
|
|
13
|
+
* The above copyright notice and this permission notice shall be included in all
|
|
14
|
+
* copies or substantial portions of the Software.
|
|
15
|
+
*
|
|
16
|
+
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
17
|
+
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
18
|
+
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
19
|
+
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
20
|
+
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
21
|
+
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
22
|
+
* SOFTWARE.
|
|
23
|
+
*/
|
|
24
|
+
|
|
25
|
+
import React from 'react'
|
|
26
|
+
import PropTypes from 'prop-types'
|
|
27
|
+
|
|
28
|
+
import { ThemeablePropTypes } from '@instructure/emotion'
|
|
29
|
+
|
|
30
|
+
import type { Spacing, WithStyleProps } from '@instructure/emotion'
|
|
31
|
+
import type { PropValidators } from '@instructure/shared-types'
|
|
32
|
+
|
|
33
|
+
type ListItemOwnProps = {
|
|
34
|
+
children: React.ReactNode | ((...args: any[]) => React.ReactNode)
|
|
35
|
+
delimiter?: 'none' | 'dashed' | 'solid'
|
|
36
|
+
size?: 'small' | 'medium' | 'large'
|
|
37
|
+
margin?: Spacing
|
|
38
|
+
padding?: Spacing
|
|
39
|
+
spacing?:
|
|
40
|
+
| 'none'
|
|
41
|
+
| 'xxx-small'
|
|
42
|
+
| 'xx-small'
|
|
43
|
+
| 'x-small'
|
|
44
|
+
| 'small'
|
|
45
|
+
| 'medium'
|
|
46
|
+
| 'large'
|
|
47
|
+
| 'x-large'
|
|
48
|
+
| 'xx-large'
|
|
49
|
+
elementRef?: (...args: any[]) => any
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
type PropKeys = keyof ListItemOwnProps
|
|
53
|
+
|
|
54
|
+
type AllowedPropKeys = Readonly<Array<PropKeys>>
|
|
55
|
+
|
|
56
|
+
type ListItemProps = ListItemOwnProps & WithStyleProps
|
|
57
|
+
|
|
58
|
+
const propTypes: PropValidators<PropKeys> = {
|
|
59
|
+
children: PropTypes.oneOfType([PropTypes.node, PropTypes.func]).isRequired,
|
|
60
|
+
/**
|
|
61
|
+
* Inherits delimiter from the parent List component.
|
|
62
|
+
*/
|
|
63
|
+
delimiter: PropTypes.oneOf(['none', 'dashed', 'solid']),
|
|
64
|
+
size: PropTypes.oneOf(['small', 'medium', 'large']),
|
|
65
|
+
/**
|
|
66
|
+
* Valid values are `0`, `none`, `auto`, `xxx-small`, `xx-small`, `x-small`,
|
|
67
|
+
* `small`, `medium`, `large`, `x-large`, `xx-large`. Apply these values via
|
|
68
|
+
* familiar CSS-like shorthand. For example: `margin="small auto large"`.
|
|
69
|
+
*/
|
|
70
|
+
margin: ThemeablePropTypes.spacing,
|
|
71
|
+
/**
|
|
72
|
+
* Valid values are `0`, `none`, `xxx-small`, `xx-small`, `x-small`,
|
|
73
|
+
* `small`, `medium`, `large`, `x-large`, `xx-large`. Apply these values via
|
|
74
|
+
* familiar CSS-like shorthand. For example: `padding="small x-large large"`.
|
|
75
|
+
*/
|
|
76
|
+
padding: ThemeablePropTypes.spacing,
|
|
77
|
+
/**
|
|
78
|
+
* Inherits itemSpacing from the parent List component
|
|
79
|
+
*/
|
|
80
|
+
spacing: PropTypes.oneOf([
|
|
81
|
+
'none',
|
|
82
|
+
'xxx-small',
|
|
83
|
+
'xx-small',
|
|
84
|
+
'x-small',
|
|
85
|
+
'small',
|
|
86
|
+
'medium',
|
|
87
|
+
'large',
|
|
88
|
+
'x-large',
|
|
89
|
+
'xx-large'
|
|
90
|
+
]),
|
|
91
|
+
elementRef: PropTypes.func
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
const allowedProps: AllowedPropKeys = [
|
|
95
|
+
'children',
|
|
96
|
+
'delimiter',
|
|
97
|
+
'size',
|
|
98
|
+
'margin',
|
|
99
|
+
'padding',
|
|
100
|
+
'spacing',
|
|
101
|
+
'elementRef'
|
|
102
|
+
]
|
|
103
|
+
|
|
104
|
+
export type { ListItemProps }
|
|
105
|
+
export { propTypes, allowedProps }
|
package/src/List/index.tsx
CHANGED
|
@@ -24,20 +24,20 @@
|
|
|
24
24
|
|
|
25
25
|
/** @jsx jsx */
|
|
26
26
|
import { Children, Component, ReactElement } from 'react'
|
|
27
|
-
import PropTypes from 'prop-types'
|
|
28
27
|
|
|
29
28
|
import { View } from '@instructure/ui-view'
|
|
30
29
|
import { passthroughProps, safeCloneElement } from '@instructure/ui-react-utils'
|
|
31
|
-
import { Children as ChildrenPropTypes } from '@instructure/ui-prop-types'
|
|
32
30
|
import { testable } from '@instructure/ui-testable'
|
|
33
31
|
|
|
34
32
|
import { ListItem } from './ListItem'
|
|
35
33
|
|
|
36
|
-
import { withStyle, jsx
|
|
34
|
+
import { withStyle, jsx } from '@instructure/emotion'
|
|
37
35
|
|
|
38
36
|
import generateStyle from './styles'
|
|
39
37
|
import generateComponentTheme from './theme'
|
|
40
|
-
|
|
38
|
+
|
|
39
|
+
import { propTypes, allowedProps } from './props'
|
|
40
|
+
import type { ListProps } from './props'
|
|
41
41
|
|
|
42
42
|
/**
|
|
43
43
|
---
|
|
@@ -49,54 +49,13 @@ category: components
|
|
|
49
49
|
class List extends Component<ListProps> {
|
|
50
50
|
static readonly componentId = 'List'
|
|
51
51
|
|
|
52
|
-
static propTypes =
|
|
53
|
-
|
|
54
|
-
makeStyles: PropTypes.func,
|
|
55
|
-
// eslint-disable-next-line react/require-default-props
|
|
56
|
-
styles: PropTypes.object,
|
|
57
|
-
/**
|
|
58
|
-
* Only accepts `<List.Item>` as a child
|
|
59
|
-
*/
|
|
60
|
-
children: ChildrenPropTypes.oneOf([ListItem]),
|
|
61
|
-
as: PropTypes.oneOf(['ul', 'ol']),
|
|
62
|
-
/**
|
|
63
|
-
* One of: none, dashed, solid
|
|
64
|
-
*/
|
|
65
|
-
delimiter: PropTypes.oneOf(['none', 'dashed', 'solid']),
|
|
66
|
-
/**
|
|
67
|
-
* When set, renders the List Items without a list style type.
|
|
68
|
-
*/
|
|
69
|
-
isUnstyled: PropTypes.bool,
|
|
70
|
-
/**
|
|
71
|
-
* Valid values are `0`, `none`, `auto`, `xxx-small`, `xx-small`, `x-small`,
|
|
72
|
-
* `small`, `medium`, `large`, `x-large`, `xx-large`. Apply these values via
|
|
73
|
-
* familiar CSS-like shorthand. For example: `margin="small auto large"`.
|
|
74
|
-
*/
|
|
75
|
-
margin: ThemeablePropTypes.spacing,
|
|
76
|
-
size: PropTypes.oneOf(['small', 'medium', 'large']),
|
|
77
|
-
/**
|
|
78
|
-
* Sets the margin separating each ListItem.
|
|
79
|
-
*/
|
|
80
|
-
itemSpacing: PropTypes.oneOf([
|
|
81
|
-
'none',
|
|
82
|
-
'xxx-small',
|
|
83
|
-
'xx-small',
|
|
84
|
-
'x-small',
|
|
85
|
-
'small',
|
|
86
|
-
'medium',
|
|
87
|
-
'large',
|
|
88
|
-
'x-large',
|
|
89
|
-
'xx-large'
|
|
90
|
-
]),
|
|
91
|
-
elementRef: PropTypes.func
|
|
92
|
-
}
|
|
93
|
-
|
|
52
|
+
static propTypes = propTypes
|
|
53
|
+
static allowedProps = allowedProps
|
|
94
54
|
static defaultProps = {
|
|
95
55
|
children: null,
|
|
96
56
|
as: 'ul',
|
|
97
57
|
delimiter: 'none',
|
|
98
58
|
isUnstyled: false,
|
|
99
|
-
margin: undefined,
|
|
100
59
|
size: 'medium',
|
|
101
60
|
itemSpacing: 'none',
|
|
102
61
|
// @ts-expect-error ts-migrate(6133) FIXME: 'el' is declared but its value is never read.
|
|
@@ -135,7 +94,7 @@ class List extends Component<ListProps> {
|
|
|
135
94
|
return (
|
|
136
95
|
<View
|
|
137
96
|
{...passthroughProps(rest)}
|
|
138
|
-
css={styles
|
|
97
|
+
css={styles?.list}
|
|
139
98
|
as={as}
|
|
140
99
|
margin={margin}
|
|
141
100
|
elementRef={elementRef}
|
|
@@ -0,0 +1,111 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* The MIT License (MIT)
|
|
3
|
+
*
|
|
4
|
+
* Copyright (c) 2015 - present Instructure, Inc.
|
|
5
|
+
*
|
|
6
|
+
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
7
|
+
* of this software and associated documentation files (the "Software"), to deal
|
|
8
|
+
* in the Software without restriction, including without limitation the rights
|
|
9
|
+
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
10
|
+
* copies of the Software, and to permit persons to whom the Software is
|
|
11
|
+
* furnished to do so, subject to the following conditions:
|
|
12
|
+
*
|
|
13
|
+
* The above copyright notice and this permission notice shall be included in all
|
|
14
|
+
* copies or substantial portions of the Software.
|
|
15
|
+
*
|
|
16
|
+
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
17
|
+
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
18
|
+
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
19
|
+
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
20
|
+
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
21
|
+
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
22
|
+
* SOFTWARE.
|
|
23
|
+
*/
|
|
24
|
+
|
|
25
|
+
import PropTypes from 'prop-types'
|
|
26
|
+
|
|
27
|
+
import { Children as ChildrenPropTypes } from '@instructure/ui-prop-types'
|
|
28
|
+
import { ThemeablePropTypes } from '@instructure/emotion'
|
|
29
|
+
import { ListItem } from './ListItem'
|
|
30
|
+
|
|
31
|
+
import type { Spacing, WithStyleProps } from '@instructure/emotion'
|
|
32
|
+
import type { PropValidators } from '@instructure/shared-types'
|
|
33
|
+
import React from 'react'
|
|
34
|
+
|
|
35
|
+
type ListOwnProps = {
|
|
36
|
+
children?: React.ReactNode // TODO: oneOf([ListItem])
|
|
37
|
+
as?: 'ul' | 'ol'
|
|
38
|
+
delimiter?: 'none' | 'dashed' | 'solid'
|
|
39
|
+
isUnstyled?: boolean
|
|
40
|
+
margin?: Spacing
|
|
41
|
+
size?: 'small' | 'medium' | 'large'
|
|
42
|
+
itemSpacing?:
|
|
43
|
+
| 'none'
|
|
44
|
+
| 'xxx-small'
|
|
45
|
+
| 'xx-small'
|
|
46
|
+
| 'x-small'
|
|
47
|
+
| 'small'
|
|
48
|
+
| 'medium'
|
|
49
|
+
| 'large'
|
|
50
|
+
| 'x-large'
|
|
51
|
+
| 'xx-large'
|
|
52
|
+
elementRef?: (...args: any[]) => any
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
type PropKeys = keyof ListOwnProps
|
|
56
|
+
|
|
57
|
+
type AllowedPropKeys = Readonly<Array<PropKeys>>
|
|
58
|
+
|
|
59
|
+
type ListProps = ListOwnProps & WithStyleProps
|
|
60
|
+
|
|
61
|
+
const propTypes: PropValidators<PropKeys> = {
|
|
62
|
+
/**
|
|
63
|
+
* Only accepts `<List.Item>` as a child
|
|
64
|
+
*/
|
|
65
|
+
children: ChildrenPropTypes.oneOf([ListItem]),
|
|
66
|
+
as: PropTypes.oneOf(['ul', 'ol']),
|
|
67
|
+
/**
|
|
68
|
+
* One of: none, dashed, solid
|
|
69
|
+
*/
|
|
70
|
+
delimiter: PropTypes.oneOf(['none', 'dashed', 'solid']),
|
|
71
|
+
/**
|
|
72
|
+
* When set, renders the List Items without a list style type.
|
|
73
|
+
*/
|
|
74
|
+
isUnstyled: PropTypes.bool,
|
|
75
|
+
/**
|
|
76
|
+
* Valid values are `0`, `none`, `auto`, `xxx-small`, `xx-small`, `x-small`,
|
|
77
|
+
* `small`, `medium`, `large`, `x-large`, `xx-large`. Apply these values via
|
|
78
|
+
* familiar CSS-like shorthand. For example: `margin="small auto large"`.
|
|
79
|
+
*/
|
|
80
|
+
margin: ThemeablePropTypes.spacing,
|
|
81
|
+
size: PropTypes.oneOf(['small', 'medium', 'large']),
|
|
82
|
+
/**
|
|
83
|
+
* Sets the margin separating each ListItem.
|
|
84
|
+
*/
|
|
85
|
+
itemSpacing: PropTypes.oneOf([
|
|
86
|
+
'none',
|
|
87
|
+
'xxx-small',
|
|
88
|
+
'xx-small',
|
|
89
|
+
'x-small',
|
|
90
|
+
'small',
|
|
91
|
+
'medium',
|
|
92
|
+
'large',
|
|
93
|
+
'x-large',
|
|
94
|
+
'xx-large'
|
|
95
|
+
]),
|
|
96
|
+
elementRef: PropTypes.func
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
const allowedProps: AllowedPropKeys = [
|
|
100
|
+
'children',
|
|
101
|
+
'as',
|
|
102
|
+
'delimiter',
|
|
103
|
+
'isUnstyled',
|
|
104
|
+
'margin',
|
|
105
|
+
'size',
|
|
106
|
+
'itemSpacing',
|
|
107
|
+
'elementRef'
|
|
108
|
+
]
|
|
109
|
+
|
|
110
|
+
export type { ListProps }
|
|
111
|
+
export { propTypes, allowedProps }
|