@equinor/eds-core-react 2.0.1 → 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.
Files changed (47) hide show
  1. package/README.md +50 -5
  2. package/dist/eds-core-react.cjs +755 -500
  3. package/dist/esm/components/Autocomplete/AddNewOption.js +31 -14
  4. package/dist/esm/components/Autocomplete/Autocomplete.js +54 -874
  5. package/dist/esm/components/Autocomplete/AutocompleteContext.js +12 -0
  6. package/dist/esm/components/Autocomplete/EmptyOption.js +21 -0
  7. package/dist/esm/components/Autocomplete/MultipleInput.js +85 -0
  8. package/dist/esm/components/Autocomplete/Option.js +42 -23
  9. package/dist/esm/components/Autocomplete/OptionList.js +124 -0
  10. package/dist/esm/components/Autocomplete/RightAdornments.js +48 -0
  11. package/dist/esm/components/Autocomplete/SelectAllOption.js +63 -0
  12. package/dist/esm/components/Autocomplete/SingleInput.js +28 -0
  13. package/dist/esm/components/Autocomplete/useAutocomplete.js +605 -0
  14. package/dist/esm/components/Autocomplete/utils.js +93 -0
  15. package/dist/esm/components/Datepicker/fields/FieldWrapper.js +10 -0
  16. package/dist/esm/components/Dialog/Dialog.js +6 -4
  17. package/dist/esm/components/Typography/Typography.new.js +1 -1
  18. package/dist/esm/components/next/Icon/Icon.js +57 -0
  19. package/dist/esm/components/next/Icon/icon.css.js +6 -0
  20. package/dist/esm/components/next/Placeholder/Placeholder.js +17 -0
  21. package/dist/esm/index.js +1 -1
  22. package/dist/esm/index.next.js +2 -0
  23. package/dist/esm/node_modules/.pnpm/style-inject@0.3.0/node_modules/style-inject/dist/style-inject.es.js +26 -0
  24. package/dist/index.next.cjs +101 -0
  25. package/dist/types/components/Autocomplete/AddNewOption.d.ts +4 -12
  26. package/dist/types/components/Autocomplete/Autocomplete.d.ts +33 -11
  27. package/dist/types/components/Autocomplete/AutocompleteContext.d.ts +228 -0
  28. package/dist/types/components/Autocomplete/EmptyOption.d.ts +1 -0
  29. package/dist/types/components/Autocomplete/MultipleInput.d.ts +1 -0
  30. package/dist/types/components/Autocomplete/Option.d.ts +7 -15
  31. package/dist/types/components/Autocomplete/OptionList.d.ts +2 -0
  32. package/dist/types/components/Autocomplete/RightAdornments.d.ts +1 -0
  33. package/dist/types/components/Autocomplete/SelectAllOption.d.ts +6 -0
  34. package/dist/types/components/Autocomplete/SingleInput.d.ts +1 -0
  35. package/dist/types/components/Autocomplete/useAutocomplete.d.ts +122 -0
  36. package/dist/types/components/Autocomplete/utils.d.ts +13 -0
  37. package/dist/types/components/Datepicker/DateRangePicker.d.ts +1 -1
  38. package/dist/types/components/SideBar/SideBarButton/index.d.ts +1 -1
  39. package/dist/types/components/next/Icon/Icon.d.ts +29 -0
  40. package/dist/types/components/next/Icon/Icon.types.d.ts +19 -0
  41. package/dist/types/components/next/Icon/index.d.ts +2 -0
  42. package/dist/types/components/next/Placeholder/Placeholder.d.ts +9 -0
  43. package/dist/types/components/next/Placeholder/Placeholder.figma.d.ts +16 -0
  44. package/dist/types/components/next/Placeholder/index.d.ts +2 -0
  45. package/dist/types/components/next/index.d.ts +4 -0
  46. package/dist/types/index.next.d.ts +11 -0
  47. package/package.json +13 -8
@@ -1,26 +1,18 @@
1
- import { LiHTMLAttributes, ReactNode } from 'react';
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
- value: string;
13
- multiple: boolean;
14
- highlighted: string;
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
- } & LiHTMLAttributes<HTMLLIElement>;
21
- declare function AutocompleteOptionInner(props: AutocompleteOptionProps, ref: React.ForwardedRef<HTMLLIElement>): import("react/jsx-runtime").JSX.Element;
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,2 @@
1
+ import { UseFloatingReturn } from '@floating-ui/react';
2
+ export declare const OptionList: ({ refs, strategy, x, y, update, }: UseFloatingReturn) => import("react/jsx-runtime").JSX.Element;
@@ -0,0 +1 @@
1
+ export declare const RightAdornments: () => import("react/jsx-runtime").JSX.Element;
@@ -0,0 +1,6 @@
1
+ export type AutocompleteOptionProps = {
2
+ item: unknown;
3
+ index: number;
4
+ ref?: React.Ref<HTMLLIElement>;
5
+ };
6
+ export declare function SelectAllOption({ item, index, ref }: AutocompleteOptionProps): import("react/jsx-runtime").JSX.Element;
@@ -0,0 +1 @@
1
+ export declare const SingleInput: () => import("react/jsx-runtime").JSX.Element;
@@ -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, "defaultValue" | "onChange" | "value" | "multiple" | "showTimeInput" | "stateRef"> & Partial<{
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" | "variant" | "href" | "fullWidth"> & import("react").RefAttributes<HTMLButtonElement>>;
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,2 @@
1
+ export { Icon } from './Icon';
2
+ export type { IconProps, IconSize, IconData, IconName } from './Icon.types';
@@ -0,0 +1,9 @@
1
+ /**
2
+ * Placeholder component for testing the /next entry point.
3
+ * This component should be removed once real EDS 2.0 components are added.
4
+ */
5
+ export type PlaceholderProps = {
6
+ /** Text to display */
7
+ text?: string;
8
+ };
9
+ export declare const Placeholder: ({ text, }: PlaceholderProps) => import("react/jsx-runtime").JSX.Element;
@@ -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 {};
@@ -0,0 +1,2 @@
1
+ export { Placeholder } from './Placeholder';
2
+ export type { PlaceholderProps } from './Placeholder';
@@ -0,0 +1,4 @@
1
+ export { Placeholder } from './Placeholder';
2
+ export type { PlaceholderProps } from './Placeholder';
3
+ export { Icon } from './Icon';
4
+ export type { IconProps, IconSize, IconData, IconName } from './Icon';
@@ -0,0 +1,11 @@
1
+ /**
2
+ * EDS 2.0 Beta Components
3
+ *
4
+ * These components are experimental and under active development.
5
+ * Breaking changes may occur between beta releases.
6
+ *
7
+ * Install: npm install @equinor/eds-core-react@beta
8
+ *
9
+ * @packageDocumentation
10
+ */
11
+ export * from './components/next';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@equinor/eds-core-react",
3
- "version": "2.0.1",
3
+ "version": "2.2.0-beta.0",
4
4
  "description": "The React implementation of the Equinor Design System",
5
5
  "sideEffects": [
6
6
  "**/*.css"
@@ -30,6 +30,11 @@
30
30
  "types": "./dist/types/index.d.ts",
31
31
  "import": "./dist/esm/index.js",
32
32
  "require": "./dist/eds-core-react.cjs"
33
+ },
34
+ "./next": {
35
+ "types": "./dist/types/index.next.d.ts",
36
+ "import": "./dist/esm/index.next.js",
37
+ "require": "./dist/index.next.cjs"
33
38
  }
34
39
  },
35
40
  "keywords": [
@@ -39,7 +44,8 @@
39
44
  "react"
40
45
  ],
41
46
  "devDependencies": {
42
- "@playwright/test": "^1.55.0",
47
+ "@figma/code-connect": "^1.3.12",
48
+ "@playwright/test": "^1.57.0",
43
49
  "@rollup/plugin-babel": "^6.1.0",
44
50
  "@rollup/plugin-commonjs": "^28.0.8",
45
51
  "@rollup/plugin-node-resolve": "^16.0.3",
@@ -82,8 +88,7 @@
82
88
  "peerDependencies": {
83
89
  "react": "^19",
84
90
  "react-dom": "^19",
85
- "styled-components": "^6",
86
- "@equinor/eds-tokens": "^2.0.1"
91
+ "styled-components": "^6"
87
92
  },
88
93
  "dependencies": {
89
94
  "@babel/runtime": "^7.28.4",
@@ -96,13 +101,13 @@
96
101
  "@tanstack/react-virtual": "3.13.12",
97
102
  "downshift": "9.0.10",
98
103
  "react-aria": "^3.44.0",
99
- "@equinor/eds-icons": "^1.0.1",
100
- "@equinor/eds-tokens": "^2.0.1",
101
- "@equinor/eds-utils": "^2.0.0"
104
+ "@equinor/eds-icons": "^1.2.0",
105
+ "@equinor/eds-utils": "^2.0.0",
106
+ "@equinor/eds-tokens": "^2.1.1"
102
107
  },
103
108
  "scripts": {
104
109
  "build": "rollup -c && tsc -p tsconfig.build.json",
105
- "test": "tsc -p tsconfig.test.json && jest",
110
+ "test": "tsc -p tsconfig.test.json && jest --ci",
106
111
  "test:watch": "tsc-watch -p tsconfig.test.json --onFirstSuccess \"jest --watch\"",
107
112
  "test:update-snapshots": "jest --updateSnapshot",
108
113
  "test:visual": "playwright test",