@instructure/ui-list 11.6.0 → 11.6.1-snapshot-129
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/CHANGELOG.md +38 -288
- package/es/InlineList/{InlineListItem → v1/InlineListItem}/index.js +2 -2
- package/es/InlineList/{index.js → v1/index.js} +1 -1
- package/es/InlineList/v2/InlineListItem/index.js +97 -0
- package/es/InlineList/v2/InlineListItem/styles.js +143 -0
- package/es/InlineList/v2/index.js +93 -0
- package/es/{index.js → InlineList/v2/props.js} +3 -3
- package/es/List/{ListItem → v1/ListItem}/index.js +2 -2
- package/es/List/v1/ListItem/props.js +28 -0
- package/es/List/{index.js → v1/index.js} +2 -2
- package/es/List/v2/ListItem/index.js +91 -0
- package/es/List/v2/ListItem/props.js +28 -0
- package/es/List/v2/ListItem/styles.js +131 -0
- package/es/List/v2/index.js +100 -0
- package/es/List/v2/props.js +26 -0
- package/es/List/v2/styles.js +66 -0
- package/es/exports/a.js +26 -0
- package/es/exports/b.js +26 -0
- package/lib/InlineList/{InlineListItem → v1/InlineListItem}/index.js +3 -3
- package/lib/InlineList/{index.js → v1/index.js} +2 -2
- package/lib/InlineList/v2/InlineListItem/index.js +102 -0
- package/lib/InlineList/v2/InlineListItem/styles.js +149 -0
- package/lib/InlineList/v2/index.js +101 -0
- package/lib/InlineList/v2/props.js +31 -0
- package/lib/List/{ListItem → v1/ListItem}/index.js +3 -3
- package/lib/List/v1/ListItem/props.js +33 -0
- package/lib/List/v1/index.js +114 -0
- package/lib/List/v2/ListItem/index.js +96 -0
- package/lib/List/v2/ListItem/props.js +33 -0
- package/lib/List/v2/ListItem/styles.js +137 -0
- package/lib/List/{index.js → v2/index.js} +4 -5
- package/lib/List/v2/props.js +31 -0
- package/lib/List/v2/styles.js +72 -0
- package/lib/{index.js → exports/a.js} +6 -6
- package/lib/exports/b.js +32 -0
- package/package.json +39 -17
- package/src/InlineList/{InlineListItem → v1/InlineListItem}/index.tsx +2 -2
- package/src/InlineList/{index.tsx → v1/index.tsx} +1 -1
- package/src/InlineList/v2/InlineListItem/index.tsx +110 -0
- package/src/InlineList/v2/InlineListItem/props.ts +99 -0
- package/src/InlineList/v2/InlineListItem/styles.ts +142 -0
- package/src/InlineList/v2/README.md +146 -0
- package/src/InlineList/v2/index.tsx +102 -0
- package/src/InlineList/v2/props.ts +80 -0
- package/src/List/{ListItem → v1/ListItem}/index.tsx +2 -2
- package/src/List/{index.tsx → v1/index.tsx} +2 -2
- package/src/List/v2/ListItem/index.tsx +104 -0
- package/src/List/v2/ListItem/props.ts +94 -0
- package/src/List/v2/ListItem/styles.ts +136 -0
- package/src/List/v2/README.md +142 -0
- package/src/List/v2/index.tsx +109 -0
- package/src/List/v2/props.ts +95 -0
- package/src/List/v2/styles.ts +77 -0
- package/src/exports/a.ts +32 -0
- package/src/exports/b.ts +32 -0
- package/tsconfig.build.tsbuildinfo +1 -1
- package/types/InlineList/v1/InlineListItem/index.d.ts.map +1 -0
- package/types/InlineList/v1/InlineListItem/props.d.ts.map +1 -0
- package/types/InlineList/v1/InlineListItem/styles.d.ts.map +1 -0
- package/types/InlineList/v1/InlineListItem/theme.d.ts.map +1 -0
- package/types/InlineList/v1/index.d.ts.map +1 -0
- package/types/InlineList/v1/props.d.ts.map +1 -0
- package/types/InlineList/v2/InlineListItem/index.d.ts +27 -0
- package/types/InlineList/v2/InlineListItem/index.d.ts.map +1 -0
- package/types/InlineList/v2/InlineListItem/props.d.ts +42 -0
- package/types/InlineList/v2/InlineListItem/props.d.ts.map +1 -0
- package/types/InlineList/v2/InlineListItem/styles.d.ts +14 -0
- package/types/InlineList/v2/InlineListItem/styles.d.ts.map +1 -0
- package/types/InlineList/v2/index.d.ts +35 -0
- package/types/InlineList/v2/index.d.ts.map +1 -0
- package/types/InlineList/v2/props.d.ts +33 -0
- package/types/InlineList/v2/props.d.ts.map +1 -0
- package/types/List/v1/ListItem/index.d.ts.map +1 -0
- package/types/List/v1/ListItem/props.d.ts.map +1 -0
- package/types/List/v1/ListItem/styles.d.ts.map +1 -0
- package/types/List/v1/ListItem/theme.d.ts.map +1 -0
- package/types/List/v1/index.d.ts.map +1 -0
- package/types/List/v1/props.d.ts.map +1 -0
- package/types/List/v1/styles.d.ts.map +1 -0
- package/types/List/v1/theme.d.ts.map +1 -0
- package/types/List/v2/ListItem/index.d.ts +26 -0
- package/types/List/v2/ListItem/index.d.ts.map +1 -0
- package/types/List/v2/ListItem/props.d.ts +38 -0
- package/types/List/v2/ListItem/props.d.ts.map +1 -0
- package/types/List/v2/ListItem/styles.d.ts +14 -0
- package/types/List/v2/ListItem/styles.d.ts.map +1 -0
- package/types/List/v2/index.d.ts +38 -0
- package/types/List/v2/index.d.ts.map +1 -0
- package/types/List/v2/props.d.ts +41 -0
- package/types/List/v2/props.d.ts.map +1 -0
- package/types/List/v2/styles.d.ts +15 -0
- package/types/List/v2/styles.d.ts.map +1 -0
- package/types/exports/a.d.ts +8 -0
- package/types/exports/a.d.ts.map +1 -0
- package/types/exports/b.d.ts +8 -0
- package/types/exports/b.d.ts.map +1 -0
- package/src/index.ts +0 -32
- package/types/InlineList/InlineListItem/index.d.ts.map +0 -1
- package/types/InlineList/InlineListItem/props.d.ts.map +0 -1
- package/types/InlineList/InlineListItem/styles.d.ts.map +0 -1
- package/types/InlineList/InlineListItem/theme.d.ts.map +0 -1
- package/types/InlineList/index.d.ts.map +0 -1
- package/types/InlineList/props.d.ts.map +0 -1
- package/types/List/ListItem/index.d.ts.map +0 -1
- package/types/List/ListItem/props.d.ts.map +0 -1
- package/types/List/ListItem/styles.d.ts.map +0 -1
- package/types/List/ListItem/theme.d.ts.map +0 -1
- package/types/List/index.d.ts.map +0 -1
- package/types/List/props.d.ts.map +0 -1
- package/types/List/styles.d.ts.map +0 -1
- package/types/List/theme.d.ts.map +0 -1
- package/types/index.d.ts +0 -8
- package/types/index.d.ts.map +0 -1
- /package/es/InlineList/{InlineListItem → v1/InlineListItem}/props.js +0 -0
- /package/es/InlineList/{InlineListItem → v1/InlineListItem}/styles.js +0 -0
- /package/es/InlineList/{InlineListItem → v1/InlineListItem}/theme.js +0 -0
- /package/es/InlineList/{props.js → v1/props.js} +0 -0
- /package/es/{List/ListItem → InlineList/v2/InlineListItem}/props.js +0 -0
- /package/es/List/{ListItem → v1/ListItem}/styles.js +0 -0
- /package/es/List/{ListItem → v1/ListItem}/theme.js +0 -0
- /package/es/List/{props.js → v1/props.js} +0 -0
- /package/es/List/{styles.js → v1/styles.js} +0 -0
- /package/es/List/{theme.js → v1/theme.js} +0 -0
- /package/lib/InlineList/{InlineListItem → v1/InlineListItem}/props.js +0 -0
- /package/lib/InlineList/{InlineListItem → v1/InlineListItem}/styles.js +0 -0
- /package/lib/InlineList/{InlineListItem → v1/InlineListItem}/theme.js +0 -0
- /package/lib/InlineList/{props.js → v1/props.js} +0 -0
- /package/lib/{List/ListItem → InlineList/v2/InlineListItem}/props.js +0 -0
- /package/lib/List/{ListItem → v1/ListItem}/styles.js +0 -0
- /package/lib/List/{ListItem → v1/ListItem}/theme.js +0 -0
- /package/lib/List/{props.js → v1/props.js} +0 -0
- /package/lib/List/{styles.js → v1/styles.js} +0 -0
- /package/lib/List/{theme.js → v1/theme.js} +0 -0
- /package/src/InlineList/{InlineListItem → v1/InlineListItem}/props.ts +0 -0
- /package/src/InlineList/{InlineListItem → v1/InlineListItem}/styles.ts +0 -0
- /package/src/InlineList/{InlineListItem → v1/InlineListItem}/theme.ts +0 -0
- /package/src/InlineList/{README.md → v1/README.md} +0 -0
- /package/src/InlineList/{props.ts → v1/props.ts} +0 -0
- /package/src/List/{ListItem → v1/ListItem}/props.ts +0 -0
- /package/src/List/{ListItem → v1/ListItem}/styles.ts +0 -0
- /package/src/List/{ListItem → v1/ListItem}/theme.ts +0 -0
- /package/src/List/{README.md → v1/README.md} +0 -0
- /package/src/List/{props.ts → v1/props.ts} +0 -0
- /package/src/List/{styles.ts → v1/styles.ts} +0 -0
- /package/src/List/{theme.ts → v1/theme.ts} +0 -0
- /package/types/InlineList/{InlineListItem → v1/InlineListItem}/index.d.ts +0 -0
- /package/types/InlineList/{InlineListItem → v1/InlineListItem}/props.d.ts +0 -0
- /package/types/InlineList/{InlineListItem → v1/InlineListItem}/styles.d.ts +0 -0
- /package/types/InlineList/{InlineListItem → v1/InlineListItem}/theme.d.ts +0 -0
- /package/types/InlineList/{index.d.ts → v1/index.d.ts} +0 -0
- /package/types/InlineList/{props.d.ts → v1/props.d.ts} +0 -0
- /package/types/List/{ListItem → v1/ListItem}/index.d.ts +0 -0
- /package/types/List/{ListItem → v1/ListItem}/props.d.ts +0 -0
- /package/types/List/{ListItem → v1/ListItem}/styles.d.ts +0 -0
- /package/types/List/{ListItem → v1/ListItem}/theme.d.ts +0 -0
- /package/types/List/{index.d.ts → v1/index.d.ts} +0 -0
- /package/types/List/{props.d.ts → v1/props.d.ts} +0 -0
- /package/types/List/{styles.d.ts → v1/styles.d.ts} +0 -0
- /package/types/List/{theme.d.ts → v1/theme.d.ts} +0 -0
|
@@ -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
|
+
import { Children, Component, ReactElement } from 'react'
|
|
25
|
+
|
|
26
|
+
import { View } from '@instructure/ui-view/latest'
|
|
27
|
+
import { passthroughProps, safeCloneElement } from '@instructure/ui-react-utils'
|
|
28
|
+
|
|
29
|
+
import { InlineListItem } from './InlineListItem'
|
|
30
|
+
|
|
31
|
+
import { allowedProps } from './props'
|
|
32
|
+
import type { InlineListProps } from './props'
|
|
33
|
+
|
|
34
|
+
/**
|
|
35
|
+
---
|
|
36
|
+
category: components
|
|
37
|
+
---
|
|
38
|
+
|
|
39
|
+
**/
|
|
40
|
+
class InlineList extends Component<InlineListProps> {
|
|
41
|
+
static allowedProps = allowedProps
|
|
42
|
+
static defaultProps = {
|
|
43
|
+
itemSpacing: 'none',
|
|
44
|
+
as: 'ul',
|
|
45
|
+
margin: 'none',
|
|
46
|
+
delimiter: 'none',
|
|
47
|
+
size: 'medium'
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
static Item = InlineListItem
|
|
51
|
+
|
|
52
|
+
ref: Element | null = null
|
|
53
|
+
|
|
54
|
+
handleRef = (el: Element | null) => {
|
|
55
|
+
const { elementRef } = this.props
|
|
56
|
+
|
|
57
|
+
this.ref = el
|
|
58
|
+
|
|
59
|
+
if (typeof elementRef === 'function') {
|
|
60
|
+
elementRef(el)
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
renderChildren() {
|
|
65
|
+
const childrenArray = Children.toArray(this.props.children)
|
|
66
|
+
const lastIndex = childrenArray.length - 1
|
|
67
|
+
|
|
68
|
+
return childrenArray.map((child, index) => {
|
|
69
|
+
if (!child) return null
|
|
70
|
+
|
|
71
|
+
const shouldRenderPlaceholder = index === lastIndex
|
|
72
|
+
|
|
73
|
+
return safeCloneElement(child as ReactElement, {
|
|
74
|
+
delimiter: this.props.delimiter,
|
|
75
|
+
size: this.props.size,
|
|
76
|
+
spacing: this.props.itemSpacing,
|
|
77
|
+
lastPlaceholder: shouldRenderPlaceholder
|
|
78
|
+
})
|
|
79
|
+
})
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
render() {
|
|
83
|
+
const { as, margin, elementRef, ...rest } = this.props
|
|
84
|
+
|
|
85
|
+
return (
|
|
86
|
+
<View
|
|
87
|
+
{...passthroughProps(rest)}
|
|
88
|
+
as={as}
|
|
89
|
+
margin={margin}
|
|
90
|
+
padding="0"
|
|
91
|
+
elementRef={this.handleRef}
|
|
92
|
+
display="block"
|
|
93
|
+
data-cid="InlineList"
|
|
94
|
+
>
|
|
95
|
+
{this.renderChildren()}
|
|
96
|
+
</View>
|
|
97
|
+
)
|
|
98
|
+
}
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
export default InlineList
|
|
102
|
+
export { InlineList }
|
|
@@ -0,0 +1,80 @@
|
|
|
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 type { Spacing } from '@instructure/emotion'
|
|
27
|
+
import type { OtherHTMLAttributes } from '@instructure/shared-types'
|
|
28
|
+
|
|
29
|
+
type InlineListOwnProps = {
|
|
30
|
+
/**
|
|
31
|
+
* Only accepts `<InlineList.Item>` as a child
|
|
32
|
+
*/
|
|
33
|
+
//TODO type children better e.g.:ChildrenPropTypes.oneOf([InlineListItem])
|
|
34
|
+
children?: React.ReactNode
|
|
35
|
+
as?: 'ul' | 'ol'
|
|
36
|
+
/**
|
|
37
|
+
* Valid values are `0`, `none`, `auto`, `xxx-small`, `xx-small`, `x-small`,
|
|
38
|
+
* `small`, `medium`, `large`, `x-large`, `xx-large`. Apply these values via
|
|
39
|
+
* familiar CSS-like shorthand. For example: `margin="small auto large"`.
|
|
40
|
+
*/
|
|
41
|
+
margin?: Spacing
|
|
42
|
+
size?: 'small' | 'medium' | 'large'
|
|
43
|
+
delimiter?: 'none' | 'pipe' | 'slash' | 'arrow'
|
|
44
|
+
/**
|
|
45
|
+
* Sets the margin separating each ListItem.
|
|
46
|
+
*/
|
|
47
|
+
itemSpacing?:
|
|
48
|
+
| 'none'
|
|
49
|
+
| 'xxx-small'
|
|
50
|
+
| 'xx-small'
|
|
51
|
+
| 'x-small'
|
|
52
|
+
| 'small'
|
|
53
|
+
| 'medium'
|
|
54
|
+
| 'large'
|
|
55
|
+
| 'x-large'
|
|
56
|
+
| 'xx-large'
|
|
57
|
+
/**
|
|
58
|
+
* provides a reference to the underlying html root element
|
|
59
|
+
*/
|
|
60
|
+
elementRef?: (element: Element | null) => void
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
type PropKeys = keyof InlineListOwnProps
|
|
64
|
+
|
|
65
|
+
type AllowedPropKeys = Readonly<Array<PropKeys>>
|
|
66
|
+
|
|
67
|
+
type InlineListProps = InlineListOwnProps &
|
|
68
|
+
OtherHTMLAttributes<InlineListOwnProps>
|
|
69
|
+
const allowedProps: AllowedPropKeys = [
|
|
70
|
+
'children',
|
|
71
|
+
'as',
|
|
72
|
+
'margin',
|
|
73
|
+
'size',
|
|
74
|
+
'delimiter',
|
|
75
|
+
'itemSpacing',
|
|
76
|
+
'elementRef'
|
|
77
|
+
]
|
|
78
|
+
|
|
79
|
+
export type { InlineListProps }
|
|
80
|
+
export { allowedProps }
|
|
@@ -24,10 +24,10 @@
|
|
|
24
24
|
|
|
25
25
|
import { Component } from 'react'
|
|
26
26
|
|
|
27
|
-
import { View } from '@instructure/ui-view'
|
|
27
|
+
import { View } from '@instructure/ui-view/v11_6'
|
|
28
28
|
import { passthroughProps } from '@instructure/ui-react-utils'
|
|
29
29
|
|
|
30
|
-
import { withStyle } from '@instructure/emotion'
|
|
30
|
+
import { withStyleLegacy as withStyle } from '@instructure/emotion'
|
|
31
31
|
|
|
32
32
|
import generateStyle from './styles'
|
|
33
33
|
import generateComponentTheme from './theme'
|
|
@@ -24,12 +24,12 @@
|
|
|
24
24
|
|
|
25
25
|
import { Children, Component, ReactElement } from 'react'
|
|
26
26
|
|
|
27
|
-
import { View } from '@instructure/ui-view'
|
|
27
|
+
import { View } from '@instructure/ui-view/v11_6'
|
|
28
28
|
import { passthroughProps, safeCloneElement } from '@instructure/ui-react-utils'
|
|
29
29
|
|
|
30
30
|
import { ListItem } from './ListItem'
|
|
31
31
|
|
|
32
|
-
import { withStyle } from '@instructure/emotion'
|
|
32
|
+
import { withStyleLegacy as withStyle } from '@instructure/emotion'
|
|
33
33
|
|
|
34
34
|
import generateStyle from './styles'
|
|
35
35
|
import generateComponentTheme from './theme'
|
|
@@ -0,0 +1,104 @@
|
|
|
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 { Component } from 'react'
|
|
26
|
+
|
|
27
|
+
import { View } from '@instructure/ui-view/latest'
|
|
28
|
+
import { passthroughProps } from '@instructure/ui-react-utils'
|
|
29
|
+
import { withStyle } from '@instructure/emotion'
|
|
30
|
+
|
|
31
|
+
import generateStyle from './styles'
|
|
32
|
+
import { allowedProps } from './props'
|
|
33
|
+
import type { ListItemProps } from './props'
|
|
34
|
+
|
|
35
|
+
/**
|
|
36
|
+
---
|
|
37
|
+
parent: List
|
|
38
|
+
id: List.Item
|
|
39
|
+
---
|
|
40
|
+
**/
|
|
41
|
+
@withStyle(generateStyle)
|
|
42
|
+
class ListItem extends Component<ListItemProps> {
|
|
43
|
+
static readonly componentId = 'List.Item'
|
|
44
|
+
|
|
45
|
+
static allowedProps = allowedProps
|
|
46
|
+
static defaultProps = {
|
|
47
|
+
padding: 'none',
|
|
48
|
+
spacing: 'none',
|
|
49
|
+
delimiter: 'none',
|
|
50
|
+
size: 'medium'
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
ref: Element | null = null
|
|
54
|
+
|
|
55
|
+
handleRef = (el: Element | null) => {
|
|
56
|
+
const { elementRef } = this.props
|
|
57
|
+
|
|
58
|
+
this.ref = el
|
|
59
|
+
|
|
60
|
+
if (typeof elementRef === 'function') {
|
|
61
|
+
elementRef(el)
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
componentDidMount() {
|
|
66
|
+
this.props.makeStyles?.()
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
componentDidUpdate() {
|
|
70
|
+
this.props.makeStyles?.()
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
render() {
|
|
74
|
+
const {
|
|
75
|
+
delimiter,
|
|
76
|
+
spacing,
|
|
77
|
+
size,
|
|
78
|
+
margin,
|
|
79
|
+
padding,
|
|
80
|
+
elementRef,
|
|
81
|
+
children,
|
|
82
|
+
styles,
|
|
83
|
+
...rest
|
|
84
|
+
} = this.props
|
|
85
|
+
|
|
86
|
+
return (
|
|
87
|
+
<View
|
|
88
|
+
{...passthroughProps(rest)}
|
|
89
|
+
css={styles?.listItem}
|
|
90
|
+
as="li"
|
|
91
|
+
margin={margin}
|
|
92
|
+
padding={padding}
|
|
93
|
+
maxWidth="100%"
|
|
94
|
+
elementRef={this.handleRef}
|
|
95
|
+
data-cid="ListItem"
|
|
96
|
+
>
|
|
97
|
+
{children}
|
|
98
|
+
</View>
|
|
99
|
+
)
|
|
100
|
+
}
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
export default ListItem
|
|
104
|
+
export { ListItem }
|
|
@@ -0,0 +1,94 @@
|
|
|
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 { PropsWithChildren } from 'react'
|
|
26
|
+
|
|
27
|
+
import type {
|
|
28
|
+
Spacing,
|
|
29
|
+
WithStyleProps,
|
|
30
|
+
ComponentStyle
|
|
31
|
+
} from '@instructure/emotion'
|
|
32
|
+
import type {
|
|
33
|
+
ListItemTheme,
|
|
34
|
+
OtherHTMLAttributes
|
|
35
|
+
} from '@instructure/shared-types'
|
|
36
|
+
|
|
37
|
+
type ListItemOwnProps = {
|
|
38
|
+
/**
|
|
39
|
+
* Inherits delimiter from the parent List component.
|
|
40
|
+
*/
|
|
41
|
+
delimiter?: 'none' | 'dashed' | 'solid'
|
|
42
|
+
size?: 'small' | 'medium' | 'large'
|
|
43
|
+
/**
|
|
44
|
+
* Valid values are `0`, `none`, `auto`, `xxx-small`, `xx-small`, `x-small`,
|
|
45
|
+
* `small`, `medium`, `large`, `x-large`, `xx-large`. Apply these values via
|
|
46
|
+
* familiar CSS-like shorthand. For example: `margin="small auto large"`.
|
|
47
|
+
*/
|
|
48
|
+
margin?: Spacing
|
|
49
|
+
/**
|
|
50
|
+
* Valid values are `0`, `none`, `xxx-small`, `xx-small`, `x-small`,
|
|
51
|
+
* `small`, `medium`, `large`, `x-large`, `xx-large`. Apply these values via
|
|
52
|
+
* familiar CSS-like shorthand. For example: `padding="small x-large large"`.
|
|
53
|
+
*/
|
|
54
|
+
padding?: Spacing
|
|
55
|
+
/**
|
|
56
|
+
* Inherits itemSpacing from the parent List component
|
|
57
|
+
*/
|
|
58
|
+
spacing?:
|
|
59
|
+
| 'none'
|
|
60
|
+
| 'xxx-small'
|
|
61
|
+
| 'xx-small'
|
|
62
|
+
| 'x-small'
|
|
63
|
+
| 'small'
|
|
64
|
+
| 'medium'
|
|
65
|
+
| 'large'
|
|
66
|
+
| 'x-large'
|
|
67
|
+
| 'xx-large'
|
|
68
|
+
/**
|
|
69
|
+
* provides a reference to the underlying html root element
|
|
70
|
+
*/
|
|
71
|
+
elementRef?: (element: Element | null) => void
|
|
72
|
+
} & PropsWithChildren<unknown> // <unknown> is needed for React 17 compatibility
|
|
73
|
+
|
|
74
|
+
type PropKeys = keyof ListItemOwnProps
|
|
75
|
+
|
|
76
|
+
type AllowedPropKeys = Readonly<Array<PropKeys>>
|
|
77
|
+
|
|
78
|
+
type ListItemProps = ListItemOwnProps &
|
|
79
|
+
WithStyleProps<ListItemTheme, ListItemStyle> &
|
|
80
|
+
OtherHTMLAttributes<ListItemOwnProps>
|
|
81
|
+
|
|
82
|
+
type ListItemStyle = ComponentStyle<'listItem'>
|
|
83
|
+
const allowedProps: AllowedPropKeys = [
|
|
84
|
+
'children',
|
|
85
|
+
'delimiter',
|
|
86
|
+
'size',
|
|
87
|
+
'margin',
|
|
88
|
+
'padding',
|
|
89
|
+
'spacing',
|
|
90
|
+
'elementRef'
|
|
91
|
+
]
|
|
92
|
+
|
|
93
|
+
export type { ListItemProps, ListItemStyle }
|
|
94
|
+
export { allowedProps }
|
|
@@ -0,0 +1,136 @@
|
|
|
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 { logError as error } from '@instructure/console'
|
|
26
|
+
import type { NewComponentTypes } from '@instructure/ui-themes'
|
|
27
|
+
import type { ListItemProps, ListItemStyle } from './props'
|
|
28
|
+
|
|
29
|
+
/**
|
|
30
|
+
* ---
|
|
31
|
+
* private: true
|
|
32
|
+
* ---
|
|
33
|
+
* Generates the style object from the theme and provided additional information
|
|
34
|
+
* @param {Object} componentTheme The theme variable object.
|
|
35
|
+
* @param {Object} props the props of the component, the style is applied to
|
|
36
|
+
* @return {Object} The final style object, which will be used in the component
|
|
37
|
+
*/
|
|
38
|
+
const generateStyle = (
|
|
39
|
+
componentTheme: NewComponentTypes['ListItem'],
|
|
40
|
+
props: ListItemProps
|
|
41
|
+
): ListItemStyle => {
|
|
42
|
+
const { size, delimiter, spacing } = props
|
|
43
|
+
|
|
44
|
+
const withDelimiter = delimiter !== 'none'
|
|
45
|
+
const withSpacing = spacing !== 'none'
|
|
46
|
+
|
|
47
|
+
error(
|
|
48
|
+
!(withDelimiter && withSpacing),
|
|
49
|
+
`[List] \`itemSpacing\` has no effect inside Lists with the \`delimiter\` prop set to anything other than \`none\`.`
|
|
50
|
+
)
|
|
51
|
+
|
|
52
|
+
const sizeVariants = {
|
|
53
|
+
small: { fontSize: componentTheme.fontSizeSmall },
|
|
54
|
+
medium: { fontSize: componentTheme.fontSizeMedium },
|
|
55
|
+
large: { fontSize: componentTheme.fontSizeLarge }
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
const spacingVariants = {
|
|
59
|
+
'xxx-small': {
|
|
60
|
+
marginTop: componentTheme.spacingXXXSmall,
|
|
61
|
+
marginBottom: componentTheme.spacingXXXSmall
|
|
62
|
+
},
|
|
63
|
+
'xx-small': {
|
|
64
|
+
marginTop: componentTheme.spacingXXSmall,
|
|
65
|
+
marginBottom: componentTheme.spacingXXSmall
|
|
66
|
+
},
|
|
67
|
+
'x-small': {
|
|
68
|
+
marginTop: componentTheme.spacingXSmall,
|
|
69
|
+
marginBottom: componentTheme.spacingXSmall
|
|
70
|
+
},
|
|
71
|
+
small: {
|
|
72
|
+
marginTop: componentTheme.spacingSmall,
|
|
73
|
+
marginBottom: componentTheme.spacingSmall
|
|
74
|
+
},
|
|
75
|
+
medium: {
|
|
76
|
+
marginTop: componentTheme.spacingMedium,
|
|
77
|
+
marginBottom: componentTheme.spacingMedium
|
|
78
|
+
},
|
|
79
|
+
large: {
|
|
80
|
+
marginTop: componentTheme.spacingLarge,
|
|
81
|
+
marginBottom: componentTheme.spacingLarge
|
|
82
|
+
},
|
|
83
|
+
'x-large': {
|
|
84
|
+
marginTop: componentTheme.spacingXLarge,
|
|
85
|
+
marginBottom: componentTheme.spacingXLarge
|
|
86
|
+
},
|
|
87
|
+
'xx-large': {
|
|
88
|
+
marginTop: componentTheme.spacingXXLarge,
|
|
89
|
+
marginBottom: componentTheme.spacingXXLarge
|
|
90
|
+
},
|
|
91
|
+
none: {}
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
const delimiterVariants = {
|
|
95
|
+
dashed: {
|
|
96
|
+
listStylePosition: 'inside',
|
|
97
|
+
'&:not(:first-of-type)': {
|
|
98
|
+
borderTop: `
|
|
99
|
+
${componentTheme.delimiterDashedBorder.width}
|
|
100
|
+
${componentTheme.delimiterDashedBorder.style}
|
|
101
|
+
${componentTheme.delimiterDashedBorder.color}
|
|
102
|
+
`
|
|
103
|
+
}
|
|
104
|
+
},
|
|
105
|
+
solid: {
|
|
106
|
+
listStylePosition: 'inside',
|
|
107
|
+
'&:not(:first-of-type)': {
|
|
108
|
+
borderTop: `
|
|
109
|
+
${componentTheme.delimiterSolidBorder.width}
|
|
110
|
+
${componentTheme.delimiterSolidBorder.style}
|
|
111
|
+
${componentTheme.delimiterSolidBorder.color}
|
|
112
|
+
`
|
|
113
|
+
}
|
|
114
|
+
},
|
|
115
|
+
none: {}
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
return {
|
|
119
|
+
listItem: {
|
|
120
|
+
label: 'listItem',
|
|
121
|
+
fontWeight: componentTheme.fontWeight,
|
|
122
|
+
fontFamily: componentTheme.fontFamily,
|
|
123
|
+
lineHeight: componentTheme.lineHeight,
|
|
124
|
+
color: componentTheme.color,
|
|
125
|
+
padding: 0,
|
|
126
|
+
...sizeVariants[size!],
|
|
127
|
+
...(withSpacing && !withDelimiter && spacingVariants[spacing!]),
|
|
128
|
+
...(withDelimiter && delimiterVariants[delimiter!]),
|
|
129
|
+
|
|
130
|
+
'&:first-of-type': { marginTop: '0' },
|
|
131
|
+
'&:last-of-type': { marginBottom: '0' }
|
|
132
|
+
}
|
|
133
|
+
}
|
|
134
|
+
}
|
|
135
|
+
|
|
136
|
+
export default generateStyle
|
|
@@ -0,0 +1,142 @@
|
|
|
1
|
+
---
|
|
2
|
+
describes: List
|
|
3
|
+
---
|
|
4
|
+
|
|
5
|
+
> ### What about 'inline' lists?
|
|
6
|
+
>
|
|
7
|
+
> For inline lists use the [InlineList](InlineList) component.
|
|
8
|
+
|
|
9
|
+
`<List>` accepts only `<List.Item>` as a child.
|
|
10
|
+
|
|
11
|
+
```js
|
|
12
|
+
---
|
|
13
|
+
type: example
|
|
14
|
+
---
|
|
15
|
+
<div>
|
|
16
|
+
<List margin="0 0 medium">
|
|
17
|
+
<List.Item>List item 1</List.Item>
|
|
18
|
+
<List.Item>List item 2</List.Item>
|
|
19
|
+
<List.Item>List item 3</List.Item>
|
|
20
|
+
</List>
|
|
21
|
+
<List as="ol" margin="0 0 medium">
|
|
22
|
+
<List.Item>List item 1</List.Item>
|
|
23
|
+
<List.Item>List item 2</List.Item>
|
|
24
|
+
<List.Item>List item 3</List.Item>
|
|
25
|
+
</List>
|
|
26
|
+
<List isUnstyled>
|
|
27
|
+
<List.Item><Link href="https://www.canvaslms.com/try-canvas">Canvas by Instructure</Link></List.Item>
|
|
28
|
+
<List.Item><Link href="https://www.getbridge.com">Bridge by Instructure</Link></List.Item>
|
|
29
|
+
<List.Item><Link href="https://www.arcmedia.com">Arc by Instructure</Link></List.Item>
|
|
30
|
+
</List>
|
|
31
|
+
</div>
|
|
32
|
+
```
|
|
33
|
+
|
|
34
|
+
### Adding a delimiter
|
|
35
|
+
|
|
36
|
+
The `delimiter` lets you set a separator between items of the list. The predefined options are ['none', 'solid', and 'dashed'].
|
|
37
|
+
|
|
38
|
+
```js
|
|
39
|
+
---
|
|
40
|
+
type: example
|
|
41
|
+
---
|
|
42
|
+
<div>
|
|
43
|
+
<List delimiter="none" margin="large 0">
|
|
44
|
+
<List.Item>{lorem.sentence()}</List.Item>
|
|
45
|
+
<List.Item>{lorem.sentence()}</List.Item>
|
|
46
|
+
<List.Item>{lorem.sentence()}</List.Item>
|
|
47
|
+
</List>
|
|
48
|
+
<List delimiter="solid" isUnstyled margin="large 0">
|
|
49
|
+
<List.Item>{lorem.sentence()}</List.Item>
|
|
50
|
+
<List.Item>{lorem.sentence()}</List.Item>
|
|
51
|
+
<List.Item>{lorem.sentence()}</List.Item>
|
|
52
|
+
</List>
|
|
53
|
+
<List delimiter="dashed" as="ol" margin="large 0">
|
|
54
|
+
<List.Item>{lorem.sentence()}</List.Item>
|
|
55
|
+
<List.Item>{lorem.sentence()}</List.Item>
|
|
56
|
+
<List.Item>{lorem.sentence()}</List.Item>
|
|
57
|
+
</List>
|
|
58
|
+
</div>
|
|
59
|
+
```
|
|
60
|
+
|
|
61
|
+
### Sizing
|
|
62
|
+
|
|
63
|
+
The `size` prop lets you adjust the font-size of the List. The predefined values are aligned with other components that use a 'size' prop for overall consistency within your application. The default is 'medium'.
|
|
64
|
+
|
|
65
|
+
```javascript
|
|
66
|
+
---
|
|
67
|
+
type: example
|
|
68
|
+
---
|
|
69
|
+
<div>
|
|
70
|
+
<List size="small" margin="large 0">
|
|
71
|
+
<List.Item>{lorem.sentence()}</List.Item>
|
|
72
|
+
<List.Item>Small Size</List.Item>
|
|
73
|
+
<List.Item><b>Due:</b> Oct 1, 2019</List.Item>
|
|
74
|
+
</List>
|
|
75
|
+
<List margin="large 0">
|
|
76
|
+
<List.Item>{lorem.sentence()}</List.Item>
|
|
77
|
+
<List.Item>Medium (default) Size</List.Item>
|
|
78
|
+
<List.Item><b>Due:</b> Oct 1, 2019</List.Item>
|
|
79
|
+
</List>
|
|
80
|
+
<List size="large" margin="large 0">
|
|
81
|
+
<List.Item>{lorem.sentence()}</List.Item>
|
|
82
|
+
<List.Item>Large Size</List.Item>
|
|
83
|
+
<List.Item><b>Due:</b> Oct 1, 2019</List.Item>
|
|
84
|
+
</List>
|
|
85
|
+
</div>
|
|
86
|
+
```
|
|
87
|
+
|
|
88
|
+
### Adding predefined space between each List.Item
|
|
89
|
+
|
|
90
|
+
Use the `itemSpacing` prop to add space around your list’s items. To avoid unwanted excess space at the start/end of a List, the first and last List.Item will not receive margin via the `itemSpacing` prop.
|
|
91
|
+
|
|
92
|
+
> NOTE: itemSpacing has no affect on an List.Item that has the `delimiter` prop set to anything other than **none**.
|
|
93
|
+
|
|
94
|
+
```js
|
|
95
|
+
---
|
|
96
|
+
type: example
|
|
97
|
+
---
|
|
98
|
+
<List isUnstyled itemSpacing="small">
|
|
99
|
+
<List.Item>{lorem.sentence()}</List.Item>
|
|
100
|
+
<List.Item><b>Due:</b> Oct 1, 2019</List.Item>
|
|
101
|
+
<List.Item><Link href="#">itemSpacing has been set to xx-small</Link></List.Item>
|
|
102
|
+
</List>
|
|
103
|
+
```
|
|
104
|
+
|
|
105
|
+
**itemSpacing** set to `medium`
|
|
106
|
+
|
|
107
|
+
```js
|
|
108
|
+
---
|
|
109
|
+
type: example
|
|
110
|
+
---
|
|
111
|
+
<List itemSpacing="medium">
|
|
112
|
+
<List.Item>{lorem.sentence()}</List.Item>
|
|
113
|
+
<List.Item><b>Due:</b> Oct 1, 2019</List.Item>
|
|
114
|
+
<List.Item><Link href="#">itemSpacing has been set to medium</Link></List.Item>
|
|
115
|
+
</List>
|
|
116
|
+
```
|
|
117
|
+
|
|
118
|
+
**itemSpacing** set to `x-large`
|
|
119
|
+
|
|
120
|
+
```js
|
|
121
|
+
---
|
|
122
|
+
type: example
|
|
123
|
+
---
|
|
124
|
+
<List isUnstyled itemSpacing="x-large">
|
|
125
|
+
<List.Item>{lorem.sentence()}</List.Item>
|
|
126
|
+
<List.Item><b>Due:</b> Oct 1, 2019</List.Item>
|
|
127
|
+
<List.Item><Link href="#">itemSpacing has been set to x-large</Link></List.Item>
|
|
128
|
+
</List>
|
|
129
|
+
```
|
|
130
|
+
|
|
131
|
+
List.Items also accept the same `margin` prop as List, in the event you need different spacing around certain List.Items in the List.
|
|
132
|
+
|
|
133
|
+
```js
|
|
134
|
+
---
|
|
135
|
+
type: example
|
|
136
|
+
---
|
|
137
|
+
<List isUnstyled itemSpacing="small">
|
|
138
|
+
<List.Item margin="x-large 0"><Link href="https://www.canvaslms.com/try-canvas">Canvas by Instructure</Link></List.Item>
|
|
139
|
+
<List.Item><Link href="https://www.getbridge.com">Bridge by Instructure</Link></List.Item>
|
|
140
|
+
<List.Item><Link href="https://www.arcmedia.com">Arc by Instructure</Link></List.Item>
|
|
141
|
+
</List>
|
|
142
|
+
```
|