@skedulo/sked-ui 20.2.0 → 21.0.0-beta.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.
@@ -8,7 +8,9 @@ export interface IPopOutProps {
8
8
  /**
9
9
  * The content to pop out
10
10
  */
11
- children: (hideDropdown: PopOut['hideDropdown']) => JSX.Element | React.ReactNode;
11
+ children: (closePopOut: () => void) => JSX.Element | React.ReactNode;
12
+ className?: string;
13
+ displayInline?: boolean;
12
14
  /**
13
15
  * The position where the content will try to fit
14
16
  */
@@ -27,6 +29,10 @@ export interface IPopOutProps {
27
29
  * Defaults to false
28
30
  */
29
31
  closeOnScroll?: boolean;
32
+ /**
33
+ * Delay the render of the info window after the trigger event has been fired
34
+ */
35
+ delayShow?: number;
30
36
  /**
31
37
  * Override the default PopOut container which is a Portal
32
38
  */
@@ -39,16 +45,15 @@ export interface IPopOutProps {
39
45
  * When the popout hides, fire this callback.
40
46
  */
41
47
  onClose?: () => void;
48
+ onMouseLeave?: React.MouseEventHandler<HTMLSpanElement>;
49
+ onMouseOver?: React.MouseEventHandler<HTMLSpanElement>;
50
+ preventShow?: boolean;
51
+ showArrow?: boolean;
52
+ triggerClassName?: string;
42
53
  }
43
54
  export interface IPopOutState {
44
55
  isOpen: boolean;
45
56
  }
46
- interface IEventHandlerItem {
47
- register: boolean;
48
- type: string;
49
- method: EventListener;
50
- options?: EventListenerOptions;
51
- }
52
57
  /**
53
58
  * The PopOut component displays/hides it's children when either the supplied trigger is clicked or if the openOnMount prop is supplied.
54
59
  * It should now be used in preference of InfoWindow where possible.
@@ -56,22 +61,4 @@ interface IEventHandlerItem {
56
61
  *
57
62
  * @requires PopOutBase
58
63
  */
59
- export declare class PopOut extends React.PureComponent<IPopOutProps, IPopOutState> {
60
- private _contentRef;
61
- private _triggerRef;
62
- static defaultProps: {
63
- usePortal: boolean;
64
- };
65
- constructor(props: IPopOutProps);
66
- componentDidMount(): void;
67
- componentWillUnmount(): void;
68
- getEventHandlers: () => IEventHandlerItem[];
69
- handleDocumentClick: (e: Event) => void;
70
- addOptionalListeners: () => void;
71
- removeOptionalListeners: () => void;
72
- showDropdown: () => void;
73
- hideDropdown: () => void;
74
- triggerClick: (e: React.MouseEvent<HTMLDivElement, MouseEvent>) => void;
75
- render(): JSX.Element;
76
- }
77
- export {};
64
+ export declare const PopOut: (props: IPopOutProps) => JSX.Element;
@@ -4,12 +4,16 @@ export interface IPopOutBase {
4
4
  /**
5
5
  * The element you are rendering the content from
6
6
  */
7
+ className?: string;
8
+ displayInline?: boolean;
7
9
  trigger: JSX.Element;
10
+ triggerClassName?: string;
8
11
  visible?: boolean;
9
12
  placement?: PopperJS.Options['placement'];
10
13
  modifiers?: PopperJS.Options['modifiers'];
11
14
  popOutContainer?: (PopperWrappedContent: JSX.Element) => JSX.Element;
12
15
  children?: React.ReactNode;
16
+ showArrow?: boolean;
13
17
  }
14
18
  /**
15
19
  * PopOutBase uses react-popper/popperjs under the hood and is a wrapper that sets up the Popperjs Manager, Reference and Popper.
@@ -0,0 +1,8 @@
1
+ import { IPopOutProps } from './PopOut';
2
+ declare type UsePopOutProps = Pick<IPopOutProps, 'delayShow' | 'preventShow' | 'onClose' | 'openOnMount'>;
3
+ export declare const usePopOut: ({ delayShow, preventShow, onClose, openOnMount }: UsePopOutProps) => {
4
+ visible: boolean;
5
+ openPopOut: () => void;
6
+ closePopOut: () => void;
7
+ };
8
+ export {};
@@ -1,21 +1,7 @@
1
1
  import * as React from 'react';
2
- import { IAnchorScores, ICursorOptions, ICursorPoints, Position as PositionType } from './info-window-utils';
3
- interface InfoWindowState {
4
- closeInfoWindow: () => void;
5
- }
2
+ import { IPopOutProps } from '../../popout/PopOut';
3
+ import { ICursorOptions, Position } from './info-window-utils';
6
4
  export declare const InfoWindowContext: React.Context<InfoWindowState>;
7
- export declare type Position = PositionType;
8
- export declare type IEvent = 'click' | 'hover' | 'mount';
9
- export interface IInfoWindowStyles<T> {
10
- triangleStyles: {
11
- top: T;
12
- left: T;
13
- };
14
- contentStyles: {
15
- top: T;
16
- left: T;
17
- };
18
- }
19
5
  export interface IRequiredProps {
20
6
  /**
21
7
  * Content to be shown inside the info window
@@ -26,8 +12,10 @@ export interface IRequiredProps {
26
12
  */
27
13
  position: Position;
28
14
  }
29
- export declare type IInfoWindowProps = IRequiredProps & {
30
- children?: React.ReactNode;
15
+ export declare type IPopOutPropsSubset = IRequiredProps & Omit<IPopOutProps, 'children' | 'trigger' | 'showArrow'>;
16
+ declare type IEvent = 'click' | 'mount' | 'hover';
17
+ export declare type IInfoWindowPopOutProps = IPopOutPropsSubset & {
18
+ children: React.ReactNode;
31
19
  /**
32
20
  * IEvent type used to trigger the info window
33
21
  */
@@ -44,9 +32,6 @@ export declare type IInfoWindowProps = IRequiredProps & {
44
32
  * Prevent the display of the info window regardless of the trigger event
45
33
  */
46
34
  preventShow?: boolean;
47
- /**
48
- * ClassName to be given to the wrapper around the info window content
49
- */
50
35
  containerClassName?: string;
51
36
  /**
52
37
  * ClassName to be given to the wrapper around the trigger component
@@ -58,103 +43,25 @@ export declare type IInfoWindowProps = IRequiredProps & {
58
43
  dataAttributes?: {
59
44
  [key: string]: string;
60
45
  };
61
- /**
62
- * Apply 'display: inline-block' style to the wrapper around the trigger component
63
- */
64
- displayInline?: boolean;
65
46
  /**
66
47
  * Render a close button within the wrapper around the info window content
67
48
  */
68
49
  withCloseButton?: boolean;
69
- /**
70
- * Offset the trigger points used to calculate the render positions by this number of pixels
71
- */
72
- positionOffset?: number;
73
- /**
74
- * Will be called when the mouse over event is fired on the trigger component
75
- */
76
- onMouseOver?: (e: React.MouseEvent<HTMLDivElement>) => void;
77
- /**
78
- * Will be called when the mouse leave event is fired on the trigger component
79
- */
80
- onMouseLeave?: (e: React.MouseEvent<HTMLDivElement>) => void;
81
- /**
82
- * Will be called when the info window is closed (regardless of the trigger event)
83
- */
84
- onClose?: () => void;
85
50
  /**
86
51
  * Styles to apply to the wrapper around the trigger component
87
52
  */
88
53
  style?: React.CSSProperties;
54
+ triggerClassName?: string;
89
55
  };
90
- interface IState {
91
- show: boolean;
92
- }
93
56
  /**
94
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
95
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
96
59
  where the least amount of overflow is occuring. The order it tries to find a new placement in is top, right, down, left.
97
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
98
61
  */
99
- export declare class InfoWindow extends React.PureComponent<IInfoWindowProps, IState> {
100
- private _showDelayId;
101
- private _triggerRef;
102
- private _renderContainer;
103
- private _contentRef;
104
- private _triangleRef;
105
- private _cursorPosition;
106
- private _triggerRect;
107
- constructor(props: IInfoWindowProps);
108
- componentDidMount(): void;
109
- componentDidUpdate(oldProps: IInfoWindowProps): void;
110
- componentWillUnmount(): void;
111
- computeStylesFromDisplayPosition: (anchor: IAnchorScores, triangleRect: ClientRect) => IInfoWindowStyles<number>;
112
- setTriggerRef: (div: HTMLDivElement) => void;
113
- setContentRef: (div: HTMLDivElement) => void;
114
- setTriangleRef: (span: HTMLSpanElement) => void;
115
- showHideToggle: () => void;
116
- setShow: (show: boolean) => void;
117
- handleBodyClick: (e: MouseEvent) => void;
118
- handleScroll: () => void;
119
- onTriggerClick: (e: React.MouseEvent<HTMLDivElement>) => void;
120
- onMouseOver: (e: React.MouseEvent<HTMLDivElement>) => void;
121
- onMouseLeave: (e: React.MouseEvent<any>) => void;
122
- onMouseMove: (e: MouseEvent) => void;
123
- getDisplayPosition: (triggerPoint: ICursorPoints, triggerRect: ClientRect, triangleRect: ClientRect, contentRect: ClientRect) => IAnchorScores;
124
- closeInfoWindow(): void;
125
- notTargetArea(e: MouseEvent): boolean;
126
- registerMousePosition(e: MouseEvent | React.MouseEvent<any> | null): void;
127
- detachEventListeners(): void;
128
- attachEventListeners(): void;
129
- computeStyles(): {
130
- contentStyles: React.CSSProperties;
131
- triangleStyles: React.CSSProperties;
132
- position: PositionType;
133
- } | {
134
- position: PositionType;
135
- triangleStyles: {
136
- top: string;
137
- left: string;
138
- } | {
139
- top: string;
140
- left: string;
141
- };
142
- contentStyles: {
143
- top: string;
144
- left: string;
145
- } | {
146
- top: string;
147
- left: string;
148
- };
149
- };
150
- removeRenderingContainer(): void;
151
- createRenderContainer(): HTMLDivElement;
152
- /**
153
- * The first render wont be positioned properly since we don't have the width/height to calculate the position.
154
- * `runStyleRender` runs a second render when we have the contentContainer rendered to calculate the position.
155
- */
156
- renderContent(runStyleRender?: boolean): void;
157
- render(): JSX.Element;
62
+ export declare const InfoWindow: (props: IInfoWindowPopOutProps) => JSX.Element;
63
+ interface InfoWindowState {
64
+ closeInfoWindow: () => void;
158
65
  }
159
66
  export declare const useInfoWindow: () => InfoWindowState;
160
67
  export {};
@@ -0,0 +1,154 @@
1
+ import * as React from 'react';
2
+ import { IAnchorScores, ICursorOptions, ICursorPoints, Position } from './info-window-utils';
3
+ export declare type IEvent = 'click' | 'hover' | 'mount';
4
+ export interface IInfoWindowStyles<T> {
5
+ triangleStyles: {
6
+ top: T;
7
+ left: T;
8
+ };
9
+ contentStyles: {
10
+ top: T;
11
+ left: T;
12
+ };
13
+ }
14
+ export interface IRequiredProps {
15
+ /**
16
+ * Content to be shown inside the info window
17
+ */
18
+ content: JSX.Element | JSX.Element[] | React.ReactNode | string;
19
+ /**
20
+ * Preferred direction around the trigger to open the info window
21
+ */
22
+ position: Position;
23
+ }
24
+ export declare type IInfoWindowProps = IRequiredProps & {
25
+ children?: React.ReactNode;
26
+ /**
27
+ * IEvent type used to trigger the info window
28
+ */
29
+ event?: IEvent;
30
+ /**
31
+ * Cursor options control what happens to the info window while moving the mouse within the trigger
32
+ */
33
+ cursorOption?: ICursorOptions;
34
+ /**
35
+ * Delay the render of the info window after the trigger event has been fired
36
+ */
37
+ delayShow?: number;
38
+ /**
39
+ * Prevent the display of the info window regardless of the trigger event
40
+ */
41
+ preventShow?: boolean;
42
+ /**
43
+ * ClassName to be given to the wrapper around the info window content
44
+ */
45
+ containerClassName?: string;
46
+ /**
47
+ * ClassName to be given to the wrapper around the trigger component
48
+ */
49
+ className?: string;
50
+ /**
51
+ * Data attributes to be applied to the wrapper around the trigger component
52
+ */
53
+ dataAttributes?: {
54
+ [key: string]: string;
55
+ };
56
+ /**
57
+ * Apply 'display: inline-block' style to the wrapper around the trigger component
58
+ */
59
+ displayInline?: boolean;
60
+ /**
61
+ * Render a close button within the wrapper around the info window content
62
+ */
63
+ withCloseButton?: boolean;
64
+ /**
65
+ * Offset the trigger points used to calculate the render positions by this number of pixels
66
+ */
67
+ positionOffset?: number;
68
+ /**
69
+ * Will be called when the mouse over event is fired on the trigger component
70
+ */
71
+ onMouseOver?: (e: React.MouseEvent<HTMLDivElement>) => void;
72
+ /**
73
+ * Will be called when the mouse leave event is fired on the trigger component
74
+ */
75
+ onMouseLeave?: (e: React.MouseEvent<HTMLDivElement>) => void;
76
+ /**
77
+ * Will be called when the info window is closed (regardless of the trigger event)
78
+ */
79
+ onClose?: () => void;
80
+ /**
81
+ * Styles to apply to the wrapper around the trigger component
82
+ */
83
+ style?: React.CSSProperties;
84
+ };
85
+ interface IState {
86
+ show: boolean;
87
+ }
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
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
+ where the least amount of overflow is occuring. The order it tries to find a new placement in is top, right, down, left.
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
+ */
94
+ export declare class LegacyInfoWindow extends React.PureComponent<IInfoWindowProps, IState> {
95
+ private _showDelayId;
96
+ private _triggerRef;
97
+ private _renderContainer;
98
+ private _contentRef;
99
+ private _triangleRef;
100
+ private _cursorPosition;
101
+ private _triggerRect;
102
+ constructor(props: IInfoWindowProps);
103
+ componentDidMount(): void;
104
+ componentDidUpdate(oldProps: IInfoWindowProps): void;
105
+ componentWillUnmount(): void;
106
+ computeStylesFromDisplayPosition: (anchor: IAnchorScores, triangleRect: ClientRect) => IInfoWindowStyles<number>;
107
+ setTriggerRef: (div: HTMLDivElement) => void;
108
+ setContentRef: (div: HTMLDivElement) => void;
109
+ setTriangleRef: (span: HTMLSpanElement) => void;
110
+ showHideToggle: () => void;
111
+ setShow: (show: boolean) => void;
112
+ handleBodyClick: (e: MouseEvent) => void;
113
+ handleScroll: () => void;
114
+ onTriggerClick: (e: React.MouseEvent<HTMLDivElement>) => void;
115
+ onMouseOver: (e: React.MouseEvent<HTMLDivElement>) => void;
116
+ onMouseLeave: (e: React.MouseEvent<any>) => void;
117
+ onMouseMove: (e: MouseEvent) => void;
118
+ getDisplayPosition: (triggerPoint: ICursorPoints, triggerRect: ClientRect, triangleRect: ClientRect, contentRect: ClientRect) => IAnchorScores;
119
+ closeInfoWindow(): void;
120
+ notTargetArea(e: MouseEvent): boolean;
121
+ registerMousePosition(e: MouseEvent | React.MouseEvent<any> | null): void;
122
+ detachEventListeners(): void;
123
+ attachEventListeners(): void;
124
+ computeStyles(): {
125
+ contentStyles: React.CSSProperties;
126
+ triangleStyles: React.CSSProperties;
127
+ position: Position;
128
+ } | {
129
+ position: Position;
130
+ triangleStyles: {
131
+ top: string;
132
+ left: string;
133
+ } | {
134
+ top: string;
135
+ left: string;
136
+ };
137
+ contentStyles: {
138
+ top: string;
139
+ left: string;
140
+ } | {
141
+ top: string;
142
+ left: string;
143
+ };
144
+ };
145
+ removeRenderingContainer(): void;
146
+ createRenderContainer(): HTMLDivElement;
147
+ /**
148
+ * The first render wont be positioned properly since we don't have the width/height to calculate the position.
149
+ * `runStyleRender` runs a second render when we have the contentContainer rendered to calculate the position.
150
+ */
151
+ renderContent(runStyleRender?: boolean): void;
152
+ render(): JSX.Element;
153
+ }
154
+ export {};
@@ -1,5 +1,6 @@
1
- import * as React from 'react';
2
- import { IInfoWindowProps, Position } from '../info-window/InfoWindow';
1
+ /// <reference types="react" />
2
+ import { IInfoWindowProps } from '../info-window/LegacyInfoWindow';
3
+ import { Position } from '../info-window/info-window-utils';
3
4
  import './tooltip.scss';
4
5
  export declare type ITooltipPosition = Position;
5
6
  declare type IColorScheme = 'dark' | 'light';
@@ -8,19 +9,13 @@ export interface ITooltipProps extends IInfoWindowProps {
8
9
  /**
9
10
  * Colour scheme for the tooltip content. Available options are 'dark' and 'light'
10
11
  */
12
+ delayShow?: IInfoWindowProps['delayShow'];
13
+ event?: IInfoWindowProps['event'];
11
14
  colorScheme?: IColorScheme;
12
15
  textAlignment?: IAlignStyle;
13
16
  }
14
17
  /**
15
- * Tooltips are an extened version of the info window that triggers on hover by default, delayed slightly and is styled with tooltip styles
18
+ * Tooltips are an extended version of the info window that triggers on hover by default, delayed slightly and is styled with tooltip styles
16
19
  */
17
- export declare class Tooltip extends React.PureComponent<ITooltipProps, {}> {
18
- static defaultProps: {
19
- event: string;
20
- delayShow: number;
21
- colorScheme: string;
22
- textAlignment: string;
23
- };
24
- render(): JSX.Element;
25
- }
20
+ export declare const Tooltip: (props: ITooltipProps) => JSX.Element;
26
21
  export {};
@@ -0,0 +1 @@
1
+ export declare function useDebounce<T>(value: T, delay?: number): T;
package/dist/index.d.ts CHANGED
@@ -51,6 +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
55
  export * from './components/popups/tooltip/Tooltip';
55
56
  export * from './components/pill/Pill';
56
57
  export * from './components/table/Table';