@instructure/ui-link 8.13.1-snapshot.9 → 8.14.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/CHANGELOG.md +4 -0
- package/es/Link/LinkLocator.js +2 -1
- package/es/Link/__examples__/Link.examples.js +2 -2
- package/es/Link/index.js +19 -14
- package/es/Link/props.js +0 -58
- package/lib/Link/LinkLocator.js +1 -0
- package/lib/Link/__examples__/Link.examples.js +2 -2
- package/lib/Link/index.js +19 -14
- package/lib/Link/props.js +0 -58
- package/package.json +18 -19
- package/src/Link/__examples__/Link.examples.ts +6 -7
- package/src/Link/index.tsx +15 -20
- package/src/Link/props.ts +71 -51
- package/tsconfig.build.json +22 -2
- package/tsconfig.build.tsbuildinfo +1 -0
- package/types/Link/LinkLocator.d.ts +57 -56
- package/types/Link/LinkLocator.d.ts.map +1 -1
- package/types/Link/__examples__/Link.examples.d.ts +4 -3
- package/types/Link/__examples__/Link.examples.d.ts.map +1 -1
- package/types/Link/index.d.ts +19 -17
- package/types/Link/index.d.ts.map +1 -1
- package/types/Link/props.d.ts +56 -7
- package/types/Link/props.d.ts.map +1 -1
- package/LICENSE.md +0 -27
package/src/Link/props.ts
CHANGED
|
@@ -28,6 +28,7 @@ import PropTypes from 'prop-types'
|
|
|
28
28
|
import { ThemeablePropTypes } from '@instructure/emotion'
|
|
29
29
|
|
|
30
30
|
import type {
|
|
31
|
+
ToProp,
|
|
31
32
|
AsElementType,
|
|
32
33
|
PropValidators,
|
|
33
34
|
LinkTheme,
|
|
@@ -38,22 +39,81 @@ import type {
|
|
|
38
39
|
WithStyleProps,
|
|
39
40
|
ComponentStyle
|
|
40
41
|
} from '@instructure/emotion'
|
|
42
|
+
import type { ViewOwnProps } from '@instructure/ui-view'
|
|
41
43
|
|
|
42
44
|
type LinkOwnProps = {
|
|
45
|
+
/**
|
|
46
|
+
* The text and/or icon displayed by the link
|
|
47
|
+
*/
|
|
43
48
|
children: React.ReactNode
|
|
49
|
+
|
|
50
|
+
/**
|
|
51
|
+
* Sets the link's `href` attribute
|
|
52
|
+
*/
|
|
44
53
|
href?: string
|
|
54
|
+
|
|
55
|
+
/**
|
|
56
|
+
* Designates Link's text color to accommodate light and dark backgrounds
|
|
57
|
+
*/
|
|
45
58
|
color?: 'link' | 'link-inverse'
|
|
59
|
+
|
|
60
|
+
/**
|
|
61
|
+
* Provides a reference to the underlying HTML element
|
|
62
|
+
*/
|
|
46
63
|
elementRef?: (element: Element | null) => void
|
|
64
|
+
|
|
65
|
+
/**
|
|
66
|
+
* The element type to render as (will default to `<a>` if href is provided)
|
|
67
|
+
*/
|
|
47
68
|
as?: AsElementType
|
|
69
|
+
|
|
70
|
+
/**
|
|
71
|
+
* Determines if the link is enabled or disabled
|
|
72
|
+
*/
|
|
48
73
|
interaction?: 'enabled' | 'disabled'
|
|
74
|
+
|
|
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
|
+
*/
|
|
49
80
|
margin?: Spacing
|
|
50
|
-
|
|
81
|
+
|
|
82
|
+
/**
|
|
83
|
+
* Add an SVG icon to the Link. Do not add icons directly as
|
|
84
|
+
* children.
|
|
85
|
+
*/
|
|
86
|
+
renderIcon?: (() => React.ReactNode) | React.ReactNode
|
|
87
|
+
|
|
88
|
+
/**
|
|
89
|
+
* Place the icon before or after the text in the Link.
|
|
90
|
+
*/
|
|
51
91
|
iconPlacement?: 'start' | 'end'
|
|
92
|
+
|
|
93
|
+
/**
|
|
94
|
+
* Set the CSS display property of the Link element. 'auto' sets no display property.
|
|
95
|
+
*/
|
|
52
96
|
display?: 'auto' | 'block' | 'inline-block' | 'flex' | 'inline-flex'
|
|
97
|
+
|
|
98
|
+
/**
|
|
99
|
+
* Set `false` to remove default underline if Link does not appear inline with text
|
|
100
|
+
*/
|
|
53
101
|
isWithinText?: boolean
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
102
|
+
|
|
103
|
+
/**
|
|
104
|
+
* Fires when the Link is clicked
|
|
105
|
+
*/
|
|
106
|
+
onClick?: (event: React.MouseEvent<ViewOwnProps>) => void
|
|
107
|
+
|
|
108
|
+
/**
|
|
109
|
+
* Fires when the Link gains focus
|
|
110
|
+
*/
|
|
111
|
+
onFocus?: (event: React.FocusEvent<ViewOwnProps>) => void
|
|
112
|
+
|
|
113
|
+
/**
|
|
114
|
+
* Fires when the Link loses focus
|
|
115
|
+
*/
|
|
116
|
+
onBlur?: (event: React.FocusEvent<ViewOwnProps>) => void
|
|
57
117
|
}
|
|
58
118
|
|
|
59
119
|
export type LinkStyleProps = {
|
|
@@ -65,55 +125,27 @@ type PropKeys = keyof LinkOwnProps
|
|
|
65
125
|
|
|
66
126
|
type AllowedPropKeys = Readonly<Array<PropKeys>>
|
|
67
127
|
|
|
128
|
+
type LinkState = {
|
|
129
|
+
hasFocus: boolean
|
|
130
|
+
}
|
|
131
|
+
|
|
68
132
|
type LinkProps = LinkOwnProps &
|
|
69
133
|
WithStyleProps<LinkTheme, LinkStyle> &
|
|
70
|
-
OtherHTMLAttributes<LinkOwnProps>
|
|
134
|
+
OtherHTMLAttributes<LinkOwnProps> &
|
|
135
|
+
ToProp
|
|
71
136
|
|
|
72
137
|
type LinkStyle = ComponentStyle<'link' | 'icon'>
|
|
73
138
|
|
|
74
139
|
const propTypes: PropValidators<PropKeys> = {
|
|
75
|
-
/**
|
|
76
|
-
* The text and/or icon displayed by the link
|
|
77
|
-
*/
|
|
78
140
|
children: PropTypes.node.isRequired,
|
|
79
|
-
/**
|
|
80
|
-
* Sets the link's `href` attribute
|
|
81
|
-
*/
|
|
82
141
|
href: PropTypes.string,
|
|
83
|
-
/**
|
|
84
|
-
* Designates Link's text color to accommodate light and dark backgrounds
|
|
85
|
-
*/
|
|
86
142
|
color: PropTypes.oneOf(['link', 'link-inverse']),
|
|
87
|
-
/**
|
|
88
|
-
* Provides a reference to the underlying HTML element
|
|
89
|
-
*/
|
|
90
143
|
elementRef: PropTypes.func,
|
|
91
|
-
/**
|
|
92
|
-
* The element type to render as (will default to `<a>` if href is provided)
|
|
93
|
-
*/
|
|
94
144
|
as: PropTypes.elementType,
|
|
95
|
-
/**
|
|
96
|
-
* Determines if the link is enabled or disabled
|
|
97
|
-
*/
|
|
98
145
|
interaction: PropTypes.oneOf(['enabled', 'disabled']),
|
|
99
|
-
/**
|
|
100
|
-
* Valid values are `0`, `none`, `auto`, `xxx-small`, `xx-small`, `x-small`,
|
|
101
|
-
* `small`, `medium`, `large`, `x-large`, `xx-large`. Apply these values via
|
|
102
|
-
* familiar CSS-like shorthand. For example: `margin="small auto large"`.
|
|
103
|
-
*/
|
|
104
146
|
margin: ThemeablePropTypes.spacing,
|
|
105
|
-
/**
|
|
106
|
-
* Add an SVG icon to the Link. Do not add icons directly as
|
|
107
|
-
* children.
|
|
108
|
-
*/
|
|
109
147
|
renderIcon: PropTypes.oneOfType([PropTypes.func, PropTypes.node]),
|
|
110
|
-
/**
|
|
111
|
-
* Place the icon before or after the text in the Link.
|
|
112
|
-
*/
|
|
113
148
|
iconPlacement: PropTypes.oneOf(['start', 'end']),
|
|
114
|
-
/**
|
|
115
|
-
* Set the CSS display property of the Link element. 'auto' sets no display property.
|
|
116
|
-
*/
|
|
117
149
|
display: PropTypes.oneOf([
|
|
118
150
|
'auto',
|
|
119
151
|
'block',
|
|
@@ -121,21 +153,9 @@ const propTypes: PropValidators<PropKeys> = {
|
|
|
121
153
|
'flex',
|
|
122
154
|
'inline-flex'
|
|
123
155
|
]),
|
|
124
|
-
/**
|
|
125
|
-
* Set `false` to remove default underline if Link does not appear inline with text
|
|
126
|
-
*/
|
|
127
156
|
isWithinText: PropTypes.bool,
|
|
128
|
-
/**
|
|
129
|
-
* Fires when the Link is clicked
|
|
130
|
-
*/
|
|
131
157
|
onClick: PropTypes.func,
|
|
132
|
-
/**
|
|
133
|
-
* Fires when the Link gains focus
|
|
134
|
-
*/
|
|
135
158
|
onFocus: PropTypes.func,
|
|
136
|
-
/**
|
|
137
|
-
* Fires when the Link loses focus
|
|
138
|
-
*/
|
|
139
159
|
onBlur: PropTypes.func
|
|
140
160
|
}
|
|
141
161
|
|
|
@@ -156,5 +176,5 @@ const allowedProps: AllowedPropKeys = [
|
|
|
156
176
|
'onBlur'
|
|
157
177
|
]
|
|
158
178
|
|
|
159
|
-
export type { LinkProps, LinkStyle }
|
|
179
|
+
export type { LinkProps, LinkState, LinkStyle }
|
|
160
180
|
export { propTypes, allowedProps }
|
package/tsconfig.build.json
CHANGED
|
@@ -1,7 +1,27 @@
|
|
|
1
1
|
{
|
|
2
2
|
"extends": "../../tsconfig.build.json",
|
|
3
3
|
"compilerOptions": {
|
|
4
|
-
"outDir": "./types"
|
|
4
|
+
"outDir": "./types",
|
|
5
|
+
"composite": true,
|
|
6
|
+
"rootDir": "./src"
|
|
5
7
|
},
|
|
6
|
-
"include": ["src
|
|
8
|
+
"include": ["src"],
|
|
9
|
+
"references": [
|
|
10
|
+
{ "path": "../console/tsconfig.build.json" },
|
|
11
|
+
{ "path": "../emotion/tsconfig.build.json" },
|
|
12
|
+
{ "path": "../shared-types/tsconfig.build.json" },
|
|
13
|
+
{ "path": "../ui-a11y-utils/tsconfig.build.json" },
|
|
14
|
+
{ "path": "../ui-color-utils/tsconfig.build.json" },
|
|
15
|
+
{ "path": "../ui-dom-utils/tsconfig.build.json" },
|
|
16
|
+
{ "path": "../ui-icons/tsconfig.build.json" },
|
|
17
|
+
{ "path": "../ui-prop-types/tsconfig.build.json" },
|
|
18
|
+
{ "path": "../ui-react-utils/tsconfig.build.json" },
|
|
19
|
+
{ "path": "../ui-testable/tsconfig.build.json" },
|
|
20
|
+
{ "path": "../ui-view/tsconfig.build.json" },
|
|
21
|
+
{ "path": "../ui-babel-preset/tsconfig.build.json" },
|
|
22
|
+
{ "path": "../ui-test-locator/tsconfig.build.json" },
|
|
23
|
+
{ "path": "../ui-test-queries/tsconfig.build.json" },
|
|
24
|
+
{ "path": "../ui-test-utils/tsconfig.build.json" },
|
|
25
|
+
{ "path": "../ui-themes/tsconfig.build.json" }
|
|
26
|
+
]
|
|
7
27
|
}
|