@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
|
@@ -88,7 +88,10 @@ var AccordionHeader = /*#__PURE__*/forwardRef(function AccordionHeader(_ref5, re
|
|
|
88
88
|
style = _ref5.style,
|
|
89
89
|
props = _objectWithoutProperties(_ref5, _excluded);
|
|
90
90
|
|
|
91
|
-
var handleClick = function handleClick() {
|
|
91
|
+
var handleClick = function handleClick(e) {
|
|
92
|
+
e.preventDefault();
|
|
93
|
+
e.stopPropagation();
|
|
94
|
+
|
|
92
95
|
if (!disabled) {
|
|
93
96
|
toggleExpanded();
|
|
94
97
|
|
|
@@ -98,8 +101,8 @@ var AccordionHeader = /*#__PURE__*/forwardRef(function AccordionHeader(_ref5, re
|
|
|
98
101
|
}
|
|
99
102
|
};
|
|
100
103
|
|
|
101
|
-
var handleKeyDown = function handleKeyDown(
|
|
102
|
-
var key =
|
|
104
|
+
var handleKeyDown = function handleKeyDown(e) {
|
|
105
|
+
var key = e.key;
|
|
103
106
|
|
|
104
107
|
if (key === 'Enter' || key === ' ') {
|
|
105
108
|
toggleExpanded();
|
|
@@ -108,7 +111,8 @@ var AccordionHeader = /*#__PURE__*/forwardRef(function AccordionHeader(_ref5, re
|
|
|
108
111
|
props.onToggle();
|
|
109
112
|
}
|
|
110
113
|
|
|
111
|
-
|
|
114
|
+
e.preventDefault();
|
|
115
|
+
e.stopPropagation();
|
|
112
116
|
}
|
|
113
117
|
};
|
|
114
118
|
|
|
@@ -162,7 +166,8 @@ var AccordionHeader = /*#__PURE__*/forwardRef(function AccordionHeader(_ref5, re
|
|
|
162
166
|
panelId: panelId,
|
|
163
167
|
onClick: handleClick,
|
|
164
168
|
onKeyDown: handleKeyDown,
|
|
165
|
-
ref: ref
|
|
169
|
+
ref: ref,
|
|
170
|
+
type: "button"
|
|
166
171
|
}, props), {}, {
|
|
167
172
|
children: chevronPosition === 'left' ? newChildren : newChildren.reverse()
|
|
168
173
|
})), headerActions && headerActions]
|
|
@@ -13,43 +13,36 @@ import { multiSelect, selectTokens } from './Autocomplete.tokens.js';
|
|
|
13
13
|
import { bordersTemplate, useToken } from '@equinor/eds-utils';
|
|
14
14
|
import { AutocompleteOption } from './Option.js';
|
|
15
15
|
import { useFloating, offset, flip, shift, size, useInteractions, autoUpdate, FloatingPortal } from '@floating-ui/react-dom-interactions';
|
|
16
|
-
import { jsx, jsxs } from 'react/jsx-runtime';
|
|
17
|
-
import { Input } from '../Input/Input.js';
|
|
16
|
+
import { jsx, jsxs, Fragment } from 'react/jsx-runtime';
|
|
18
17
|
import { useEds } from '../EdsProvider/eds.context.js';
|
|
19
18
|
import { Label } from '../Label/Label.js';
|
|
19
|
+
import { Input } from '../Input/Input.js';
|
|
20
20
|
|
|
21
21
|
var _excluded = ["options", "label", "meta", "className", "style", "disabled", "readOnly", "hideClearButton", "onOptionsChange", "selectedOptions", "multiple", "initialSelectedOptions", "disablePortal", "optionDisabled", "optionsFilter", "autoWidth", "placeholder", "optionLabel", "clearSearchOnChange"];
|
|
22
22
|
var Container = styled.div.withConfig({
|
|
23
23
|
displayName: "Autocomplete__Container",
|
|
24
24
|
componentId: "sc-yvif0e-0"
|
|
25
25
|
})(["position:relative;"]);
|
|
26
|
-
var StyledInput = styled(Input).withConfig({
|
|
27
|
-
displayName: "Autocomplete__StyledInput",
|
|
28
|
-
componentId: "sc-yvif0e-1"
|
|
29
|
-
})(function (_ref) {
|
|
30
|
-
var button = _ref.theme.entities.button;
|
|
31
|
-
return css(["padding-right:calc( ", " + ", " + (", " * 2) );"], button.spacings.left, button.spacings.right, button.height);
|
|
32
|
-
});
|
|
33
26
|
var StyledList = styled(List).withConfig({
|
|
34
27
|
displayName: "Autocomplete__StyledList",
|
|
35
|
-
componentId: "sc-yvif0e-
|
|
36
|
-
})(function (
|
|
37
|
-
var theme =
|
|
28
|
+
componentId: "sc-yvif0e-1"
|
|
29
|
+
})(function (_ref) {
|
|
30
|
+
var theme = _ref.theme;
|
|
38
31
|
return css(["background-color:", ";box-shadow:", ";", " overflow-y:auto;max-height:300px;padding:0;"], theme.background, theme.boxShadow, bordersTemplate(theme.border));
|
|
39
32
|
});
|
|
40
33
|
var StyledButton = styled(Button).withConfig({
|
|
41
34
|
displayName: "Autocomplete__StyledButton",
|
|
42
|
-
componentId: "sc-yvif0e-
|
|
43
|
-
})(function (
|
|
44
|
-
var button =
|
|
45
|
-
return css(["
|
|
35
|
+
componentId: "sc-yvif0e-2"
|
|
36
|
+
})(function (_ref2) {
|
|
37
|
+
var button = _ref2.theme.entities.button;
|
|
38
|
+
return css(["height:", ";width:", ";"], button.height, button.height);
|
|
46
39
|
});
|
|
47
40
|
|
|
48
|
-
var findIndex = function findIndex(
|
|
49
|
-
var calc =
|
|
50
|
-
index =
|
|
51
|
-
optionDisabled =
|
|
52
|
-
availableItems =
|
|
41
|
+
var findIndex = function findIndex(_ref3) {
|
|
42
|
+
var calc = _ref3.calc,
|
|
43
|
+
index = _ref3.index,
|
|
44
|
+
optionDisabled = _ref3.optionDisabled,
|
|
45
|
+
availableItems = _ref3.availableItems;
|
|
53
46
|
var nextItem = availableItems[index];
|
|
54
47
|
|
|
55
48
|
if (optionDisabled(nextItem)) {
|
|
@@ -65,10 +58,10 @@ var findIndex = function findIndex(_ref4) {
|
|
|
65
58
|
return index;
|
|
66
59
|
};
|
|
67
60
|
|
|
68
|
-
var findNextIndex = function findNextIndex(
|
|
69
|
-
var index =
|
|
70
|
-
optionDisabled =
|
|
71
|
-
availableItems =
|
|
61
|
+
var findNextIndex = function findNextIndex(_ref4) {
|
|
62
|
+
var index = _ref4.index,
|
|
63
|
+
optionDisabled = _ref4.optionDisabled,
|
|
64
|
+
availableItems = _ref4.availableItems;
|
|
72
65
|
var options = {
|
|
73
66
|
index: index,
|
|
74
67
|
optionDisabled: optionDisabled,
|
|
@@ -89,10 +82,10 @@ var findNextIndex = function findNextIndex(_ref5) {
|
|
|
89
82
|
return nextIndex;
|
|
90
83
|
};
|
|
91
84
|
|
|
92
|
-
var findPrevIndex = function findPrevIndex(
|
|
93
|
-
var index =
|
|
94
|
-
optionDisabled =
|
|
95
|
-
availableItems =
|
|
85
|
+
var findPrevIndex = function findPrevIndex(_ref5) {
|
|
86
|
+
var index = _ref5.index,
|
|
87
|
+
optionDisabled = _ref5.optionDisabled,
|
|
88
|
+
availableItems = _ref5.availableItems;
|
|
96
89
|
var options = {
|
|
97
90
|
index: index,
|
|
98
91
|
optionDisabled: optionDisabled,
|
|
@@ -242,8 +235,8 @@ function AutocompleteInner(props, ref) {
|
|
|
242
235
|
items: availableItems,
|
|
243
236
|
initialSelectedItem: initialSelectedOptions[0],
|
|
244
237
|
itemToString: getLabel,
|
|
245
|
-
onInputValueChange: function onInputValueChange(
|
|
246
|
-
var inputValue =
|
|
238
|
+
onInputValueChange: function onInputValueChange(_ref6) {
|
|
239
|
+
var inputValue = _ref6.inputValue;
|
|
247
240
|
setAvailableItems(options.filter(function (item) {
|
|
248
241
|
if (optionsFilter) {
|
|
249
242
|
return optionsFilter(item, inputValue);
|
|
@@ -252,16 +245,16 @@ function AutocompleteInner(props, ref) {
|
|
|
252
245
|
return getLabel(item).toLowerCase().includes(inputValue.toLowerCase());
|
|
253
246
|
}));
|
|
254
247
|
},
|
|
255
|
-
onIsOpenChange: function onIsOpenChange(
|
|
256
|
-
var selectedItem =
|
|
248
|
+
onIsOpenChange: function onIsOpenChange(_ref7) {
|
|
249
|
+
var selectedItem = _ref7.selectedItem;
|
|
257
250
|
|
|
258
251
|
if (!multiple && selectedItem !== null) {
|
|
259
252
|
setAvailableItems(options);
|
|
260
253
|
}
|
|
261
254
|
},
|
|
262
|
-
onStateChange: function onStateChange(
|
|
263
|
-
var type =
|
|
264
|
-
selectedItem =
|
|
255
|
+
onStateChange: function onStateChange(_ref8) {
|
|
256
|
+
var type = _ref8.type,
|
|
257
|
+
selectedItem = _ref8.selectedItem;
|
|
265
258
|
|
|
266
259
|
switch (type) {
|
|
267
260
|
case useCombobox.stateChangeTypes.InputChange:
|
|
@@ -370,6 +363,7 @@ function AutocompleteInner(props, ref) {
|
|
|
370
363
|
});
|
|
371
364
|
|
|
372
365
|
case useCombobox.stateChangeTypes.InputBlur:
|
|
366
|
+
setTypedInputValue('');
|
|
373
367
|
return _objectSpread(_objectSpread({}, changes), {}, {
|
|
374
368
|
inputValue: ''
|
|
375
369
|
});
|
|
@@ -416,10 +410,10 @@ function AutocompleteInner(props, ref) {
|
|
|
416
410
|
middleware: [offset(4), flip(), shift({
|
|
417
411
|
padding: 8
|
|
418
412
|
}), size({
|
|
419
|
-
apply: function apply(
|
|
420
|
-
var rects =
|
|
421
|
-
availableHeight =
|
|
422
|
-
elements =
|
|
413
|
+
apply: function apply(_ref9) {
|
|
414
|
+
var rects = _ref9.rects,
|
|
415
|
+
availableHeight = _ref9.availableHeight,
|
|
416
|
+
elements = _ref9.elements;
|
|
423
417
|
var anchorWidth = "".concat(rects.reference.width, "px");
|
|
424
418
|
Object.assign(elements.floating.style, {
|
|
425
419
|
width: "".concat(autoWidth ? anchorWidth : 'auto'),
|
|
@@ -466,7 +460,7 @@ function AutocompleteInner(props, ref) {
|
|
|
466
460
|
position: strategy,
|
|
467
461
|
top: y || 0,
|
|
468
462
|
left: x || 0,
|
|
469
|
-
zIndex:
|
|
463
|
+
zIndex: 1500
|
|
470
464
|
}
|
|
471
465
|
})), {}, {
|
|
472
466
|
children: /*#__PURE__*/jsx(StyledList, _objectSpread(_objectSpread({}, getMenuProps({
|
|
@@ -503,8 +497,8 @@ function AutocompleteInner(props, ref) {
|
|
|
503
497
|
label: label,
|
|
504
498
|
meta: meta,
|
|
505
499
|
disabled: disabled
|
|
506
|
-
})), /*#__PURE__*/
|
|
507
|
-
children:
|
|
500
|
+
})), /*#__PURE__*/jsx(Container, _objectSpread(_objectSpread({}, getComboboxProps()), {}, {
|
|
501
|
+
children: /*#__PURE__*/jsx(Input, _objectSpread(_objectSpread({}, getInputProps( // eslint-disable-next-line @typescript-eslint/no-unsafe-argument
|
|
508
502
|
getDropdownProps({
|
|
509
503
|
preventKeyAction: multiple ? isOpen : undefined,
|
|
510
504
|
disabled: disabled,
|
|
@@ -518,31 +512,32 @@ function AutocompleteInner(props, ref) {
|
|
|
518
512
|
placeholder: placeholderText,
|
|
519
513
|
readOnly: readOnly,
|
|
520
514
|
onFocus: openSelect,
|
|
521
|
-
onClick: openSelect
|
|
522
|
-
|
|
523
|
-
|
|
524
|
-
|
|
525
|
-
|
|
526
|
-
|
|
527
|
-
|
|
528
|
-
|
|
529
|
-
|
|
530
|
-
|
|
531
|
-
|
|
532
|
-
|
|
533
|
-
|
|
534
|
-
|
|
535
|
-
|
|
536
|
-
|
|
537
|
-
|
|
538
|
-
|
|
539
|
-
|
|
540
|
-
|
|
541
|
-
|
|
542
|
-
|
|
543
|
-
|
|
515
|
+
onClick: openSelect,
|
|
516
|
+
rightAdornmentsWidth: 24 * 2 + 8 + 8,
|
|
517
|
+
rightAdornments: /*#__PURE__*/jsxs(Fragment, {
|
|
518
|
+
children: [showClearButton && /*#__PURE__*/jsx(StyledButton, {
|
|
519
|
+
variant: "ghost_icon",
|
|
520
|
+
disabled: disabled || readOnly,
|
|
521
|
+
"aria-label": 'clear options',
|
|
522
|
+
title: "clear",
|
|
523
|
+
onClick: clear,
|
|
524
|
+
children: /*#__PURE__*/jsx(Icon, {
|
|
525
|
+
data: close,
|
|
526
|
+
size: 16
|
|
527
|
+
})
|
|
528
|
+
}), !readOnly && /*#__PURE__*/jsx(StyledButton, _objectSpread(_objectSpread({
|
|
529
|
+
variant: "ghost_icon"
|
|
530
|
+
}, getToggleButtonProps({
|
|
531
|
+
disabled: disabled || readOnly
|
|
532
|
+
})), {}, {
|
|
533
|
+
"aria-label": 'toggle options',
|
|
534
|
+
title: "open",
|
|
535
|
+
children: /*#__PURE__*/jsx(Icon, {
|
|
536
|
+
data: isOpen ? arrow_drop_up : arrow_drop_down
|
|
537
|
+
})
|
|
538
|
+
}))]
|
|
544
539
|
})
|
|
545
|
-
}))
|
|
540
|
+
}, other))
|
|
546
541
|
})), disablePortal ? optionsList : /*#__PURE__*/jsx(FloatingPortal, {
|
|
547
542
|
id: "eds-autocomplete-container",
|
|
548
543
|
children: optionsList
|
|
@@ -1,55 +1,152 @@
|
|
|
1
1
|
import _objectSpread from '@babel/runtime/helpers/objectSpread2';
|
|
2
|
+
import _slicedToArray from '@babel/runtime/helpers/slicedToArray';
|
|
2
3
|
import _objectWithoutProperties from '@babel/runtime/helpers/objectWithoutProperties';
|
|
3
|
-
import { forwardRef } from 'react';
|
|
4
|
-
import styled, { css
|
|
4
|
+
import { forwardRef, useState, useCallback } from 'react';
|
|
5
|
+
import styled, { css } from 'styled-components';
|
|
6
|
+
import { outlineTemplate, spacingsTemplate, typographyMixin, useToken } from '@equinor/eds-utils';
|
|
5
7
|
import { inputToken } from './Input.tokens.js';
|
|
6
|
-
import {
|
|
7
|
-
import { jsx } from 'react/jsx-runtime';
|
|
8
|
+
import { jsxs, jsx } from 'react/jsx-runtime';
|
|
8
9
|
import { useEds } from '../EdsProvider/eds.context.js';
|
|
9
10
|
|
|
10
|
-
var _excluded = ["variant", "disabled", "type"];
|
|
11
|
-
var
|
|
12
|
-
displayName: "
|
|
11
|
+
var _excluded = ["variant", "disabled", "type", "leftAdornments", "rightAdornments", "readOnly", "className", "style", "leftAdornmentsProps", "rightAdornmentsProps", "leftAdornmentsWidth", "rightAdornmentsWidth"];
|
|
12
|
+
var Container = styled.div.withConfig({
|
|
13
|
+
displayName: "Input__Container",
|
|
13
14
|
componentId: "sc-1ykv024-0"
|
|
14
15
|
})(function (_ref) {
|
|
15
|
-
var
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
return css(["
|
|
16
|
+
var _entities$adornment, _entities$adornment$s;
|
|
17
|
+
|
|
18
|
+
var token = _ref.token,
|
|
19
|
+
disabled = _ref.disabled,
|
|
20
|
+
readOnly = _ref.readOnly;
|
|
21
|
+
var states = token.states,
|
|
22
|
+
entities = token.entities;
|
|
23
|
+
return css(["--eds-input-adornment-color:", ";--eds-input-color:", ";position:relative;height:", ";width:", ";display:flex;flex-direction:row;border:none;box-sizing:border-box;box-shadow:", ";background:", ";", " &:focus-within{--eds-input-adornment-color:", ";box-shadow:none;", "}", " ", ""], entities.adornment.typography.color, token.typography.color, token.height, token.width, token.boxShadow, token.background, outlineTemplate(token.outline), (_entities$adornment = entities.adornment) === null || _entities$adornment === void 0 ? void 0 : (_entities$adornment$s = _entities$adornment.states.focus) === null || _entities$adornment$s === void 0 ? void 0 : _entities$adornment$s.outline.color, outlineTemplate(states.focus.outline), disabled && css(["--eds-input-adornment-color:", ";--eds-input-color:", ";cursor:not-allowed;box-shadow:none;"], states.disabled.typography.color, states.disabled.typography.color), readOnly && css({
|
|
24
|
+
background: states.readOnly.background,
|
|
25
|
+
boxShadow: states.readOnly.boxShadow
|
|
26
|
+
}));
|
|
27
|
+
});
|
|
28
|
+
var StyledInput = styled.input.withConfig({
|
|
29
|
+
displayName: "Input__StyledInput",
|
|
30
|
+
componentId: "sc-1ykv024-1"
|
|
31
|
+
})(function (_ref2) {
|
|
32
|
+
var token = _ref2.token,
|
|
33
|
+
paddingLeft = _ref2.paddingLeft,
|
|
34
|
+
paddingRight = _ref2.paddingRight;
|
|
35
|
+
return css(["width:100%;border:none;background:transparent;", " ", " outline:none;padding-left:", ";padding-right:", ";&::placeholder{color:", ";}&:disabled{color:var(--eds-input-color);cursor:not-allowed;}"], spacingsTemplate(token.spacings), typographyMixin(token.typography), paddingLeft, paddingRight, token.entities.placeholder.typography.color);
|
|
36
|
+
});
|
|
37
|
+
var Adornments = styled.div.withConfig({
|
|
38
|
+
displayName: "Input__Adornments",
|
|
39
|
+
componentId: "sc-1ykv024-2"
|
|
40
|
+
})(function (_ref3) {
|
|
41
|
+
var token = _ref3.token;
|
|
42
|
+
return css(["position:absolute;top:", ";bottom:", ";display:flex;align-items:center;", " color:var(--eds-input-adornment-color);"], token.spacings.top, token.spacings.bottom, typographyMixin(token.entities.adornment.typography));
|
|
43
|
+
});
|
|
44
|
+
var LeftAdornments = styled(Adornments).withConfig({
|
|
45
|
+
displayName: "Input__LeftAdornments",
|
|
46
|
+
componentId: "sc-1ykv024-3"
|
|
47
|
+
})(function (_ref4) {
|
|
48
|
+
var token = _ref4.token;
|
|
49
|
+
return css(["left:0;padding-left:", ";"], token.entities.adornment.spacings.left);
|
|
23
50
|
});
|
|
24
|
-
var
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
51
|
+
var RightAdornments = styled(Adornments).withConfig({
|
|
52
|
+
displayName: "Input__RightAdornments",
|
|
53
|
+
componentId: "sc-1ykv024-4"
|
|
54
|
+
})(function (_ref5) {
|
|
55
|
+
var token = _ref5.token;
|
|
56
|
+
return css(["right:0;padding-right:", ";"], token.entities.adornment.spacings.right);
|
|
57
|
+
});
|
|
58
|
+
var Input = /*#__PURE__*/forwardRef(function Input(_ref6, ref) {
|
|
59
|
+
var variant = _ref6.variant,
|
|
60
|
+
_ref6$disabled = _ref6.disabled,
|
|
61
|
+
disabled = _ref6$disabled === void 0 ? false : _ref6$disabled,
|
|
62
|
+
_ref6$type = _ref6.type,
|
|
63
|
+
type = _ref6$type === void 0 ? 'text' : _ref6$type,
|
|
64
|
+
leftAdornments = _ref6.leftAdornments,
|
|
65
|
+
rightAdornments = _ref6.rightAdornments,
|
|
66
|
+
readOnly = _ref6.readOnly,
|
|
67
|
+
className = _ref6.className,
|
|
68
|
+
style = _ref6.style,
|
|
69
|
+
leftAdornmentsProps = _ref6.leftAdornmentsProps,
|
|
70
|
+
rightAdornmentsProps = _ref6.rightAdornmentsProps,
|
|
71
|
+
leftAdornmentsWidth = _ref6.leftAdornmentsWidth,
|
|
72
|
+
rightAdornmentsWidth = _ref6.rightAdornmentsWidth,
|
|
73
|
+
other = _objectWithoutProperties(_ref6, _excluded);
|
|
74
|
+
|
|
75
|
+
var inputVariant = inputToken[variant] ? inputToken[variant] : inputToken.input;
|
|
35
76
|
|
|
36
77
|
var _useEds = useEds(),
|
|
37
78
|
density = _useEds.density;
|
|
38
79
|
|
|
39
|
-
var
|
|
80
|
+
var _token = useToken({
|
|
40
81
|
density: density
|
|
41
|
-
}, inputVariant);
|
|
82
|
+
}, inputVariant)();
|
|
83
|
+
|
|
84
|
+
var _useState = useState(),
|
|
85
|
+
_useState2 = _slicedToArray(_useState, 2),
|
|
86
|
+
rightAdornmentsRef = _useState2[0],
|
|
87
|
+
setRightAdornmentsRef = _useState2[1];
|
|
88
|
+
|
|
89
|
+
var _useState3 = useState(),
|
|
90
|
+
_useState4 = _slicedToArray(_useState3, 2),
|
|
91
|
+
leftAdornmentsRef = _useState4[0],
|
|
92
|
+
setLeftAdornmentsRef = _useState4[1];
|
|
93
|
+
|
|
94
|
+
var token = useCallback(function () {
|
|
95
|
+
var _leftAdornmentsWidth = leftAdornmentsWidth || (leftAdornmentsRef ? leftAdornmentsRef.clientWidth : 0);
|
|
96
|
+
|
|
97
|
+
var _rightAdornmentsWidth = rightAdornmentsWidth || (rightAdornmentsRef ? rightAdornmentsRef.clientWidth : 0);
|
|
98
|
+
|
|
99
|
+
return _objectSpread(_objectSpread({}, _token), {}, {
|
|
100
|
+
spacings: _objectSpread(_objectSpread({}, _token.spacings), {}, {
|
|
101
|
+
left: "".concat(_leftAdornmentsWidth + parseInt(_token.spacings.left), "px"),
|
|
102
|
+
right: "".concat(_rightAdornmentsWidth + parseInt(_token.spacings.right), "px")
|
|
103
|
+
})
|
|
104
|
+
});
|
|
105
|
+
}, [leftAdornmentsWidth, leftAdornmentsRef, rightAdornmentsWidth, rightAdornmentsRef, _token])();
|
|
42
106
|
|
|
43
107
|
var inputProps = _objectSpread({
|
|
44
108
|
ref: ref,
|
|
45
109
|
type: type,
|
|
46
|
-
disabled: disabled
|
|
110
|
+
disabled: disabled,
|
|
111
|
+
readOnly: readOnly,
|
|
112
|
+
token: token,
|
|
113
|
+
style: {
|
|
114
|
+
resize: 'none'
|
|
115
|
+
}
|
|
47
116
|
}, other);
|
|
48
117
|
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
118
|
+
var containerProps = {
|
|
119
|
+
disabled: disabled,
|
|
120
|
+
readOnly: readOnly,
|
|
121
|
+
className: className,
|
|
122
|
+
style: style,
|
|
123
|
+
token: token
|
|
124
|
+
};
|
|
125
|
+
|
|
126
|
+
var _leftAdornmentProps = _objectSpread(_objectSpread({}, leftAdornmentsProps), {}, {
|
|
127
|
+
ref: setLeftAdornmentsRef,
|
|
128
|
+
token: token
|
|
129
|
+
});
|
|
130
|
+
|
|
131
|
+
var _rightAdornmentProps = _objectSpread(_objectSpread({}, rightAdornmentsProps), {}, {
|
|
132
|
+
ref: setRightAdornmentsRef,
|
|
133
|
+
token: token
|
|
52
134
|
});
|
|
135
|
+
|
|
136
|
+
return (
|
|
137
|
+
/*#__PURE__*/
|
|
138
|
+
// Not using <ThemeProvider> because of cascading styling messing with adornments
|
|
139
|
+
jsxs(Container, _objectSpread(_objectSpread({}, containerProps), {}, {
|
|
140
|
+
children: [leftAdornments ? /*#__PURE__*/jsx(LeftAdornments, _objectSpread(_objectSpread({}, _leftAdornmentProps), {}, {
|
|
141
|
+
children: leftAdornments
|
|
142
|
+
})) : null, /*#__PURE__*/jsx(StyledInput, _objectSpread({
|
|
143
|
+
paddingLeft: token.spacings.left,
|
|
144
|
+
paddingRight: token.spacings.right
|
|
145
|
+
}, inputProps)), rightAdornments ? /*#__PURE__*/jsx(RightAdornments, _objectSpread(_objectSpread({}, _rightAdornmentProps), {}, {
|
|
146
|
+
children: rightAdornments
|
|
147
|
+
})) : null]
|
|
148
|
+
}))
|
|
149
|
+
);
|
|
53
150
|
});
|
|
54
151
|
|
|
55
152
|
export { Input };
|
|
@@ -22,7 +22,8 @@ var _tokens$colors = tokens$1.colors,
|
|
|
22
22
|
typography = tokens$1.typography,
|
|
23
23
|
shape = tokens$1.shape;
|
|
24
24
|
var input = {
|
|
25
|
-
|
|
25
|
+
height: shape.straight.minHeight,
|
|
26
|
+
width: '100%',
|
|
26
27
|
background: background,
|
|
27
28
|
spacings: {
|
|
28
29
|
left: small,
|
|
@@ -33,11 +34,34 @@ var input = {
|
|
|
33
34
|
typography: _objectSpread(_objectSpread({}, typography.input.text), {}, {
|
|
34
35
|
color: static_icons__default.rgba
|
|
35
36
|
}),
|
|
37
|
+
outline: {
|
|
38
|
+
type: 'outline',
|
|
39
|
+
color: 'transparent',
|
|
40
|
+
width: '1px',
|
|
41
|
+
style: 'solid',
|
|
42
|
+
offset: '0px'
|
|
43
|
+
},
|
|
36
44
|
entities: {
|
|
37
45
|
placeholder: {
|
|
38
46
|
typography: {
|
|
39
47
|
color: static_icons__tertiary.rgba
|
|
40
48
|
}
|
|
49
|
+
},
|
|
50
|
+
adornment: {
|
|
51
|
+
typography: _objectSpread(_objectSpread({}, typography.input.label), {}, {
|
|
52
|
+
color: static_icons__tertiary.rgba
|
|
53
|
+
}),
|
|
54
|
+
spacings: {
|
|
55
|
+
left: small,
|
|
56
|
+
right: small
|
|
57
|
+
},
|
|
58
|
+
states: {
|
|
59
|
+
disabled: {
|
|
60
|
+
typography: {
|
|
61
|
+
color: disabled__text.rgba
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
}
|
|
41
65
|
}
|
|
42
66
|
},
|
|
43
67
|
states: {
|
|
@@ -50,15 +74,7 @@ var input = {
|
|
|
50
74
|
background: 'transparent',
|
|
51
75
|
boxShadow: 'none'
|
|
52
76
|
},
|
|
53
|
-
active: {
|
|
54
|
-
outline: {
|
|
55
|
-
type: 'outline',
|
|
56
|
-
color: 'transparent',
|
|
57
|
-
width: '1px',
|
|
58
|
-
style: 'solid',
|
|
59
|
-
offset: '0px'
|
|
60
|
-
}
|
|
61
|
-
},
|
|
77
|
+
active: {},
|
|
62
78
|
focus: {
|
|
63
79
|
outline: {
|
|
64
80
|
type: 'outline',
|
|
@@ -72,7 +88,7 @@ var input = {
|
|
|
72
88
|
boxShadow: 'inset 0px -1px 0px 0px ' + static_icons__tertiary.rgba,
|
|
73
89
|
modes: {
|
|
74
90
|
compact: {
|
|
75
|
-
|
|
91
|
+
height: shape._modes.compact.straight.minHeight,
|
|
76
92
|
spacings: {
|
|
77
93
|
left: x_small,
|
|
78
94
|
right: x_small,
|
|
@@ -83,70 +99,82 @@ var input = {
|
|
|
83
99
|
}
|
|
84
100
|
};
|
|
85
101
|
var error = mergeDeepRight(input, {
|
|
86
|
-
boxShadow: '
|
|
102
|
+
boxShadow: 'none',
|
|
103
|
+
outline: {
|
|
104
|
+
color: danger__resting.rgba
|
|
105
|
+
},
|
|
87
106
|
states: {
|
|
88
|
-
active: {
|
|
89
|
-
outline: {
|
|
90
|
-
type: 'outline',
|
|
91
|
-
color: danger__resting.rgba,
|
|
92
|
-
width: '1px',
|
|
93
|
-
style: 'solid',
|
|
94
|
-
offset: '0px'
|
|
95
|
-
}
|
|
96
|
-
},
|
|
97
107
|
focus: {
|
|
98
108
|
outline: {
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
109
|
+
color: danger__hover.rgba
|
|
110
|
+
}
|
|
111
|
+
}
|
|
112
|
+
},
|
|
113
|
+
entities: {
|
|
114
|
+
adornment: {
|
|
115
|
+
typography: _objectSpread(_objectSpread({}, typography.input.label), {}, {
|
|
116
|
+
color: danger__resting.rgba
|
|
117
|
+
}),
|
|
118
|
+
states: {
|
|
119
|
+
focus: {
|
|
120
|
+
outline: {
|
|
121
|
+
color: danger__hover.rgba
|
|
122
|
+
}
|
|
123
|
+
}
|
|
104
124
|
}
|
|
105
125
|
}
|
|
106
126
|
}
|
|
107
127
|
});
|
|
108
128
|
var warning = mergeDeepRight(input, {
|
|
109
|
-
boxShadow: '
|
|
129
|
+
boxShadow: 'none',
|
|
130
|
+
outline: {
|
|
131
|
+
color: warning__resting.rgba
|
|
132
|
+
},
|
|
110
133
|
states: {
|
|
111
|
-
active: {
|
|
112
|
-
outline: {
|
|
113
|
-
type: 'outline',
|
|
114
|
-
color: warning__resting.rgba,
|
|
115
|
-
width: '1px',
|
|
116
|
-
style: 'solid',
|
|
117
|
-
offset: '0px'
|
|
118
|
-
}
|
|
119
|
-
},
|
|
120
134
|
focus: {
|
|
121
135
|
outline: {
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
136
|
+
color: warning__hover.rgba
|
|
137
|
+
}
|
|
138
|
+
}
|
|
139
|
+
},
|
|
140
|
+
entities: {
|
|
141
|
+
adornment: {
|
|
142
|
+
typography: _objectSpread(_objectSpread({}, typography.input.label), {}, {
|
|
143
|
+
color: warning__resting.rgba
|
|
144
|
+
}),
|
|
145
|
+
states: {
|
|
146
|
+
focus: {
|
|
147
|
+
outline: {
|
|
148
|
+
color: warning__hover.rgba
|
|
149
|
+
}
|
|
150
|
+
}
|
|
127
151
|
}
|
|
128
152
|
}
|
|
129
153
|
}
|
|
130
154
|
});
|
|
131
155
|
var success = mergeDeepRight(input, {
|
|
132
|
-
boxShadow: '
|
|
156
|
+
boxShadow: 'none',
|
|
157
|
+
outline: {
|
|
158
|
+
color: success__resting.rgba
|
|
159
|
+
},
|
|
133
160
|
states: {
|
|
134
|
-
active: {
|
|
135
|
-
outline: {
|
|
136
|
-
type: 'outline',
|
|
137
|
-
color: success__resting.rgba,
|
|
138
|
-
width: '1px',
|
|
139
|
-
style: 'solid',
|
|
140
|
-
offset: '0px'
|
|
141
|
-
}
|
|
142
|
-
},
|
|
143
161
|
focus: {
|
|
144
162
|
outline: {
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
163
|
+
color: success__hover.rgba
|
|
164
|
+
}
|
|
165
|
+
}
|
|
166
|
+
},
|
|
167
|
+
entities: {
|
|
168
|
+
adornment: {
|
|
169
|
+
typography: _objectSpread(_objectSpread({}, typography.input.label), {}, {
|
|
170
|
+
color: success__resting.rgba
|
|
171
|
+
}),
|
|
172
|
+
states: {
|
|
173
|
+
focus: {
|
|
174
|
+
outline: {
|
|
175
|
+
color: success__hover.rgba
|
|
176
|
+
}
|
|
177
|
+
}
|
|
150
178
|
}
|
|
151
179
|
}
|
|
152
180
|
}
|