@equinor/eds-core-react 0.24.0-dev.20221007 → 0.25.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.js +1027 -1321
- package/dist/esm/components/Accordion/AccordionHeader.js +10 -5
- package/dist/esm/components/Autocomplete/Autocomplete.js +62 -67
- package/dist/esm/components/Autocomplete/Autocomplete.tokens.js +1 -0
- package/dist/esm/components/Input/Input.js +129 -32
- package/dist/esm/components/Input/Input.tokens.js +84 -56
- package/dist/esm/components/InputWrapper/HelperText/HelperText.js +49 -0
- package/dist/esm/components/InputWrapper/HelperText/HelperText.token.js +28 -0
- package/dist/esm/components/InputWrapper/InputWrapper.js +68 -0
- package/dist/esm/components/InputWrapper/InputWrapper.tokens.js +164 -0
- package/dist/esm/components/Popover/Popover.js +69 -54
- package/dist/esm/components/Popover/Popover.tokens.js +17 -2
- package/dist/esm/components/Search/Search.js +60 -187
- package/dist/esm/components/TextField/TextField.js +52 -46
- package/dist/esm/components/Textarea/Textarea.js +26 -43
- package/dist/esm/components/Tooltip/Tooltip.js +37 -36
- package/dist/esm/index.js +1 -0
- package/dist/types/components/Input/Input.d.ts +22 -15
- package/dist/types/components/InputWrapper/HelperText/HelperText.d.ts +18 -0
- package/dist/types/components/{TextField → InputWrapper}/HelperText/HelperText.token.d.ts +0 -5
- package/dist/types/components/InputWrapper/HelperText/index.d.ts +1 -0
- package/dist/types/components/InputWrapper/InputWrapper.d.ts +41 -0
- package/dist/types/components/InputWrapper/InputWrapper.tokens.d.ts +12 -0
- package/dist/types/components/InputWrapper/index.d.ts +2 -0
- package/dist/types/components/Popover/Popover.d.ts +10 -0
- package/dist/types/components/Search/Search.d.ts +2 -2
- package/dist/types/components/Select/commonStyles.d.ts +1 -7
- package/dist/types/components/TextField/TextField.d.ts +15 -21
- package/dist/types/components/Textarea/Textarea.d.ts +3 -3
- package/dist/types/components/types.d.ts +1 -0
- package/dist/types/index.d.ts +1 -0
- package/package.json +4 -4
- package/dist/esm/components/Search/Search.tokens.js +0 -83
- package/dist/esm/components/TextField/Field.js +0 -151
- package/dist/esm/components/TextField/HelperText/HelperText.js +0 -89
- package/dist/esm/components/TextField/HelperText/HelperText.token.js +0 -45
- package/dist/esm/components/TextField/Icon/Icon.js +0 -65
- package/dist/esm/components/TextField/Icon/Icon.tokens.js +0 -42
- package/dist/esm/components/TextField/TextField.context.js +0 -48
- package/dist/esm/components/TextField/TextField.tokens.js +0 -120
- package/dist/types/components/Search/Search.tokens.d.ts +0 -4
- package/dist/types/components/TextField/Field.d.ts +0 -34
- package/dist/types/components/TextField/HelperText/HelperText.d.ts +0 -14
- package/dist/types/components/TextField/HelperText/index.d.ts +0 -1
- package/dist/types/components/TextField/Icon/Icon.d.ts +0 -13
- package/dist/types/components/TextField/Icon/Icon.tokens.d.ts +0 -14
- package/dist/types/components/TextField/Icon/index.d.ts +0 -1
- package/dist/types/components/TextField/TextField.context.d.ts +0 -17
- package/dist/types/components/TextField/TextField.tokens.d.ts +0 -10
- package/dist/types/components/TextField/types.d.ts +0 -6
|
@@ -2,220 +2,93 @@ import _objectSpread from '@babel/runtime/helpers/objectSpread2';
|
|
|
2
2
|
import _slicedToArray from '@babel/runtime/helpers/slicedToArray';
|
|
3
3
|
import _objectWithoutProperties from '@babel/runtime/helpers/objectWithoutProperties';
|
|
4
4
|
import { forwardRef, useRef, useState, useEffect, useMemo } from 'react';
|
|
5
|
-
import styled
|
|
6
|
-
import { search
|
|
7
|
-
import { search } from './Search.tokens.js';
|
|
5
|
+
import styled from 'styled-components';
|
|
6
|
+
import { search, close } from '@equinor/eds-icons';
|
|
8
7
|
import { Button } from '../Button/index.js';
|
|
9
8
|
import { Icon } from '../Icon/index.js';
|
|
10
|
-
import {
|
|
11
|
-
import { jsx,
|
|
9
|
+
import { mergeRefs, setReactInputValue } from '@equinor/eds-utils';
|
|
10
|
+
import { jsx, Fragment } from 'react/jsx-runtime';
|
|
11
|
+
import { InputWrapper } from '../InputWrapper/InputWrapper.js';
|
|
12
12
|
import { Input } from '../Input/Input.js';
|
|
13
|
-
import { useEds } from '../EdsProvider/eds.context.js';
|
|
14
13
|
|
|
15
|
-
var _excluded = ["onChange", "
|
|
16
|
-
var Container = styled.span.withConfig({
|
|
17
|
-
displayName: "Search__Container",
|
|
18
|
-
componentId: "sc-v8l23u-0"
|
|
19
|
-
})(function (_ref) {
|
|
20
|
-
var disabled = _ref.disabled,
|
|
21
|
-
isFocused = _ref.isFocused,
|
|
22
|
-
theme = _ref.theme;
|
|
23
|
-
var height = theme.height,
|
|
24
|
-
spacings = theme.spacings,
|
|
25
|
-
background = theme.background,
|
|
26
|
-
border = theme.border,
|
|
27
|
-
clickbound = theme.clickbound,
|
|
28
|
-
_theme$entities = theme.entities,
|
|
29
|
-
icon = _theme$entities.icon,
|
|
30
|
-
placeholder = _theme$entities.placeholder,
|
|
31
|
-
states = theme.states;
|
|
32
|
-
return css(["position:relative;background:", ";width:100%;height:", ";display:grid;grid-gap:8px;grid-auto-flow:column;grid-auto-columns:max-content auto max-content;align-items:center;box-sizing:border-box;", " z-index:0;svg{fill:", ";}", " ", " &::placeholder{color:", ";}", " &::after{z-index:-1;position:absolute;top:-", ";left:0;width:100%;height:", ";content:'';}&::before{position:absolute;top:0;left:0;width:auto;min-height:auto;content:'';}"], background, height, bordersTemplate(border), icon.typography.color, spacingsTemplate(spacings), isFocused && bordersTemplate(states.focus.border), placeholder.typography.color, disabled ? css(["cursor:not-allowed;"]) : css(["@media (hover:hover) and (pointer:fine){&:hover{", " cursor:text;}}"], bordersTemplate(states.focus.border)), clickbound.offset, clickbound.height);
|
|
33
|
-
});
|
|
14
|
+
var _excluded = ["onChange", "style", "className"];
|
|
34
15
|
var SearchInput = styled(Input).withConfig({
|
|
35
16
|
displayName: "Search__SearchInput",
|
|
36
|
-
componentId: "sc-v8l23u-
|
|
37
|
-
})(
|
|
38
|
-
var theme = _ref2.theme,
|
|
39
|
-
disabled = _ref2.disabled;
|
|
40
|
-
return css(["height:calc(", " - 2px);align-self:start;box-shadow:unset;&[type='search']::-webkit-search-decoration,&[type='search']::-webkit-search-cancel-button,&[type='search']::-webkit-search-results-button,&[type='search']::-webkit-search-results-decoration{-webkit-appearance:none;}", " &:focus{outline:none;}&:-webkit-autofill{box-shadow:0 0 0px 1000px ", " inset;}&:autofill{box-shadow:0 0 0px 1000px ", " inset;}", ""], theme.height, typographyTemplate(theme.typography), theme.background, theme.background, disabled && css(["cursor:not-allowed;"]));
|
|
41
|
-
});
|
|
17
|
+
componentId: "sc-v8l23u-0"
|
|
18
|
+
})(["input{&[type='search']::-webkit-search-decoration,&[type='search']::-webkit-search-cancel-button,&[type='search']::-webkit-search-results-button,&[type='search']::-webkit-search-results-decoration{-webkit-appearance:none;}}"]);
|
|
42
19
|
var InsideButton = styled(Button).withConfig({
|
|
43
20
|
displayName: "Search__InsideButton",
|
|
44
|
-
componentId: "sc-v8l23u-
|
|
45
|
-
})(
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
var Search = /*#__PURE__*/forwardRef(function Search(_ref4, ref) {
|
|
52
|
-
var _onChange = _ref4.onChange,
|
|
53
|
-
_ref4$defaultValue = _ref4.defaultValue,
|
|
54
|
-
defaultValue = _ref4$defaultValue === void 0 ? '' : _ref4$defaultValue,
|
|
55
|
-
value = _ref4.value,
|
|
56
|
-
_ref4$className = _ref4.className,
|
|
57
|
-
className = _ref4$className === void 0 ? '' : _ref4$className,
|
|
58
|
-
style = _ref4.style,
|
|
59
|
-
_ref4$disabled = _ref4.disabled,
|
|
60
|
-
disabled = _ref4$disabled === void 0 ? false : _ref4$disabled,
|
|
61
|
-
_onBlur = _ref4.onBlur,
|
|
62
|
-
_onFocus = _ref4.onFocus,
|
|
63
|
-
rest = _objectWithoutProperties(_ref4, _excluded);
|
|
64
|
-
|
|
65
|
-
var _useEds = useEds(),
|
|
66
|
-
density = _useEds.density;
|
|
21
|
+
componentId: "sc-v8l23u-1"
|
|
22
|
+
})(["height:24px;width:24px;"]);
|
|
23
|
+
var Search = /*#__PURE__*/forwardRef(function Search(_ref, ref) {
|
|
24
|
+
var _onChange = _ref.onChange,
|
|
25
|
+
style = _ref.style,
|
|
26
|
+
className = _ref.className,
|
|
27
|
+
rest = _objectWithoutProperties(_ref, _excluded);
|
|
67
28
|
|
|
68
|
-
var token = useToken({
|
|
69
|
-
density: density
|
|
70
|
-
}, search);
|
|
71
|
-
var isControlled = typeof value !== 'undefined';
|
|
72
|
-
var isActive = isControlled && value !== '' || defaultValue !== '';
|
|
73
29
|
var inputRef = useRef(null);
|
|
74
30
|
|
|
75
|
-
var _useState = useState(
|
|
76
|
-
isActive: isActive,
|
|
77
|
-
isFocused: false
|
|
78
|
-
}),
|
|
31
|
+
var _useState = useState(Boolean(rest.defaultValue)),
|
|
79
32
|
_useState2 = _slicedToArray(_useState, 2),
|
|
80
|
-
|
|
81
|
-
|
|
33
|
+
showClear = _useState2[0],
|
|
34
|
+
setShowClear = _useState2[1];
|
|
82
35
|
|
|
83
36
|
useEffect(function () {
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
});
|
|
89
|
-
}, [value, defaultValue, isActive]);
|
|
90
|
-
|
|
91
|
-
var handleOnClick = function handleOnClick() {
|
|
92
|
-
var inputEl = inputRef.current;
|
|
93
|
-
inputEl.focus();
|
|
94
|
-
};
|
|
95
|
-
|
|
96
|
-
var handleFocus = function handleFocus() {
|
|
97
|
-
return setState(function (prevState) {
|
|
98
|
-
return _objectSpread(_objectSpread({}, prevState), {}, {
|
|
99
|
-
isFocused: true
|
|
100
|
-
});
|
|
101
|
-
});
|
|
102
|
-
};
|
|
103
|
-
|
|
104
|
-
var handleBlur = function handleBlur() {
|
|
105
|
-
return setState(function (prevState) {
|
|
106
|
-
return _objectSpread(_objectSpread({}, prevState), {}, {
|
|
107
|
-
isFocused: false
|
|
108
|
-
});
|
|
109
|
-
});
|
|
110
|
-
};
|
|
111
|
-
|
|
112
|
-
var handleOnChange = function handleOnChange(event) {
|
|
113
|
-
setIsActive(event.target.value);
|
|
114
|
-
};
|
|
37
|
+
if (rest.value) {
|
|
38
|
+
setShowClear(Boolean(rest.value));
|
|
39
|
+
}
|
|
40
|
+
}, [rest.value]);
|
|
115
41
|
|
|
116
|
-
var
|
|
42
|
+
var clearInputValue = function clearInputValue() {
|
|
117
43
|
var input = inputRef.current;
|
|
118
44
|
var clearedValue = '';
|
|
119
45
|
setReactInputValue(input, clearedValue);
|
|
120
|
-
setState(function (prevState) {
|
|
121
|
-
return _objectSpread(_objectSpread({}, prevState), {}, {
|
|
122
|
-
isActive: false
|
|
123
|
-
});
|
|
124
|
-
});
|
|
125
46
|
};
|
|
126
47
|
|
|
127
|
-
var
|
|
128
|
-
|
|
129
|
-
return _objectSpread(_objectSpread({}, prevState), {}, {
|
|
130
|
-
isActive: newValue !== ''
|
|
131
|
-
});
|
|
132
|
-
});
|
|
48
|
+
var handleOnChange = function handleOnChange(e) {
|
|
49
|
+
setShowClear(Boolean(e.currentTarget.value));
|
|
133
50
|
};
|
|
134
|
-
/** Applying props for controlled vs. uncontrolled scnarios */
|
|
135
|
-
|
|
136
51
|
|
|
137
|
-
var applyControllingProps = function applyControllingProps(props, value, defaultValue) {
|
|
138
|
-
if (isControlled) {
|
|
139
|
-
return _objectSpread(_objectSpread({}, props), {}, {
|
|
140
|
-
value: value
|
|
141
|
-
});
|
|
142
|
-
}
|
|
143
|
-
|
|
144
|
-
return _objectSpread(_objectSpread({}, props), {}, {
|
|
145
|
-
defaultValue: defaultValue
|
|
146
|
-
});
|
|
147
|
-
};
|
|
148
|
-
|
|
149
|
-
var isFocused = state.isFocused;
|
|
150
|
-
var size = 24;
|
|
151
|
-
var containerProps = {
|
|
152
|
-
isFocused: isFocused,
|
|
153
|
-
className: className,
|
|
154
|
-
style: style,
|
|
155
|
-
disabled: disabled,
|
|
156
|
-
role: 'search',
|
|
157
|
-
'aria-label': rest['aria-label'],
|
|
158
|
-
onClick: handleOnClick
|
|
159
|
-
};
|
|
160
52
|
var combinedRef = useMemo(function () {
|
|
161
53
|
return mergeRefs(inputRef, ref);
|
|
162
54
|
}, [inputRef, ref]);
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
}
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
if (_onFocus) {
|
|
180
|
-
_onFocus(e);
|
|
181
|
-
}
|
|
182
|
-
},
|
|
183
|
-
onChange: function onChange(e) {
|
|
184
|
-
handleOnChange(e);
|
|
185
|
-
|
|
186
|
-
if (_onChange) {
|
|
187
|
-
_onChange(e);
|
|
188
|
-
}
|
|
189
|
-
}
|
|
190
|
-
}), value, defaultValue);
|
|
191
|
-
var clearButtonProps = {
|
|
192
|
-
isActive: state.isActive,
|
|
193
|
-
onClick: function onClick(e) {
|
|
194
|
-
e.stopPropagation();
|
|
195
|
-
|
|
196
|
-
if (state.isActive) {
|
|
197
|
-
handleOnDelete();
|
|
198
|
-
}
|
|
199
|
-
}
|
|
200
|
-
};
|
|
201
|
-
return /*#__PURE__*/jsx(ThemeProvider, {
|
|
202
|
-
theme: token,
|
|
203
|
-
children: /*#__PURE__*/jsxs(Container, _objectSpread(_objectSpread({}, containerProps), {}, {
|
|
204
|
-
children: [/*#__PURE__*/jsx(Icon, {
|
|
205
|
-
data: search$1,
|
|
55
|
+
return /*#__PURE__*/jsx(InputWrapper, {
|
|
56
|
+
role: "search",
|
|
57
|
+
style: style,
|
|
58
|
+
className: className,
|
|
59
|
+
children: /*#__PURE__*/jsx(SearchInput, _objectSpread({
|
|
60
|
+
onChange: function onChange(e) {
|
|
61
|
+
handleOnChange(e);
|
|
62
|
+
|
|
63
|
+
if (_onChange) {
|
|
64
|
+
_onChange(e);
|
|
65
|
+
}
|
|
66
|
+
},
|
|
67
|
+
ref: combinedRef,
|
|
68
|
+
leftAdornmentsWidth: 24 + 8,
|
|
69
|
+
leftAdornments: /*#__PURE__*/jsx(Icon, {
|
|
70
|
+
data: search,
|
|
206
71
|
"aria-hidden": true,
|
|
207
|
-
size:
|
|
208
|
-
}),
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
72
|
+
size: 18
|
|
73
|
+
}),
|
|
74
|
+
rightAdornmentsWidth: 24 + 8,
|
|
75
|
+
rightAdornments: /*#__PURE__*/jsx(Fragment, {
|
|
76
|
+
children: showClear && /*#__PURE__*/jsx(InsideButton, {
|
|
77
|
+
"aria-label": 'clear search',
|
|
78
|
+
title: "clear",
|
|
79
|
+
variant: "ghost_icon",
|
|
80
|
+
onClick: function onClick(e) {
|
|
81
|
+
e.stopPropagation();
|
|
82
|
+
clearInputValue();
|
|
83
|
+
},
|
|
84
|
+
children: /*#__PURE__*/jsx(Icon, {
|
|
85
|
+
data: close,
|
|
86
|
+
size: 16
|
|
87
|
+
})
|
|
215
88
|
})
|
|
216
|
-
})
|
|
217
|
-
}))
|
|
89
|
+
})
|
|
90
|
+
}, rest))
|
|
218
91
|
});
|
|
219
|
-
});
|
|
92
|
+
});
|
|
220
93
|
|
|
221
94
|
export { Search };
|
|
@@ -1,21 +1,22 @@
|
|
|
1
|
-
import _objectSpread from '@babel/runtime/helpers/objectSpread2';
|
|
2
1
|
import _objectWithoutProperties from '@babel/runtime/helpers/objectWithoutProperties';
|
|
2
|
+
import _objectSpread from '@babel/runtime/helpers/objectSpread2';
|
|
3
3
|
import { forwardRef } from 'react';
|
|
4
|
-
import
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
7
|
-
import {
|
|
8
|
-
import {
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
import { HelperText as TextfieldHelperText } from './HelperText/HelperText.js';
|
|
12
|
-
import { useEds } from '../EdsProvider/eds.context.js';
|
|
4
|
+
import { useId } from '@equinor/eds-utils';
|
|
5
|
+
import { jsxs, Fragment, jsx } from 'react/jsx-runtime';
|
|
6
|
+
import { InputWrapper } from '../InputWrapper/InputWrapper.js';
|
|
7
|
+
import { Textarea } from '../Textarea/Textarea.js';
|
|
8
|
+
import { Input } from '../Input/Input.js';
|
|
9
|
+
|
|
10
|
+
var _excluded = ["id", "label", "meta", "unit", "helperText", "placeholder", "disabled", "multiline", "className", "variant", "inputIcon", "helperIcon", "style", "rowsMax", "textareaRef", "inputRef"];
|
|
13
11
|
|
|
14
|
-
|
|
15
|
-
var
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
})(
|
|
12
|
+
/** Proxy component for working around typescript and element type switching */
|
|
13
|
+
var Field = /*#__PURE__*/forwardRef(function Field(props, ref) {
|
|
14
|
+
return props.multiline ? /*#__PURE__*/jsx(Textarea, _objectSpread({
|
|
15
|
+
ref: ref
|
|
16
|
+
}, props)) : /*#__PURE__*/jsx(Input, _objectSpread({
|
|
17
|
+
ref: ref
|
|
18
|
+
}, props));
|
|
19
|
+
});
|
|
19
20
|
var TextField = /*#__PURE__*/forwardRef(function TextField(_ref, ref) {
|
|
20
21
|
var id = _ref.id,
|
|
21
22
|
label = _ref.label,
|
|
@@ -24,43 +25,49 @@ var TextField = /*#__PURE__*/forwardRef(function TextField(_ref, ref) {
|
|
|
24
25
|
helperText = _ref.helperText,
|
|
25
26
|
placeholder = _ref.placeholder,
|
|
26
27
|
disabled = _ref.disabled,
|
|
27
|
-
multiline = _ref.multiline,
|
|
28
|
+
_ref$multiline = _ref.multiline,
|
|
29
|
+
multiline = _ref$multiline === void 0 ? false : _ref$multiline,
|
|
28
30
|
className = _ref.className,
|
|
29
|
-
|
|
30
|
-
variant = _ref$variant === void 0 ? 'default' : _ref$variant,
|
|
31
|
-
inputRef = _ref.inputRef,
|
|
31
|
+
variant = _ref.variant,
|
|
32
32
|
inputIcon = _ref.inputIcon,
|
|
33
33
|
helperIcon = _ref.helperIcon,
|
|
34
|
-
rowsMax = _ref.rowsMax,
|
|
35
34
|
style = _ref.style,
|
|
35
|
+
rowsMax = _ref.rowsMax,
|
|
36
|
+
textareaRef = _ref.textareaRef,
|
|
37
|
+
inputRef = _ref.inputRef,
|
|
36
38
|
other = _objectWithoutProperties(_ref, _excluded);
|
|
37
39
|
|
|
38
40
|
var helperTextId = useId(null, 'helpertext');
|
|
39
41
|
|
|
40
|
-
var
|
|
41
|
-
'aria-
|
|
42
|
-
multiline: multiline,
|
|
42
|
+
var fieldProps = _objectSpread({
|
|
43
|
+
'aria-invalid': variant === 'error' || undefined,
|
|
43
44
|
disabled: disabled,
|
|
44
45
|
placeholder: placeholder,
|
|
45
46
|
id: id,
|
|
46
47
|
variant: variant,
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
48
|
+
rightAdornments: /*#__PURE__*/jsxs(Fragment, {
|
|
49
|
+
children: [inputIcon, /*#__PURE__*/jsx("span", {
|
|
50
|
+
children: unit
|
|
51
|
+
})]
|
|
52
|
+
}),
|
|
53
|
+
rowsMax: rowsMax,
|
|
54
|
+
ref: inputRef || textareaRef,
|
|
55
|
+
multiline: multiline
|
|
51
56
|
}, other);
|
|
52
57
|
|
|
53
58
|
var helperProps = {
|
|
54
|
-
id:
|
|
55
|
-
|
|
56
|
-
helperText: helperText,
|
|
59
|
+
id: null,
|
|
60
|
+
text: helperText,
|
|
57
61
|
icon: helperIcon,
|
|
58
62
|
disabled: disabled
|
|
59
63
|
};
|
|
60
64
|
var containerProps = {
|
|
61
65
|
ref: ref,
|
|
62
66
|
className: className,
|
|
63
|
-
style:
|
|
67
|
+
style: _objectSpread({
|
|
68
|
+
width: '100%'
|
|
69
|
+
}, style),
|
|
70
|
+
color: variant
|
|
64
71
|
};
|
|
65
72
|
var labelProps = {
|
|
66
73
|
htmlFor: id,
|
|
@@ -68,23 +75,22 @@ var TextField = /*#__PURE__*/forwardRef(function TextField(_ref, ref) {
|
|
|
68
75
|
meta: meta,
|
|
69
76
|
disabled: disabled
|
|
70
77
|
};
|
|
71
|
-
var showLabel = label || meta;
|
|
72
|
-
var showHelperText = helperText;
|
|
73
78
|
|
|
74
|
-
|
|
75
|
-
|
|
79
|
+
if (helperText) {
|
|
80
|
+
fieldProps = _objectSpread({
|
|
81
|
+
'aria-describedby': helperTextId
|
|
82
|
+
}, fieldProps);
|
|
83
|
+
helperProps = _objectSpread({
|
|
84
|
+
id: helperTextId
|
|
85
|
+
}, helperProps);
|
|
86
|
+
}
|
|
76
87
|
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
children: /*#__PURE__*/jsxs(TextFieldProvider, {
|
|
84
|
-
children: [showLabel && /*#__PURE__*/jsx(Label, _objectSpread({}, labelProps)), /*#__PURE__*/jsx(Field, _objectSpread({}, inputProps)), showHelperText && /*#__PURE__*/jsx(TextfieldHelperText, _objectSpread({}, helperProps))]
|
|
85
|
-
})
|
|
86
|
-
}))
|
|
87
|
-
});
|
|
88
|
+
return /*#__PURE__*/jsx(InputWrapper, _objectSpread(_objectSpread({
|
|
89
|
+
helperProps: helperProps,
|
|
90
|
+
labelProps: labelProps
|
|
91
|
+
}, containerProps), {}, {
|
|
92
|
+
children: /*#__PURE__*/jsx(Field, _objectSpread({}, fieldProps))
|
|
93
|
+
}));
|
|
88
94
|
});
|
|
89
95
|
|
|
90
96
|
export { TextField };
|
|
@@ -1,55 +1,26 @@
|
|
|
1
1
|
import _objectSpread from '@babel/runtime/helpers/objectSpread2';
|
|
2
2
|
import _slicedToArray from '@babel/runtime/helpers/slicedToArray';
|
|
3
3
|
import _objectWithoutProperties from '@babel/runtime/helpers/objectWithoutProperties';
|
|
4
|
-
import { forwardRef, useState,
|
|
5
|
-
import styled, { css } from 'styled-components';
|
|
4
|
+
import { forwardRef, useState, useCallback } from 'react';
|
|
6
5
|
import * as Input_tokens from '../Input/Input.tokens.js';
|
|
7
6
|
import { input as input$1 } from '../Input/Input.tokens.js';
|
|
8
|
-
import {
|
|
7
|
+
import { useAutoResize, mergeRefs } from '@equinor/eds-utils';
|
|
9
8
|
import { jsx } from 'react/jsx-runtime';
|
|
9
|
+
import { Input } from '../Input/Input.js';
|
|
10
10
|
import { useEds } from '../EdsProvider/eds.context.js';
|
|
11
11
|
|
|
12
12
|
var _excluded = ["variant", "disabled", "type", "rowsMax"];
|
|
13
13
|
var input = input$1;
|
|
14
|
-
|
|
15
|
-
var Variation = function Variation(_ref) {
|
|
14
|
+
var Textarea = /*#__PURE__*/forwardRef(function Textarea(_ref, ref) {
|
|
16
15
|
var variant = _ref.variant,
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
var _token$states = token.states,
|
|
25
|
-
focusOutline = _token$states.focus.outline,
|
|
26
|
-
activeOutline = _token$states.active.outline,
|
|
27
|
-
boxShadow = token.boxShadow;
|
|
28
|
-
var spacings = input.spacings;
|
|
29
|
-
|
|
30
|
-
if (density === 'compact') {
|
|
31
|
-
spacings = input.modes.compact.spacings;
|
|
32
|
-
}
|
|
33
|
-
|
|
34
|
-
return css(["border:none;", " ", " box-shadow:", ";&:active,&:focus{outline-offset:0;box-shadow:none;", "}&:disabled{cursor:not-allowed;box-shadow:none;outline:none;&:focus,&:active{outline:none;}}"], spacingsTemplate(spacings), outlineTemplate(activeOutline), boxShadow, outlineTemplate(focusOutline));
|
|
35
|
-
};
|
|
36
|
-
|
|
37
|
-
var StyledTextarea = styled.textarea.withConfig({
|
|
38
|
-
displayName: "Textarea__StyledTextarea",
|
|
39
|
-
componentId: "sc-2yjdcc-0"
|
|
40
|
-
})(["width:100%;box-sizing:border-box;margin:0;border:none;appearance:none;background:", ";height:auto;", " ", " &::placeholder{color:", ";}&:disabled{color:", ";}&[readOnly]{box-shadow:", ";background:", ";}"], input.background, typographyTemplate(input.typography), Variation, input.entities.placeholder.typography.color, input.states.disabled.typography.color, input.states.readOnly.boxShadow, input.states.readOnly.background);
|
|
41
|
-
var Textarea = /*#__PURE__*/forwardRef(function Textarea(_ref2, ref) {
|
|
42
|
-
var _ref2$variant = _ref2.variant,
|
|
43
|
-
variant = _ref2$variant === void 0 ? 'default' : _ref2$variant,
|
|
44
|
-
_ref2$disabled = _ref2.disabled,
|
|
45
|
-
disabled = _ref2$disabled === void 0 ? false : _ref2$disabled,
|
|
46
|
-
_ref2$type = _ref2.type,
|
|
47
|
-
type = _ref2$type === void 0 ? 'text' : _ref2$type,
|
|
48
|
-
rowsMax = _ref2.rowsMax,
|
|
49
|
-
other = _objectWithoutProperties(_ref2, _excluded);
|
|
16
|
+
_ref$disabled = _ref.disabled,
|
|
17
|
+
disabled = _ref$disabled === void 0 ? false : _ref$disabled,
|
|
18
|
+
_ref$type = _ref.type,
|
|
19
|
+
type = _ref$type === void 0 ? 'text' : _ref$type,
|
|
20
|
+
rowsMax = _ref.rowsMax,
|
|
21
|
+
other = _objectWithoutProperties(_ref, _excluded);
|
|
50
22
|
|
|
51
|
-
var
|
|
52
|
-
var inputVariant = Input_tokens[actualVariant];
|
|
23
|
+
var inputVariant = Input_tokens[variant] ? Input_tokens[variant] : input$1;
|
|
53
24
|
|
|
54
25
|
var _useState = useState(null),
|
|
55
26
|
_useState2 = _slicedToArray(_useState, 2),
|
|
@@ -72,9 +43,9 @@ var Textarea = /*#__PURE__*/forwardRef(function Textarea(_ref2, ref) {
|
|
|
72
43
|
var padding = parseInt(top) + parseInt(bottom);
|
|
73
44
|
var maxHeight = parseFloat(lineHeight) * fontSize * rowsMax + padding;
|
|
74
45
|
useAutoResize(textareaEl, rowsMax ? maxHeight : null);
|
|
75
|
-
var combinedRef =
|
|
46
|
+
var combinedRef = useCallback(function () {
|
|
76
47
|
return mergeRefs(ref, setTextareaEl);
|
|
77
|
-
}, [setTextareaEl, ref]);
|
|
48
|
+
}, [setTextareaEl, ref])();
|
|
78
49
|
|
|
79
50
|
var inputProps = _objectSpread({
|
|
80
51
|
ref: combinedRef,
|
|
@@ -85,7 +56,19 @@ var Textarea = /*#__PURE__*/forwardRef(function Textarea(_ref2, ref) {
|
|
|
85
56
|
density: density
|
|
86
57
|
}, other);
|
|
87
58
|
|
|
88
|
-
|
|
59
|
+
var adornmentsToTop = {
|
|
60
|
+
style: {
|
|
61
|
+
alignItems: 'flex-start'
|
|
62
|
+
}
|
|
63
|
+
};
|
|
64
|
+
return /*#__PURE__*/jsx(Input, _objectSpread({
|
|
65
|
+
as: "textarea",
|
|
66
|
+
rightAdornmentsProps: adornmentsToTop,
|
|
67
|
+
leftAdornmentsProps: adornmentsToTop,
|
|
68
|
+
style: {
|
|
69
|
+
height: 'auto'
|
|
70
|
+
}
|
|
71
|
+
}, inputProps));
|
|
89
72
|
});
|
|
90
73
|
|
|
91
74
|
export { Textarea };
|
|
@@ -2,7 +2,7 @@ import _objectSpread from '@babel/runtime/helpers/objectSpread2';
|
|
|
2
2
|
import _defineProperty from '@babel/runtime/helpers/defineProperty';
|
|
3
3
|
import _slicedToArray from '@babel/runtime/helpers/slicedToArray';
|
|
4
4
|
import _objectWithoutProperties from '@babel/runtime/helpers/objectWithoutProperties';
|
|
5
|
-
import { forwardRef, useRef, useState, useMemo, cloneElement } from 'react';
|
|
5
|
+
import { forwardRef, useRef, useState, useMemo, useEffect, cloneElement } from 'react';
|
|
6
6
|
import styled from 'styled-components';
|
|
7
7
|
import { typographyTemplate, spacingsTemplate, bordersTemplate, mergeRefs } from '@equinor/eds-utils';
|
|
8
8
|
import { tooltip } from './Tooltip.tokens.js';
|
|
@@ -81,43 +81,44 @@ var Tooltip = /*#__PURE__*/forwardRef(function Tooltip(_ref, ref) {
|
|
|
81
81
|
getReferenceProps = _useInteractions.getReferenceProps,
|
|
82
82
|
getFloatingProps = _useInteractions.getFloatingProps;
|
|
83
83
|
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
if (arrowRef.current) {
|
|
111
|
-
var _Object$assign;
|
|
84
|
+
useEffect(function () {
|
|
85
|
+
var staticSide = {
|
|
86
|
+
top: 'bottom',
|
|
87
|
+
right: 'left',
|
|
88
|
+
bottom: 'top',
|
|
89
|
+
left: 'right'
|
|
90
|
+
}[finalPlacement.split('-')[0]];
|
|
91
|
+
var arrowTransform = 'none';
|
|
92
|
+
|
|
93
|
+
switch (staticSide) {
|
|
94
|
+
case 'right':
|
|
95
|
+
arrowTransform = 'rotateY(180deg)';
|
|
96
|
+
break;
|
|
97
|
+
|
|
98
|
+
case 'left':
|
|
99
|
+
arrowTransform = 'none';
|
|
100
|
+
break;
|
|
101
|
+
|
|
102
|
+
case 'top':
|
|
103
|
+
arrowTransform = 'rotate(90deg)';
|
|
104
|
+
break;
|
|
105
|
+
|
|
106
|
+
case 'bottom':
|
|
107
|
+
arrowTransform = 'rotate(-90deg)';
|
|
108
|
+
break;
|
|
109
|
+
}
|
|
112
110
|
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
top: arrowY != null ? "".concat(arrowY, "px") : '',
|
|
116
|
-
right: '',
|
|
117
|
-
bottom: ''
|
|
118
|
-
}, _defineProperty(_Object$assign, staticSide, '-6px'), _defineProperty(_Object$assign, "transform", arrowTransform), _Object$assign));
|
|
119
|
-
}
|
|
111
|
+
if (arrowRef.current) {
|
|
112
|
+
var _Object$assign;
|
|
120
113
|
|
|
114
|
+
Object.assign(arrowRef.current.style, (_Object$assign = {
|
|
115
|
+
left: arrowX != null ? "".concat(arrowX, "px") : '',
|
|
116
|
+
top: arrowY != null ? "".concat(arrowY, "px") : '',
|
|
117
|
+
right: '',
|
|
118
|
+
bottom: ''
|
|
119
|
+
}, _defineProperty(_Object$assign, staticSide, '-6px'), _defineProperty(_Object$assign, "transform", arrowTransform), _Object$assign));
|
|
120
|
+
}
|
|
121
|
+
});
|
|
121
122
|
var updatedChildren = /*#__PURE__*/cloneElement(children, _objectSpread({}, getReferenceProps(_objectSpread({
|
|
122
123
|
ref: anchorRef
|
|
123
124
|
}, children.props))));
|
package/dist/esm/index.js
CHANGED
|
@@ -40,3 +40,4 @@ export { Switch } from './components/Switch/Switch.js';
|
|
|
40
40
|
export { EdsProvider, useEds } from './components/EdsProvider/eds.context.js';
|
|
41
41
|
export { Paper } from './components/Paper/Paper.js';
|
|
42
42
|
export { Autocomplete } from './components/Autocomplete/Autocomplete.js';
|
|
43
|
+
export { InputWrapper } from './components/InputWrapper/InputWrapper.js';
|
|
@@ -1,5 +1,6 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import
|
|
1
|
+
import { ReactNode, CSSProperties, ElementType, ComponentPropsWithoutRef } from 'react';
|
|
2
|
+
import { OverridableComponent } from '@equinor/eds-utils';
|
|
3
|
+
import type { Variants } from '../types';
|
|
3
4
|
export declare type InputProps = {
|
|
4
5
|
/** Placeholder */
|
|
5
6
|
placeholder?: string;
|
|
@@ -11,16 +12,22 @@ export declare type InputProps = {
|
|
|
11
12
|
type?: string;
|
|
12
13
|
/** Read Only */
|
|
13
14
|
readOnly?: boolean;
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
/**
|
|
17
|
-
|
|
18
|
-
/**
|
|
19
|
-
|
|
20
|
-
/**
|
|
21
|
-
|
|
22
|
-
/**
|
|
23
|
-
|
|
24
|
-
/**
|
|
25
|
-
|
|
26
|
-
|
|
15
|
+
/** Left adornments */
|
|
16
|
+
leftAdornments?: ReactNode;
|
|
17
|
+
/** Right adornments */
|
|
18
|
+
rightAdornments?: ReactNode;
|
|
19
|
+
/** Left adornments props */
|
|
20
|
+
leftAdornmentsProps?: ComponentPropsWithoutRef<'div'>;
|
|
21
|
+
/** Right adornments props */
|
|
22
|
+
rightAdornmentsProps?: ComponentPropsWithoutRef<'div'>;
|
|
23
|
+
/** Manually specify left adornments width. The width will be the dom element width if not defined */
|
|
24
|
+
leftAdornmentsWidth?: number;
|
|
25
|
+
/** Manually specify right adornments width. The width will be the dom element width if not defined */
|
|
26
|
+
rightAdornmentsWidth?: number;
|
|
27
|
+
/** Cast the input to another element */
|
|
28
|
+
as?: ElementType;
|
|
29
|
+
/** */
|
|
30
|
+
className?: string;
|
|
31
|
+
style?: CSSProperties;
|
|
32
|
+
};
|
|
33
|
+
export declare const Input: OverridableComponent<InputProps, HTMLInputElement>;
|