@instructure/ui-tooltip 8.10.0 → 8.10.1

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 CHANGED
@@ -3,6 +3,10 @@
3
3
  All notable changes to this project will be documented in this file.
4
4
  See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
5
5
 
6
+ ## [8.10.1](https://github.com/instructure/instructure-ui/compare/v8.10.0...v8.10.1) (2021-10-01)
7
+
8
+ **Note:** Version bump only for package @instructure/ui-tooltip
9
+
6
10
  # [8.10.0](https://github.com/instructure/instructure-ui/compare/v8.9.1...v8.10.0) (2021-09-28)
7
11
 
8
12
  **Note:** Version bump only for package @instructure/ui-tooltip
@@ -90,13 +90,12 @@ let Tooltip = (_dec = withStyle(generateStyle, generateComponentTheme), _dec2 =
90
90
  const props = omitProps(this.props, Tooltip.allowedProps);
91
91
  return jsx(Trigger, Object.assign({}, props, triggerProps), children);
92
92
  } else if (typeof children === 'function') {
93
+ // TODO: try to remove cast when typing Tooltip (React children types are badly calculated)
93
94
  return children({
94
95
  focused: hasFocus,
95
- getTriggerProps: props => {
96
- return { ...triggerProps,
97
- ...props
98
- };
99
- }
96
+ getTriggerProps: props => ({ ...triggerProps,
97
+ ...props
98
+ })
100
99
  });
101
100
  } else {
102
101
  return ensureSingleChild(this.props.children, triggerProps);
@@ -91,13 +91,12 @@ let Tooltip = (_dec = (0, _emotion.withStyle)(_styles.default, _theme.default),
91
91
  const props = (0, _omitProps.omitProps)(this.props, Tooltip.allowedProps);
92
92
  return (0, _emotion.jsx)(Trigger, Object.assign({}, props, triggerProps), children);
93
93
  } else if (typeof children === 'function') {
94
+ // TODO: try to remove cast when typing Tooltip (React children types are badly calculated)
94
95
  return children({
95
96
  focused: hasFocus,
96
- getTriggerProps: props => {
97
- return { ...triggerProps,
98
- ...props
99
- };
100
- }
97
+ getTriggerProps: props => ({ ...triggerProps,
98
+ ...props
99
+ })
101
100
  });
102
101
  } else {
103
102
  return (0, _ensureSingleChild.ensureSingleChild)(this.props.children, triggerProps);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@instructure/ui-tooltip",
3
- "version": "8.10.0",
3
+ "version": "8.10.1",
4
4
  "description": "A component for showing small text-only overlays on hover/focus.",
5
5
  "author": "Instructure, Inc. Engineering and Product Design",
6
6
  "type": "commonjs",
@@ -25,23 +25,23 @@
25
25
  "license": "MIT",
26
26
  "dependencies": {
27
27
  "@babel/runtime": "^7.13.10",
28
- "@instructure/emotion": "8.10.0",
29
- "@instructure/shared-types": "8.10.0",
30
- "@instructure/ui-popover": "8.10.0",
31
- "@instructure/ui-position": "8.10.0",
32
- "@instructure/ui-prop-types": "8.10.0",
33
- "@instructure/ui-react-utils": "8.10.0",
34
- "@instructure/ui-testable": "8.10.0",
35
- "@instructure/uid": "8.10.0",
28
+ "@instructure/emotion": "8.10.1",
29
+ "@instructure/shared-types": "8.10.1",
30
+ "@instructure/ui-popover": "8.10.1",
31
+ "@instructure/ui-position": "8.10.1",
32
+ "@instructure/ui-prop-types": "8.10.1",
33
+ "@instructure/ui-react-utils": "8.10.1",
34
+ "@instructure/ui-testable": "8.10.1",
35
+ "@instructure/uid": "8.10.1",
36
36
  "prop-types": "^15"
37
37
  },
38
38
  "devDependencies": {
39
- "@instructure/ui-babel-preset": "8.10.0",
40
- "@instructure/ui-color-utils": "8.10.0",
41
- "@instructure/ui-test-locator": "8.10.0",
42
- "@instructure/ui-test-queries": "8.10.0",
43
- "@instructure/ui-test-utils": "8.10.0",
44
- "@instructure/ui-themes": "8.10.0"
39
+ "@instructure/ui-babel-preset": "8.10.1",
40
+ "@instructure/ui-color-utils": "8.10.1",
41
+ "@instructure/ui-test-locator": "8.10.1",
42
+ "@instructure/ui-test-queries": "8.10.1",
43
+ "@instructure/ui-test-utils": "8.10.1",
44
+ "@instructure/ui-themes": "8.10.1"
45
45
  },
46
46
  "peerDependencies": {
47
47
  "react": ">=16.8 <=17"
@@ -39,7 +39,8 @@ import { withStyle, jsx } from '@instructure/emotion'
39
39
 
40
40
  import generateStyle from './styles'
41
41
  import generateComponentTheme from './theme'
42
- import type { TooltipProps } from './props'
42
+
43
+ import type { TooltipProps, TooltipRenderChildren } from './props'
43
44
  import { allowedProps, propTypes } from './props'
44
45
 
45
46
  /**
@@ -107,16 +108,13 @@ class Tooltip extends Component<TooltipProps> {
107
108
  </Trigger>
108
109
  )
109
110
  } else if (typeof children === 'function') {
110
- // @ts-expect-error FIXME: React children types are badly calculated
111
- return children({
111
+ // TODO: try to remove cast when typing Tooltip (React children types are badly calculated)
112
+ return (children as TooltipRenderChildren)({
112
113
  focused: hasFocus,
113
- // @ts-expect-error ts-migrate(7006) FIXME: Parameter 'props' implicitly has an 'any' type.
114
- getTriggerProps: (props) => {
115
- return {
116
- ...triggerProps,
117
- ...props
118
- }
119
- }
114
+ getTriggerProps: (props) => ({
115
+ ...triggerProps,
116
+ ...props
117
+ })
120
118
  })
121
119
  } else {
122
120
  return ensureSingleChild(this.props.children, triggerProps)
@@ -40,9 +40,20 @@ import type {
40
40
  } from '@instructure/ui-position'
41
41
  import type { WithStyleProps, ComponentStyle } from '@instructure/emotion'
42
42
 
43
+ type TooltipRenderChildrenArgs = {
44
+ focused: boolean
45
+ getTriggerProps: <P extends Record<string, any>>(
46
+ props: P
47
+ ) => { 'aria-describedby': string } & P
48
+ }
49
+
50
+ type TooltipRenderChildren = (
51
+ args: TooltipRenderChildrenArgs
52
+ ) => React.ReactNode
53
+
43
54
  type TooltipOwnProps = {
44
55
  renderTip: React.ReactNode | ((...args: any[]) => any)
45
- children: React.ReactNode | ((...args: any[]) => React.ReactNode)
56
+ children: React.ReactNode | TooltipRenderChildren
46
57
  isShowingContent?: boolean
47
58
  defaultIsShowingContent?: boolean
48
59
  as?: AsElementType
@@ -160,5 +171,10 @@ const allowedProps: AllowedPropKeys = [
160
171
  'onHideContent'
161
172
  ]
162
173
 
163
- export type { TooltipProps, TooltipStyle }
174
+ export type {
175
+ TooltipProps,
176
+ TooltipStyle,
177
+ TooltipRenderChildren,
178
+ TooltipRenderChildrenArgs
179
+ }
164
180
  export { propTypes, allowedProps }
package/src/index.ts CHANGED
@@ -22,4 +22,4 @@
22
22
  * SOFTWARE.
23
23
  */
24
24
  export { Tooltip } from './Tooltip'
25
- export type { TooltipProps } from './Tooltip/props'
25
+ export type { TooltipProps, TooltipRenderChildrenArgs } from './Tooltip/props'
@@ -1,7 +1,7 @@
1
1
  /** @jsx jsx */
2
2
  import { Component } from 'react';
3
3
  import { jsx } from '@instructure/emotion';
4
- import type { TooltipProps } from './props';
4
+ import type { TooltipProps, TooltipRenderChildren } from './props';
5
5
  /**
6
6
  ---
7
7
  category: components
@@ -11,7 +11,7 @@ declare class Tooltip extends Component<TooltipProps> {
11
11
  static readonly componentId = "Tooltip";
12
12
  static allowedProps: readonly (keyof {
13
13
  renderTip: import("react").ReactNode | ((...args: any[]) => any);
14
- children: import("react").ReactNode | ((...args: any[]) => import("react").ReactNode);
14
+ children: import("react").ReactNode | TooltipRenderChildren;
15
15
  isShowingContent?: boolean | undefined;
16
16
  defaultIsShowingContent?: boolean | undefined;
17
17
  as?: import("@instructure/shared-types/types/CommonProps").AsElementType | undefined;
@@ -28,7 +28,7 @@ declare class Tooltip extends Component<TooltipProps> {
28
28
  })[];
29
29
  static propTypes: import("@instructure/shared-types/types/UtilityTypes").PropValidators<keyof {
30
30
  renderTip: import("react").ReactNode | ((...args: any[]) => any);
31
- children: import("react").ReactNode | ((...args: any[]) => import("react").ReactNode);
31
+ children: import("react").ReactNode | TooltipRenderChildren;
32
32
  isShowingContent?: boolean | undefined;
33
33
  defaultIsShowingContent?: boolean | undefined;
34
34
  as?: import("@instructure/shared-types/types/CommonProps").AsElementType | undefined;
@@ -64,7 +64,7 @@ declare class Tooltip extends Component<TooltipProps> {
64
64
  componentDidUpdate(prevProps: any, prevState: any, snapshot: any): void;
65
65
  handleFocus: (event: any) => void;
66
66
  handleBlur: (event: any) => void;
67
- renderTrigger(): any;
67
+ renderTrigger(): import("react").ReactNode;
68
68
  render(): jsx.JSX.Element;
69
69
  }
70
70
  export default Tooltip;
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/Tooltip/index.tsx"],"names":[],"mappings":"AAwBA,eAAe;AACf,OAAO,EAAE,SAAS,EAAE,MAAM,OAAO,CAAA;AAYjC,OAAO,EAAa,GAAG,EAAE,MAAM,sBAAsB,CAAA;AAIrD,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,SAAS,CAAA;AAG3C;;;;GAIG;AACH,cAEM,OAAQ,SAAQ,SAAS,CAAC,YAAY,CAAC;IAC3C,MAAM,CAAC,QAAQ,CAAC,WAAW,aAAY;IAEvC,MAAM,CAAC,YAAY;;;;;;;;;;;;;;;;SAAe;IAClC,MAAM,CAAC,SAAS;;;;;;;;;;;;;;;;OAAY;IAE5B,MAAM,CAAC,YAAY;;;;;;;;;;;;MAYT;IAEV,GAAG,SAAiB;IACpB,KAAK;;MAAsB;IAE3B,iBAAiB;IAKjB,kBAAkB,CAAC,SAAS,KAAA,EAAE,SAAS,KAAA,EAAE,QAAQ,KAAA;IAKjD,WAAW,uBAEV;IAGD,UAAU,uBAET;IAED,aAAa;IAgCb,MAAM;CA+CP;AAED,eAAe,OAAO,CAAA;AACtB,OAAO,EAAE,OAAO,EAAE,CAAA"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/Tooltip/index.tsx"],"names":[],"mappings":"AAwBA,eAAe;AACf,OAAO,EAAE,SAAS,EAAE,MAAM,OAAO,CAAA;AAYjC,OAAO,EAAa,GAAG,EAAE,MAAM,sBAAsB,CAAA;AAKrD,OAAO,KAAK,EAAE,YAAY,EAAE,qBAAqB,EAAE,MAAM,SAAS,CAAA;AAGlE;;;;GAIG;AACH,cAEM,OAAQ,SAAQ,SAAS,CAAC,YAAY,CAAC;IAC3C,MAAM,CAAC,QAAQ,CAAC,WAAW,aAAY;IAEvC,MAAM,CAAC,YAAY;;;;;;;;;;;;;;;;SAAe;IAClC,MAAM,CAAC,SAAS;;;;;;;;;;;;;;;;OAAY;IAE5B,MAAM,CAAC,YAAY;;;;;;;;;;;;MAYT;IAEV,GAAG,SAAiB;IACpB,KAAK;;MAAsB;IAE3B,iBAAiB;IAKjB,kBAAkB,CAAC,SAAS,KAAA,EAAE,SAAS,KAAA,EAAE,QAAQ,KAAA;IAKjD,WAAW,uBAEV;IAGD,UAAU,uBAET;IAED,aAAa;IA6Bb,MAAM;CA+CP;AAED,eAAe,OAAO,CAAA;AACtB,OAAO,EAAE,OAAO,EAAE,CAAA"}
@@ -2,9 +2,16 @@ import React from 'react';
2
2
  import type { PropValidators, AsElementType, TooltipTheme } from '@instructure/shared-types';
3
3
  import type { PlacementPropValues, PositionConstraint, PositionMountNode } from '@instructure/ui-position';
4
4
  import type { WithStyleProps, ComponentStyle } from '@instructure/emotion';
5
+ declare type TooltipRenderChildrenArgs = {
6
+ focused: boolean;
7
+ getTriggerProps: <P extends Record<string, any>>(props: P) => {
8
+ 'aria-describedby': string;
9
+ } & P;
10
+ };
11
+ declare type TooltipRenderChildren = (args: TooltipRenderChildrenArgs) => React.ReactNode;
5
12
  declare type TooltipOwnProps = {
6
13
  renderTip: React.ReactNode | ((...args: any[]) => any);
7
- children: React.ReactNode | ((...args: any[]) => React.ReactNode);
14
+ children: React.ReactNode | TooltipRenderChildren;
8
15
  isShowingContent?: boolean;
9
16
  defaultIsShowingContent?: boolean;
10
17
  as?: AsElementType;
@@ -25,6 +32,6 @@ declare type TooltipProps = TooltipOwnProps & WithStyleProps<TooltipTheme, Toolt
25
32
  declare type TooltipStyle = ComponentStyle<'tooltip'>;
26
33
  declare const propTypes: PropValidators<PropKeys>;
27
34
  declare const allowedProps: AllowedPropKeys;
28
- export type { TooltipProps, TooltipStyle };
35
+ export type { TooltipProps, TooltipStyle, TooltipRenderChildren, TooltipRenderChildrenArgs };
29
36
  export { propTypes, allowedProps };
30
37
  //# s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M,YAAY,EAAE,eAgBnB,CAAA;AAED,YAAY,EACV,YAAY,EACZ,YAAY,EACZ,qBAAqB,EACrB,yBAAyB,EAC1B,CAAA;AACD,OAAO,EAAE,SAAS,EAAE,YAAY,EAAE,CAAA"}
package/types/index.d.ts CHANGED
@@ -1,3 +1,3 @@
1
1
  export { Tooltip } from './Tooltip';
2
- export type { TooltipProps } from './Tooltip/props';
2
+ export type { TooltipProps, TooltipRenderChildrenArgs } from './Tooltip/props';
3
3
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAuBA,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAA;AACnC,YAAY,EAAE,YAAY,EAAE,MAAM,iBAAiB,CAAA"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAuBA,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAA;AACnC,YAAY,EAAE,YAAY,EAAE,yBAAyB,EAAE,MAAM,iBAAiB,CAAA"}