@splunk/react-ui 5.0.0-beta.5 → 5.0.0-rc.2
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/ButtonSimple.js +92 -168
- package/{CHANGELOG.v5.mdx → CHANGELOG.v5.md} +43 -0
- package/Calendar.js +148 -151
- package/Card.js +139 -139
- package/Code.js +197 -167
- package/CollapsiblePanel.js +172 -164
- package/Color.js +584 -506
- package/ComboBox.js +51 -51
- package/ControlGroup.js +132 -127
- package/Date.js +137 -150
- package/Dropdown.js +97 -96
- package/DualListbox.js +468 -469
- package/FetchOptions.d.ts +2 -2
- package/FormRows.js +158 -157
- package/JSONTree.js +354 -360
- package/{MIGRATION.mdx → MIGRATION.md} +13 -43
- package/{MIGRATION.v5.mdx → MIGRATION.v5.md} +67 -1
- package/Markdown.js +3 -4
- package/Menu.js +194 -195
- package/Modal.js +18 -18
- package/ModalLayer.js +171 -217
- package/Multiselect.js +785 -778
- package/Number.js +103 -102
- package/Popover.js +48 -46
- package/RadioBar.js +144 -146
- package/Resize.js +149 -151
- package/ResultsMenu.js +112 -114
- package/Search.js +49 -49
- package/Select.js +455 -457
- package/Slider.js +328 -331
- package/Switch.js +251 -178
- package/TabBar.js +277 -280
- package/Table.js +1212 -1178
- package/Text.js +45 -46
- package/Tooltip.js +192 -189
- package/Tree.js +177 -188
- package/package.json +10 -9
- package/types/src/Code/Code.d.ts +1 -1
- package/types/src/Color/Color.d.ts +2 -2
- package/types/src/ControlGroup/ControlGroup.d.ts +1 -2
- package/types/src/Dropdown/Dropdown.d.ts +5 -2
- package/types/src/Layer/Layer.d.ts +2 -1
- package/types/src/Layer/index.d.ts +1 -0
- package/types/src/ModalLayer/ModalLayer.d.ts +16 -21
- package/types/src/Number/Number.d.ts +1 -1
- package/types/src/Popover/Popover.d.ts +5 -2
- package/types/src/Table/HeadCell.d.ts +6 -1
- package/types/src/Table/HeadInner.d.ts +3 -1
- package/types/src/Tooltip/Tooltip.d.ts +7 -7
- package/types/src/fixtures/useFetchOptions.d.ts +33 -0
- package/useRovingFocus.js +20 -23
- package/types/src/fixtures/FetchOptions.d.ts +0 -76
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@splunk/react-ui",
|
|
3
|
-
"version": "5.0.0-
|
|
3
|
+
"version": "5.0.0-rc.2",
|
|
4
4
|
"description": "Library of React components that implement the Splunk design language",
|
|
5
5
|
"license": "Apache-2.0",
|
|
6
6
|
"author": "Splunk Inc.",
|
|
@@ -45,8 +45,8 @@
|
|
|
45
45
|
"@dnd-kit/sortable": "^8.0.0",
|
|
46
46
|
"@dnd-kit/utilities": "^3.2.2",
|
|
47
47
|
"@react-spring/web": "^9.7.5",
|
|
48
|
-
"@splunk/react-icons": "5.0.0-
|
|
49
|
-
"@splunk/themes": "1.0.0-
|
|
48
|
+
"@splunk/react-icons": "5.0.0-rc.2",
|
|
49
|
+
"@splunk/themes": "1.0.0-rc.2",
|
|
50
50
|
"@splunk/ui-utils": "^1.8.0",
|
|
51
51
|
"decimal.js-light": "^2.2.3",
|
|
52
52
|
"lodash": "^4.17.14",
|
|
@@ -61,9 +61,9 @@
|
|
|
61
61
|
"@babel/core": "^7.2.0",
|
|
62
62
|
"@babel/plugin-transform-runtime": "^7.18.6",
|
|
63
63
|
"@splunk/babel-preset": "^4.0.0",
|
|
64
|
-
"@splunk/docs-gen": "1.0.0-
|
|
64
|
+
"@splunk/docs-gen": "1.0.0-rc.2",
|
|
65
65
|
"@splunk/eslint-config": "^5.0.0",
|
|
66
|
-
"@splunk/react-docs": "1.0.0-
|
|
66
|
+
"@splunk/react-docs": "1.0.0-rc.2",
|
|
67
67
|
"@splunk/stylelint-config": "^5.0.0",
|
|
68
68
|
"@splunk/test-runner-utils": "^0.4.1",
|
|
69
69
|
"@splunk/webpack-configs": "^7.0.2",
|
|
@@ -75,10 +75,11 @@
|
|
|
75
75
|
"@storybook/react-webpack5": "^7.6.17",
|
|
76
76
|
"@storybook/test-runner": "0.16.0",
|
|
77
77
|
"@testing-library/cypress": "^9.0.0",
|
|
78
|
-
"@testing-library/
|
|
79
|
-
"@testing-library/
|
|
80
|
-
"@testing-library/react
|
|
81
|
-
"@testing-library/
|
|
78
|
+
"@testing-library/dom": "^10.4.0",
|
|
79
|
+
"@testing-library/jest-dom": "^6.6.3",
|
|
80
|
+
"@testing-library/react": "^16.3.0",
|
|
81
|
+
"@testing-library/react-hooks": "^8.0.1",
|
|
82
|
+
"@testing-library/user-event": "^14.6.1",
|
|
82
83
|
"@types/jest": "^26.0.0",
|
|
83
84
|
"@types/lodash": "^4.14.156",
|
|
84
85
|
"@types/node": "^10.17.26",
|
package/types/src/Code/Code.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
import PropTypes from 'prop-types';
|
|
3
3
|
import { ComponentProps } from '../utils/types';
|
|
4
|
-
type CodeSupportedLanguages = 'bash' | 'clike' | 'css' | 'html' | 'json' | 'javascript' | 'js' | 'jsx' | 'typescript' | 'ts' | 'tsx' | 'markup' | 'mathml' | 'plain' | 'plaintext' | 'splunk-spl' | 'svg' | 'text' | 'txt' | 'xml' | 'yaml' | 'yml';
|
|
4
|
+
type CodeSupportedLanguages = 'bash' | 'clike' | 'css' | 'html' | 'json' | 'javascript' | 'js' | 'jsx' | 'typescript' | 'ts' | 'tsx' | 'markup' | 'mathml' | 'plain' | 'plaintext' | 'splunk-spl' | 'sql' | 'svg' | 'text' | 'txt' | 'xml' | 'yaml' | 'yml';
|
|
5
5
|
interface CodePropsBase {
|
|
6
6
|
/**
|
|
7
7
|
* A React ref which is set to the DOM element when the component mounts and null when it unmounts.
|
|
@@ -22,7 +22,7 @@ interface ColorPropsBase {
|
|
|
22
22
|
/**
|
|
23
23
|
* A React ref which is set to the DOM element when the component mounts and null when it unmounts.
|
|
24
24
|
*/
|
|
25
|
-
elementRef?: React.Ref<
|
|
25
|
+
elementRef?: React.Ref<HTMLDivElement>;
|
|
26
26
|
/** Add an error attribute. */
|
|
27
27
|
error?: boolean;
|
|
28
28
|
/**
|
|
@@ -64,7 +64,7 @@ interface ColorPropsBaseUncontrolled extends ColorPropsBase {
|
|
|
64
64
|
defaultValue?: string | null;
|
|
65
65
|
value?: never;
|
|
66
66
|
}
|
|
67
|
-
type ColorProps = ComponentProps<ColorPropsBaseControlled | ColorPropsBaseUncontrolled, '
|
|
67
|
+
type ColorProps = ComponentProps<ColorPropsBaseControlled | ColorPropsBaseUncontrolled, 'div'>;
|
|
68
68
|
declare function Color({ append, defaultValue, disabled, describedBy, elementRef, error, hideInput, labelledBy, name, onChange, palette, prepend, required, value: valueProp, ...otherProps }: ColorProps): React.JSX.Element;
|
|
69
69
|
declare namespace Color {
|
|
70
70
|
var propTypes: {
|
|
@@ -15,8 +15,7 @@ interface ControlGroupPropsBase {
|
|
|
15
15
|
/**
|
|
16
16
|
* Highlight the control group as having an error and optionally provide error text.
|
|
17
17
|
* If error text is provided, displays it below the control.
|
|
18
|
-
*
|
|
19
|
-
* Child components will not turn red.
|
|
18
|
+
* In addition to passing this prop, set the error prop on child components.
|
|
20
19
|
*/
|
|
21
20
|
error?: boolean | string;
|
|
22
21
|
help?: React.ReactNode;
|
|
@@ -14,6 +14,8 @@ type DropdownPlacement = 'above' | 'below' | 'left' | 'right' | 'vertical' | 'ho
|
|
|
14
14
|
/** @public */
|
|
15
15
|
type DropdownPlacementStatus = 'above' | 'below' | 'left' | 'right' | 'misaligned';
|
|
16
16
|
/** @public */
|
|
17
|
+
type DropdownPossibleOpenReason = 'toggleClick' | 'toggleKeydown';
|
|
18
|
+
/** @public */
|
|
17
19
|
type DropdownPossibleCloseReason = 'clickAway' | 'contentClick' | 'escapeKey' | 'offScreen' | 'tabKey' | 'toggleClick';
|
|
18
20
|
/** @public */
|
|
19
21
|
type DropdownRequestCloseHandler = (data: {
|
|
@@ -22,7 +24,7 @@ type DropdownRequestCloseHandler = (data: {
|
|
|
22
24
|
}) => void;
|
|
23
25
|
/** @public */
|
|
24
26
|
type DropdownRequestOpenHandler = (event: React.MouseEvent<HTMLElement> | React.KeyboardEvent<HTMLElement>, data: {
|
|
25
|
-
reason:
|
|
27
|
+
reason: DropdownPossibleOpenReason;
|
|
26
28
|
}) => void;
|
|
27
29
|
/** @public */
|
|
28
30
|
type DropdownToggleElement = React.ReactElement<React.HTMLAttributes<HTMLElement> & {
|
|
@@ -147,7 +149,8 @@ declare namespace Dropdown {
|
|
|
147
149
|
takeFocus: PropTypes.Requireable<boolean>;
|
|
148
150
|
toggle: PropTypes.Validator<PropTypes.ReactElementLike>;
|
|
149
151
|
};
|
|
152
|
+
var possibleOpenReasons: DropdownPossibleOpenReason[];
|
|
150
153
|
var possibleCloseReasons: DropdownPossibleCloseReason[];
|
|
151
154
|
}
|
|
152
155
|
export default Dropdown;
|
|
153
|
-
export type { DropdownChildrenRenderer, DropdownPlacement, DropdownPlacementStatus, DropdownPossibleCloseReason, DropdownRequestCloseHandler, DropdownRequestOpenHandler, DropdownToggleElement, };
|
|
156
|
+
export type { DropdownChildrenRenderer, DropdownPlacement, DropdownPlacementStatus, DropdownPossibleOpenReason, DropdownPossibleCloseReason, DropdownRequestCloseHandler, DropdownRequestOpenHandler, DropdownToggleElement, };
|
|
@@ -28,4 +28,5 @@ declare const Layer: JSXElementConstructor<LayerProps> & {
|
|
|
28
28
|
propTypes: React.WeakValidationMap<LayerProps>;
|
|
29
29
|
};
|
|
30
30
|
export default Layer;
|
|
31
|
-
export { LayerProps,
|
|
31
|
+
export { LayerProps, LayerRequestCloseHandler };
|
|
32
|
+
export type { LayerPossibleCloseReason };
|
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import React
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import PropTypes from 'prop-types';
|
|
2
3
|
interface AdditionalInterpolationProperties {
|
|
3
4
|
top?: number;
|
|
4
5
|
}
|
|
@@ -16,12 +17,12 @@ interface ModalLayerPropsBase {
|
|
|
16
17
|
*/
|
|
17
18
|
childrenInAnimation?: boolean;
|
|
18
19
|
/**
|
|
19
|
-
* A function that returns a default style object for
|
|
20
|
+
* A function that returns a default style object for the animation. The values will be
|
|
20
21
|
* used as initial values.
|
|
21
22
|
*/
|
|
22
23
|
getDefaultMotionStyle?: () => AdditionalInterpolationProperties;
|
|
23
24
|
/**
|
|
24
|
-
* A function that returns a
|
|
25
|
+
* A function that returns a style object. The resulting interpolated style
|
|
25
26
|
* will be passed to `renderModal`.
|
|
26
27
|
*/
|
|
27
28
|
getMotionStyle?: () => AdditionalInterpolationProperties;
|
|
@@ -35,7 +36,7 @@ interface ModalLayerPropsBase {
|
|
|
35
36
|
*/
|
|
36
37
|
open?: boolean;
|
|
37
38
|
/**
|
|
38
|
-
* Function that renders the modal. It is passed the current style object as interpolated by
|
|
39
|
+
* Function that renders the modal. It is passed the current style object as interpolated by the animation,
|
|
39
40
|
* and is expected to return renderable content.
|
|
40
41
|
*/
|
|
41
42
|
renderModal: ModalLayerRenderModalHandler;
|
|
@@ -45,23 +46,17 @@ interface ModalLayerPropsBase {
|
|
|
45
46
|
*/
|
|
46
47
|
scrim?: 'visible' | 'hidden' | 'interactive';
|
|
47
48
|
}
|
|
48
|
-
declare
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
constructor(props: Readonly<ModalLayerProps>);
|
|
60
|
-
componentWillUnmount(): void;
|
|
61
|
-
private handleClickAway;
|
|
62
|
-
private handleAnimationEnd;
|
|
63
|
-
private renderLayer;
|
|
64
|
-
render(): React.JSX.Element;
|
|
49
|
+
declare function ModalLayer({ childrenInAnimation, getDefaultMotionStyle, getMotionStyle, onRequestClose, open, renderModal, scrim, }: ModalLayerPropsBase): React.JSX.Element;
|
|
50
|
+
declare namespace ModalLayer {
|
|
51
|
+
var propTypes: {
|
|
52
|
+
childrenInAnimation: PropTypes.Requireable<boolean>;
|
|
53
|
+
getDefaultMotionStyle: PropTypes.Requireable<(...args: any[]) => any>;
|
|
54
|
+
getMotionStyle: PropTypes.Requireable<(...args: any[]) => any>;
|
|
55
|
+
onRequestClose: PropTypes.Requireable<(...args: any[]) => any>;
|
|
56
|
+
open: PropTypes.Requireable<boolean>;
|
|
57
|
+
renderModal: PropTypes.Validator<(...args: any[]) => any>;
|
|
58
|
+
scrim: PropTypes.Requireable<string>;
|
|
59
|
+
};
|
|
65
60
|
}
|
|
66
61
|
export default ModalLayer;
|
|
67
62
|
export { ModalLayerRequestCloseHandler, ModalLayerRenderModalHandler };
|
|
@@ -66,8 +66,10 @@ interface PopoverPropsBase {
|
|
|
66
66
|
*/
|
|
67
67
|
animationConfig?: SpringConfig;
|
|
68
68
|
/**
|
|
69
|
-
* `'normal'` is the default appearance
|
|
70
|
-
*
|
|
69
|
+
* `'normal'` is the default appearance.`'none'` is a transparent box.
|
|
70
|
+
*
|
|
71
|
+
* @deprecatedValue 'inverted'
|
|
72
|
+
* The 'inverted' value is deprecated and will be removed in a future major version.
|
|
71
73
|
*/
|
|
72
74
|
appearance?: 'normal' | 'inverted' | 'none';
|
|
73
75
|
/**
|
|
@@ -177,6 +179,7 @@ declare namespace Popover {
|
|
|
177
179
|
takeFocus: PropTypes.Requireable<boolean>;
|
|
178
180
|
splunkTheme: PropTypes.Requireable<object>;
|
|
179
181
|
};
|
|
182
|
+
var possibleCloseReasons: PopoverPossibleCloseReason[];
|
|
180
183
|
}
|
|
181
184
|
export default Popover;
|
|
182
185
|
export type { PopoverChildrenRenderer, PopoverPlacement, PopoverPlacementStatus, PopoverPossibleCloseReason, PopoverRequestCloseHandler, };
|
|
@@ -75,6 +75,10 @@ interface HeadCellPropsBase {
|
|
|
75
75
|
* The `sortKey` is passed in the data object to the `onSort` callback, if provided.
|
|
76
76
|
*/
|
|
77
77
|
sortKey?: string;
|
|
78
|
+
/**
|
|
79
|
+
* Content to show in a tooltip.
|
|
80
|
+
*/
|
|
81
|
+
tooltip?: React.ReactNode;
|
|
78
82
|
/**
|
|
79
83
|
* Truncate the text in the label. `truncate=false` is not compatible with `Table`'s
|
|
80
84
|
* `onRequestResize`.
|
|
@@ -94,7 +98,7 @@ interface HeadCellPropsBase {
|
|
|
94
98
|
variant?: 'toggleAll' | 'info' | 'actions';
|
|
95
99
|
}
|
|
96
100
|
type HeadCellProps = ComponentProps<HeadCellPropsBase, 'th'>;
|
|
97
|
-
declare function HeadCell({ align, appearClickable, children, columnId, elementRef, dragId, headCellScreenReaderText, id, index, onAutosizeColumn, onClick, onKeyDown, onRequestMoveColumn, onRequestResize, onSort, resizable, sortDir, sortKey, style, truncate: truncateProp, variant, visible, width, ...otherProps }: HeadCellProps): React.JSX.Element;
|
|
101
|
+
declare function HeadCell({ align, appearClickable, children, columnId, elementRef, dragId, headCellScreenReaderText, id, index, onAutosizeColumn, onClick, onKeyDown, onRequestMoveColumn, onRequestResize, onSort, resizable, sortDir, sortKey, style, tooltip, truncate: truncateProp, variant, visible, width, ...otherProps }: HeadCellProps): React.JSX.Element;
|
|
98
102
|
declare namespace HeadCell {
|
|
99
103
|
var propTypes: {
|
|
100
104
|
align: PropTypes.Requireable<string>;
|
|
@@ -124,6 +128,7 @@ declare namespace HeadCell {
|
|
|
124
128
|
resizable: PropTypes.Requireable<boolean>;
|
|
125
129
|
sortDir: PropTypes.Requireable<string>;
|
|
126
130
|
sortKey: PropTypes.Requireable<string>;
|
|
131
|
+
tooltip: PropTypes.Requireable<PropTypes.ReactNodeLike>;
|
|
127
132
|
truncate: PropTypes.Requireable<boolean>;
|
|
128
133
|
/** @private. */
|
|
129
134
|
variant: PropTypes.Requireable<string>;
|
|
@@ -10,6 +10,7 @@ interface HeadInnerPropsBase {
|
|
|
10
10
|
columnId?: string;
|
|
11
11
|
elementRef?: React.Ref<HTMLButtonElement | HTMLDivElement>;
|
|
12
12
|
focusWithin?: boolean;
|
|
13
|
+
hasTooltip?: boolean;
|
|
13
14
|
id?: string;
|
|
14
15
|
index?: number;
|
|
15
16
|
isMenu?: boolean;
|
|
@@ -23,7 +24,7 @@ interface HeadInnerPropsBase {
|
|
|
23
24
|
variant?: 'toggleAll' | 'info' | 'actions';
|
|
24
25
|
}
|
|
25
26
|
type HeadInnerProps = ComponentProps<HeadInnerPropsBase, 'div'>;
|
|
26
|
-
declare function HeadInner({ align, clickable, columnId, elementRef, focusWithin, id, index, isMenu, label, onAutosizeColumn, onRequestResize, resizable, sortDir, truncate, variant, width: widthProp, ...otherProps }: HeadInnerProps): React.JSX.Element;
|
|
27
|
+
declare function HeadInner({ align, clickable, columnId, elementRef, focusWithin, hasTooltip, id, index, isMenu, label, onAutosizeColumn, onRequestResize, resizable, sortDir, truncate, variant, width: widthProp, ...otherProps }: HeadInnerProps): React.JSX.Element;
|
|
27
28
|
declare namespace HeadInner {
|
|
28
29
|
var propTypes: {
|
|
29
30
|
align: PropTypes.Requireable<string>;
|
|
@@ -31,6 +32,7 @@ declare namespace HeadInner {
|
|
|
31
32
|
columnId: PropTypes.Requireable<string>;
|
|
32
33
|
elementRef: PropTypes.Requireable<object>;
|
|
33
34
|
focusWithin: PropTypes.Requireable<boolean>;
|
|
35
|
+
hasTooltip: PropTypes.Requireable<boolean>;
|
|
34
36
|
id: PropTypes.Requireable<string>;
|
|
35
37
|
index: PropTypes.Requireable<number>;
|
|
36
38
|
isMenu: PropTypes.Requireable<boolean>;
|
|
@@ -1,18 +1,17 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
import PropTypes from 'prop-types';
|
|
3
|
-
import { PopoverPossibleCloseReason } from '@splunk/react-ui/Popover';
|
|
4
3
|
import { ComponentProps } from '../utils/types';
|
|
5
4
|
/** @public */
|
|
6
|
-
type
|
|
5
|
+
type TooltipPossibleOpenReason = 'focusToggle' | 'mouseEnterPopover' | 'mouseEnterToggle' | 'mouseEnterHitArea';
|
|
7
6
|
/** @public */
|
|
8
|
-
type
|
|
7
|
+
type TooltipPossibleCloseReason = 'blurToggle' | 'clickAway' | 'escapeKey' | 'mouseLeaveHitArea' | 'mouseLeavePopover' | 'mouseLeaveToggle' | 'mouseStopHitArea' | 'offScreen' | 'tabKey' | 'toggleClick';
|
|
9
8
|
/** @public */
|
|
10
9
|
type TooltipRequestCloseHandler = (event: React.FocusEvent<HTMLSpanElement> | React.MouseEvent | MouseEvent | null, data: {
|
|
11
|
-
reason:
|
|
10
|
+
reason: TooltipPossibleCloseReason;
|
|
12
11
|
}) => void;
|
|
13
12
|
/** @public */
|
|
14
13
|
type TooltipRequestOpenHandler = (event: React.FocusEvent<HTMLSpanElement> | MouseEvent, data: {
|
|
15
|
-
reason:
|
|
14
|
+
reason: TooltipPossibleOpenReason;
|
|
16
15
|
}) => void;
|
|
17
16
|
interface AnchorProps {
|
|
18
17
|
onFocus: React.FocusEventHandler<HTMLElement>;
|
|
@@ -117,7 +116,6 @@ interface TooltipPropsBase {
|
|
|
117
116
|
*/
|
|
118
117
|
renderAnchor?: (props: AnchorProps) => React.ReactNode;
|
|
119
118
|
}
|
|
120
|
-
declare const closeReasons: PopoverPossibleCloseReason[];
|
|
121
119
|
type TooltipProps = ComponentProps<TooltipPropsBase, 'span'>;
|
|
122
120
|
/**
|
|
123
121
|
* The Tooltip component wraps arbitrary content to be displayed when the target element is hovered
|
|
@@ -143,7 +141,9 @@ declare namespace Tooltip {
|
|
|
143
141
|
openDelay: PropTypes.Requireable<NonNullable<string | number | null | undefined>>;
|
|
144
142
|
renderAnchor: PropTypes.Requireable<(...args: any[]) => any>;
|
|
145
143
|
};
|
|
144
|
+
var possibleOpenReasons: TooltipPossibleOpenReason[];
|
|
145
|
+
var possibleCloseReasons: TooltipPossibleCloseReason[];
|
|
146
146
|
}
|
|
147
147
|
export default Tooltip;
|
|
148
148
|
export { TooltipRequestCloseHandler, TooltipRequestOpenHandler };
|
|
149
|
-
export type { TooltipPropsBase };
|
|
149
|
+
export type { AnchorProps, TooltipPropsBase, TooltipPossibleOpenReason, TooltipPossibleCloseReason, };
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import 'core-js/es/promise';
|
|
2
|
+
type Movie = {
|
|
3
|
+
id: number;
|
|
4
|
+
title: string;
|
|
5
|
+
};
|
|
6
|
+
type MovieOption = Movie & {
|
|
7
|
+
matchRanges?: {
|
|
8
|
+
start: number;
|
|
9
|
+
end: number;
|
|
10
|
+
}[];
|
|
11
|
+
};
|
|
12
|
+
declare function isMovieOption(movie: Movie | MovieOption): movie is MovieOption;
|
|
13
|
+
interface FetchOptionsParams {
|
|
14
|
+
fetchTimeout?: number;
|
|
15
|
+
fetchMoreTimeout?: number;
|
|
16
|
+
numberOfResults?: number;
|
|
17
|
+
}
|
|
18
|
+
/**
|
|
19
|
+
* @param fetchTimeout: number - The number of milliseconds to defer fetching of options.
|
|
20
|
+
* @param fetchMoreTimeout: number - The number of milliseconds to defer fetching additional options.
|
|
21
|
+
* @param numberOfResults: number - Then number of options to retrieve per fetch.
|
|
22
|
+
*/
|
|
23
|
+
export default function useFetchOptions({ fetchTimeout, fetchMoreTimeout, numberOfResults, }?: FetchOptionsParams): {
|
|
24
|
+
fetch: (filter?: string, timeout?: number) => Promise<MovieOption[]>;
|
|
25
|
+
fetchMore: (opts?: MovieOption[]) => Promise<MovieOption[]>;
|
|
26
|
+
reset: () => void;
|
|
27
|
+
stop: () => void;
|
|
28
|
+
getOption: (value: number) => Movie | undefined;
|
|
29
|
+
getSelectedOptions: (values: number[]) => Movie[];
|
|
30
|
+
getCurrentCount: () => number;
|
|
31
|
+
getFullCount: () => number;
|
|
32
|
+
};
|
|
33
|
+
export { isMovieOption, Movie, MovieOption };
|
package/useRovingFocus.js
CHANGED
|
@@ -46,16 +46,14 @@
|
|
|
46
46
|
e.r(t);
|
|
47
47
|
// EXPORTS
|
|
48
48
|
e.d(t, {
|
|
49
|
-
default: () => /* reexport */
|
|
49
|
+
default: () => /* reexport */ u
|
|
50
50
|
});
|
|
51
51
|
// CONCATENATED MODULE: external "react"
|
|
52
52
|
const r = require("react");
|
|
53
53
|
// CONCATENATED MODULE: external "@splunk/ui-utils/focus"
|
|
54
54
|
const n = require("@splunk/ui-utils/focus");
|
|
55
|
-
// CONCATENATED MODULE: external "@splunk/ui-utils/keyboard"
|
|
56
|
-
const a = require("@splunk/ui-utils/keyboard");
|
|
57
55
|
// CONCATENATED MODULE: ./src/useRovingFocus/useRovingFocus.tsx
|
|
58
|
-
var
|
|
56
|
+
var a = {
|
|
59
57
|
enableLoop: false,
|
|
60
58
|
orientation: "horizontal",
|
|
61
59
|
enableTab: false,
|
|
@@ -80,49 +78,48 @@
|
|
|
80
78
|
* <button type="button">second</button>
|
|
81
79
|
* </div>
|
|
82
80
|
* ```
|
|
83
|
-
*/ function
|
|
81
|
+
*/ function o() {
|
|
84
82
|
var e = (0, r.useRef)(0);
|
|
85
83
|
var t = (0, r.useRef)([]);
|
|
86
|
-
var
|
|
84
|
+
var o = function r(n) {
|
|
87
85
|
e.current = n;
|
|
88
86
|
t.current.forEach((function(t, r) {
|
|
89
87
|
return r === e.current ? t.removeAttribute("tabindex") : t.setAttribute("tabindex", "-1");
|
|
90
88
|
}));
|
|
91
89
|
};
|
|
92
|
-
var
|
|
90
|
+
var u = function r(a) {
|
|
93
91
|
t.current = a != null ? (0, n.getSortedTabbableElements)(a, {
|
|
94
92
|
ignoreTabIndex: true
|
|
95
93
|
}) : [];
|
|
96
|
-
|
|
94
|
+
o(e.current);
|
|
97
95
|
};
|
|
98
|
-
var
|
|
96
|
+
var i = function e(r) {
|
|
99
97
|
var n = r.relatedTarget instanceof Element && t.current.includes(r.relatedTarget);
|
|
100
98
|
if (!n) {
|
|
101
|
-
|
|
99
|
+
o(0);
|
|
102
100
|
}
|
|
103
101
|
};
|
|
104
|
-
var
|
|
102
|
+
var c = function e(r) {
|
|
105
103
|
var n = r.target instanceof Element ? t.current.indexOf(r.target) : -1;
|
|
106
104
|
if (n >= 0) {
|
|
107
|
-
|
|
105
|
+
o(n);
|
|
108
106
|
}
|
|
109
107
|
};
|
|
110
|
-
var
|
|
111
|
-
var
|
|
112
|
-
/* Only apply focus if we are among the navigable items in this container */ if (r.nativeEvent.target instanceof HTMLElement &&
|
|
113
|
-
var
|
|
114
|
-
|
|
115
|
-
(0, n.handleFocus)(c, t.current, i, o);
|
|
108
|
+
var l = function e(r) {
|
|
109
|
+
var o = t.current.includes(r.nativeEvent.target);
|
|
110
|
+
/* Only apply focus if we are among the navigable items in this container */ if (r.nativeEvent.target instanceof HTMLElement && o) {
|
|
111
|
+
var u = t.current.indexOf(r.nativeEvent.target);
|
|
112
|
+
(0, n.handleFocus)(r.key, t.current, u, a);
|
|
116
113
|
}
|
|
117
114
|
};
|
|
118
115
|
return {
|
|
119
|
-
ref:
|
|
120
|
-
onBlur:
|
|
121
|
-
onFocus:
|
|
122
|
-
onKeyDown:
|
|
116
|
+
ref: u,
|
|
117
|
+
onBlur: i,
|
|
118
|
+
onFocus: c,
|
|
119
|
+
onKeyDown: l
|
|
123
120
|
};
|
|
124
121
|
}
|
|
125
|
-
/* harmony default export */ const
|
|
122
|
+
/* harmony default export */ const u = o;
|
|
126
123
|
// CONCATENATED MODULE: ./src/useRovingFocus/index.ts
|
|
127
124
|
module.exports = t;
|
|
128
125
|
/******/})();
|
|
@@ -1,76 +0,0 @@
|
|
|
1
|
-
import 'core-js/es/promise';
|
|
2
|
-
type Movie = {
|
|
3
|
-
id: number;
|
|
4
|
-
title: string;
|
|
5
|
-
};
|
|
6
|
-
type MovieOption = Movie & {
|
|
7
|
-
matchRanges?: {
|
|
8
|
-
start: number;
|
|
9
|
-
end: number;
|
|
10
|
-
}[];
|
|
11
|
-
};
|
|
12
|
-
declare function isMovieOption(movie: Movie | MovieOption): movie is MovieOption;
|
|
13
|
-
/**
|
|
14
|
-
* @param fetchTimeout: number - The number of milliseconds to defer fetching of options.
|
|
15
|
-
* @param fetchMoreTimeout: number - The number of milliseconds to defer fetching additional options.
|
|
16
|
-
* @param numberOfResults: number - Then mumber of options to retrieve per fetch.
|
|
17
|
-
*/
|
|
18
|
-
export default class FetchOptions {
|
|
19
|
-
private currentFetch;
|
|
20
|
-
private currentOptions;
|
|
21
|
-
private fetching;
|
|
22
|
-
private fetchMoreTimeout;
|
|
23
|
-
private fetchPromise?;
|
|
24
|
-
private fetchTimeout;
|
|
25
|
-
private filter?;
|
|
26
|
-
private firstIndex;
|
|
27
|
-
private lastIndex;
|
|
28
|
-
private list;
|
|
29
|
-
private numberOfResults;
|
|
30
|
-
private timer?;
|
|
31
|
-
constructor({ fetchTimeout, fetchMoreTimeout, numberOfResults }?: {
|
|
32
|
-
fetchTimeout?: number | undefined;
|
|
33
|
-
fetchMoreTimeout?: number | undefined;
|
|
34
|
-
numberOfResults?: number | undefined;
|
|
35
|
-
});
|
|
36
|
-
/**
|
|
37
|
-
* Fake fetches options from a server.
|
|
38
|
-
* @param filter: string - filter options.
|
|
39
|
-
* @param timeout: number - Number of milliseconds to defer fetch.
|
|
40
|
-
* @return A promise that will resolve based on the fetchTimeout value.
|
|
41
|
-
* Returns array of new options.
|
|
42
|
-
*/
|
|
43
|
-
fetch(filter?: string, timeout?: number): Promise<MovieOption[]>;
|
|
44
|
-
/**
|
|
45
|
-
* Increases searching index for new options and runs fetch.
|
|
46
|
-
* @param currentOptions: array - Append options to given array.
|
|
47
|
-
* @return A promise that will resolve based on the fetchTimeout value.
|
|
48
|
-
* Returns array of new options appended to currentOptions.
|
|
49
|
-
*/
|
|
50
|
-
fetchMore(currentOptions?: MovieOption[]): Promise<MovieOption[]>;
|
|
51
|
-
private concatAndFilter;
|
|
52
|
-
private filterResults;
|
|
53
|
-
/**
|
|
54
|
-
* Resets firstIndex, LastIndex, currentOptions and list to default values.
|
|
55
|
-
*/
|
|
56
|
-
reset(): void;
|
|
57
|
-
/** Cancels pending fetch promises. */
|
|
58
|
-
stop(): void;
|
|
59
|
-
/**
|
|
60
|
-
* @return Option of given value;
|
|
61
|
-
*/
|
|
62
|
-
getOption: (value: number) => Movie | undefined;
|
|
63
|
-
/**
|
|
64
|
-
* @return Options of given values;
|
|
65
|
-
*/
|
|
66
|
-
getSelectedOptions: (values: number[]) => Movie[];
|
|
67
|
-
/**
|
|
68
|
-
* Get current length of indexes fetched.
|
|
69
|
-
*/
|
|
70
|
-
getCurrentCount: () => number;
|
|
71
|
-
/**
|
|
72
|
-
* Get full count of all possible items fetched.
|
|
73
|
-
*/
|
|
74
|
-
getFullCount: () => number;
|
|
75
|
-
}
|
|
76
|
-
export { isMovieOption, Movie, MovieOption };
|