@equinor/eds-core-react 2.2.1-beta.0 → 2.3.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/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/index.js +1 -1
- package/dist/esm/index.next.js +1 -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 +82 -0
- package/dist/types/components/Autocomplete/AddNewOption.d.ts +4 -12
- package/dist/types/components/Autocomplete/Autocomplete.d.ts +22 -7
- 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.figma.d.ts +16 -0
- package/dist/types/components/next/index.d.ts +2 -0
- package/package.json +5 -4
|
@@ -0,0 +1,122 @@
|
|
|
1
|
+
import { AutocompleteProps } from './Autocomplete';
|
|
2
|
+
import { AutocompleteToken } from './Autocomplete.tokens';
|
|
3
|
+
export declare const useAutocomplete: <T>({ options, totalOptions, label, meta, className, style, disabled, readOnly, loading, hideClearButton, onOptionsChange, onAddNewOption, onInputChange, selectedOptions: _selectedOptions, selectionDisplay, multiple, itemToKey: _itemToKey, itemCompare: _itemCompare, allowSelectAll, initialSelectedOptions: _initialSelectedOptions, optionDisabled, optionsFilter, autoWidth, placeholder, optionLabel, clearSearchOnChange, multiline, dropdownHeight, optionComponent, helperText, helperIcon, noOptionsText, variant, onClear, ref, ...other }: AutocompleteProps<T> & {
|
|
4
|
+
ref?: React.Ref<HTMLInputElement>;
|
|
5
|
+
}) => {
|
|
6
|
+
getDropdownProps: <Options>(options?: import("downshift").UseMultipleSelectionGetDropdownPropsOptions & Options, extraOptions?: import("downshift").GetPropsCommonOptions) => Omit<import("downshift").Overwrite<import("downshift").UseMultipleSelectionGetDropdownReturnValue, Options>, "preventKeyAction">;
|
|
7
|
+
addSelectedItem: (item: T) => void;
|
|
8
|
+
removeSelectedItem: (item: T) => void;
|
|
9
|
+
selectedItems: T[];
|
|
10
|
+
setSelectedItems: (items: T[]) => void;
|
|
11
|
+
clear: () => void;
|
|
12
|
+
availableItems: readonly T[];
|
|
13
|
+
getLabel: (item: T) => string;
|
|
14
|
+
scrollContainer: import("react").RefObject<HTMLUListElement>;
|
|
15
|
+
rowVirtualizer: import("@tanstack/react-virtual").Virtualizer<HTMLUListElement, Element>;
|
|
16
|
+
allSelectedState: string;
|
|
17
|
+
toggleAllSelected: () => void;
|
|
18
|
+
typedInputValue: string;
|
|
19
|
+
inputRef: import("react").RefObject<HTMLInputElement>;
|
|
20
|
+
token: () => import("styled-components").DefaultTheme;
|
|
21
|
+
tokens: AutocompleteToken;
|
|
22
|
+
placeholderText: string;
|
|
23
|
+
readOnly: boolean;
|
|
24
|
+
inputProps: import("downshift").Overwrite<import("downshift").UseComboboxGetInputPropsReturnValue, Omit<import("downshift").Overwrite<import("downshift").UseMultipleSelectionGetDropdownReturnValue, {
|
|
25
|
+
preventKeyAction: boolean;
|
|
26
|
+
disabled: boolean;
|
|
27
|
+
ref: import("react").RefObject<HTMLInputElement>;
|
|
28
|
+
}>, "preventKeyAction">>;
|
|
29
|
+
consolidatedEvents: Partial<import("react").DOMAttributes<unknown>>;
|
|
30
|
+
multiple: boolean;
|
|
31
|
+
disabled: boolean;
|
|
32
|
+
optionDisabled: (option: T) => boolean;
|
|
33
|
+
onAddNewOption: (text: string) => void;
|
|
34
|
+
options: readonly T[];
|
|
35
|
+
totalOptions: number;
|
|
36
|
+
label: import("react").ReactNode;
|
|
37
|
+
meta: import("react").ReactNode;
|
|
38
|
+
className: string;
|
|
39
|
+
style: import("react").CSSProperties;
|
|
40
|
+
loading: boolean;
|
|
41
|
+
hideClearButton: boolean;
|
|
42
|
+
onOptionsChange: (changes: import("./Autocomplete").AutocompleteChanges<T>) => void;
|
|
43
|
+
onInputChange: (text: string) => void;
|
|
44
|
+
selectedOptions: T[];
|
|
45
|
+
selectionDisplay: "summary" | "chips";
|
|
46
|
+
itemToKey: (item: T) => unknown;
|
|
47
|
+
itemCompare: (value: T, compare: T) => boolean;
|
|
48
|
+
allowSelectAll: boolean;
|
|
49
|
+
initialSelectedOptions: T[];
|
|
50
|
+
optionsFilter: (option: T, inputValue: string) => boolean;
|
|
51
|
+
autoWidth: boolean;
|
|
52
|
+
placeholder: string;
|
|
53
|
+
optionLabel: ((option: T) => string) | ((option: T) => string) | ((option: T) => string);
|
|
54
|
+
clearSearchOnChange: boolean;
|
|
55
|
+
multiline: boolean;
|
|
56
|
+
dropdownHeight: number;
|
|
57
|
+
optionComponent: (option: T, isSelected: boolean) => import("react").ReactNode;
|
|
58
|
+
helperText: string;
|
|
59
|
+
helperIcon: import("react").ReactNode;
|
|
60
|
+
noOptionsText: string;
|
|
61
|
+
variant: import("../types").Variants;
|
|
62
|
+
onClear: () => void;
|
|
63
|
+
selectedItemsLabels: string[];
|
|
64
|
+
restHtmlProps: Omit<{
|
|
65
|
+
options: readonly T[];
|
|
66
|
+
totalOptions?: number;
|
|
67
|
+
label: import("react").ReactNode;
|
|
68
|
+
initialSelectedOptions?: T[];
|
|
69
|
+
helperText?: string;
|
|
70
|
+
helperIcon?: import("react").ReactNode;
|
|
71
|
+
noOptionsText?: string;
|
|
72
|
+
variant?: import("../types").Variants;
|
|
73
|
+
meta?: import("react").ReactNode;
|
|
74
|
+
disabled?: boolean;
|
|
75
|
+
loading?: boolean;
|
|
76
|
+
readOnly?: boolean;
|
|
77
|
+
hideClearButton?: boolean;
|
|
78
|
+
selectedOptions?: T[];
|
|
79
|
+
selectionDisplay?: "chips" | "summary";
|
|
80
|
+
onOptionsChange?: (changes: import("./Autocomplete").AutocompleteChanges<T>) => void;
|
|
81
|
+
onInputChange?: (text: string) => void;
|
|
82
|
+
onAddNewOption?: (text: string) => void;
|
|
83
|
+
multiple?: boolean;
|
|
84
|
+
allowSelectAll?: boolean;
|
|
85
|
+
optionComponent?: (option: T, isSelected: boolean) => import("react").ReactNode;
|
|
86
|
+
optionDisabled?: (option: T) => boolean;
|
|
87
|
+
optionsFilter?: (option: T, inputValue: string) => boolean;
|
|
88
|
+
autoWidth?: boolean;
|
|
89
|
+
placeholder?: string;
|
|
90
|
+
clearSearchOnChange?: boolean;
|
|
91
|
+
multiline?: boolean;
|
|
92
|
+
dropdownHeight?: number;
|
|
93
|
+
itemToKey?: (value: T) => unknown;
|
|
94
|
+
itemCompare?: (value: T, compare: T) => boolean;
|
|
95
|
+
onClear?: () => void;
|
|
96
|
+
ref?: React.Ref<HTMLInputElement>;
|
|
97
|
+
} & import("react").HTMLAttributes<HTMLDivElement> & (T extends string | number ? {
|
|
98
|
+
optionLabel?: (option: T) => string;
|
|
99
|
+
} : T extends object ? {
|
|
100
|
+
optionLabel: (option: T) => string;
|
|
101
|
+
} : {
|
|
102
|
+
optionLabel?: (option: T) => string;
|
|
103
|
+
}) & {
|
|
104
|
+
ref?: React.Ref<HTMLInputElement>;
|
|
105
|
+
}, "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">;
|
|
106
|
+
highlightedIndex: number;
|
|
107
|
+
selectedItem: T;
|
|
108
|
+
isOpen: boolean;
|
|
109
|
+
inputValue: string;
|
|
110
|
+
getToggleButtonProps: <Options>(options?: import("downshift").UseComboboxGetToggleButtonPropsOptions & Options) => import("downshift").Overwrite<import("downshift").UseComboboxGetToggleButtonPropsReturnValue, Options>;
|
|
111
|
+
getLabelProps: <Options>(options?: import("downshift").UseComboboxGetLabelPropsOptions & Options) => import("downshift").Overwrite<import("downshift").UseComboboxGetLabelPropsReturnValue, Options>;
|
|
112
|
+
getMenuProps: <Options>(options?: import("downshift").UseComboboxGetMenuPropsOptions & Options, otherOptions?: import("downshift").GetPropsCommonOptions) => import("downshift").Overwrite<import("downshift").UseComboboxGetMenuPropsReturnValue, Options>;
|
|
113
|
+
getItemProps: <Options>(options: import("downshift").UseComboboxGetItemPropsOptions<T> & Options) => Omit<import("downshift").Overwrite<import("downshift").UseComboboxGetItemPropsReturnValue, Options>, "index" | "item">;
|
|
114
|
+
getInputProps: <Options>(options?: import("downshift").UseComboboxGetInputPropsOptions & Options, otherOptions?: import("downshift").GetPropsCommonOptions) => import("downshift").Overwrite<import("downshift").UseComboboxGetInputPropsReturnValue, Options>;
|
|
115
|
+
reset: () => void;
|
|
116
|
+
openMenu: () => void;
|
|
117
|
+
closeMenu: () => void;
|
|
118
|
+
toggleMenu: () => void;
|
|
119
|
+
selectItem: (item: T) => void;
|
|
120
|
+
setHighlightedIndex: (index: number) => void;
|
|
121
|
+
setInputValue: (inputValue: string) => void;
|
|
122
|
+
};
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { DOMAttributes, FocusEvent } from 'react';
|
|
2
|
+
export declare const findNextIndex: IndexFinderType;
|
|
3
|
+
export declare const findPrevIndex: IndexFinderType;
|
|
4
|
+
type IndexFinderType = <T>({ calc, index, optionDisabled, availableItems, allDisabled, }: {
|
|
5
|
+
index: number;
|
|
6
|
+
optionDisabled: (option: T) => boolean;
|
|
7
|
+
availableItems: readonly T[];
|
|
8
|
+
allDisabled?: boolean;
|
|
9
|
+
calc?: (n: number) => number;
|
|
10
|
+
}) => number;
|
|
11
|
+
export declare function mergeEventsFromRight(props1: DOMAttributes<unknown>, props2: DOMAttributes<unknown>): Partial<DOMAttributes<unknown>>;
|
|
12
|
+
export declare const handleListFocus: (e: FocusEvent<HTMLElement>) => void;
|
|
13
|
+
export {};
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
* DateRangePicker component encapsulates the logic for selecting a range of dates
|
|
3
3
|
* Either by accessible input fields or by a calendar.
|
|
4
4
|
*/
|
|
5
|
-
export declare const DateRangePicker: import("react").ForwardRefExoticComponent<Omit<import("./props").DatePickerProps, "
|
|
5
|
+
export declare const DateRangePicker: import("react").ForwardRefExoticComponent<Omit<import("./props").DatePickerProps, "onChange" | "defaultValue" | "value" | "multiple" | "showTimeInput" | "stateRef"> & Partial<{
|
|
6
6
|
onChange: (range: {
|
|
7
7
|
from: Date | null;
|
|
8
8
|
to: Date | null;
|
|
@@ -7,4 +7,4 @@ export type SideBarButtonProps = {
|
|
|
7
7
|
export declare const SideBarButton: import("react").ForwardRefExoticComponent<{
|
|
8
8
|
label: string;
|
|
9
9
|
icon: IconData;
|
|
10
|
-
} & Omit<ButtonProps, "type" | "
|
|
10
|
+
} & Omit<ButtonProps, "type" | "href" | "variant" | "fullWidth"> & import("react").RefAttributes<HTMLButtonElement>>;
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import type { IconProps } from './Icon.types';
|
|
2
|
+
import './icon.css';
|
|
3
|
+
/**
|
|
4
|
+
* Icon component for EDS 2.0
|
|
5
|
+
*
|
|
6
|
+
* Features:
|
|
7
|
+
* - Automatic sizing from parent's data-font-size via --eds-typography-icon-size
|
|
8
|
+
* - Dynamic fallback sizing (1.5em) when no tokens are set
|
|
9
|
+
* - Explicit size prop for standalone usage
|
|
10
|
+
* - WCAG 2.1 AA accessible with optional title for semantic icons
|
|
11
|
+
*
|
|
12
|
+
* @example
|
|
13
|
+
* ```tsx
|
|
14
|
+
* import { Icon } from '@equinor/eds-core-react/next'
|
|
15
|
+
* import { save } from '@equinor/eds-icons'
|
|
16
|
+
*
|
|
17
|
+
* // Auto-sized from parent's data-font-size
|
|
18
|
+
* <div data-font-size="md">
|
|
19
|
+
* <Icon data={warning} /> Error message
|
|
20
|
+
* </div>
|
|
21
|
+
*
|
|
22
|
+
* // Explicit size for standalone usage
|
|
23
|
+
* <Icon data={save} size="lg" />
|
|
24
|
+
*
|
|
25
|
+
* // Semantic icon with accessible name
|
|
26
|
+
* <Icon data={save} title="Save document" />
|
|
27
|
+
* ```
|
|
28
|
+
*/
|
|
29
|
+
export declare const Icon: import("react").ForwardRefExoticComponent<Omit<IconProps, "ref"> & import("react").RefAttributes<SVGSVGElement>>;
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import type { IconData, IconName } from '@equinor/eds-icons';
|
|
2
|
+
import type { SVGProps, Ref } from 'react';
|
|
3
|
+
export type IconSize = 'xs' | 'sm' | 'md' | 'lg' | 'xl' | '2xl' | '3xl' | '4xl' | '5xl' | '6xl';
|
|
4
|
+
export type IconProps = {
|
|
5
|
+
/** Icon data from @equinor/eds-icons */
|
|
6
|
+
data: IconData;
|
|
7
|
+
/** Title for accessibility - when provided, icon becomes semantic with role="img" */
|
|
8
|
+
title?: string;
|
|
9
|
+
/** Color of the icon. Defaults to currentColor for inheritance */
|
|
10
|
+
color?: string;
|
|
11
|
+
/**
|
|
12
|
+
* Explicit size. Overrides automatic sizing from parent's data-font-size.
|
|
13
|
+
* When not set, icon inherits size from --eds-typography-icon-size or scales dynamically (1.5em).
|
|
14
|
+
*/
|
|
15
|
+
size?: IconSize;
|
|
16
|
+
/** @ignore */
|
|
17
|
+
ref?: Ref<SVGSVGElement>;
|
|
18
|
+
} & Omit<SVGProps<SVGSVGElement>, 'color'>;
|
|
19
|
+
export type { IconData, IconName };
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Example Code Connect file for EDS components.
|
|
3
|
+
*
|
|
4
|
+
* This file demonstrates how to connect a React component to its Figma counterpart.
|
|
5
|
+
* Code Connect files should be placed alongside the component they connect.
|
|
6
|
+
*
|
|
7
|
+
* To use Code Connect:
|
|
8
|
+
* 1. Copy this file as a template for your component
|
|
9
|
+
* 2. Update the import and component reference
|
|
10
|
+
* 3. Replace the Figma URL with your component's URL (right-click → "Copy link to selection")
|
|
11
|
+
* 4. Map Figma properties to code props
|
|
12
|
+
* 5. Run `npx figma connect publish` from packages/eds-core-react/
|
|
13
|
+
*
|
|
14
|
+
* See FIGMA_CODE_CONNECT.md for full documentation.
|
|
15
|
+
*/
|
|
16
|
+
export {};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@equinor/eds-core-react",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.3.0",
|
|
4
4
|
"description": "The React implementation of the Equinor Design System",
|
|
5
5
|
"sideEffects": [
|
|
6
6
|
"**/*.css"
|
|
@@ -44,6 +44,7 @@
|
|
|
44
44
|
"react"
|
|
45
45
|
],
|
|
46
46
|
"devDependencies": {
|
|
47
|
+
"@figma/code-connect": "^1.3.12",
|
|
47
48
|
"@playwright/test": "^1.57.0",
|
|
48
49
|
"@rollup/plugin-babel": "^6.1.0",
|
|
49
50
|
"@rollup/plugin-commonjs": "^28.0.8",
|
|
@@ -100,9 +101,9 @@
|
|
|
100
101
|
"@tanstack/react-virtual": "3.13.12",
|
|
101
102
|
"downshift": "9.0.10",
|
|
102
103
|
"react-aria": "^3.44.0",
|
|
103
|
-
"@equinor/eds-icons": "^1.
|
|
104
|
-
"@equinor/eds-
|
|
105
|
-
"@equinor/eds-
|
|
104
|
+
"@equinor/eds-icons": "^1.2.0",
|
|
105
|
+
"@equinor/eds-tokens": "^2.1.1",
|
|
106
|
+
"@equinor/eds-utils": "^2.0.0"
|
|
106
107
|
},
|
|
107
108
|
"scripts": {
|
|
108
109
|
"build": "rollup -c && tsc -p tsconfig.build.json",
|