@instructure/ui-link 8.13.1-snapshot.3 → 8.13.1-snapshot.35

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/src/Link/props.ts CHANGED
@@ -38,22 +38,81 @@ import type {
38
38
  WithStyleProps,
39
39
  ComponentStyle
40
40
  } from '@instructure/emotion'
41
+ import type { ViewOwnProps } from '@instructure/ui-view'
41
42
 
42
43
  type LinkOwnProps = {
44
+ /**
45
+ * The text and/or icon displayed by the link
46
+ */
43
47
  children: React.ReactNode
48
+
49
+ /**
50
+ * Sets the link's `href` attribute
51
+ */
44
52
  href?: string
53
+
54
+ /**
55
+ * Designates Link's text color to accommodate light and dark backgrounds
56
+ */
45
57
  color?: 'link' | 'link-inverse'
58
+
59
+ /**
60
+ * Provides a reference to the underlying HTML element
61
+ */
46
62
  elementRef?: (element: Element | null) => void
63
+
64
+ /**
65
+ * The element type to render as (will default to `<a>` if href is provided)
66
+ */
47
67
  as?: AsElementType
68
+
69
+ /**
70
+ * Determines if the link is enabled or disabled
71
+ */
48
72
  interaction?: 'enabled' | 'disabled'
73
+
74
+ /**
75
+ * Valid values are `0`, `none`, `auto`, `xxx-small`, `xx-small`, `x-small`,
76
+ * `small`, `medium`, `large`, `x-large`, `xx-large`. Apply these values via
77
+ * familiar CSS-like shorthand. For example: `margin="small auto large"`.
78
+ */
49
79
  margin?: Spacing
50
- renderIcon?: ((...args: any[]) => any) | React.ReactNode
80
+
81
+ /**
82
+ * Add an SVG icon to the Link. Do not add icons directly as
83
+ * children.
84
+ */
85
+ renderIcon?: (() => React.ReactNode) | React.ReactNode
86
+
87
+ /**
88
+ * Place the icon before or after the text in the Link.
89
+ */
51
90
  iconPlacement?: 'start' | 'end'
91
+
92
+ /**
93
+ * Set the CSS display property of the Link element. 'auto' sets no display property.
94
+ */
52
95
  display?: 'auto' | 'block' | 'inline-block' | 'flex' | 'inline-flex'
96
+
97
+ /**
98
+ * Set `false` to remove default underline if Link does not appear inline with text
99
+ */
53
100
  isWithinText?: boolean
54
- onClick?: (...args: any[]) => any
55
- onFocus?: (...args: any[]) => any
56
- onBlur?: (...args: any[]) => any
101
+
102
+ /**
103
+ * Fires when the Link is clicked
104
+ */
105
+ onClick?: (event: React.MouseEvent<ViewOwnProps>) => void
106
+
107
+ /**
108
+ * Fires when the Link gains focus
109
+ */
110
+ onFocus?: (event: React.FocusEvent<ViewOwnProps>) => void
111
+
112
+ /**
113
+ * Fires when the Link loses focus
114
+ */
115
+ onBlur?: (event: React.FocusEvent<ViewOwnProps>) => void
57
116
  }
58
117
 
59
118
  export type LinkStyleProps = {
@@ -65,55 +124,29 @@ type PropKeys = keyof LinkOwnProps
65
124
 
66
125
  type AllowedPropKeys = Readonly<Array<PropKeys>>
67
126
 
127
+ type LinkState = {
128
+ hasFocus: boolean
129
+ }
130
+
68
131
  type LinkProps = LinkOwnProps &
69
132
  WithStyleProps<LinkTheme, LinkStyle> &
70
- OtherHTMLAttributes<LinkOwnProps>
133
+ OtherHTMLAttributes<LinkOwnProps> & {
134
+ // React Router might add a `to` prop
135
+ to?: string
136
+ }
71
137
 
72
138
  type LinkStyle = ComponentStyle<'link' | 'icon'>
73
139
 
74
140
  const propTypes: PropValidators<PropKeys> = {
75
- /**
76
- * The text and/or icon displayed by the link
77
- */
78
141
  children: PropTypes.node.isRequired,
79
- /**
80
- * Sets the link's `href` attribute
81
- */
82
142
  href: PropTypes.string,
83
- /**
84
- * Designates Link's text color to accommodate light and dark backgrounds
85
- */
86
143
  color: PropTypes.oneOf(['link', 'link-inverse']),
87
- /**
88
- * Provides a reference to the underlying HTML element
89
- */
90
144
  elementRef: PropTypes.func,
91
- /**
92
- * The element type to render as (will default to `<a>` if href is provided)
93
- */
94
145
  as: PropTypes.elementType,
95
- /**
96
- * Determines if the link is enabled or disabled
97
- */
98
146
  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
147
  margin: ThemeablePropTypes.spacing,
105
- /**
106
- * Add an SVG icon to the Link. Do not add icons directly as
107
- * children.
108
- */
109
148
  renderIcon: PropTypes.oneOfType([PropTypes.func, PropTypes.node]),
110
- /**
111
- * Place the icon before or after the text in the Link.
112
- */
113
149
  iconPlacement: PropTypes.oneOf(['start', 'end']),
114
- /**
115
- * Set the CSS display property of the Link element. 'auto' sets no display property.
116
- */
117
150
  display: PropTypes.oneOf([
118
151
  'auto',
119
152
  'block',
@@ -121,21 +154,9 @@ const propTypes: PropValidators<PropKeys> = {
121
154
  'flex',
122
155
  'inline-flex'
123
156
  ]),
124
- /**
125
- * Set `false` to remove default underline if Link does not appear inline with text
126
- */
127
157
  isWithinText: PropTypes.bool,
128
- /**
129
- * Fires when the Link is clicked
130
- */
131
158
  onClick: PropTypes.func,
132
- /**
133
- * Fires when the Link gains focus
134
- */
135
159
  onFocus: PropTypes.func,
136
- /**
137
- * Fires when the Link loses focus
138
- */
139
160
  onBlur: PropTypes.func
140
161
  }
141
162
 
@@ -156,5 +177,5 @@ const allowedProps: AllowedPropKeys = [
156
177
  'onBlur'
157
178
  ]
158
179
 
159
- export type { LinkProps, LinkStyle }
180
+ export type { LinkProps, LinkState, LinkStyle }
160
181
  export { propTypes, allowedProps }
@@ -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
  }