@equinor/eds-core-react 0.24.0 → 0.26.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 (71) hide show
  1. package/dist/eds-core-react.cjs.js +1820 -1633
  2. package/dist/esm/components/Autocomplete/Autocomplete.js +64 -70
  3. package/dist/esm/components/Autocomplete/Autocomplete.tokens.js +1 -0
  4. package/dist/esm/components/Button/Button.js +1 -1
  5. package/dist/esm/components/Input/Input.js +129 -32
  6. package/dist/esm/components/Input/Input.tokens.js +84 -56
  7. package/dist/esm/components/InputWrapper/HelperText/HelperText.js +49 -0
  8. package/dist/esm/components/InputWrapper/HelperText/HelperText.token.js +28 -0
  9. package/dist/esm/components/InputWrapper/InputWrapper.js +68 -0
  10. package/dist/esm/components/InputWrapper/InputWrapper.tokens.js +164 -0
  11. package/dist/esm/components/Menu/Menu.js +2 -2
  12. package/dist/esm/components/Pagination/Pagination.js +3 -3
  13. package/dist/esm/components/Popover/Popover.js +71 -56
  14. package/dist/esm/components/Popover/Popover.tokens.js +17 -2
  15. package/dist/esm/components/Search/Search.js +60 -187
  16. package/dist/esm/components/SideBar/SideBar.context.js +53 -0
  17. package/dist/esm/components/SideBar/SideBar.js +79 -0
  18. package/dist/esm/components/SideBar/SideBar.tokens.js +110 -0
  19. package/dist/esm/components/SideBar/SideBarButton/index.js +86 -0
  20. package/dist/esm/components/SideBar/SideBarContent.js +27 -0
  21. package/dist/esm/components/SideBar/SideBarFooter.js +27 -0
  22. package/dist/esm/components/SideBar/SideBarToggle.js +57 -0
  23. package/dist/esm/components/SideBar/SidebarLink/index.js +106 -0
  24. package/dist/esm/components/SideBar/index.js +20 -0
  25. package/dist/esm/components/TextField/TextField.js +52 -46
  26. package/dist/esm/components/Textarea/Textarea.js +26 -43
  27. package/dist/esm/components/Tooltip/Tooltip.js +38 -37
  28. package/dist/esm/components/TopBar/Header.js +1 -1
  29. package/dist/esm/index.js +3 -0
  30. package/dist/types/components/Input/Input.d.ts +22 -15
  31. package/dist/types/components/InputWrapper/HelperText/HelperText.d.ts +18 -0
  32. package/dist/types/components/{TextField → InputWrapper}/HelperText/HelperText.token.d.ts +0 -5
  33. package/dist/types/components/InputWrapper/HelperText/index.d.ts +1 -0
  34. package/dist/types/components/InputWrapper/InputWrapper.d.ts +41 -0
  35. package/dist/types/components/InputWrapper/InputWrapper.tokens.d.ts +12 -0
  36. package/dist/types/components/InputWrapper/index.d.ts +2 -0
  37. package/dist/types/components/Popover/Popover.d.ts +10 -0
  38. package/dist/types/components/Search/Search.d.ts +2 -2
  39. package/dist/types/components/Select/commonStyles.d.ts +1 -7
  40. package/dist/types/components/SideBar/SideBar.context.d.ts +15 -0
  41. package/dist/types/components/SideBar/SideBar.d.ts +5 -0
  42. package/dist/types/components/SideBar/SideBar.tokens.d.ts +2 -0
  43. package/dist/types/components/SideBar/SideBarButton/index.d.ts +8 -0
  44. package/dist/types/components/SideBar/SideBarContent.d.ts +4 -0
  45. package/dist/types/components/SideBar/SideBarFooter.d.ts +4 -0
  46. package/dist/types/components/SideBar/SideBarToggle.d.ts +4 -0
  47. package/dist/types/components/SideBar/SidebarLink/index.d.ts +18 -0
  48. package/dist/types/components/SideBar/index.d.ts +17 -0
  49. package/dist/types/components/TextField/TextField.d.ts +15 -21
  50. package/dist/types/components/Textarea/Textarea.d.ts +3 -3
  51. package/dist/types/components/types.d.ts +1 -0
  52. package/dist/types/index.d.ts +2 -0
  53. package/package.json +3 -3
  54. package/dist/esm/components/Search/Search.tokens.js +0 -83
  55. package/dist/esm/components/TextField/Field.js +0 -151
  56. package/dist/esm/components/TextField/HelperText/HelperText.js +0 -89
  57. package/dist/esm/components/TextField/HelperText/HelperText.token.js +0 -45
  58. package/dist/esm/components/TextField/Icon/Icon.js +0 -65
  59. package/dist/esm/components/TextField/Icon/Icon.tokens.js +0 -42
  60. package/dist/esm/components/TextField/TextField.context.js +0 -48
  61. package/dist/esm/components/TextField/TextField.tokens.js +0 -120
  62. package/dist/types/components/Search/Search.tokens.d.ts +0 -4
  63. package/dist/types/components/TextField/Field.d.ts +0 -34
  64. package/dist/types/components/TextField/HelperText/HelperText.d.ts +0 -14
  65. package/dist/types/components/TextField/HelperText/index.d.ts +0 -1
  66. package/dist/types/components/TextField/Icon/Icon.d.ts +0 -13
  67. package/dist/types/components/TextField/Icon/Icon.tokens.d.ts +0 -14
  68. package/dist/types/components/TextField/Icon/index.d.ts +0 -1
  69. package/dist/types/components/TextField/TextField.context.d.ts +0 -17
  70. package/dist/types/components/TextField/TextField.tokens.d.ts +0 -10
  71. package/dist/types/components/TextField/types.d.ts +0 -6
@@ -0,0 +1,41 @@
1
+ import { HTMLAttributes, ReactNode } from 'react';
2
+ import { LabelProps } from '../Label';
3
+ import { HelperTextProps } from './HelperText';
4
+ import { Variants } from '../types';
5
+ export declare type InputWrapperProps = {
6
+ /** Label */
7
+ label?: string;
8
+ /** Disabled state */
9
+ disabled?: boolean;
10
+ /** Read Only */
11
+ readOnly?: boolean;
12
+ /** Highlight color */
13
+ color?: Variants;
14
+ /** Label props */
15
+ labelProps?: LabelProps;
16
+ /** Helpertext props */
17
+ helperProps?: HelperTextProps;
18
+ /** Helper Icon */
19
+ helperIcon?: ReactNode;
20
+ /** Input or Textarea element */
21
+ children: ReactNode;
22
+ } & HTMLAttributes<HTMLDivElement>;
23
+ /** InputWrapper is a internal skeleton component for structuring input elements */
24
+ export declare const InputWrapper: import("react").ForwardRefExoticComponent<{
25
+ /** Label */
26
+ label?: string;
27
+ /** Disabled state */
28
+ disabled?: boolean;
29
+ /** Read Only */
30
+ readOnly?: boolean;
31
+ /** Highlight color */
32
+ color?: Variants;
33
+ /** Label props */
34
+ labelProps?: LabelProps;
35
+ /** Helpertext props */
36
+ helperProps?: HelperTextProps;
37
+ /** Helper Icon */
38
+ helperIcon?: ReactNode;
39
+ /** Input or Textarea element */
40
+ children: ReactNode;
41
+ } & HTMLAttributes<HTMLDivElement> & import("react").RefAttributes<HTMLDivElement>>;
@@ -0,0 +1,12 @@
1
+ import type { ComponentToken } from '@equinor/eds-tokens';
2
+ export declare type InputToken = ComponentToken;
3
+ export declare const input: InputToken;
4
+ export declare const error: InputToken;
5
+ export declare const warning: InputToken;
6
+ export declare const success: InputToken;
7
+ export declare const inputToken: {
8
+ input: ComponentToken;
9
+ error: ComponentToken;
10
+ warning: ComponentToken;
11
+ success: ComponentToken;
12
+ };
@@ -0,0 +1,2 @@
1
+ export { InputWrapper } from './InputWrapper';
2
+ export type { InputWrapperProps } from './InputWrapper';
@@ -9,6 +9,11 @@ export declare type PopoverProps = {
9
9
  anchorEl?: HTMLElement | null;
10
10
  /** Is Popover open */
11
11
  open: boolean;
12
+ /** initializes react portal for dropdown, default to false. */
13
+ withinPortal?: boolean;
14
+ /** Determines whether focus should be trapped within dropdown,
15
+ * default to false. */
16
+ trapFocus?: boolean;
12
17
  } & HTMLAttributes<HTMLDivElement>;
13
18
  export declare const Popover: import("react").ForwardRefExoticComponent<{
14
19
  /** Popover placement relative to anchor */
@@ -19,4 +24,9 @@ export declare const Popover: import("react").ForwardRefExoticComponent<{
19
24
  anchorEl?: HTMLElement | null;
20
25
  /** Is Popover open */
21
26
  open: boolean;
27
+ /** initializes react portal for dropdown, default to false. */
28
+ withinPortal?: boolean;
29
+ /** Determines whether focus should be trapped within dropdown,
30
+ * default to false. */
31
+ trapFocus?: boolean;
22
32
  } & HTMLAttributes<HTMLDivElement> & import("react").RefAttributes<HTMLDivElement>>;
@@ -1,3 +1,3 @@
1
- import { InputHTMLAttributes, RefAttributes } from 'react';
1
+ import { InputHTMLAttributes } from 'react';
2
2
  export declare type SearchProps = InputHTMLAttributes<HTMLInputElement>;
3
- export declare const Search: import("react").ForwardRefExoticComponent<SearchProps & RefAttributes<HTMLInputElement>>;
3
+ export declare const Search: import("react").ForwardRefExoticComponent<SearchProps & import("react").RefAttributes<HTMLInputElement>>;
@@ -5,13 +5,7 @@ declare type StyledListItemType = {
5
5
  active?: string;
6
6
  };
7
7
  export declare const Container: import("styled-components").StyledComponent<"div", import("styled-components").DefaultTheme, ContainerProps, never>;
8
- export declare const PaddedInput: import("styled-components").StyledComponent<import("react").ForwardRefExoticComponent<{
9
- placeholder?: string;
10
- variant?: import("../TextField/types").Variants;
11
- disabled?: boolean;
12
- type?: string;
13
- readOnly?: boolean;
14
- } & import("react").InputHTMLAttributes<HTMLInputElement> & import("react").RefAttributes<HTMLInputElement>>, import("styled-components").DefaultTheme, {}, never>;
8
+ export declare const PaddedInput: import("styled-components").StyledComponent<import("@equinor/eds-utils").OverridableComponent<import("../Input").InputProps, HTMLInputElement>, import("styled-components").DefaultTheme, {}, never>;
15
9
  export declare const StyledList: import("styled-components").StyledComponent<import("react").ForwardRefExoticComponent<{
16
10
  variant?: "bullet" | "numbered";
17
11
  start?: string;
@@ -0,0 +1,15 @@
1
+ import { ReactNode } from 'react';
2
+ export declare type State = {
3
+ isOpen: boolean;
4
+ onToggle: (state: boolean) => void;
5
+ };
6
+ declare type UseSidebarProps<T> = T & {
7
+ setIsOpen: (open: boolean) => void;
8
+ setOnToggle: (onToggle: (state: boolean) => void) => void;
9
+ };
10
+ declare type ProviderProps = {
11
+ children: ReactNode;
12
+ };
13
+ export declare const SideBarProvider: ({ children }: ProviderProps) => JSX.Element;
14
+ export declare const useSideBar: () => UseSidebarProps<State>;
15
+ export {};
@@ -0,0 +1,5 @@
1
+ import { HTMLAttributes } from 'react';
2
+ export declare const SideBar: import("react").ForwardRefExoticComponent<{
3
+ open?: boolean;
4
+ onToggle?: (state: boolean) => void;
5
+ } & HTMLAttributes<HTMLDivElement> & import("react").RefAttributes<HTMLDivElement>>;
@@ -0,0 +1,2 @@
1
+ import type { ComponentToken } from '@equinor/eds-tokens';
2
+ export declare const sidebar: ComponentToken;
@@ -0,0 +1,8 @@
1
+ import { ForwardRefExoticComponent } from 'react';
2
+ import { ButtonProps } from '../../..';
3
+ import { IconData } from '@equinor/eds-icons';
4
+ export declare type SideBarButtonProps = {
5
+ label: string;
6
+ icon: IconData;
7
+ } & Omit<ButtonProps, 'href' | 'type' | 'fullWidth' | 'variant'>;
8
+ export declare const SideBarButton: ForwardRefExoticComponent<SideBarButtonProps>;
@@ -0,0 +1,4 @@
1
+ import { HTMLAttributes } from 'react';
2
+ declare type SideBarContentProps = HTMLAttributes<HTMLDivElement>;
3
+ export declare const SideBarContent: import("react").ForwardRefExoticComponent<SideBarContentProps & import("react").RefAttributes<HTMLDivElement>>;
4
+ export {};
@@ -0,0 +1,4 @@
1
+ import { HTMLAttributes } from 'react';
2
+ declare type SideBarFooterProps = HTMLAttributes<HTMLDivElement>;
3
+ export declare const SideBarFooter: import("react").ForwardRefExoticComponent<SideBarFooterProps & import("react").RefAttributes<HTMLDivElement>>;
4
+ export {};
@@ -0,0 +1,4 @@
1
+ import { ForwardRefExoticComponent, HTMLAttributes } from 'react';
2
+ declare type SideBarToggleProps = HTMLAttributes<HTMLDivElement>;
3
+ export declare const SideBarToggle: ForwardRefExoticComponent<SideBarToggleProps>;
4
+ export {};
@@ -0,0 +1,18 @@
1
+ import { AnchorHTMLAttributes, ElementType } from 'react';
2
+ import { OverridableComponent } from '@equinor/eds-utils';
3
+ import { IconData } from '@equinor/eds-icons';
4
+ declare type OverridableSubComponent = OverridableComponent<SidebarLinkProps, HTMLAnchorElement> & {
5
+ displayName?: string;
6
+ };
7
+ export declare type SidebarLinkProps = {
8
+ /** Icon*/
9
+ icon: IconData;
10
+ /** Label text */
11
+ label: string;
12
+ /** Active/current url */
13
+ active?: boolean;
14
+ onClick?: () => void;
15
+ as?: ElementType;
16
+ } & AnchorHTMLAttributes<HTMLAnchorElement>;
17
+ export declare const SidebarLink: OverridableSubComponent;
18
+ export {};
@@ -0,0 +1,17 @@
1
+ import { SideBar as BaseSideBar } from './SideBar';
2
+ import { useSideBar } from './SideBar.context';
3
+ import { SidebarLink, SidebarLinkProps } from './SidebarLink';
4
+ import { SideBarContent } from './SideBarContent';
5
+ import { SideBarFooter } from './SideBarFooter';
6
+ import { SideBarToggle } from './SideBarToggle';
7
+ import { SideBarButton } from './SideBarButton';
8
+ declare type SidebarType = typeof BaseSideBar & {
9
+ Link: typeof SidebarLink;
10
+ Content: typeof SideBarContent;
11
+ Footer: typeof SideBarFooter;
12
+ Toggle: typeof SideBarToggle;
13
+ Button: typeof SideBarButton;
14
+ };
15
+ declare const SideBar: SidebarType;
16
+ export { SideBar, useSideBar };
17
+ export type { SidebarType, SidebarLinkProps };
@@ -1,11 +1,9 @@
1
- import { ReactNode, InputHTMLAttributes, TextareaHTMLAttributes, Ref } from 'react';
2
- import type { Variants } from './types';
3
- export declare type TextFieldProps = {
4
- /** @ignore */
5
- className?: string;
1
+ import { ReactNode, InputHTMLAttributes, TextareaHTMLAttributes, ForwardedRef } from 'react';
2
+ import type { Variants } from '../types';
3
+ declare type SharedTextFieldProps = {
6
4
  /** Variants */
7
5
  variant?: Variants;
8
- /** Input unique id */
6
+ /** Input unique id. This is required to ensure accesibility */
9
7
  id: string;
10
8
  /** Label text */
11
9
  label?: string;
@@ -15,23 +13,19 @@ export declare type TextFieldProps = {
15
13
  unit?: string;
16
14
  /** Helper text */
17
15
  helperText?: string;
18
- /** Placeholder text */
19
- placeholder?: string;
20
- /** Disabled */
21
- disabled?: boolean;
22
- /** Multiline input */
23
- multiline?: boolean;
24
- /** Specifies max rows for multiline input */
25
- rowsMax?: number;
26
- /** Input ref */
27
- inputRef?: Ref<HTMLInputElement> | Ref<HTMLTextAreaElement>;
28
16
  /** InputIcon */
29
17
  inputIcon?: ReactNode;
30
18
  /** HelperIcon */
31
19
  helperIcon?: ReactNode;
32
- /** Value */
33
- value?: string;
34
- /** Read Only */
35
- readOnly?: boolean;
36
- } & (InputHTMLAttributes<HTMLInputElement> | TextareaHTMLAttributes<HTMLTextAreaElement>);
20
+ /** Maximum number of rows if `multiline` is set to `true` */
21
+ rowsMax?: number;
22
+ /** Input ref */
23
+ inputRef?: ForwardedRef<HTMLInputElement>;
24
+ /** Textarea ref when multiline is set to `true` */
25
+ textareaRef?: ForwardedRef<HTMLTextAreaElement>;
26
+ /** If `true` a `textarea` is rendered for multiline support. Make sure to use `textareaRef` if you need to access reference element */
27
+ multiline?: boolean;
28
+ };
29
+ export declare type TextFieldProps = SharedTextFieldProps & (TextareaHTMLAttributes<HTMLTextAreaElement> | InputHTMLAttributes<HTMLInputElement>);
37
30
  export declare const TextField: import("react").ForwardRefExoticComponent<TextFieldProps & import("react").RefAttributes<HTMLDivElement>>;
31
+ export {};
@@ -1,5 +1,5 @@
1
1
  import { TextareaHTMLAttributes } from 'react';
2
- import type { Variants } from '../TextField/types';
2
+ import type { Variants } from '../types';
3
3
  export declare type TextareaProps = {
4
4
  /** Placeholder */
5
5
  placeholder?: string;
@@ -11,7 +11,7 @@ export declare type TextareaProps = {
11
11
  type?: string;
12
12
  /** Read Only */
13
13
  readOnly?: boolean;
14
- /** Specifies max rows for multiline input */
14
+ /** Specifies max rows for multiline */
15
15
  rowsMax?: number;
16
16
  } & TextareaHTMLAttributes<HTMLTextAreaElement>;
17
17
  export declare const Textarea: import("react").ForwardRefExoticComponent<{
@@ -25,6 +25,6 @@ export declare const Textarea: import("react").ForwardRefExoticComponent<{
25
25
  type?: string;
26
26
  /** Read Only */
27
27
  readOnly?: boolean;
28
- /** Specifies max rows for multiline input */
28
+ /** Specifies max rows for multiline */
29
29
  rowsMax?: number;
30
30
  } & TextareaHTMLAttributes<HTMLTextAreaElement> & import("react").RefAttributes<HTMLTextAreaElement>>;
@@ -0,0 +1 @@
1
+ export declare type Variants = 'error' | 'warning' | 'success';
@@ -34,3 +34,5 @@ export * from './components/Switch';
34
34
  export * from './components/EdsProvider';
35
35
  export * from './components/Paper';
36
36
  export * from './components/Autocomplete';
37
+ export * from './components/InputWrapper';
38
+ export * from './components/SideBar';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@equinor/eds-core-react",
3
- "version": "0.24.0",
3
+ "version": "0.26.0",
4
4
  "description": "The React implementation of the Equinor Design System",
5
5
  "sideEffects": [
6
6
  "**/*.css"
@@ -80,8 +80,8 @@
80
80
  "dependencies": {
81
81
  "@babel/runtime": "^7.19.0",
82
82
  "@equinor/eds-icons": "0.15.0",
83
- "@equinor/eds-tokens": "0.8.0",
84
- "@equinor/eds-utils": "0.5.0",
83
+ "@equinor/eds-tokens": "0.9.0",
84
+ "@equinor/eds-utils": "0.7.0",
85
85
  "@floating-ui/react-dom-interactions": "^0.10.1",
86
86
  "downshift": "^6.1.12"
87
87
  },
@@ -1,83 +0,0 @@
1
- import { tokens } from '@equinor/eds-tokens';
2
-
3
- var _tokens$colors = tokens.colors,
4
- background = _tokens$colors.ui.background__light.rgba,
5
- _tokens$colors$intera = _tokens$colors.interactive,
6
- primaryHoverAlt = _tokens$colors$intera.primary__hover_alt.rgba,
7
- primaryColor = _tokens$colors$intera.primary__resting.rgba,
8
- placeholderColor = _tokens$colors.text.static_icons__tertiary.rgba,
9
- small = tokens.spacings.comfortable.small,
10
- typography = tokens.typography.input.text,
11
- shape = tokens.shape;
12
- var search = {
13
- background: background,
14
- typography: typography,
15
- height: '36px',
16
- clickbound: {
17
- offset: {
18
- top: '6px'
19
- },
20
- height: '48px'
21
- },
22
- spacings: {
23
- left: small,
24
- right: small
25
- },
26
- border: {
27
- type: 'border',
28
- width: '1px',
29
- style: 'solid',
30
- color: 'transparent'
31
- },
32
- states: {
33
- focus: {
34
- border: {
35
- type: 'border',
36
- width: '1px',
37
- style: 'solid',
38
- color: primaryColor
39
- }
40
- }
41
- },
42
- entities: {
43
- placeholder: {
44
- typography: {
45
- color: placeholderColor
46
- }
47
- },
48
- icon: {
49
- typography: {
50
- color: placeholderColor
51
- },
52
- border: {
53
- type: 'border',
54
- radius: '50%'
55
- },
56
- states: {
57
- hover: {
58
- background: primaryHoverAlt
59
- }
60
- },
61
- clickbound: {
62
- offset: {
63
- top: '6px'
64
- },
65
- height: '36px'
66
- }
67
- },
68
- button: {
69
- height: '24px',
70
- width: '24px',
71
- spacings: {
72
- right: small
73
- }
74
- }
75
- },
76
- modes: {
77
- compact: {
78
- height: shape._modes.compact.straight.minHeight
79
- }
80
- }
81
- };
82
-
83
- export { search };
@@ -1,151 +0,0 @@
1
- import _objectSpread from '@babel/runtime/helpers/objectSpread2';
2
- import _objectWithoutProperties from '@babel/runtime/helpers/objectWithoutProperties';
3
- import { forwardRef } from 'react';
4
- import { useTextField } from './TextField.context.js';
5
- import styled, { css } from 'styled-components';
6
- import { typographyTemplate, outlineTemplate } from '@equinor/eds-utils';
7
- import * as TextField_tokens from './TextField.tokens.js';
8
- import { textfield as textfield$1 } from './TextField.tokens.js';
9
- import { jsxs, jsx } from 'react/jsx-runtime';
10
- import { Input } from '../Input/Input.js';
11
- import { Textarea } from '../Textarea/Textarea.js';
12
- import { Icon as InputIcon } from './Icon/Icon.js';
13
- import { useEds } from '../EdsProvider/eds.context.js';
14
-
15
- var _excluded = ["multiline", "variant", "disabled", "readOnly", "type", "unit", "inputIcon", "rowsMax", "onBlur", "onFocus"];
16
- var textfield = textfield$1;
17
-
18
- var Variation = function Variation(_ref) {
19
- var _token$border, _token$border2, _token$border3, _token$border4;
20
-
21
- var variant = _ref.variant,
22
- isFocused = _ref.isFocused,
23
- token = _ref.token;
24
-
25
- if (!variant) {
26
- return "";
27
- }
28
-
29
- return css(["box-shadow:", ";", ""], isFocused ? "none" : variant === 'default' ? "inset 0 -1px 0 0 ".concat(((_token$border = token.border) === null || _token$border === void 0 ? void 0 : _token$border.type) === 'border' && ((_token$border2 = token.border) === null || _token$border2 === void 0 ? void 0 : _token$border2.color)) : "0 0 0 1px ".concat(((_token$border3 = token.border) === null || _token$border3 === void 0 ? void 0 : _token$border3.type) === 'border' && ((_token$border4 = token.border) === null || _token$border4 === void 0 ? void 0 : _token$border4.color)), isFocused && outlineTemplate(token.states.focus.outline));
30
- };
31
-
32
- var StrippedInput = styled(Input).withConfig({
33
- displayName: "Field__StrippedInput",
34
- componentId: "sc-455b88-0"
35
- })(["outline:none;&:active,&:focus{outline:none;box-shadow:none;}"]);
36
- var StrippedTextarea = styled(Textarea).withConfig({
37
- displayName: "Field__StrippedTextarea",
38
- componentId: "sc-455b88-1"
39
- })(["outline:none;&:active,&:focus{outline:none;box-shadow:none;}"]);
40
- var InputWrapper = styled.div.withConfig({
41
- displayName: "Field__InputWrapper",
42
- componentId: "sc-455b88-2"
43
- })(function (_ref2) {
44
- var inputIcon = _ref2.inputIcon,
45
- unit = _ref2.unit,
46
- isDisabled = _ref2.isDisabled,
47
- isReadOnly = _ref2.isReadOnly,
48
- multiline = _ref2.multiline,
49
- variant = _ref2.variant;
50
- return css(["", " ", " ", " ", " ", ""], Variation, (inputIcon || unit) && css(["display:flex;align-items:center;background:", ";padding-right:", ";"], textfield.background, textfield.spacings.right), isReadOnly && css(["box-shadow:", ";background:", ";"], textfield.states.readOnly.boxShadow, textfield.states.readOnly.background), isDisabled && css(["box-shadow:none;cursor:not-allowed;outline:none;"]), multiline && variant === 'default' && !inputIcon && !unit && css(["box-shadow:none;"]));
51
- });
52
- var Unit = styled.span.withConfig({
53
- displayName: "Field__Unit",
54
- componentId: "sc-455b88-3"
55
- })(["", ";display:inline-block;margin-top:3px;", ""], typographyTemplate(textfield.entities.unit.typography), function (_ref3) {
56
- var isDisabled = _ref3.isDisabled;
57
- return isDisabled && {
58
- color: textfield.entities.unit.states.disabled.typography.color
59
- };
60
- });
61
- var Adornments = styled.div.withConfig({
62
- displayName: "Field__Adornments",
63
- componentId: "sc-455b88-4"
64
- })(["display:flex;align-items:center;justify-content:center;height:100%;margin-left:", ";& div:nth-child(2){margin-left:", ";}", ""], textfield.spacings.left, textfield.spacings.left, function (_ref4) {
65
- var multiline = _ref4.multiline,
66
- theme = _ref4.theme;
67
- return multiline && {
68
- marginTop: theme.spacings.top,
69
- alignSelf: 'start'
70
- };
71
- });
72
- var Field = /*#__PURE__*/forwardRef(function Field(_ref5, ref) {
73
- var multiline = _ref5.multiline,
74
- variant = _ref5.variant,
75
- disabled = _ref5.disabled,
76
- readOnly = _ref5.readOnly,
77
- type = _ref5.type,
78
- unit = _ref5.unit,
79
- inputIcon = _ref5.inputIcon,
80
- rowsMax = _ref5.rowsMax,
81
- onBlur = _ref5.onBlur,
82
- onFocus = _ref5.onFocus,
83
- other = _objectWithoutProperties(_ref5, _excluded);
84
-
85
- var _useTextField = useTextField(),
86
- handleFocus = _useTextField.handleFocus,
87
- handleBlur = _useTextField.handleBlur,
88
- isFocused = _useTextField.isFocused;
89
-
90
- var _useEds = useEds(),
91
- density = _useEds.density;
92
-
93
- var iconSize = density === 'compact' ? 16 : 24;
94
- var actualVariant = variant === 'default' ? 'textfield' : variant;
95
- var inputVariant = TextField_tokens[actualVariant];
96
- var isError = actualVariant === 'error';
97
-
98
- var focusHandler = function focusHandler(e) {
99
- handleFocus();
100
- onFocus && onFocus(e);
101
- };
102
-
103
- var blurHandler = function blurHandler(e) {
104
- handleBlur();
105
- onBlur && onBlur(e);
106
- };
107
-
108
- var inputWrapperProps = {
109
- isFocused: isFocused,
110
- isDisabled: disabled,
111
- isReadOnly: readOnly,
112
- variant: variant,
113
- token: inputVariant,
114
- inputIcon: inputIcon,
115
- unit: unit,
116
- multiline: multiline
117
- };
118
-
119
- var inputProps = _objectSpread({
120
- ref: ref,
121
- 'aria-invalid': isError,
122
- type: type,
123
- disabled: disabled,
124
- readOnly: readOnly,
125
- variant: variant,
126
- onBlur: blurHandler,
127
- onFocus: focusHandler
128
- }, other);
129
-
130
- var textareaProps = _objectSpread(_objectSpread({}, inputProps), {}, {
131
- rowsMax: rowsMax,
132
- ref: ref
133
- });
134
-
135
- return /*#__PURE__*/jsxs(InputWrapper, _objectSpread(_objectSpread({}, inputWrapperProps), {}, {
136
- children: [multiline ? /*#__PURE__*/jsx(StrippedTextarea, _objectSpread({}, textareaProps)) : /*#__PURE__*/jsx(StrippedInput, _objectSpread({}, inputProps)), (inputIcon || unit) && /*#__PURE__*/jsxs(Adornments, {
137
- multiline: multiline,
138
- children: [unit && /*#__PURE__*/jsx(Unit, {
139
- isDisabled: disabled,
140
- children: unit
141
- }), inputIcon && /*#__PURE__*/jsx(InputIcon, {
142
- isDisabled: disabled,
143
- variant: variant,
144
- size: iconSize,
145
- children: inputIcon
146
- })]
147
- })]
148
- }));
149
- });
150
-
151
- export { Field, InputWrapper };
@@ -1,89 +0,0 @@
1
- import _objectSpread from '@babel/runtime/helpers/objectSpread2';
2
- import _objectWithoutProperties from '@babel/runtime/helpers/objectWithoutProperties';
3
- import { forwardRef } from 'react';
4
- import styled, { css } from 'styled-components';
5
- import { typographyTemplate } from '@equinor/eds-utils';
6
- import { helperText } from './HelperText.token.js';
7
- import { useTextField } from '../TextField.context.js';
8
- import { jsxs, jsx } from 'react/jsx-runtime';
9
- import { Icon as InputIcon } from '../Icon/Icon.js';
10
-
11
- var _excluded = ["helperText", "icon", "variant", "disabled"];
12
-
13
- var Variation = function Variation(_ref) {
14
- var variant = _ref.variant,
15
- isFocused = _ref.isFocused,
16
- isDisabled = _ref.isDisabled;
17
-
18
- if (!variant) {
19
- return "";
20
- }
21
-
22
- var focusColor = variant.focusColor,
23
- color = variant.color,
24
- disabledColor = variant.disabledColor;
25
-
26
- if (isDisabled) {
27
- return css(["color:", ";"], disabledColor);
28
- }
29
-
30
- if (isFocused) {
31
- return css(["color:", ";"], focusColor);
32
- }
33
-
34
- return css(["color:", ";"], color);
35
- };
36
-
37
- var Container = styled.div.withConfig({
38
- displayName: "HelperText__Container",
39
- componentId: "sc-1kfkyxg-0"
40
- })(["display:flex;align-items:flex-start;margin-top:", ";"], function (_ref2) {
41
- var spacings = _ref2.spacings;
42
- return spacings.top;
43
- });
44
- var Text = styled.p.withConfig({
45
- displayName: "HelperText__Text",
46
- componentId: "sc-1kfkyxg-1"
47
- })(["", " margin:0 0 0 ", ";", ""], typographyTemplate(helperText.typography), function (_ref3) {
48
- var spacings = _ref3.spacings;
49
- return spacings.left;
50
- }, Variation);
51
- var TextfieldHelperText = /*#__PURE__*/forwardRef(function TextfieldHelperText(_ref4, ref) {
52
- var helperText$1 = _ref4.helperText,
53
- icon = _ref4.icon,
54
- _ref4$variant = _ref4.variant,
55
- variant = _ref4$variant === void 0 ? 'default' : _ref4$variant,
56
- isDisabled = _ref4.disabled,
57
- rest = _objectWithoutProperties(_ref4, _excluded);
58
-
59
- var helperVariant = helperText[variant];
60
- var spacings = helperText.spacings.comfortable;
61
-
62
- var _useTextField = useTextField(),
63
- isFocused = _useTextField.isFocused;
64
-
65
- var colors = {
66
- color: helperVariant.color,
67
- disabledColor: helperVariant.disabledColor,
68
- focusColor: helperVariant.focusColor
69
- };
70
- return /*#__PURE__*/jsxs(Container, _objectSpread(_objectSpread({
71
- ref: ref
72
- }, rest), {}, {
73
- spacings: spacings,
74
- children: [icon && /*#__PURE__*/jsx(InputIcon, {
75
- isDisabled: isDisabled,
76
- colors: colors,
77
- size: 16,
78
- children: icon
79
- }), /*#__PURE__*/jsx(Text, {
80
- variant: helperVariant,
81
- isFocused: isFocused,
82
- isDisabled: isDisabled,
83
- spacings: spacings,
84
- children: helperText$1
85
- })]
86
- }));
87
- });
88
-
89
- export { TextfieldHelperText as HelperText };