@skedulo/sked-ui 21.0.0-beta.1 → 21.0.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.
@@ -1,6 +1,7 @@
1
1
  import * as React from 'react';
2
2
  import { IPopOutBase } from './PopOutBase';
3
- export interface IPopOutProps {
3
+ declare type IPopOutBaseSubset = Omit<IPopOutBase, 'visible' | 'trigger'>;
4
+ export interface IPopOutProps extends IPopOutBaseSubset {
4
5
  /**
5
6
  * The element you are rendering the content from
6
7
  */
@@ -9,19 +10,12 @@ export interface IPopOutProps {
9
10
  * The content to pop out
10
11
  */
11
12
  children: (closePopOut: () => void) => JSX.Element | React.ReactNode;
12
- className?: string;
13
- displayInline?: boolean;
14
13
  /**
15
- * The position where the content will try to fit
16
- */
17
- placement?: IPopOutBase['placement'];
18
- /**
19
- * Defaults to false
14
+ * Close on clicking in the content area. Defaults to false
20
15
  */
21
16
  closeOnFirstClick?: boolean;
22
17
  /**
23
- * Defaults to false
24
- * If you've set closeOnFirstClick to true, you don't need this
18
+ * Close content on clicking outside the content area. Defaults to false
25
19
  */
26
20
  closeOnOuterClick?: boolean;
27
21
  /**
@@ -30,13 +24,9 @@ export interface IPopOutProps {
30
24
  */
31
25
  closeOnScroll?: boolean;
32
26
  /**
33
- * Delay the render of the info window after the trigger event has been fired
27
+ * Delay the render of the pop out after the trigger event has been fired
34
28
  */
35
29
  delayShow?: number;
36
- /**
37
- * Override the default PopOut container which is a Portal
38
- */
39
- popOutContainer?: IPopOutBase['popOutContainer'];
40
30
  /**
41
31
  * Open the popout container on mount, ignoring any trigger.
42
32
  */
@@ -45,20 +35,27 @@ export interface IPopOutProps {
45
35
  * When the popout hides, fire this callback.
46
36
  */
47
37
  onClose?: () => void;
38
+ /**
39
+ * Event to fire on mouse leave of reference content
40
+ */
48
41
  onMouseLeave?: React.MouseEventHandler<HTMLSpanElement>;
42
+ /**
43
+ * Event to fire on mouse over of reference content
44
+ */
49
45
  onMouseOver?: React.MouseEventHandler<HTMLSpanElement>;
46
+ /**
47
+ * Prevent the display of the info window regardless of the trigger event
48
+ */
50
49
  preventShow?: boolean;
51
- showArrow?: boolean;
52
- triggerClassName?: string;
53
50
  }
54
51
  export interface IPopOutState {
55
52
  isOpen: boolean;
56
53
  }
57
54
  /**
58
- * The PopOut component displays/hides it's children when either the supplied trigger is clicked or if the openOnMount prop is supplied.
59
- * It should now be used in preference of InfoWindow where possible.
55
+ * The PopOut component displays/hides its children when either the supplied trigger is clicked or if the openOnMount prop is supplied.
60
56
  * Default placement is bottom-start
61
57
  *
62
58
  * @requires PopOutBase
63
59
  */
64
60
  export declare const PopOut: (props: IPopOutProps) => JSX.Element;
61
+ export {};
@@ -1,20 +1,34 @@
1
1
  import * as React from 'react';
2
2
  import * as PopperJS from '@popperjs/core';
3
+ import { StrictModifier } from 'react-popper';
3
4
  export interface IPopOutBase {
4
5
  /**
5
6
  * The element you are rendering the content from
6
7
  */
7
8
  className?: string;
9
+ /**
10
+ * Whether to add inline-block to the reference element
11
+ */
8
12
  displayInline?: boolean;
9
13
  trigger: JSX.Element;
10
14
  triggerClassName?: string;
11
15
  visible?: boolean;
16
+ /**
17
+ * Placement options supported by PopperJS
18
+ */
12
19
  placement?: PopperJS.Options['placement'];
20
+ /**
21
+ * Modifiers supported by PopperJS if overriding defaults
22
+ */
13
23
  modifiers?: PopperJS.Options['modifiers'];
24
+ /**
25
+ * Optional PopOut container to override Portal component if needed
26
+ */
14
27
  popOutContainer?: (PopperWrappedContent: JSX.Element) => JSX.Element;
15
28
  children?: React.ReactNode;
16
29
  showArrow?: boolean;
17
30
  }
31
+ export declare const DEFAULT_MODIFIERS: StrictModifier[];
18
32
  /**
19
33
  * PopOutBase uses react-popper/popperjs under the hood and is a wrapper that sets up the Popperjs Manager, Reference and Popper.
20
34
  * It will place any content next to the trigger based on whether it fits and what placement you specify.
@@ -4,5 +4,6 @@ export declare const usePopOut: ({ delayShow, preventShow, onClose, openOnMount
4
4
  visible: boolean;
5
5
  openPopOut: () => void;
6
6
  closePopOut: () => void;
7
+ togglePopOut: () => void;
7
8
  };
8
9
  export {};
@@ -1,7 +1,6 @@
1
1
  import * as React from 'react';
2
2
  import { IPopOutProps } from '../../popout/PopOut';
3
- import { ICursorOptions, Position } from './info-window-utils';
4
- export declare const InfoWindowContext: React.Context<InfoWindowState>;
3
+ import { ICursorOptions } from './info-window-utils';
5
4
  export interface IRequiredProps {
6
5
  /**
7
6
  * Content to be shown inside the info window
@@ -10,33 +9,24 @@ export interface IRequiredProps {
10
9
  /**
11
10
  * Preferred direction around the trigger to open the info window
12
11
  */
13
- position: Position;
12
+ position: IPopOutProps['placement'];
14
13
  }
15
14
  export declare type IPopOutPropsSubset = IRequiredProps & Omit<IPopOutProps, 'children' | 'trigger' | 'showArrow'>;
16
- declare type IEvent = 'click' | 'mount' | 'hover';
17
- export declare type IInfoWindowPopOutProps = IPopOutPropsSubset & {
15
+ export declare type IInfoWindowEvent = 'click' | 'mount';
16
+ export declare type IInfoWindowProps = IPopOutPropsSubset & {
18
17
  children: React.ReactNode;
19
18
  /**
20
- * IEvent type used to trigger the info window
19
+ * Event type used to trigger the info window, 'hover' is now deprecated
21
20
  */
22
- event?: IEvent;
21
+ event?: IInfoWindowEvent;
23
22
  /**
24
- * Cursor options control what happens to the info window while moving the mouse within the trigger
23
+ * Deprecated: Cursor options control what happens to the info window while moving the mouse within the trigger
25
24
  */
26
25
  cursorOption?: ICursorOptions;
27
26
  /**
28
- * Delay the render of the info window after the trigger event has been fired
27
+ * ClassName to be given to the wrapper around the info window content
29
28
  */
30
- delayShow?: number;
31
- /**
32
- * Prevent the display of the info window regardless of the trigger event
33
- */
34
- preventShow?: boolean;
35
29
  containerClassName?: string;
36
- /**
37
- * ClassName to be given to the wrapper around the trigger component
38
- */
39
- className?: string;
40
30
  /**
41
31
  * Data attributes to be applied to the wrapper around the trigger component
42
32
  */
@@ -51,17 +41,5 @@ export declare type IInfoWindowPopOutProps = IPopOutPropsSubset & {
51
41
  * Styles to apply to the wrapper around the trigger component
52
42
  */
53
43
  style?: React.CSSProperties;
54
- triggerClassName?: string;
55
44
  };
56
- /**
57
- * The infowindow module allows us to create an element next to an element. By setting props, we can determine the direction of its placement and how it gets triggered. The infowindow module has some smarts that will
58
- detect if it's about to get rendered off the screen. If it is, it will adjust the placement of the infowindow until it can be rendered. If it cannot be rendered in any direction, the code will pick the direction
59
- where the least amount of overflow is occuring. The order it tries to find a new placement in is top, right, down, left.
60
- The above example uses a button as the trigger for the info window, but any html element can be used as long as its passed as a child of the <InfoWindow /> component
61
- */
62
- export declare const InfoWindow: (props: IInfoWindowPopOutProps) => JSX.Element;
63
- interface InfoWindowState {
64
- closeInfoWindow: () => void;
65
- }
66
- export declare const useInfoWindow: () => InfoWindowState;
67
- export {};
45
+ export declare const InfoWindow: (props: IInfoWindowProps) => JSX.Element;
@@ -1,7 +1,7 @@
1
1
  import * as React from 'react';
2
2
  import { IAnchorScores, ICursorOptions, ICursorPoints, Position } from './info-window-utils';
3
- export declare type IEvent = 'click' | 'hover' | 'mount';
4
- export interface IInfoWindowStyles<T> {
3
+ declare type ILegacyInfoWindowEvent = 'click' | 'hover' | 'mount';
4
+ interface IInfoWindowStyles<T> {
5
5
  triangleStyles: {
6
6
  top: T;
7
7
  left: T;
@@ -11,7 +11,7 @@ export interface IInfoWindowStyles<T> {
11
11
  left: T;
12
12
  };
13
13
  }
14
- export interface IRequiredProps {
14
+ export interface ILegacyInfoWindowRequiredProps {
15
15
  /**
16
16
  * Content to be shown inside the info window
17
17
  */
@@ -21,22 +21,22 @@ export interface IRequiredProps {
21
21
  */
22
22
  position: Position;
23
23
  }
24
- export declare type IInfoWindowProps = IRequiredProps & {
24
+ export declare type ILegacyInfoWindowProps = ILegacyInfoWindowRequiredProps & {
25
25
  children?: React.ReactNode;
26
26
  /**
27
- * IEvent type used to trigger the info window
27
+ * ILegacyInfoWindowEvent type used to trigger the info window
28
28
  */
29
- event?: IEvent;
29
+ event?: ILegacyInfoWindowEvent;
30
30
  /**
31
31
  * Cursor options control what happens to the info window while moving the mouse within the trigger
32
32
  */
33
33
  cursorOption?: ICursorOptions;
34
34
  /**
35
- * Delay the render of the info window after the trigger event has been fired
35
+ * Delay render of the info window after the trigger event has been fired
36
36
  */
37
37
  delayShow?: number;
38
38
  /**
39
- * Prevent the display of the info window regardless of the trigger event
39
+ * Prevent the display of the pop out regardless of the trigger event
40
40
  */
41
41
  preventShow?: boolean;
42
42
  /**
@@ -86,12 +86,12 @@ interface IState {
86
86
  show: boolean;
87
87
  }
88
88
  /**
89
- * The infowindow module allows us to create an element next to an element. By setting props, we can determine the direction of its placement and how it gets triggered. The infowindow module has some smarts that will
89
+ * The LegacyInfoWindow module allows us to create an element next to an element. By setting props, we can determine the direction of its placement and how it gets triggered. The infowindow module has some smarts that will
90
90
  detect if it's about to get rendered off the screen. If it is, it will adjust the placement of the infowindow until it can be rendered. If it cannot be rendered in any direction, the code will pick the direction
91
91
  where the least amount of overflow is occuring. The order it tries to find a new placement in is top, right, down, left.
92
92
  The above example uses a button as the trigger for the info window, but any html element can be used as long as its passed as a child of the <InfoWindow /> component
93
93
  */
94
- export declare class LegacyInfoWindow extends React.PureComponent<IInfoWindowProps, IState> {
94
+ export declare class LegacyInfoWindow extends React.PureComponent<ILegacyInfoWindowProps, IState> {
95
95
  private _showDelayId;
96
96
  private _triggerRef;
97
97
  private _renderContainer;
@@ -99,9 +99,9 @@ export declare class LegacyInfoWindow extends React.PureComponent<IInfoWindowPro
99
99
  private _triangleRef;
100
100
  private _cursorPosition;
101
101
  private _triggerRect;
102
- constructor(props: IInfoWindowProps);
102
+ constructor(props: ILegacyInfoWindowProps);
103
103
  componentDidMount(): void;
104
- componentDidUpdate(oldProps: IInfoWindowProps): void;
104
+ componentDidUpdate(oldProps: ILegacyInfoWindowProps): void;
105
105
  componentWillUnmount(): void;
106
106
  computeStylesFromDisplayPosition: (anchor: IAnchorScores, triangleRect: ClientRect) => IInfoWindowStyles<number>;
107
107
  setTriggerRef: (div: HTMLDivElement) => void;
@@ -151,4 +151,9 @@ export declare class LegacyInfoWindow extends React.PureComponent<IInfoWindowPro
151
151
  renderContent(runStyleRender?: boolean): void;
152
152
  render(): JSX.Element;
153
153
  }
154
+ export declare const InfoWindowContext: React.Context<InfoWindowState>;
155
+ interface InfoWindowState {
156
+ closeInfoWindow: () => void;
157
+ }
158
+ export declare const useLegacyInfoWindow: () => InfoWindowState;
154
159
  export {};
@@ -0,0 +1,2 @@
1
+ import { StrictModifier } from 'react-popper';
2
+ export declare const useInfoWindowModifiers: (updatePositionWhenChanged: any) => (StrictModifier<import("react-popper").StrictModifierNames> | Partial<import("@popperjs/core").Modifier<"handleOverflowPositions", {}>>)[];
@@ -1,16 +1,16 @@
1
1
  /// <reference types="react" />
2
- import { IInfoWindowProps } from '../info-window/LegacyInfoWindow';
2
+ import { ILegacyInfoWindowProps } from '../info-window/LegacyInfoWindow';
3
3
  import { Position } from '../info-window/info-window-utils';
4
4
  import './tooltip.scss';
5
5
  export declare type ITooltipPosition = Position;
6
6
  declare type IColorScheme = 'dark' | 'light';
7
7
  declare type IAlignStyle = 'center' | 'left' | 'right';
8
- export interface ITooltipProps extends IInfoWindowProps {
8
+ export interface ITooltipProps extends ILegacyInfoWindowProps {
9
9
  /**
10
10
  * Colour scheme for the tooltip content. Available options are 'dark' and 'light'
11
11
  */
12
- delayShow?: IInfoWindowProps['delayShow'];
13
- event?: IInfoWindowProps['event'];
12
+ delayShow?: ILegacyInfoWindowProps['delayShow'];
13
+ event?: ILegacyInfoWindowProps['event'];
14
14
  colorScheme?: IColorScheme;
15
15
  textAlignment?: IAlignStyle;
16
16
  }
package/dist/index.d.ts CHANGED
@@ -51,7 +51,7 @@ export * from './components/popout/PopOutBase';
51
51
  export * from './components/popout/PopOut';
52
52
  export * from './components/popups/info-window/InfoWindow';
53
53
  export * from './components/popups/overflow-tooltip/OverflowTooltip';
54
- export { LegacyInfoWindow } from './components/popups/info-window/LegacyInfoWindow';
54
+ export * from './components/popups/info-window/LegacyInfoWindow';
55
55
  export * from './components/popups/tooltip/Tooltip';
56
56
  export * from './components/pill/Pill';
57
57
  export * from './components/table/Table';