@equinor/eds-core-react 2.1.0 → 2.2.0-beta.0
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/README.md +49 -4
- package/dist/eds-core-react.cjs +754 -499
- package/dist/esm/components/Autocomplete/AddNewOption.js +31 -14
- package/dist/esm/components/Autocomplete/Autocomplete.js +54 -874
- package/dist/esm/components/Autocomplete/AutocompleteContext.js +12 -0
- package/dist/esm/components/Autocomplete/EmptyOption.js +21 -0
- package/dist/esm/components/Autocomplete/MultipleInput.js +85 -0
- package/dist/esm/components/Autocomplete/Option.js +42 -23
- package/dist/esm/components/Autocomplete/OptionList.js +124 -0
- package/dist/esm/components/Autocomplete/RightAdornments.js +48 -0
- package/dist/esm/components/Autocomplete/SelectAllOption.js +63 -0
- package/dist/esm/components/Autocomplete/SingleInput.js +28 -0
- package/dist/esm/components/Autocomplete/useAutocomplete.js +605 -0
- package/dist/esm/components/Autocomplete/utils.js +93 -0
- package/dist/esm/components/Datepicker/fields/FieldWrapper.js +10 -0
- package/dist/esm/components/Dialog/Dialog.js +6 -4
- package/dist/esm/components/next/Icon/Icon.js +57 -0
- package/dist/esm/components/next/Icon/icon.css.js +6 -0
- package/dist/esm/components/next/Placeholder/Placeholder.js +17 -0
- package/dist/esm/index.js +1 -1
- package/dist/esm/index.next.js +2 -0
- package/dist/esm/node_modules/.pnpm/style-inject@0.3.0/node_modules/style-inject/dist/style-inject.es.js +26 -0
- package/dist/index.next.cjs +101 -0
- package/dist/types/components/Autocomplete/AddNewOption.d.ts +4 -12
- package/dist/types/components/Autocomplete/Autocomplete.d.ts +33 -11
- package/dist/types/components/Autocomplete/AutocompleteContext.d.ts +228 -0
- package/dist/types/components/Autocomplete/EmptyOption.d.ts +1 -0
- package/dist/types/components/Autocomplete/MultipleInput.d.ts +1 -0
- package/dist/types/components/Autocomplete/Option.d.ts +7 -15
- package/dist/types/components/Autocomplete/OptionList.d.ts +2 -0
- package/dist/types/components/Autocomplete/RightAdornments.d.ts +1 -0
- package/dist/types/components/Autocomplete/SelectAllOption.d.ts +6 -0
- package/dist/types/components/Autocomplete/SingleInput.d.ts +1 -0
- package/dist/types/components/Autocomplete/useAutocomplete.d.ts +122 -0
- package/dist/types/components/Autocomplete/utils.d.ts +13 -0
- package/dist/types/components/Datepicker/DateRangePicker.d.ts +1 -1
- package/dist/types/components/SideBar/SideBarButton/index.d.ts +1 -1
- package/dist/types/components/next/Icon/Icon.d.ts +29 -0
- package/dist/types/components/next/Icon/Icon.types.d.ts +19 -0
- package/dist/types/components/next/Icon/index.d.ts +2 -0
- package/dist/types/components/next/Placeholder/Placeholder.d.ts +9 -0
- package/dist/types/components/next/Placeholder/Placeholder.figma.d.ts +16 -0
- package/dist/types/components/next/Placeholder/index.d.ts +2 -0
- package/dist/types/components/next/index.d.ts +4 -0
- package/dist/types/index.next.d.ts +11 -0
- package/package.json +11 -5
|
@@ -123,12 +123,22 @@ const FieldWrapper = /*#__PURE__*/forwardRef(({
|
|
|
123
123
|
if (!isIconTarget && (event.code === 'Space' || event.code === 'Enter')) {
|
|
124
124
|
setIsOpen(true);
|
|
125
125
|
}
|
|
126
|
+
if (event.key === 'Escape' && isOpen) {
|
|
127
|
+
event.stopPropagation();
|
|
128
|
+
event.preventDefault();
|
|
129
|
+
setIsOpen(false);
|
|
130
|
+
}
|
|
126
131
|
},
|
|
127
132
|
...props,
|
|
128
133
|
children: children
|
|
129
134
|
}), /*#__PURE__*/jsx(Popover, {
|
|
130
135
|
open: isOpen ?? false,
|
|
131
136
|
onClose: () => setIsOpen(false),
|
|
137
|
+
onKeyDown: e => {
|
|
138
|
+
if (e.key !== 'Escape') return;
|
|
139
|
+
e.stopPropagation();
|
|
140
|
+
e.preventDefault();
|
|
141
|
+
},
|
|
132
142
|
anchorEl: anchorEl,
|
|
133
143
|
placement: 'bottom-start',
|
|
134
144
|
children: calendar
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { forwardRef, useRef, useMemo, useEffect } from 'react';
|
|
2
2
|
import styled, { ThemeProvider, css } from 'styled-components';
|
|
3
|
-
import { useToken, mergeRefs, useHideBodyScroll,
|
|
3
|
+
import { useToken, mergeRefs, useHideBodyScroll, bordersTemplate, typographyTemplate } from '@equinor/eds-utils';
|
|
4
4
|
import { dialog } from './Dialog.tokens.js';
|
|
5
5
|
import { jsx } from 'react/jsx-runtime';
|
|
6
6
|
import { useEds } from '../EdsProvider/eds.context.js';
|
|
@@ -60,17 +60,19 @@ const Dialog = /*#__PURE__*/forwardRef(function Dialog({
|
|
|
60
60
|
onClose && onClose();
|
|
61
61
|
}
|
|
62
62
|
};
|
|
63
|
-
|
|
63
|
+
const handleKeyDown = e => {
|
|
64
|
+
if (e.key !== 'Escape') return;
|
|
64
65
|
e.preventDefault();
|
|
65
66
|
if (isDismissable && onClose && open) {
|
|
66
|
-
onClose
|
|
67
|
+
onClose();
|
|
67
68
|
}
|
|
68
|
-
}
|
|
69
|
+
};
|
|
69
70
|
return /*#__PURE__*/jsx(ThemeProvider, {
|
|
70
71
|
theme: token,
|
|
71
72
|
children: /*#__PURE__*/jsx(StyledNativeDialog, {
|
|
72
73
|
ref: combinedDialogRef,
|
|
73
74
|
onMouseDown: handleDismiss,
|
|
75
|
+
onKeyDown: handleKeyDown,
|
|
74
76
|
children: open && /*#__PURE__*/jsx(StyledDialog, {
|
|
75
77
|
...props,
|
|
76
78
|
ref: ref,
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
import { forwardRef, useId } from 'react';
|
|
2
|
+
import './icon.css.js';
|
|
3
|
+
import { jsxs, jsx } from 'react/jsx-runtime';
|
|
4
|
+
|
|
5
|
+
const Icon = /*#__PURE__*/forwardRef(function Icon({
|
|
6
|
+
data,
|
|
7
|
+
title,
|
|
8
|
+
color = 'currentColor',
|
|
9
|
+
size,
|
|
10
|
+
className,
|
|
11
|
+
...rest
|
|
12
|
+
}, ref) {
|
|
13
|
+
const titleId = useId();
|
|
14
|
+
if (!data) {
|
|
15
|
+
console.error('Icon: data prop is required');
|
|
16
|
+
return null;
|
|
17
|
+
}
|
|
18
|
+
const {
|
|
19
|
+
svgPathData,
|
|
20
|
+
height = '24',
|
|
21
|
+
width = '24'
|
|
22
|
+
} = data;
|
|
23
|
+
const classes = ['icon', className].filter(Boolean).join(' ');
|
|
24
|
+
|
|
25
|
+
// Accessibility: decorative icons are hidden, semantic icons have role="img"
|
|
26
|
+
const accessibilityProps = title ? {
|
|
27
|
+
role: 'img',
|
|
28
|
+
'aria-labelledby': titleId
|
|
29
|
+
} : {
|
|
30
|
+
'aria-hidden': true
|
|
31
|
+
};
|
|
32
|
+
return /*#__PURE__*/jsxs("svg", {
|
|
33
|
+
ref: ref,
|
|
34
|
+
xmlns: "http://www.w3.org/2000/svg",
|
|
35
|
+
viewBox: `0 0 ${width} ${height}`,
|
|
36
|
+
fill: color,
|
|
37
|
+
className: classes,
|
|
38
|
+
"data-testid": "eds-icon",
|
|
39
|
+
"data-icon-size": size,
|
|
40
|
+
...accessibilityProps,
|
|
41
|
+
...rest,
|
|
42
|
+
children: [title && /*#__PURE__*/jsx("title", {
|
|
43
|
+
id: titleId,
|
|
44
|
+
children: title
|
|
45
|
+
}), Array.isArray(svgPathData) ? svgPathData.map(pathData => /*#__PURE__*/jsx("path", {
|
|
46
|
+
fillRule: "evenodd",
|
|
47
|
+
clipRule: "evenodd",
|
|
48
|
+
d: pathData
|
|
49
|
+
}, pathData)) : /*#__PURE__*/jsx("path", {
|
|
50
|
+
fillRule: "evenodd",
|
|
51
|
+
clipRule: "evenodd",
|
|
52
|
+
d: svgPathData
|
|
53
|
+
})]
|
|
54
|
+
});
|
|
55
|
+
});
|
|
56
|
+
|
|
57
|
+
export { Icon };
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import styleInject from '../../../node_modules/.pnpm/style-inject@0.3.0/node_modules/style-inject/dist/style-inject.es.js';
|
|
2
|
+
|
|
3
|
+
var css_248z = "/* Inline with text: uses token from parent's data-font-size, or 1.5em fallback */\n.icon {\n /*\n * Set font-size first to establish the icon's size context.\n * Then use 1em for width/height (relative to computed font-size).\n * This avoids compound scaling (1.5em × 1.5em = 2.25em would be wrong).\n */\n font-size: var(--eds-typography-icon-size, 1.5em);\n width: 1em;\n height: 1em;\n\n /* Negative margins for optical alignment with text baseline */\n margin-block: -0.25em;\n margin-inline: -0.1em;\n\n flex-shrink: 0;\n}\n\n/* Explicit size: fixed size from design tokens, no margins */\n.icon[data-icon-size] {\n --_explicit-size: var(--eds-sizing-icon-md); /* fallback */\n\n width: var(--_explicit-size);\n height: var(--_explicit-size);\n margin: 0;\n font-size: inherit;\n}\n\n.icon[data-icon-size='xs'] {\n --_explicit-size: var(--eds-sizing-icon-xs);\n}\n.icon[data-icon-size='sm'] {\n --_explicit-size: var(--eds-sizing-icon-sm);\n}\n.icon[data-icon-size='md'] {\n --_explicit-size: var(--eds-sizing-icon-md);\n}\n.icon[data-icon-size='lg'] {\n --_explicit-size: var(--eds-sizing-icon-lg);\n}\n.icon[data-icon-size='xl'] {\n --_explicit-size: var(--eds-sizing-icon-xl);\n}\n.icon[data-icon-size='2xl'] {\n --_explicit-size: var(--eds-sizing-icon-2xl);\n}\n.icon[data-icon-size='3xl'] {\n --_explicit-size: var(--eds-sizing-icon-3xl);\n}\n.icon[data-icon-size='4xl'] {\n --_explicit-size: var(--eds-sizing-icon-4xl);\n}\n.icon[data-icon-size='5xl'] {\n --_explicit-size: var(--eds-sizing-icon-5xl);\n}\n.icon[data-icon-size='6xl'] {\n --_explicit-size: var(--eds-sizing-icon-6xl);\n}\n";
|
|
4
|
+
styleInject(css_248z);
|
|
5
|
+
|
|
6
|
+
export { css_248z as default };
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { jsx } from 'react/jsx-runtime';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Placeholder component for testing the /next entry point.
|
|
5
|
+
* This component should be removed once real EDS 2.0 components are added.
|
|
6
|
+
*/
|
|
7
|
+
|
|
8
|
+
const Placeholder = ({
|
|
9
|
+
text = 'EDS 2.0 Placeholder'
|
|
10
|
+
}) => {
|
|
11
|
+
return /*#__PURE__*/jsx("div", {
|
|
12
|
+
"data-testid": "eds-placeholder",
|
|
13
|
+
children: text
|
|
14
|
+
});
|
|
15
|
+
};
|
|
16
|
+
|
|
17
|
+
export { Placeholder };
|
package/dist/esm/index.js
CHANGED
|
@@ -85,7 +85,7 @@ export { Radio } from './components/Radio/Radio.js';
|
|
|
85
85
|
export { Switch } from './components/Switch/Switch.js';
|
|
86
86
|
export { EdsProvider, useEds } from './components/EdsProvider/eds.context.js';
|
|
87
87
|
export { Paper } from './components/Paper/Paper.js';
|
|
88
|
-
export { Autocomplete } from './components/Autocomplete/Autocomplete.js';
|
|
88
|
+
export { AddSymbol, AllSymbol, Autocomplete, StyledButton, defaultOptionDisabled } from './components/Autocomplete/Autocomplete.js';
|
|
89
89
|
export { InputWrapper } from './components/InputWrapper/InputWrapper.js';
|
|
90
90
|
export { useInputField } from './components/InputWrapper/useInputField.js';
|
|
91
91
|
export { useSideBar } from './components/SideBar/SideBar.context.js';
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
function styleInject(css, ref) {
|
|
2
|
+
if (ref === void 0) ref = {};
|
|
3
|
+
var insertAt = ref.insertAt;
|
|
4
|
+
if (typeof document === 'undefined') {
|
|
5
|
+
return;
|
|
6
|
+
}
|
|
7
|
+
var head = document.head || document.getElementsByTagName('head')[0];
|
|
8
|
+
var style = document.createElement('style');
|
|
9
|
+
style.type = 'text/css';
|
|
10
|
+
if (insertAt === 'top') {
|
|
11
|
+
if (head.firstChild) {
|
|
12
|
+
head.insertBefore(style, head.firstChild);
|
|
13
|
+
} else {
|
|
14
|
+
head.appendChild(style);
|
|
15
|
+
}
|
|
16
|
+
} else {
|
|
17
|
+
head.appendChild(style);
|
|
18
|
+
}
|
|
19
|
+
if (style.styleSheet) {
|
|
20
|
+
style.styleSheet.cssText = css;
|
|
21
|
+
} else {
|
|
22
|
+
style.appendChild(document.createTextNode(css));
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
export { styleInject as default };
|
|
@@ -0,0 +1,101 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var jsxRuntime = require('react/jsx-runtime');
|
|
4
|
+
var react = require('react');
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* Placeholder component for testing the /next entry point.
|
|
8
|
+
* This component should be removed once real EDS 2.0 components are added.
|
|
9
|
+
*/
|
|
10
|
+
|
|
11
|
+
const Placeholder = ({
|
|
12
|
+
text = 'EDS 2.0 Placeholder'
|
|
13
|
+
}) => {
|
|
14
|
+
return /*#__PURE__*/jsxRuntime.jsx("div", {
|
|
15
|
+
"data-testid": "eds-placeholder",
|
|
16
|
+
children: text
|
|
17
|
+
});
|
|
18
|
+
};
|
|
19
|
+
|
|
20
|
+
function styleInject(css, ref) {
|
|
21
|
+
if (ref === void 0) ref = {};
|
|
22
|
+
var insertAt = ref.insertAt;
|
|
23
|
+
if (typeof document === 'undefined') {
|
|
24
|
+
return;
|
|
25
|
+
}
|
|
26
|
+
var head = document.head || document.getElementsByTagName('head')[0];
|
|
27
|
+
var style = document.createElement('style');
|
|
28
|
+
style.type = 'text/css';
|
|
29
|
+
if (insertAt === 'top') {
|
|
30
|
+
if (head.firstChild) {
|
|
31
|
+
head.insertBefore(style, head.firstChild);
|
|
32
|
+
} else {
|
|
33
|
+
head.appendChild(style);
|
|
34
|
+
}
|
|
35
|
+
} else {
|
|
36
|
+
head.appendChild(style);
|
|
37
|
+
}
|
|
38
|
+
if (style.styleSheet) {
|
|
39
|
+
style.styleSheet.cssText = css;
|
|
40
|
+
} else {
|
|
41
|
+
style.appendChild(document.createTextNode(css));
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
var css_248z = "/* Inline with text: uses token from parent's data-font-size, or 1.5em fallback */\n.icon {\n /*\n * Set font-size first to establish the icon's size context.\n * Then use 1em for width/height (relative to computed font-size).\n * This avoids compound scaling (1.5em × 1.5em = 2.25em would be wrong).\n */\n font-size: var(--eds-typography-icon-size, 1.5em);\n width: 1em;\n height: 1em;\n\n /* Negative margins for optical alignment with text baseline */\n margin-block: -0.25em;\n margin-inline: -0.1em;\n\n flex-shrink: 0;\n}\n\n/* Explicit size: fixed size from design tokens, no margins */\n.icon[data-icon-size] {\n --_explicit-size: var(--eds-sizing-icon-md); /* fallback */\n\n width: var(--_explicit-size);\n height: var(--_explicit-size);\n margin: 0;\n font-size: inherit;\n}\n\n.icon[data-icon-size='xs'] {\n --_explicit-size: var(--eds-sizing-icon-xs);\n}\n.icon[data-icon-size='sm'] {\n --_explicit-size: var(--eds-sizing-icon-sm);\n}\n.icon[data-icon-size='md'] {\n --_explicit-size: var(--eds-sizing-icon-md);\n}\n.icon[data-icon-size='lg'] {\n --_explicit-size: var(--eds-sizing-icon-lg);\n}\n.icon[data-icon-size='xl'] {\n --_explicit-size: var(--eds-sizing-icon-xl);\n}\n.icon[data-icon-size='2xl'] {\n --_explicit-size: var(--eds-sizing-icon-2xl);\n}\n.icon[data-icon-size='3xl'] {\n --_explicit-size: var(--eds-sizing-icon-3xl);\n}\n.icon[data-icon-size='4xl'] {\n --_explicit-size: var(--eds-sizing-icon-4xl);\n}\n.icon[data-icon-size='5xl'] {\n --_explicit-size: var(--eds-sizing-icon-5xl);\n}\n.icon[data-icon-size='6xl'] {\n --_explicit-size: var(--eds-sizing-icon-6xl);\n}\n";
|
|
46
|
+
styleInject(css_248z);
|
|
47
|
+
|
|
48
|
+
const Icon = /*#__PURE__*/react.forwardRef(function Icon({
|
|
49
|
+
data,
|
|
50
|
+
title,
|
|
51
|
+
color = 'currentColor',
|
|
52
|
+
size,
|
|
53
|
+
className,
|
|
54
|
+
...rest
|
|
55
|
+
}, ref) {
|
|
56
|
+
const titleId = react.useId();
|
|
57
|
+
if (!data) {
|
|
58
|
+
console.error('Icon: data prop is required');
|
|
59
|
+
return null;
|
|
60
|
+
}
|
|
61
|
+
const {
|
|
62
|
+
svgPathData,
|
|
63
|
+
height = '24',
|
|
64
|
+
width = '24'
|
|
65
|
+
} = data;
|
|
66
|
+
const classes = ['icon', className].filter(Boolean).join(' ');
|
|
67
|
+
|
|
68
|
+
// Accessibility: decorative icons are hidden, semantic icons have role="img"
|
|
69
|
+
const accessibilityProps = title ? {
|
|
70
|
+
role: 'img',
|
|
71
|
+
'aria-labelledby': titleId
|
|
72
|
+
} : {
|
|
73
|
+
'aria-hidden': true
|
|
74
|
+
};
|
|
75
|
+
return /*#__PURE__*/jsxRuntime.jsxs("svg", {
|
|
76
|
+
ref: ref,
|
|
77
|
+
xmlns: "http://www.w3.org/2000/svg",
|
|
78
|
+
viewBox: `0 0 ${width} ${height}`,
|
|
79
|
+
fill: color,
|
|
80
|
+
className: classes,
|
|
81
|
+
"data-testid": "eds-icon",
|
|
82
|
+
"data-icon-size": size,
|
|
83
|
+
...accessibilityProps,
|
|
84
|
+
...rest,
|
|
85
|
+
children: [title && /*#__PURE__*/jsxRuntime.jsx("title", {
|
|
86
|
+
id: titleId,
|
|
87
|
+
children: title
|
|
88
|
+
}), Array.isArray(svgPathData) ? svgPathData.map(pathData => /*#__PURE__*/jsxRuntime.jsx("path", {
|
|
89
|
+
fillRule: "evenodd",
|
|
90
|
+
clipRule: "evenodd",
|
|
91
|
+
d: pathData
|
|
92
|
+
}, pathData)) : /*#__PURE__*/jsxRuntime.jsx("path", {
|
|
93
|
+
fillRule: "evenodd",
|
|
94
|
+
clipRule: "evenodd",
|
|
95
|
+
d: svgPathData
|
|
96
|
+
})]
|
|
97
|
+
});
|
|
98
|
+
});
|
|
99
|
+
|
|
100
|
+
exports.Icon = Icon;
|
|
101
|
+
exports.Placeholder = Placeholder;
|
|
@@ -1,13 +1,5 @@
|
|
|
1
|
-
import { LiHTMLAttributes } from 'react';
|
|
2
1
|
export type AutocompleteOptionProps = {
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
} & LiHTMLAttributes<HTMLLIElement>;
|
|
8
|
-
declare function AddNewOptionInner(props: AutocompleteOptionProps, ref: React.ForwardedRef<HTMLLIElement>): import("react/jsx-runtime").JSX.Element;
|
|
9
|
-
export declare const AddNewOption: (props: AutocompleteOptionProps & {
|
|
10
|
-
ref?: React.ForwardedRef<HTMLLIElement>;
|
|
11
|
-
displayName?: string | undefined;
|
|
12
|
-
}) => ReturnType<typeof AddNewOptionInner>;
|
|
13
|
-
export {};
|
|
2
|
+
index: number;
|
|
3
|
+
item: unknown;
|
|
4
|
+
};
|
|
5
|
+
export declare function AddNewOption({ index, item }: AutocompleteOptionProps): import("react/jsx-runtime").JSX.Element;
|
|
@@ -1,9 +1,25 @@
|
|
|
1
1
|
import { HTMLAttributes, ReactNode } from 'react';
|
|
2
2
|
import { Variants } from '../types';
|
|
3
|
+
export declare const AllSymbol: unique symbol;
|
|
4
|
+
export declare const AddSymbol: unique symbol;
|
|
5
|
+
export declare const StyledButton: import("styled-components/dist/types").IStyledComponentBase<"web", import("styled-components").FastOmit<{
|
|
6
|
+
as?: import("react").ElementType;
|
|
7
|
+
} & {
|
|
8
|
+
color?: "primary" | "secondary" | "danger";
|
|
9
|
+
variant?: "contained" | "contained_icon" | "outlined" | "ghost" | "ghost_icon";
|
|
10
|
+
href?: string;
|
|
11
|
+
disabled?: boolean;
|
|
12
|
+
type?: string;
|
|
13
|
+
fullWidth?: boolean;
|
|
14
|
+
} & import("react").ButtonHTMLAttributes<HTMLButtonElement> & Omit<any, "href" | keyof import("react").ButtonHTMLAttributes<HTMLButtonElement> | "variant" | "fullWidth">, never>> & string & Omit<import("@equinor/eds-utils").OverridableComponent<import("../Button").ButtonProps, HTMLButtonElement> & {
|
|
15
|
+
Group: typeof import("../Button").ButtonGroup;
|
|
16
|
+
Toggle: typeof import("../Button").ToggleButton;
|
|
17
|
+
}, keyof import("react").Component<any, {}, any>>;
|
|
18
|
+
export declare const defaultOptionDisabled: () => boolean;
|
|
3
19
|
export type AutocompleteChanges<T> = {
|
|
4
20
|
selectedItems: T[];
|
|
5
21
|
};
|
|
6
|
-
export type AutocompleteProps<T> = {
|
|
22
|
+
export type AutocompleteProps<T = string> = {
|
|
7
23
|
/** List of options in dropdown */
|
|
8
24
|
options: readonly T[];
|
|
9
25
|
/** Total number of options */
|
|
@@ -47,6 +63,10 @@ export type AutocompleteProps<T> = {
|
|
|
47
63
|
* Note that this prop replaces the need for ```initialSelectedOptions```
|
|
48
64
|
* The items that should be selected. */
|
|
49
65
|
selectedOptions?: T[];
|
|
66
|
+
/** How selected items are displayed in the input field
|
|
67
|
+
* @default 'summary'
|
|
68
|
+
*/
|
|
69
|
+
selectionDisplay?: 'chips' | 'summary';
|
|
50
70
|
/** Callback for the selected item change
|
|
51
71
|
* changes.selectedItems gives the selected items
|
|
52
72
|
*/
|
|
@@ -61,8 +81,6 @@ export type AutocompleteProps<T> = {
|
|
|
61
81
|
multiple?: boolean;
|
|
62
82
|
/** Add select-all option. Throws an error if true while multiple = false */
|
|
63
83
|
allowSelectAll?: boolean;
|
|
64
|
-
/** Custom option label. NOTE: This is required when option is an object */
|
|
65
|
-
optionLabel?: (option: T) => string;
|
|
66
84
|
/** Custom option template */
|
|
67
85
|
optionComponent?: (option: T, isSelected: boolean) => ReactNode;
|
|
68
86
|
/** Disable option
|
|
@@ -100,11 +118,15 @@ export type AutocompleteProps<T> = {
|
|
|
100
118
|
* Callback for clear all button
|
|
101
119
|
*/
|
|
102
120
|
onClear?: () => void;
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
121
|
+
ref?: React.Ref<HTMLInputElement>;
|
|
122
|
+
} & HTMLAttributes<HTMLDivElement> & (T extends string | number ? {
|
|
123
|
+
/** Custom option label. NOTE: This is required when option is an object */
|
|
124
|
+
optionLabel?: (option: T) => string;
|
|
125
|
+
} : T extends object ? {
|
|
126
|
+
/** Custom option label. NOTE: This is required when option is an object */
|
|
127
|
+
optionLabel: (option: T) => string;
|
|
128
|
+
} : {
|
|
129
|
+
/** Custom option label. NOTE: This is required when option is an object */
|
|
130
|
+
optionLabel?: (option: T) => string;
|
|
131
|
+
});
|
|
132
|
+
export declare function Autocomplete<T>({ ...props }: AutocompleteProps<T>): import("react/jsx-runtime").JSX.Element;
|
|
@@ -0,0 +1,228 @@
|
|
|
1
|
+
export declare const AutocompleteContext: import("react").Context<{
|
|
2
|
+
getDropdownProps: <Options>(options?: import("downshift").UseMultipleSelectionGetDropdownPropsOptions & Options, extraOptions?: import("downshift").GetPropsCommonOptions) => Omit<import("downshift").Overwrite<import("downshift").UseMultipleSelectionGetDropdownReturnValue, Options>, "preventKeyAction">;
|
|
3
|
+
addSelectedItem: (item: unknown) => void;
|
|
4
|
+
removeSelectedItem: (item: unknown) => void;
|
|
5
|
+
selectedItems: unknown[];
|
|
6
|
+
setSelectedItems: (items: unknown[]) => void;
|
|
7
|
+
clear: () => void;
|
|
8
|
+
availableItems: readonly unknown[];
|
|
9
|
+
getLabel: (item: unknown) => string;
|
|
10
|
+
scrollContainer: import("react").RefObject<HTMLUListElement>;
|
|
11
|
+
rowVirtualizer: import("@tanstack/react-virtual").Virtualizer<HTMLUListElement, Element>;
|
|
12
|
+
allSelectedState: string;
|
|
13
|
+
toggleAllSelected: () => void;
|
|
14
|
+
typedInputValue: string;
|
|
15
|
+
inputRef: import("react").RefObject<HTMLInputElement>;
|
|
16
|
+
token: () => import("styled-components").DefaultTheme;
|
|
17
|
+
tokens: import("./Autocomplete.tokens").AutocompleteToken;
|
|
18
|
+
placeholderText: string;
|
|
19
|
+
readOnly: boolean;
|
|
20
|
+
inputProps: import("downshift").Overwrite<import("downshift").UseComboboxGetInputPropsReturnValue, Omit<import("downshift").Overwrite<import("downshift").UseMultipleSelectionGetDropdownReturnValue, {
|
|
21
|
+
preventKeyAction: boolean;
|
|
22
|
+
disabled: boolean;
|
|
23
|
+
ref: import("react").RefObject<HTMLInputElement>;
|
|
24
|
+
}>, "preventKeyAction">>;
|
|
25
|
+
consolidatedEvents: Partial<import("react").DOMAttributes<unknown>>;
|
|
26
|
+
multiple: boolean;
|
|
27
|
+
disabled: boolean;
|
|
28
|
+
optionDisabled: (option: unknown) => boolean;
|
|
29
|
+
onAddNewOption: (text: string) => void;
|
|
30
|
+
options: readonly unknown[];
|
|
31
|
+
totalOptions: number;
|
|
32
|
+
label: import("react").ReactNode;
|
|
33
|
+
meta: import("react").ReactNode;
|
|
34
|
+
className: string;
|
|
35
|
+
style: import("react").CSSProperties;
|
|
36
|
+
loading: boolean;
|
|
37
|
+
hideClearButton: boolean;
|
|
38
|
+
onOptionsChange: (changes: import("./Autocomplete").AutocompleteChanges<unknown>) => void;
|
|
39
|
+
onInputChange: (text: string) => void;
|
|
40
|
+
selectedOptions: unknown[];
|
|
41
|
+
selectionDisplay: "summary" | "chips";
|
|
42
|
+
itemToKey: (item: unknown) => unknown;
|
|
43
|
+
itemCompare: (value: unknown, compare: unknown) => boolean;
|
|
44
|
+
allowSelectAll: boolean;
|
|
45
|
+
initialSelectedOptions: unknown[];
|
|
46
|
+
optionsFilter: (option: unknown, inputValue: string) => boolean;
|
|
47
|
+
autoWidth: boolean;
|
|
48
|
+
placeholder: string;
|
|
49
|
+
optionLabel: ((option: string | number) => string) | ((option: object) => string) | ((option: unknown) => string);
|
|
50
|
+
clearSearchOnChange: boolean;
|
|
51
|
+
multiline: boolean;
|
|
52
|
+
dropdownHeight: number;
|
|
53
|
+
optionComponent: (option: unknown, isSelected: boolean) => import("react").ReactNode;
|
|
54
|
+
helperText: string;
|
|
55
|
+
helperIcon: import("react").ReactNode;
|
|
56
|
+
noOptionsText: string;
|
|
57
|
+
variant: import("../types").Variants;
|
|
58
|
+
onClear: () => void;
|
|
59
|
+
selectedItemsLabels: string[];
|
|
60
|
+
restHtmlProps: Omit<{
|
|
61
|
+
options: readonly unknown[];
|
|
62
|
+
totalOptions?: number;
|
|
63
|
+
label: import("react").ReactNode;
|
|
64
|
+
initialSelectedOptions?: unknown[];
|
|
65
|
+
helperText?: string;
|
|
66
|
+
helperIcon?: import("react").ReactNode;
|
|
67
|
+
noOptionsText?: string;
|
|
68
|
+
variant?: import("../types").Variants;
|
|
69
|
+
meta?: import("react").ReactNode;
|
|
70
|
+
disabled?: boolean;
|
|
71
|
+
loading?: boolean;
|
|
72
|
+
readOnly?: boolean;
|
|
73
|
+
hideClearButton?: boolean;
|
|
74
|
+
selectedOptions?: unknown[];
|
|
75
|
+
selectionDisplay?: "chips" | "summary";
|
|
76
|
+
onOptionsChange?: (changes: import("./Autocomplete").AutocompleteChanges<unknown>) => void;
|
|
77
|
+
onInputChange?: (text: string) => void;
|
|
78
|
+
onAddNewOption?: (text: string) => void;
|
|
79
|
+
multiple?: boolean;
|
|
80
|
+
allowSelectAll?: boolean;
|
|
81
|
+
optionComponent?: (option: unknown, isSelected: boolean) => import("react").ReactNode;
|
|
82
|
+
optionDisabled?: (option: unknown) => boolean;
|
|
83
|
+
optionsFilter?: (option: unknown, inputValue: string) => boolean;
|
|
84
|
+
autoWidth?: boolean;
|
|
85
|
+
placeholder?: string;
|
|
86
|
+
clearSearchOnChange?: boolean;
|
|
87
|
+
multiline?: boolean;
|
|
88
|
+
dropdownHeight?: number;
|
|
89
|
+
itemToKey?: (value: unknown) => unknown;
|
|
90
|
+
itemCompare?: (value: unknown, compare: unknown) => boolean;
|
|
91
|
+
onClear?: () => void;
|
|
92
|
+
ref?: React.Ref<HTMLInputElement>;
|
|
93
|
+
} & import("react").HTMLAttributes<HTMLDivElement> & {
|
|
94
|
+
optionLabel?: (option: unknown) => string;
|
|
95
|
+
} & {
|
|
96
|
+
ref?: React.Ref<HTMLInputElement>;
|
|
97
|
+
}, "ref" | "className" | "style" | "disabled" | "label" | "meta" | "multiple" | "variant" | "options" | "placeholder" | "readOnly" | "helperText" | "helperIcon" | "loading" | "optionDisabled" | "totalOptions" | "initialSelectedOptions" | "noOptionsText" | "hideClearButton" | "selectedOptions" | "selectionDisplay" | "onOptionsChange" | "onInputChange" | "onAddNewOption" | "allowSelectAll" | "optionComponent" | "optionsFilter" | "autoWidth" | "clearSearchOnChange" | "multiline" | "dropdownHeight" | "itemToKey" | "itemCompare" | "onClear" | "optionLabel">;
|
|
98
|
+
highlightedIndex: number;
|
|
99
|
+
selectedItem: unknown;
|
|
100
|
+
isOpen: boolean;
|
|
101
|
+
inputValue: string;
|
|
102
|
+
getToggleButtonProps: <Options>(options?: import("downshift").UseComboboxGetToggleButtonPropsOptions & Options) => import("downshift").Overwrite<import("downshift").UseComboboxGetToggleButtonPropsReturnValue, Options>;
|
|
103
|
+
getLabelProps: <Options>(options?: import("downshift").UseComboboxGetLabelPropsOptions & Options) => import("downshift").Overwrite<import("downshift").UseComboboxGetLabelPropsReturnValue, Options>;
|
|
104
|
+
getMenuProps: <Options>(options?: import("downshift").UseComboboxGetMenuPropsOptions & Options, otherOptions?: import("downshift").GetPropsCommonOptions) => import("downshift").Overwrite<import("downshift").UseComboboxGetMenuPropsReturnValue, Options>;
|
|
105
|
+
getItemProps: <Options>(options: import("downshift").UseComboboxGetItemPropsOptions<unknown> & Options) => Omit<import("downshift").Overwrite<import("downshift").UseComboboxGetItemPropsReturnValue, Options>, "index" | "item">;
|
|
106
|
+
getInputProps: <Options>(options?: import("downshift").UseComboboxGetInputPropsOptions & Options, otherOptions?: import("downshift").GetPropsCommonOptions) => import("downshift").Overwrite<import("downshift").UseComboboxGetInputPropsReturnValue, Options>;
|
|
107
|
+
reset: () => void;
|
|
108
|
+
openMenu: () => void;
|
|
109
|
+
closeMenu: () => void;
|
|
110
|
+
toggleMenu: () => void;
|
|
111
|
+
selectItem: (item: unknown) => void;
|
|
112
|
+
setHighlightedIndex: (index: number) => void;
|
|
113
|
+
setInputValue: (inputValue: string) => void;
|
|
114
|
+
}>;
|
|
115
|
+
export declare const useAutocompleteContext: () => {
|
|
116
|
+
getDropdownProps: <Options>(options?: import("downshift").UseMultipleSelectionGetDropdownPropsOptions & Options, extraOptions?: import("downshift").GetPropsCommonOptions) => Omit<import("downshift").Overwrite<import("downshift").UseMultipleSelectionGetDropdownReturnValue, Options>, "preventKeyAction">;
|
|
117
|
+
addSelectedItem: (item: unknown) => void;
|
|
118
|
+
removeSelectedItem: (item: unknown) => void;
|
|
119
|
+
selectedItems: unknown[];
|
|
120
|
+
setSelectedItems: (items: unknown[]) => void;
|
|
121
|
+
clear: () => void;
|
|
122
|
+
availableItems: readonly unknown[];
|
|
123
|
+
getLabel: (item: unknown) => string;
|
|
124
|
+
scrollContainer: import("react").RefObject<HTMLUListElement>;
|
|
125
|
+
rowVirtualizer: import("@tanstack/react-virtual").Virtualizer<HTMLUListElement, Element>;
|
|
126
|
+
allSelectedState: string;
|
|
127
|
+
toggleAllSelected: () => void;
|
|
128
|
+
typedInputValue: string;
|
|
129
|
+
inputRef: import("react").RefObject<HTMLInputElement>;
|
|
130
|
+
token: () => import("styled-components").DefaultTheme;
|
|
131
|
+
tokens: import("./Autocomplete.tokens").AutocompleteToken;
|
|
132
|
+
placeholderText: string;
|
|
133
|
+
readOnly: boolean;
|
|
134
|
+
inputProps: import("downshift").Overwrite<import("downshift").UseComboboxGetInputPropsReturnValue, Omit<import("downshift").Overwrite<import("downshift").UseMultipleSelectionGetDropdownReturnValue, {
|
|
135
|
+
preventKeyAction: boolean;
|
|
136
|
+
disabled: boolean;
|
|
137
|
+
ref: import("react").RefObject<HTMLInputElement>;
|
|
138
|
+
}>, "preventKeyAction">>;
|
|
139
|
+
consolidatedEvents: Partial<import("react").DOMAttributes<unknown>>;
|
|
140
|
+
multiple: boolean;
|
|
141
|
+
disabled: boolean;
|
|
142
|
+
optionDisabled: (option: unknown) => boolean;
|
|
143
|
+
onAddNewOption: (text: string) => void;
|
|
144
|
+
options: readonly unknown[];
|
|
145
|
+
totalOptions: number;
|
|
146
|
+
label: import("react").ReactNode;
|
|
147
|
+
meta: import("react").ReactNode;
|
|
148
|
+
className: string;
|
|
149
|
+
style: import("react").CSSProperties;
|
|
150
|
+
loading: boolean;
|
|
151
|
+
hideClearButton: boolean;
|
|
152
|
+
onOptionsChange: (changes: import("./Autocomplete").AutocompleteChanges<unknown>) => void;
|
|
153
|
+
onInputChange: (text: string) => void;
|
|
154
|
+
selectedOptions: unknown[];
|
|
155
|
+
selectionDisplay: "summary" | "chips";
|
|
156
|
+
itemToKey: (item: unknown) => unknown;
|
|
157
|
+
itemCompare: (value: unknown, compare: unknown) => boolean;
|
|
158
|
+
allowSelectAll: boolean;
|
|
159
|
+
initialSelectedOptions: unknown[];
|
|
160
|
+
optionsFilter: (option: unknown, inputValue: string) => boolean;
|
|
161
|
+
autoWidth: boolean;
|
|
162
|
+
placeholder: string;
|
|
163
|
+
optionLabel: ((option: string | number) => string) | ((option: object) => string) | ((option: unknown) => string);
|
|
164
|
+
clearSearchOnChange: boolean;
|
|
165
|
+
multiline: boolean;
|
|
166
|
+
dropdownHeight: number;
|
|
167
|
+
optionComponent: (option: unknown, isSelected: boolean) => import("react").ReactNode;
|
|
168
|
+
helperText: string;
|
|
169
|
+
helperIcon: import("react").ReactNode;
|
|
170
|
+
noOptionsText: string;
|
|
171
|
+
variant: import("../types").Variants;
|
|
172
|
+
onClear: () => void;
|
|
173
|
+
selectedItemsLabels: string[];
|
|
174
|
+
restHtmlProps: Omit<{
|
|
175
|
+
options: readonly unknown[];
|
|
176
|
+
totalOptions?: number;
|
|
177
|
+
label: import("react").ReactNode;
|
|
178
|
+
initialSelectedOptions?: unknown[];
|
|
179
|
+
helperText?: string;
|
|
180
|
+
helperIcon?: import("react").ReactNode;
|
|
181
|
+
noOptionsText?: string;
|
|
182
|
+
variant?: import("../types").Variants;
|
|
183
|
+
meta?: import("react").ReactNode;
|
|
184
|
+
disabled?: boolean;
|
|
185
|
+
loading?: boolean;
|
|
186
|
+
readOnly?: boolean;
|
|
187
|
+
hideClearButton?: boolean;
|
|
188
|
+
selectedOptions?: unknown[];
|
|
189
|
+
selectionDisplay?: "chips" | "summary";
|
|
190
|
+
onOptionsChange?: (changes: import("./Autocomplete").AutocompleteChanges<unknown>) => void;
|
|
191
|
+
onInputChange?: (text: string) => void;
|
|
192
|
+
onAddNewOption?: (text: string) => void;
|
|
193
|
+
multiple?: boolean;
|
|
194
|
+
allowSelectAll?: boolean;
|
|
195
|
+
optionComponent?: (option: unknown, isSelected: boolean) => import("react").ReactNode;
|
|
196
|
+
optionDisabled?: (option: unknown) => boolean;
|
|
197
|
+
optionsFilter?: (option: unknown, inputValue: string) => boolean;
|
|
198
|
+
autoWidth?: boolean;
|
|
199
|
+
placeholder?: string;
|
|
200
|
+
clearSearchOnChange?: boolean;
|
|
201
|
+
multiline?: boolean;
|
|
202
|
+
dropdownHeight?: number;
|
|
203
|
+
itemToKey?: (value: unknown) => unknown;
|
|
204
|
+
itemCompare?: (value: unknown, compare: unknown) => boolean;
|
|
205
|
+
onClear?: () => void;
|
|
206
|
+
ref?: React.Ref<HTMLInputElement>;
|
|
207
|
+
} & import("react").HTMLAttributes<HTMLDivElement> & {
|
|
208
|
+
optionLabel?: (option: unknown) => string;
|
|
209
|
+
} & {
|
|
210
|
+
ref?: React.Ref<HTMLInputElement>;
|
|
211
|
+
}, "ref" | "className" | "style" | "disabled" | "label" | "meta" | "multiple" | "variant" | "options" | "placeholder" | "readOnly" | "helperText" | "helperIcon" | "loading" | "optionDisabled" | "totalOptions" | "initialSelectedOptions" | "noOptionsText" | "hideClearButton" | "selectedOptions" | "selectionDisplay" | "onOptionsChange" | "onInputChange" | "onAddNewOption" | "allowSelectAll" | "optionComponent" | "optionsFilter" | "autoWidth" | "clearSearchOnChange" | "multiline" | "dropdownHeight" | "itemToKey" | "itemCompare" | "onClear" | "optionLabel">;
|
|
212
|
+
highlightedIndex: number;
|
|
213
|
+
selectedItem: unknown;
|
|
214
|
+
isOpen: boolean;
|
|
215
|
+
inputValue: string;
|
|
216
|
+
getToggleButtonProps: <Options>(options?: import("downshift").UseComboboxGetToggleButtonPropsOptions & Options) => import("downshift").Overwrite<import("downshift").UseComboboxGetToggleButtonPropsReturnValue, Options>;
|
|
217
|
+
getLabelProps: <Options>(options?: import("downshift").UseComboboxGetLabelPropsOptions & Options) => import("downshift").Overwrite<import("downshift").UseComboboxGetLabelPropsReturnValue, Options>;
|
|
218
|
+
getMenuProps: <Options>(options?: import("downshift").UseComboboxGetMenuPropsOptions & Options, otherOptions?: import("downshift").GetPropsCommonOptions) => import("downshift").Overwrite<import("downshift").UseComboboxGetMenuPropsReturnValue, Options>;
|
|
219
|
+
getItemProps: <Options>(options: import("downshift").UseComboboxGetItemPropsOptions<unknown> & Options) => Omit<import("downshift").Overwrite<import("downshift").UseComboboxGetItemPropsReturnValue, Options>, "index" | "item">;
|
|
220
|
+
getInputProps: <Options>(options?: import("downshift").UseComboboxGetInputPropsOptions & Options, otherOptions?: import("downshift").GetPropsCommonOptions) => import("downshift").Overwrite<import("downshift").UseComboboxGetInputPropsReturnValue, Options>;
|
|
221
|
+
reset: () => void;
|
|
222
|
+
openMenu: () => void;
|
|
223
|
+
closeMenu: () => void;
|
|
224
|
+
toggleMenu: () => void;
|
|
225
|
+
selectItem: (item: unknown) => void;
|
|
226
|
+
setHighlightedIndex: (index: number) => void;
|
|
227
|
+
setInputValue: (inputValue: string) => void;
|
|
228
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function EmptyOption(): import("react/jsx-runtime").JSX.Element;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const MultipleInput: () => import("react/jsx-runtime").JSX.Element;
|
|
@@ -1,26 +1,18 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { VirtualItem } from '@tanstack/react-virtual';
|
|
2
2
|
type StyledListItemType = {
|
|
3
3
|
$highlighted?: string;
|
|
4
4
|
$active?: string;
|
|
5
5
|
$isdisabled?: string;
|
|
6
6
|
};
|
|
7
|
-
export declare const StyledListItem: import("styled-components/dist/types").IStyledComponentBase<"web", import("styled-components/dist/types").Substitute<import("react").DetailedHTMLProps<LiHTMLAttributes<HTMLLIElement>, HTMLLIElement>, StyledListItemType>> & string;
|
|
7
|
+
export declare const StyledListItem: import("styled-components/dist/types").IStyledComponentBase<"web", import("styled-components/dist/types").Substitute<import("react").DetailedHTMLProps<import("react").LiHTMLAttributes<HTMLLIElement>, HTMLLIElement>, StyledListItemType>> & string;
|
|
8
8
|
export declare const AutocompleteOptionLabel: import("styled-components/dist/types").IStyledComponentBase<"web", import("styled-components/dist/types").Substitute<import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLSpanElement>, HTMLSpanElement>, {
|
|
9
9
|
$multiline: boolean;
|
|
10
10
|
}>> & string;
|
|
11
11
|
export type AutocompleteOptionProps = {
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
isSelected: boolean;
|
|
16
|
-
isDisabled?: boolean;
|
|
17
|
-
multiline: boolean;
|
|
18
|
-
optionComponent?: ReactNode;
|
|
12
|
+
index: number;
|
|
13
|
+
virtualItem: VirtualItem;
|
|
14
|
+
item: unknown;
|
|
19
15
|
indeterminate?: boolean;
|
|
20
|
-
}
|
|
21
|
-
declare function
|
|
22
|
-
export declare const AutocompleteOption: (props: AutocompleteOptionProps & {
|
|
23
|
-
ref?: React.ForwardedRef<HTMLLIElement>;
|
|
24
|
-
displayName?: string | undefined;
|
|
25
|
-
}) => ReturnType<typeof AutocompleteOptionInner>;
|
|
16
|
+
};
|
|
17
|
+
export declare function Option({ indeterminate, index, item, virtualItem, }: AutocompleteOptionProps): import("react/jsx-runtime").JSX.Element;
|
|
26
18
|
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const RightAdornments: () => import("react/jsx-runtime").JSX.Element;
|