@laerdal/life-react-components 1.7.0-dev.16 → 1.7.0-dev.18
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/Button/Button.cjs +4 -4
- package/dist/Button/Button.cjs.map +1 -1
- package/dist/Button/Button.d.ts +1 -1
- package/dist/Button/Button.js +4 -4
- package/dist/Button/Button.js.map +1 -1
- package/dist/Button/DualFunctionButton.cjs +1 -1
- package/dist/Button/DualFunctionButton.cjs.map +1 -1
- package/dist/Button/DualFunctionButton.js +1 -1
- package/dist/Button/DualFunctionButton.js.map +1 -1
- package/dist/Chips/ChipStyles.cjs +1 -1
- package/dist/Chips/ChipStyles.cjs.map +1 -1
- package/dist/Chips/ChipStyles.js +1 -1
- package/dist/Chips/ChipStyles.js.map +1 -1
- package/dist/Chips/ChipTypes.d.ts +1 -1
- package/dist/Chips/InputChip.cjs +16 -7
- package/dist/Chips/InputChip.cjs.map +1 -1
- package/dist/Chips/InputChip.js +15 -7
- package/dist/Chips/InputChip.js.map +1 -1
- package/dist/ChipsInput/ChipDropdownInput.cjs +2 -4
- package/dist/ChipsInput/ChipDropdownInput.cjs.map +1 -1
- package/dist/ChipsInput/ChipDropdownInput.js +2 -4
- package/dist/ChipsInput/ChipDropdownInput.js.map +1 -1
- package/dist/ChipsInput/ChipInput.cjs +0 -2
- package/dist/ChipsInput/ChipInput.cjs.map +1 -1
- package/dist/ChipsInput/ChipInput.js +0 -2
- package/dist/ChipsInput/ChipInput.js.map +1 -1
- package/dist/ChipsInput/ChipInputField.cjs +76 -58
- package/dist/ChipsInput/ChipInputField.cjs.map +1 -1
- package/dist/ChipsInput/ChipInputField.d.ts +3 -3
- package/dist/ChipsInput/ChipInputField.js +72 -55
- package/dist/ChipsInput/ChipInputField.js.map +1 -1
- package/dist/ChipsInput/ChipInputTypes.d.ts +0 -1
- package/dist/Dropdown/BasicDropdown.cjs +9 -9
- package/dist/Dropdown/BasicDropdown.cjs.map +1 -1
- package/dist/Dropdown/BasicDropdown.d.ts +2 -2
- package/dist/Dropdown/BasicDropdown.js +10 -10
- package/dist/Dropdown/BasicDropdown.js.map +1 -1
- package/dist/Dropdown/CommonStyling.cjs +4 -4
- package/dist/Dropdown/CommonStyling.cjs.map +1 -1
- package/dist/Dropdown/CommonStyling.d.ts +3 -3
- package/dist/Dropdown/CommonStyling.js +4 -4
- package/dist/Dropdown/CommonStyling.js.map +1 -1
- package/dist/Dropdown/DropdownFilter.cjs +18 -18
- package/dist/Dropdown/DropdownFilter.cjs.map +1 -1
- package/dist/Dropdown/DropdownFilter.d.ts +2 -2
- package/dist/Dropdown/DropdownFilter.js +19 -19
- package/dist/Dropdown/DropdownFilter.js.map +1 -1
- package/dist/InputFields/Checkbox.cjs +10 -10
- package/dist/InputFields/Checkbox.cjs.map +1 -1
- package/dist/InputFields/Checkbox.d.ts +3 -3
- package/dist/InputFields/Checkbox.js +10 -10
- package/dist/InputFields/Checkbox.js.map +1 -1
- package/dist/InputFields/DatepickerField.cjs +12 -14
- package/dist/InputFields/DatepickerField.cjs.map +1 -1
- package/dist/InputFields/DatepickerField.d.ts +3 -3
- package/dist/InputFields/DatepickerField.js +12 -18
- package/dist/InputFields/DatepickerField.js.map +1 -1
- package/dist/InputFields/PasswordField.cjs +21 -17
- package/dist/InputFields/PasswordField.cjs.map +1 -1
- package/dist/InputFields/PasswordField.d.ts +2 -3
- package/dist/InputFields/PasswordField.js +19 -15
- package/dist/InputFields/PasswordField.js.map +1 -1
- package/dist/InputFields/RadioButton.cjs +5 -7
- package/dist/InputFields/RadioButton.cjs.map +1 -1
- package/dist/InputFields/RadioButton.d.ts +1 -1
- package/dist/InputFields/RadioButton.js +5 -5
- package/dist/InputFields/RadioButton.js.map +1 -1
- package/dist/InputFields/SearchBar.cjs +2 -2
- package/dist/InputFields/SearchBar.cjs.map +1 -1
- package/dist/InputFields/SearchBar.js +3 -3
- package/dist/InputFields/SearchBar.js.map +1 -1
- package/dist/InputFields/TextField.cjs +13 -27
- package/dist/InputFields/TextField.cjs.map +1 -1
- package/dist/InputFields/TextField.d.ts +3 -5
- package/dist/InputFields/TextField.js +13 -27
- package/dist/InputFields/TextField.js.map +1 -1
- package/dist/InputFields/Textarea.cjs +3 -14
- package/dist/InputFields/Textarea.cjs.map +1 -1
- package/dist/InputFields/Textarea.d.ts +0 -1
- package/dist/InputFields/Textarea.js +5 -14
- package/dist/InputFields/Textarea.js.map +1 -1
- package/dist/InputFields/components/SearchField.cjs +1 -3
- package/dist/InputFields/components/SearchField.cjs.map +1 -1
- package/dist/InputFields/components/SearchField.js +1 -2
- package/dist/InputFields/components/SearchField.js.map +1 -1
- package/dist/InputFields/styling.cjs +16 -24
- package/dist/InputFields/styling.cjs.map +1 -1
- package/dist/InputFields/styling.d.ts +3 -6
- package/dist/InputFields/styling.js +14 -21
- package/dist/InputFields/styling.js.map +1 -1
- package/dist/MenuItem/MenuItem.cjs +1 -1
- package/dist/MenuItem/MenuItem.cjs.map +1 -1
- package/dist/MenuItem/MenuItem.js +1 -1
- package/dist/MenuItem/MenuItem.js.map +1 -1
- package/dist/Table/TableBody.cjs +1 -1
- package/dist/Table/TableBody.cjs.map +1 -1
- package/dist/Table/TableBody.js +1 -1
- package/dist/Table/TableBody.js.map +1 -1
- package/package.json +1 -1
|
@@ -5,7 +5,7 @@ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefau
|
|
|
5
5
|
Object.defineProperty(exports, "__esModule", {
|
|
6
6
|
value: true
|
|
7
7
|
});
|
|
8
|
-
exports.ChipInputField = exports.ChipInputEl = exports.ChipInputContentContainer = exports.ChipInputContainer = void 0;
|
|
8
|
+
exports.ChipInputField = exports.ChipInputEl = exports.ChipInputContentContainer = exports.ChipInputContainer = exports.ChipInputBoundItems = void 0;
|
|
9
9
|
|
|
10
10
|
var _taggedTemplateLiteral2 = _interopRequireDefault(require("@babel/runtime/helpers/taggedTemplateLiteral"));
|
|
11
11
|
|
|
@@ -35,24 +35,28 @@ var _icons = require("../icons");
|
|
|
35
35
|
|
|
36
36
|
var _jsxRuntime = require("react/jsx-runtime");
|
|
37
37
|
|
|
38
|
-
var _templateObject, _templateObject2, _templateObject3, _templateObject4, _templateObject5;
|
|
38
|
+
var _templateObject, _templateObject2, _templateObject3, _templateObject4, _templateObject5, _templateObject6;
|
|
39
39
|
|
|
40
40
|
var Wrapper = _styledComponents.default.div(_templateObject || (_templateObject = (0, _taggedTemplateLiteral2.default)(["\n position: relative;\n"])));
|
|
41
41
|
|
|
42
42
|
var Loading = _styledComponents.default.div(_templateObject2 || (_templateObject2 = (0, _taggedTemplateLiteral2.default)(["\n height: 20px;\n width: 20px;\n"])));
|
|
43
43
|
|
|
44
|
-
var
|
|
44
|
+
var ChipInputBoundItems = _styledComponents.default.div(_templateObject3 || (_templateObject3 = (0, _taggedTemplateLiteral2.default)(["\n display: flex;\n flex-direction: row;\n align-items: center;\n gap: 8px;\n flex: 1;\n min-width: 40px;\n"])));
|
|
45
45
|
|
|
46
|
-
exports.
|
|
46
|
+
exports.ChipInputBoundItems = ChipInputBoundItems;
|
|
47
47
|
|
|
48
|
-
var
|
|
48
|
+
var ChipInputContentContainer = _styledComponents.default.div(_templateObject4 || (_templateObject4 = (0, _taggedTemplateLiteral2.default)(["\n width: 100%;\n background: transparent;\n display: flex;\n flex-direction: row;\n align-items: center;\n column-gap: 8px;\n margin-right: 6px;\n padding-right: 10px;\n padding-left: 16px;\n flex-wrap: nowrap;\n overflow-x: scroll;\n min-height: 48px;\n\n ", "\n ::-webkit-scrollbar:horizontal {\n display: none;\n }\n\n .action-right:focus, button:focus {\n outline-offset: -4px !important;\n }\n"])), (0, _styles.scrollBarStyling)(_types.Size.Small));
|
|
49
49
|
|
|
50
|
-
exports.
|
|
50
|
+
exports.ChipInputContentContainer = ChipInputContentContainer;
|
|
51
51
|
|
|
52
|
-
var ChipInputEl = _styledComponents.default.input(_templateObject5 || (_templateObject5 = (0, _taggedTemplateLiteral2.default)(["\n border: none;\n outline: none;\n\n height: 40px;\n min-width: 40px;\n display: inline-flex;\n flex: 1;\n background: transparent;\n\n ", "\n color: ", " !important;\n"])), (0, _styles.ComponentMStyling)(_styles.ComponentTextStyle.Regular, null), _styles.COLORS.black);
|
|
52
|
+
var ChipInputEl = _styledComponents.default.input(_templateObject5 || (_templateObject5 = (0, _taggedTemplateLiteral2.default)(["\n border: none;\n outline: none;\n\n height: 40px;\n min-width: 40px;\n display: inline-flex;\n flex: 1;\n background: transparent;\n\n ", "\n color: ", " !important;\n\n &::placeholder {\n ", "\n }\n"])), (0, _styles.ComponentMStyling)(_styles.ComponentTextStyle.Regular, null), _styles.COLORS.black, (0, _styles.ComponentMStyling)(_styles.ComponentTextStyle.Italic, _styles.COLORS.neutral_600));
|
|
53
53
|
|
|
54
54
|
exports.ChipInputEl = ChipInputEl;
|
|
55
55
|
|
|
56
|
+
var ChipInputContainer = _styledComponents.default.div(_templateObject6 || (_templateObject6 = (0, _taggedTemplateLiteral2.default)(["\n width: 100%;\n height: auto;\n border-radius: 4px;\n box-shadow: inset 0 0 0 1px ", ";\n background-color: ", ";\n box-sizing: border-box;\n cursor: text;\n outline: none;\n display: flex;\n align-items: center;\n\n ", "\n &.small {\n padding: 0;\n min-height: 48px;\n\n ", "::placeholder {\n ", "\n }\n }\n\n &.medium {\n padding: 4px 0;\n min-height: 56px;\n\n ", "::placeholder {\n ", "\n }\n }\n\n\n &.multiline.medium {\n ", " {\n max-height: calc(48px * 3);\n flex-wrap: wrap;\n overflow-y: auto;\n overflow-x: unset;\n }\n }\n\n &.focus-visible-within, :focus {\n ", "\n }\n\n &:hover {\n box-shadow: inset 0 0 0 2px ", ";\n }\n\n &:focus-within {\n box-shadow: inset 0 0 0 2px ", ";\n }\n\n &.invalid,\n &.invalid:hover,\n &.invalid:focus {\n box-shadow: inset 0 0 0 2px ", ";\n }\n\n &.disabled {\n ", " {\n pointer-events: none;\n }\n\n cursor: not-allowed;\n box-shadow: inset 0 0 0 1px ", ";\n outline: none;\n color: ", " !important;\n }\n\n\n"])), _styles.COLORS.neutral_400, _styles.COLORS.white, (0, _styles.ComponentMStyling)(_styles.ComponentTextStyle.Regular, _styles.COLORS.black), ChipInputEl, (0, _styles.ComponentSStyling)(_styles.ComponentTextStyle.Italic, _styles.COLORS.neutral_600), ChipInputEl, (0, _styles.ComponentMStyling)(_styles.ComponentTextStyle.Italic, _styles.COLORS.neutral_600), ChipInputContentContainer, _styles.focusStyles, _styles.COLORS.primary_700, _styles.COLORS.primary_800, _styles.COLORS.critical_500, ChipInputContentContainer, _styles.COLORS.neutral_100, _styles.COLORS.neutral_300);
|
|
57
|
+
|
|
58
|
+
exports.ChipInputContainer = ChipInputContainer;
|
|
59
|
+
|
|
56
60
|
var ChipInputField = /*#__PURE__*/_react.default.forwardRef(function (_ref, ref) {
|
|
57
61
|
var inputId = _ref.inputId,
|
|
58
62
|
items = _ref.items,
|
|
@@ -64,27 +68,23 @@ var ChipInputField = /*#__PURE__*/_react.default.forwardRef(function (_ref, ref)
|
|
|
64
68
|
multiLine = _ref$multiLine === void 0 ? true : _ref$multiLine,
|
|
65
69
|
_ref$size = _ref.size,
|
|
66
70
|
size = _ref$size === void 0 ? _types.Size.Medium : _ref$size,
|
|
67
|
-
validationType = _ref.validationType,
|
|
68
71
|
validationMessage = _ref.validationMessage,
|
|
69
72
|
loading = _ref.loading,
|
|
70
73
|
onRemoveItem = _ref.onRemoveItem,
|
|
71
74
|
onInputValueChange = _ref.onInputValueChange,
|
|
72
75
|
onInputKeyDown = _ref.onInputKeyDown,
|
|
73
|
-
|
|
76
|
+
onActivationChange = _ref.onActivationChange,
|
|
74
77
|
inputValue = _ref.inputValue;
|
|
75
78
|
|
|
76
79
|
var containerRef = _react.default.useRef(null);
|
|
77
80
|
|
|
78
81
|
var inputRef = (0, _common.useFocusVisibleRef)([containerRef], ref);
|
|
79
|
-
|
|
80
|
-
var clearButtonRef = _react.default.useRef(null);
|
|
81
82
|
/**
|
|
82
83
|
* Scroll container to last item on change
|
|
83
84
|
* */
|
|
84
85
|
|
|
85
|
-
|
|
86
86
|
_react.default.useEffect(function () {
|
|
87
|
-
if (
|
|
87
|
+
if (inputRef.current) {
|
|
88
88
|
inputRef.current.scrollIntoView({
|
|
89
89
|
block: 'nearest',
|
|
90
90
|
inline: 'nearest'
|
|
@@ -97,36 +97,55 @@ var ChipInputField = /*#__PURE__*/_react.default.forwardRef(function (_ref, ref)
|
|
|
97
97
|
|
|
98
98
|
|
|
99
99
|
var handleInputKeyDown = function handleInputKeyDown(e) {
|
|
100
|
-
|
|
100
|
+
var _inputRef$current;
|
|
101
|
+
|
|
102
|
+
if (e.key === 'Backspace' && !((_inputRef$current = inputRef.current) !== null && _inputRef$current !== void 0 && _inputRef$current.value) && !e.repeat && items.length > 0) {
|
|
103
|
+
onRemoveItem(items[items.length - 1], items.length - 1);
|
|
104
|
+
} else {
|
|
105
|
+
onInputKeyDown(e);
|
|
106
|
+
}
|
|
101
107
|
};
|
|
102
108
|
|
|
103
109
|
var handleItemRemove = function handleItemRemove(event, item, index) {
|
|
104
|
-
var _inputRef$
|
|
110
|
+
var _inputRef$current2;
|
|
105
111
|
|
|
106
112
|
onRemoveItem(item, index);
|
|
107
|
-
(_inputRef$
|
|
113
|
+
(_inputRef$current2 = inputRef.current) === null || _inputRef$current2 === void 0 ? void 0 : _inputRef$current2.focus({
|
|
108
114
|
focusVisible: event.detail !== 1
|
|
109
115
|
});
|
|
110
116
|
};
|
|
111
117
|
|
|
112
118
|
var handleInputClear = function handleInputClear(e) {
|
|
113
|
-
var _inputRef$
|
|
119
|
+
var _inputRef$current3;
|
|
114
120
|
|
|
115
121
|
onInputValueChange('');
|
|
116
|
-
(_inputRef$
|
|
122
|
+
(_inputRef$current3 = inputRef.current) === null || _inputRef$current3 === void 0 ? void 0 : _inputRef$current3.focus({
|
|
117
123
|
focusVisible: (e === null || e === void 0 ? void 0 : e.detail) !== 1
|
|
118
124
|
});
|
|
119
125
|
};
|
|
120
126
|
|
|
121
|
-
var
|
|
127
|
+
var handleContainerKeyDown = function handleContainerKeyDown(e) {
|
|
128
|
+
if (!containerRef.current || e.key !== 'ArrowLeft' && e.key !== 'ArrowRight') return;
|
|
129
|
+
var items = containerRef.current.querySelectorAll('[tabindex="0"]');
|
|
130
|
+
var currentIndex = Array.from(items).indexOf(e.target);
|
|
131
|
+
var direction = e.key === 'ArrowLeft' ? -1 : 1;
|
|
132
|
+
var item = items[currentIndex + direction];
|
|
133
|
+
item === null || item === void 0 ? void 0 : item.focus({
|
|
134
|
+
focusVisible: true
|
|
135
|
+
});
|
|
136
|
+
onActivationChange && onActivationChange(false);
|
|
137
|
+
};
|
|
138
|
+
|
|
139
|
+
var cls = "".concat(multiLine ? 'multiline' : '', " ").concat(validationMessage ? 'invalid' : '', " ").concat(size, " ").concat(loading ? 'loading' : '', " ").concat(disabled ? 'disabled' : '');
|
|
122
140
|
return /*#__PURE__*/(0, _jsxRuntime.jsxs)(Wrapper, {
|
|
123
141
|
children: [/*#__PURE__*/(0, _jsxRuntime.jsx)(ChipInputContainer, {
|
|
124
142
|
ref: containerRef,
|
|
125
143
|
id: inputId,
|
|
144
|
+
onKeyDown: handleContainerKeyDown,
|
|
126
145
|
onClick: function onClick() {
|
|
127
|
-
var _inputRef$
|
|
146
|
+
var _inputRef$current4;
|
|
128
147
|
|
|
129
|
-
return !disabled && ((_inputRef$
|
|
148
|
+
return !disabled && ((_inputRef$current4 = inputRef.current) === null || _inputRef$current4 === void 0 ? void 0 : _inputRef$current4.focus());
|
|
130
149
|
},
|
|
131
150
|
className: cls,
|
|
132
151
|
children: /*#__PURE__*/(0, _jsxRuntime.jsxs)(ChipInputContentContainer, {
|
|
@@ -141,43 +160,43 @@ var ChipInputField = /*#__PURE__*/_react.default.forwardRef(function (_ref, ref)
|
|
|
141
160
|
return handleItemRemove(e, chip, index);
|
|
142
161
|
}
|
|
143
162
|
}, "chip_".concat(index));
|
|
144
|
-
}), /*#__PURE__*/(0, _jsxRuntime.
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
e
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
163
|
+
}), /*#__PURE__*/(0, _jsxRuntime.jsxs)(ChipInputBoundItems, {
|
|
164
|
+
children: [/*#__PURE__*/(0, _jsxRuntime.jsx)(ChipInputEl, {
|
|
165
|
+
ref: inputRef,
|
|
166
|
+
type: "text",
|
|
167
|
+
tabIndex: disabled ? -1 : 0,
|
|
168
|
+
value: inputValue,
|
|
169
|
+
onChange: function onChange(e) {
|
|
170
|
+
return onInputValueChange(e.target.value);
|
|
171
|
+
},
|
|
172
|
+
onKeyDown: handleInputKeyDown,
|
|
173
|
+
placeholder: (items === null || items === void 0 ? void 0 : items.length) === 0 ? placeholder : altPlaceholder || '',
|
|
174
|
+
onClick: function onClick(e) {
|
|
175
|
+
e.stopPropagation();
|
|
176
|
+
onActivationChange && onActivationChange(true);
|
|
177
|
+
}
|
|
178
|
+
}), inputValue && !disabled && /*#__PURE__*/(0, _jsxRuntime.jsx)(_Button.IconButton, {
|
|
179
|
+
action: handleInputClear,
|
|
180
|
+
ref: function ref(_ref2) {
|
|
181
|
+
_ref2 === null || _ref2 === void 0 ? void 0 : _ref2.scrollIntoView({
|
|
182
|
+
block: 'nearest',
|
|
183
|
+
inline: 'nearest'
|
|
184
|
+
});
|
|
185
|
+
},
|
|
186
|
+
useTransparentBackground: true,
|
|
187
|
+
shape: 'circular',
|
|
188
|
+
variant: 'secondary',
|
|
189
|
+
children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_icons.SystemIcons.Clear, {})
|
|
190
|
+
}), loading && /*#__PURE__*/(0, _jsxRuntime.jsx)(Loading, {
|
|
191
|
+
className: size,
|
|
192
|
+
children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_LoadingIndicator.LoadingIndicator, {
|
|
193
|
+
size: _types.Size.Small,
|
|
194
|
+
color: _styles.COLORS.neutral_600
|
|
195
|
+
})
|
|
196
|
+
})]
|
|
171
197
|
})]
|
|
172
198
|
})
|
|
173
|
-
}), validationMessage &&
|
|
174
|
-
children: [/*#__PURE__*/(0, _jsxRuntime.jsx)(_SystemIcons.TechnicalWarning, {
|
|
175
|
-
size: "20px",
|
|
176
|
-
color: _styles.COLORS.critical_500
|
|
177
|
-
}), /*#__PURE__*/(0, _jsxRuntime.jsx)("span", {
|
|
178
|
-
children: validationMessage
|
|
179
|
-
})]
|
|
180
|
-
}) : validationType === 'error' && /*#__PURE__*/(0, _jsxRuntime.jsxs)(_styling.ErrorMessage, {
|
|
199
|
+
}), validationMessage && /*#__PURE__*/(0, _jsxRuntime.jsxs)(_styling.ErrorMessage, {
|
|
181
200
|
children: [/*#__PURE__*/(0, _jsxRuntime.jsx)(_SystemIcons.TechnicalWarning, {
|
|
182
201
|
size: "20px",
|
|
183
202
|
color: _styles.COLORS.critical_400
|
|
@@ -197,12 +216,11 @@ ChipInputField.propTypes = {
|
|
|
197
216
|
altPlaceholder: _propTypes.default.string,
|
|
198
217
|
multiLine: _propTypes.default.bool,
|
|
199
218
|
loading: _propTypes.default.bool,
|
|
200
|
-
validationType: _propTypes.default.oneOf(['error', 'warning']),
|
|
201
219
|
validationMessage: _propTypes.default.string,
|
|
202
220
|
onRemoveItem: _propTypes.default.func.isRequired,
|
|
203
221
|
inputValue: _propTypes.default.string.isRequired,
|
|
204
222
|
onInputValueChange: _propTypes.default.func.isRequired,
|
|
205
223
|
onInputKeyDown: _propTypes.default.func.isRequired,
|
|
206
|
-
|
|
224
|
+
onActivationChange: _propTypes.default.func
|
|
207
225
|
};
|
|
208
226
|
//# sourceMappingURL=ChipInputField.cjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/ChipsInput/ChipInputField.tsx"],"names":["Wrapper","styled","div","Loading","ChipInputContentContainer","Size","Small","ChipInputContainer","COLORS","neutral_400","white","ComponentTextStyle","Regular","black","focusStyles","primary_700","primary_800","warning_500","critical_500","neutral_100","neutral_300","ChipInputEl","input","ChipInputField","React","forwardRef","ref","inputId","items","disabled","placeholder","altPlaceholder","multiLine","size","Medium","validationType","validationMessage","loading","onRemoveItem","onInputValueChange","onInputKeyDown","onActivation","inputValue","containerRef","useRef","inputRef","clearButtonRef","useEffect","current","scrollIntoView","block","inline","handleInputKeyDown","e","handleItemRemove","event","item","index","focus","focusVisible","detail","handleInputClear","cls","map","chip","icon","variant","label","target","value","length","stopPropagation","neutral_600","critical_400"],"mappings":";;;;;;;;;;;;;AAAA;;AAEA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;;;;;AAEA,IAAMA,OAAO,GAAGC,0BAAOC,GAAV,4GAAb;;AAIA,IAAMC,OAAO,GAAGF,0BAAOC,GAAV,wHAAb;;AAMO,IAAME,yBAAyB,GAAGH,0BAAOC,GAAV,4fAclC,8BAAiBG,YAAKC,KAAtB,CAdkC,CAA/B;;;;AAwBA,IAAMC,kBAAkB,GAAGN,0BAAOC,GAAV,opCAICM,eAAOC,WAJR,EAKTD,eAAOE,KALE,EAY3B,+BAAkBC,2BAAmBC,OAArC,EAA8CJ,eAAOK,KAArD,CAZ2B,EAyBzBT,yBAzByB,EAkCzBU,mBAlCyB,EAsCGN,eAAOO,WAtCV,EA0CGP,eAAOQ,WA1CV,EAgDGR,eAAOS,WAhDV,EAsDGT,eAAOU,YAtDV,EA0DzBd,yBA1DyB,EA+DGI,eAAOW,WA/DV,EAiElBX,eAAOY,WAjEW,CAAxB;;;;AAuEA,IAAMC,WAAW,GAAGpB,0BAAOqB,KAAV,wQAUpB,+BAAkBX,2BAAmBC,OAArC,EAA8C,IAA9C,CAVoB,EAWbJ,eAAOK,KA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AHnB;AAIY,UAAA,OAAO,EAAE,WAJrB;AAAA,iCAKE,qBAAC,kBAAD,CAAa,KAAb;AALF,UAxBJ,EAiCGT,OAAO,iBACN,qBAAC,OAAD;AAAS,UAAA,SAAS,EAAEJ,IAApB;AAAA,iCACE,qBAAC,kCAAD;AAAkB,YAAA,IAAI,EAAE5B,YAAKC,KAA7B;AAAoC,YAAA,KAAK,EAAEE,eAAOgE;AAAlD;AADF,UAlCJ;AAAA;AAJF,MADF,EA+CGpC,iBAAiB,IAAID,cAAc,KAAK,SAAxC,gBACC,sBAAC,uBAAD;AAAA,8BACE,qBAAC,6BAAD;AAAkB,QAAA,IAAI,EAAC,MAAvB;AAA8B,QAAA,KAAK,EAAE3B,eAAOU;AAA5C,QADF,eAEE;AAAA,kBAAOkB;AAAP,QAFF;AAAA,MADD,GAMCD,cAAc,KAAK,OAAnB,iBACE,sBAAC,qBAAD;AAAA,8BACE,qBAAC,6BAAD;AAAkB,QAAA,IAAI,EAAC,MAAvB;AAA8B,QAAA,KAAK,EAAE3B,eAAOiE;AAA5C,QADF,eAEE;AAAA,kBAAOrC;AAAP,QAFF;AAAA,MAtDN;AAAA,IADF;AA+DD,CApH6B,CAAvB;;;;AAnBLT,EAAAA,O;AACAC,EAAAA,K;AACAC,EAAAA,Q;AACAC,EAAAA,W;AACAC,EAAAA,c;AACAC,EAAAA,S;AAEAK,EAAAA,O;AAEAF,EAAAA,c,4BAAiB,O,EAAU,S;AAC3BC,EAAAA,iB;AAEAE,EAAAA,Y;AACAI,EAAAA,U;AACAH,EAAAA,kB;AACAC,EAAAA,c;AACAC,EAAAA,Y","sourcesContent":["import React from 'react';\nimport {ChipItem} from './ChipInputTypes';\nimport {Size} from '../types';\nimport {InputChip} from '../Chips';\nimport {ErrorMessage, WarningMessage} from '../InputFields/styling';\nimport {TechnicalWarning} from '../icons/systemicons/SystemIcons';\nimport {COLORS, ComponentMStyling, ComponentTextStyle, focusStyles, scrollBarStyling} from '../styles';\nimport styled from 'styled-components';\nimport {LoadingIndicator} from '../LoadingIndicator';\nimport {useActionWithin, useFocusVisibleRef} from '../common';\nimport {IconButton} from '../Button';\nimport {SystemIcons} from '../icons';\n\nconst Wrapper = styled.div`\n position: relative;\n`;\n\nconst Loading = styled.div`\n height: 20px;\n width: 20px;\n`;\n\n\nexport const ChipInputContentContainer = styled.div`\n width: 100%;\n background: transparent;\n display: flex;\n flex-direction: row;\n align-items: center;\n column-gap: 8px;\n margin-right: 6px;\n padding-right: 10px;\n padding-left: 16px;\n flex-wrap: nowrap;\n overflow-x: scroll;\n min-height: 48px;\n\n ${scrollBarStyling(Size.Small)}\n ::-webkit-scrollbar:horizontal {\n display: none;\n }\n\n .action-right:focus, button:focus {\n outline-offset: -4px !important;\n }\n`;\n\nexport const ChipInputContainer = styled.div`\n width: 100%;\n height: auto;\n border-radius: 4px;\n box-shadow: inset 0 0 0 1px ${COLORS.neutral_400};\n background-color: ${COLORS.white};\n box-sizing: border-box;\n cursor: text;\n outline: none;\n display: flex;\n align-items: center;\n\n ${ComponentMStyling(ComponentTextStyle.Regular, COLORS.black)}\n &.small {\n padding: 0;\n min-height: 48px;\n }\n\n &.medium {\n padding: 4px 0;\n min-height: 56px;\n }\n\n\n &.multiline.medium {\n ${ChipInputContentContainer} {\n max-height: calc(48px * 3);\n flex-wrap: wrap;\n overflow-y: auto;\n overflow-x: unset;\n }\n }\n\n &.focus-visible-within, :focus {\n ${focusStyles}\n }\n\n &:hover {\n box-shadow: inset 0 0 0 2px ${COLORS.primary_700};\n }\n\n &:focus-within {\n box-shadow: inset 0 0 0 2px ${COLORS.primary_800};\n }\n\n &.warning,\n &.warning:hover,\n &.warning:focus {\n box-shadow: inset 0 0 0 2px ${COLORS.warning_500};\n }\n\n &.error,\n &.error:hover,\n &.error:focus {\n box-shadow: inset 0 0 0 2px ${COLORS.critical_500};\n }\n\n &.disabled {\n ${ChipInputContentContainer} {\n pointer-events: none;\n }\n\n cursor: not-allowed;\n box-shadow: inset 0 0 0 1px ${COLORS.neutral_100};\n outline: none;\n color: ${COLORS.neutral_300} !important;\n }\n\n\n`;\n\nexport const ChipInputEl = styled.input`\n border: none;\n outline: none;\n\n height: 40px;\n min-width: 40px;\n display: inline-flex;\n flex: 1;\n background: transparent;\n\n ${ComponentMStyling(ComponentTextStyle.Regular, null)}\n color: ${COLORS.black} !important;\n`;\n\n\nexport interface ChipInputFieldProps {\n inputId: string;\n items: ChipItem[];\n disabled?: boolean;\n placeholder?: string;\n altPlaceholder?: string;\n multiLine?: boolean;\n size?: Size.Large | Size.Medium | Size.Small;\n loading?: boolean;\n\n validationType?: 'error' | 'warning';\n validationMessage?: string;\n\n onRemoveItem: (item: ChipItem, index: number) => void;\n inputValue: string;\n onInputValueChange: (value: string) => void;\n onInputKeyDown: (event: React.KeyboardEvent<HTMLInputElement>) => void;\n onActivation?: () => void;\n}\n\nexport const ChipInputField = React.forwardRef<HTMLInputElement, ChipInputFieldProps>(({\n inputId,\n items,\n disabled = false,\n placeholder,\n altPlaceholder,\n multiLine = true,\n size = Size.Medium,\n validationType,\n validationMessage,\n loading,\n onRemoveItem,\n onInputValueChange,\n onInputKeyDown,\n onActivation,\n inputValue\n }, ref) => {\n const containerRef = React.useRef<HTMLDivElement>(null);\n const inputRef = useFocusVisibleRef([containerRef], ref as any);\n\n const clearButtonRef = React.useRef<HTMLButtonElement>(null);\n\n /**\n * Scroll container to last item on change\n * */\n React.useEffect(() => {\n if (containerRef.current) {\n inputRef.current.scrollIntoView({\n block: 'nearest',\n inline: 'nearest',\n });\n }\n }, [containerRef, inputRef, items]);\n\n /**\n * Remove last cheap on backspace\n * */\n const handleInputKeyDown = (e: React.KeyboardEvent<HTMLInputElement>) => {\n onInputKeyDown(e);\n };\n\n const handleItemRemove = (event: any, item: ChipItem, index: number) => {\n onRemoveItem(item, index);\n inputRef.current?.focus({focusVisible: event.detail !== 1} as any);\n };\n\n const handleInputClear = (e: any) => {\n onInputValueChange('');\n inputRef.current?.focus({focusVisible: e?.detail !== 1} as any)\n };\n\n const cls = `${multiLine ? 'multiline' : ''} ${validationType || ''} ${size} ${loading ? 'loading' : ''} ${disabled ? 'disabled' : ''}`;\n\n return (\n <Wrapper>\n <ChipInputContainer ref={containerRef}\n id={inputId}\n onClick={() => !disabled && inputRef.current?.focus()}\n className={cls}>\n <ChipInputContentContainer>\n {items?.map((chip: ChipItem, index: number) => (\n <InputChip key={`chip_${index}`}\n icon={chip?.icon}\n size={size}\n disabled={chip.disabled || disabled}\n variant={chip.variant || 'normal'}\n text={chip.label}\n onRemove={(e) => handleItemRemove(e, chip, index)}/>\n ))}\n\n <ChipInputEl ref={inputRef}\n type=\"text\"\n tabIndex={disabled ? -1 : 0}\n value={inputValue}\n onChange={e => onInputValueChange(e.target.value)}\n onKeyDown={handleInputKeyDown}\n placeholder={items?.length === 0 ? placeholder : (altPlaceholder || '')}\n onClick={e => {\n e.stopPropagation();\n onActivation && onActivation();\n }}/>\n {\n inputValue && !disabled &&\n <IconButton action={handleInputClear}\n ref={clearButtonRef}\n useTransparentBackground={true}\n shape={'circular'}\n variant={'secondary'}>\n <SystemIcons.Clear/>\n </IconButton>\n }\n\n {loading &&\n <Loading className={size}>\n <LoadingIndicator size={Size.Small} color={COLORS.neutral_600}/>\n </Loading>\n }\n </ChipInputContentContainer>\n </ChipInputContainer>\n\n\n {validationMessage && validationType === 'warning' ? (\n <WarningMessage>\n <TechnicalWarning size=\"20px\" color={COLORS.critical_500}/>\n <span>{validationMessage}</span>\n </WarningMessage>\n ) : (\n validationType === 'error' && (\n <ErrorMessage>\n <TechnicalWarning size=\"20px\" color={COLORS.critical_400}/>\n <span>{validationMessage}</span>\n </ErrorMessage>\n )\n )}\n </Wrapper>\n );\n});\n"],"file":"ChipInputField.cjs"}
|
|
1
|
+
{"version":3,"sources":["../../src/ChipsInput/ChipInputField.tsx"],"names":["Wrapper","styled","div","Loading","ChipInputBoundItems","ChipInputContentContainer","Size","Small","ChipInputEl","input","ComponentTextStyle","Regular","COLORS","black","Italic","neutral_600","ChipInputContainer","neutral_400","white","focusStyles","primary_700","primary_800","critical_500","neutral_100","neutral_300","ChipInputField","React","forwardRef","ref","inputId","items","disabled","placeholder","altPlaceholder","multiLine","size","Medium","validationMessage","loading","onRemoveItem","onInputValueChange","onInputKeyDown","onActivationChange","inputValue","containerRef","useRef","inputRef","useEffect","current","scrollIntoView","block","inline","handleInputKeyDown","e","key","value","repeat","length","handleItemRemove","event","item","index","focus","focusVisible","detail","handleInputClear","handleContainerKeyDown","querySelectorAll","currentIndex","Array","from","indexOf","target","direction","cls","map","chip","icon","variant","label","stopPropagation","critical_400"],"mappings":";;;;;;;;;;;;;AAAA;;AAEA;;AACA;;AACA;;AACA;;AACA;;AAQA;;AACA;;AACA;;AACA;;AACA;;;;;;AAEA,IAAMA,OAAO,GAAGC,0BAAOC,GAAV,4GAAb;;AAIA,IAAMC,OAAO,GAAGF,0BAAOC,GAAV,wHAAb;;AAMO,IAAME,mBAAmB,GAAGH,0BAAOC,GAAV,sMAAzB;;;;AASA,IAAMG,yBAAyB,GAAGJ,0BAAOC,GAAV,4fAclC,8BAAiBI,YAAKC,KAAtB,CAdkC,CAA/B;;;;AAyBA,IAAMC,WAAW,GAAGP,0BAAOQ,KAAV,6SAUpB,+BAAkBC,2BAAmBC,OAArC,EAA8C,IAA9C,CAVoB,EAWbC,eAAOC,KAXM,EAclB,+BAAkBH,2BAAmBI,MAArC,EAA6CF,eAAOG,WAApD,CAdkB,CAAjB;;;;AAkBA,IAAMC,kBAAkB,GAAGf,0BAAOC,GAAV,ipCAICU,eAAOK,WAJR,EAKTL,eAAOM,KALE,EAY3B,+BAAkBR,2BAAmBC,OAArC,EAA8CC,eAAOC,KAArD,CAZ2B,EAiBzBL,WAjByB,EAkBvB,+BAAkBE,2BAAmBI,MAArC,EAA6CF,eAAOG,WAApD,CAlBuB,EA0BzBP,WA1ByB,EA2BvB,+BAAkBE,2BAAmBI,MAArC,EAA6CF,eAAOG,WAApD,CA3BuB,EAiCzBV,yBAjCyB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AAEqB,cAAL,CAAoB;AAClBC,gBAAAA,KAAK,EAAE,SADW;AAElBC,gBAAAA,MAAM,EAAE;AAFU,eAApB;AAID,aANb;AAOY,YAAA,wBAAwB,EAAE,IAPtC;AAQY,YAAA,KAAK,EAAE,UARnB;AASY,YAAA,OAAO,EAAE,WATrB;AAAA,mCAUE,qBAAC,kBAAD,CAAa,KAAb;AAVF,YAdJ,EA4BGb,OAAO,iBACN,qBAAC,OAAD;AAAS,YAAA,SAAS,EAAEH,IAApB;AAAA,mCACE,qBAAC,kCAAD;AAAkB,cAAA,IAAI,EAAE7B,YAAKC,KAA7B;AAAoC,cAAA,KAAK,EAAEK,eAAOG;AAAlD;AADF,YA7BJ;AAAA,UAVF;AAAA;AALF,MADF,EAuDIsB,iBAAiB,iBACjB,sBAAC,qBAAD;AAAA,8BACE,qBAAC,6BAAD;AAAkB,QAAA,IAAI,EAAC,MAAvB;AAA8B,QAAA,KAAK,EAAEzB,eAAOqE;AAA5C,QADF,eAEE;AAAA,kBAAO5C;AAAP,QAFF;AAAA,MAxDJ;AAAA,IADF;AAgED,CAlI6B,CAAvB;;;;AAlBLR,EAAAA,O;AACAC,EAAAA,K;AACAC,EAAAA,Q;AACAC,EAAAA,W;AACAC,EAAAA,c;AACAC,EAAAA,S;AAEAI,EAAAA,O;AAEAD,EAAAA,iB;AAEAE,EAAAA,Y;AACAI,EAAAA,U;AACAH,EAAAA,kB;AACAC,EAAAA,c;AACAC,EAAAA,kB","sourcesContent":["import React from 'react';\nimport {ChipItem} from './ChipInputTypes';\nimport {Size} from '../types';\nimport {InputChip} from '../Chips';\nimport {ErrorMessage} from '../InputFields/styling';\nimport {TechnicalWarning} from '../icons/systemicons/SystemIcons';\nimport {\n COLORS,\n ComponentMStyling,\n ComponentSStyling,\n ComponentTextStyle,\n focusStyles,\n scrollBarStyling\n} from '../styles';\nimport styled from 'styled-components';\nimport {LoadingIndicator} from '../LoadingIndicator';\nimport {useFocusVisibleRef} from '../common';\nimport {IconButton} from '../Button';\nimport {SystemIcons} from '../icons';\n\nconst Wrapper = styled.div`\n position: relative;\n`;\n\nconst Loading = styled.div`\n height: 20px;\n width: 20px;\n`;\n\n\nexport const ChipInputBoundItems = styled.div`\n display: flex;\n flex-direction: row;\n align-items: center;\n gap: 8px;\n flex: 1;\n min-width: 40px;\n`;\n\nexport const ChipInputContentContainer = styled.div`\n width: 100%;\n background: transparent;\n display: flex;\n flex-direction: row;\n align-items: center;\n column-gap: 8px;\n margin-right: 6px;\n padding-right: 10px;\n padding-left: 16px;\n flex-wrap: nowrap;\n overflow-x: scroll;\n min-height: 48px;\n\n ${scrollBarStyling(Size.Small)}\n ::-webkit-scrollbar:horizontal {\n display: none;\n }\n\n .action-right:focus, button:focus {\n outline-offset: -4px !important;\n }\n`;\n\n\nexport const ChipInputEl = styled.input`\n border: none;\n outline: none;\n\n height: 40px;\n min-width: 40px;\n display: inline-flex;\n flex: 1;\n background: transparent;\n\n ${ComponentMStyling(ComponentTextStyle.Regular, null)}\n color: ${COLORS.black} !important;\n\n &::placeholder {\n ${ComponentMStyling(ComponentTextStyle.Italic, COLORS.neutral_600)}\n }\n`;\n\nexport const ChipInputContainer = styled.div`\n width: 100%;\n height: auto;\n border-radius: 4px;\n box-shadow: inset 0 0 0 1px ${COLORS.neutral_400};\n background-color: ${COLORS.white};\n box-sizing: border-box;\n cursor: text;\n outline: none;\n display: flex;\n align-items: center;\n\n ${ComponentMStyling(ComponentTextStyle.Regular, COLORS.black)}\n &.small {\n padding: 0;\n min-height: 48px;\n\n ${ChipInputEl}::placeholder {\n ${ComponentSStyling(ComponentTextStyle.Italic, COLORS.neutral_600)}\n }\n }\n\n &.medium {\n padding: 4px 0;\n min-height: 56px;\n\n ${ChipInputEl}::placeholder {\n ${ComponentMStyling(ComponentTextStyle.Italic, COLORS.neutral_600)}\n }\n }\n\n\n &.multiline.medium {\n ${ChipInputContentContainer} {\n max-height: calc(48px * 3);\n flex-wrap: wrap;\n overflow-y: auto;\n overflow-x: unset;\n }\n }\n\n &.focus-visible-within, :focus {\n ${focusStyles}\n }\n\n &:hover {\n box-shadow: inset 0 0 0 2px ${COLORS.primary_700};\n }\n\n &:focus-within {\n box-shadow: inset 0 0 0 2px ${COLORS.primary_800};\n }\n\n &.invalid,\n &.invalid:hover,\n &.invalid:focus {\n box-shadow: inset 0 0 0 2px ${COLORS.critical_500};\n }\n\n &.disabled {\n ${ChipInputContentContainer} {\n pointer-events: none;\n }\n\n cursor: not-allowed;\n box-shadow: inset 0 0 0 1px ${COLORS.neutral_100};\n outline: none;\n color: ${COLORS.neutral_300} !important;\n }\n\n\n`;\n\n\nexport interface ChipInputFieldProps {\n inputId: string;\n items: ChipItem[];\n disabled?: boolean;\n placeholder?: string;\n altPlaceholder?: string;\n multiLine?: boolean;\n size?: Size.Large | Size.Medium | Size.Small;\n loading?: boolean;\n\n validationMessage?: string;\n\n onRemoveItem: (item: ChipItem, index: number) => void;\n inputValue: string;\n onInputValueChange: (value: string) => void;\n onInputKeyDown: (event: React.KeyboardEvent<HTMLInputElement>) => void;\n onActivationChange?: (active: boolean) => void;\n}\n\nexport const ChipInputField = React.forwardRef<HTMLInputElement, ChipInputFieldProps>(({\n inputId,\n items,\n disabled = false,\n placeholder,\n altPlaceholder,\n multiLine = true,\n size = Size.Medium,\n validationMessage,\n loading,\n onRemoveItem,\n onInputValueChange,\n onInputKeyDown,\n onActivationChange,\n inputValue\n }, ref) => {\n const containerRef = React.useRef<HTMLDivElement>(null);\n const inputRef = useFocusVisibleRef([containerRef], ref as any);\n\n /**\n * Scroll container to last item on change\n * */\n React.useEffect(() => {\n if (inputRef.current) {\n inputRef.current.scrollIntoView({\n block: 'nearest',\n inline: 'nearest',\n });\n }\n }, [containerRef, inputRef, items]);\n\n /**\n * Remove last cheap on backspace\n * */\n const handleInputKeyDown = (e: React.KeyboardEvent<HTMLInputElement>) => {\n if (e.key === 'Backspace' && !inputRef.current?.value && !e.repeat && items.length > 0) {\n onRemoveItem(items[items.length - 1], items.length - 1);\n } else {\n onInputKeyDown(e);\n }\n };\n\n const handleItemRemove = (event: any, item: ChipItem, index: number) => {\n onRemoveItem(item, index);\n inputRef.current?.focus({focusVisible: event.detail !== 1} as any);\n };\n\n const handleInputClear = (e: any) => {\n onInputValueChange('');\n inputRef.current?.focus({focusVisible: e?.detail !== 1} as any)\n };\n\n const handleContainerKeyDown = (e: React.KeyboardEvent) => {\n if (!containerRef.current || (e.key !== 'ArrowLeft' && e.key !== 'ArrowRight')) return;\n\n const items = containerRef.current.querySelectorAll('[tabindex=\"0\"]') as NodeListOf<HTMLElement>;\n const currentIndex = Array.from(items).indexOf(e.target as any);\n const direction = e.key === 'ArrowLeft' ? -1 : 1;\n const item = items[currentIndex + direction];\n item?.focus({focusVisible: true} as any);\n\n onActivationChange && onActivationChange(false);\n };\n\n const cls = `${multiLine ? 'multiline' : ''} ${validationMessage ? 'invalid' : ''} ${size} ${loading ? 'loading' : ''} ${disabled ? 'disabled' : ''}`;\n\n return (\n <Wrapper>\n <ChipInputContainer ref={containerRef}\n id={inputId}\n onKeyDown={handleContainerKeyDown}\n onClick={() => !disabled && inputRef.current?.focus()}\n className={cls}>\n <ChipInputContentContainer>\n {items?.map((chip: ChipItem, index: number) => (\n <InputChip key={`chip_${index}`}\n icon={chip?.icon}\n size={size}\n disabled={chip.disabled || disabled}\n variant={chip.variant || 'normal'}\n text={chip.label}\n onRemove={(e) => handleItemRemove(e, chip, index)}/>\n ))}\n <ChipInputBoundItems>\n <ChipInputEl ref={inputRef}\n type=\"text\"\n tabIndex={disabled ? -1 : 0}\n value={inputValue}\n onChange={e => onInputValueChange(e.target.value)}\n onKeyDown={handleInputKeyDown}\n placeholder={items?.length === 0 ? placeholder : (altPlaceholder || '')}\n onClick={e => {\n e.stopPropagation();\n onActivationChange && onActivationChange(true);\n }}/>\n {\n inputValue && !disabled &&\n <IconButton action={handleInputClear}\n ref={(ref) => {\n ref?.scrollIntoView({\n block: 'nearest',\n inline: 'nearest',\n });\n }}\n useTransparentBackground={true}\n shape={'circular'}\n variant={'secondary'}>\n <SystemIcons.Clear/>\n </IconButton>\n }\n\n {loading &&\n <Loading className={size}>\n <LoadingIndicator size={Size.Small} color={COLORS.neutral_600}/>\n </Loading>\n }\n </ChipInputBoundItems>\n </ChipInputContentContainer>\n </ChipInputContainer>\n\n\n {\n validationMessage &&\n <ErrorMessage>\n <TechnicalWarning size=\"20px\" color={COLORS.critical_400}/>\n <span>{validationMessage}</span>\n </ErrorMessage>\n }\n </Wrapper>\n );\n});\n"],"file":"ChipInputField.cjs"}
|
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
import { ChipItem } from './ChipInputTypes';
|
|
3
3
|
import { Size } from '../types';
|
|
4
|
+
export declare const ChipInputBoundItems: import("styled-components").StyledComponent<"div", any, {}, never>;
|
|
4
5
|
export declare const ChipInputContentContainer: import("styled-components").StyledComponent<"div", any, {}, never>;
|
|
5
|
-
export declare const ChipInputContainer: import("styled-components").StyledComponent<"div", any, {}, never>;
|
|
6
6
|
export declare const ChipInputEl: import("styled-components").StyledComponent<"input", any, {}, never>;
|
|
7
|
+
export declare const ChipInputContainer: import("styled-components").StyledComponent<"div", any, {}, never>;
|
|
7
8
|
export interface ChipInputFieldProps {
|
|
8
9
|
inputId: string;
|
|
9
10
|
items: ChipItem[];
|
|
@@ -13,12 +14,11 @@ export interface ChipInputFieldProps {
|
|
|
13
14
|
multiLine?: boolean;
|
|
14
15
|
size?: Size.Large | Size.Medium | Size.Small;
|
|
15
16
|
loading?: boolean;
|
|
16
|
-
validationType?: 'error' | 'warning';
|
|
17
17
|
validationMessage?: string;
|
|
18
18
|
onRemoveItem: (item: ChipItem, index: number) => void;
|
|
19
19
|
inputValue: string;
|
|
20
20
|
onInputValueChange: (value: string) => void;
|
|
21
21
|
onInputKeyDown: (event: React.KeyboardEvent<HTMLInputElement>) => void;
|
|
22
|
-
|
|
22
|
+
onActivationChange?: (active: boolean) => void;
|
|
23
23
|
}
|
|
24
24
|
export declare const ChipInputField: React.ForwardRefExoticComponent<ChipInputFieldProps & React.RefAttributes<HTMLInputElement>>;
|
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
import _taggedTemplateLiteral from "@babel/runtime/helpers/esm/taggedTemplateLiteral";
|
|
2
2
|
import _pt from "prop-types";
|
|
3
3
|
|
|
4
|
-
var _templateObject, _templateObject2, _templateObject3, _templateObject4, _templateObject5;
|
|
4
|
+
var _templateObject, _templateObject2, _templateObject3, _templateObject4, _templateObject5, _templateObject6;
|
|
5
5
|
|
|
6
6
|
import React from 'react';
|
|
7
7
|
import { Size } from '../types';
|
|
8
8
|
import { InputChip } from '../Chips';
|
|
9
|
-
import { ErrorMessage
|
|
9
|
+
import { ErrorMessage } from '../InputFields/styling';
|
|
10
10
|
import { TechnicalWarning } from '../icons/systemicons/SystemIcons';
|
|
11
|
-
import { COLORS, ComponentMStyling, ComponentTextStyle, focusStyles, scrollBarStyling } from '../styles';
|
|
11
|
+
import { COLORS, ComponentMStyling, ComponentSStyling, ComponentTextStyle, focusStyles, scrollBarStyling } from '../styles';
|
|
12
12
|
import styled from 'styled-components';
|
|
13
13
|
import { LoadingIndicator } from '../LoadingIndicator';
|
|
14
14
|
import { useFocusVisibleRef } from '../common';
|
|
@@ -18,9 +18,10 @@ import { jsx as _jsx } from "react/jsx-runtime";
|
|
|
18
18
|
import { jsxs as _jsxs } from "react/jsx-runtime";
|
|
19
19
|
var Wrapper = styled.div(_templateObject || (_templateObject = _taggedTemplateLiteral(["\n position: relative;\n"])));
|
|
20
20
|
var Loading = styled.div(_templateObject2 || (_templateObject2 = _taggedTemplateLiteral(["\n height: 20px;\n width: 20px;\n"])));
|
|
21
|
-
export var
|
|
22
|
-
export var
|
|
23
|
-
export var ChipInputEl = styled.input(_templateObject5 || (_templateObject5 = _taggedTemplateLiteral(["\n border: none;\n outline: none;\n\n height: 40px;\n min-width: 40px;\n display: inline-flex;\n flex: 1;\n background: transparent;\n\n ", "\n color: ", " !important;\n"])), ComponentMStyling(ComponentTextStyle.Regular, null), COLORS.black);
|
|
21
|
+
export var ChipInputBoundItems = styled.div(_templateObject3 || (_templateObject3 = _taggedTemplateLiteral(["\n display: flex;\n flex-direction: row;\n align-items: center;\n gap: 8px;\n flex: 1;\n min-width: 40px;\n"])));
|
|
22
|
+
export var ChipInputContentContainer = styled.div(_templateObject4 || (_templateObject4 = _taggedTemplateLiteral(["\n width: 100%;\n background: transparent;\n display: flex;\n flex-direction: row;\n align-items: center;\n column-gap: 8px;\n margin-right: 6px;\n padding-right: 10px;\n padding-left: 16px;\n flex-wrap: nowrap;\n overflow-x: scroll;\n min-height: 48px;\n\n ", "\n ::-webkit-scrollbar:horizontal {\n display: none;\n }\n\n .action-right:focus, button:focus {\n outline-offset: -4px !important;\n }\n"])), scrollBarStyling(Size.Small));
|
|
23
|
+
export var ChipInputEl = styled.input(_templateObject5 || (_templateObject5 = _taggedTemplateLiteral(["\n border: none;\n outline: none;\n\n height: 40px;\n min-width: 40px;\n display: inline-flex;\n flex: 1;\n background: transparent;\n\n ", "\n color: ", " !important;\n\n &::placeholder {\n ", "\n }\n"])), ComponentMStyling(ComponentTextStyle.Regular, null), COLORS.black, ComponentMStyling(ComponentTextStyle.Italic, COLORS.neutral_600));
|
|
24
|
+
export var ChipInputContainer = styled.div(_templateObject6 || (_templateObject6 = _taggedTemplateLiteral(["\n width: 100%;\n height: auto;\n border-radius: 4px;\n box-shadow: inset 0 0 0 1px ", ";\n background-color: ", ";\n box-sizing: border-box;\n cursor: text;\n outline: none;\n display: flex;\n align-items: center;\n\n ", "\n &.small {\n padding: 0;\n min-height: 48px;\n\n ", "::placeholder {\n ", "\n }\n }\n\n &.medium {\n padding: 4px 0;\n min-height: 56px;\n\n ", "::placeholder {\n ", "\n }\n }\n\n\n &.multiline.medium {\n ", " {\n max-height: calc(48px * 3);\n flex-wrap: wrap;\n overflow-y: auto;\n overflow-x: unset;\n }\n }\n\n &.focus-visible-within, :focus {\n ", "\n }\n\n &:hover {\n box-shadow: inset 0 0 0 2px ", ";\n }\n\n &:focus-within {\n box-shadow: inset 0 0 0 2px ", ";\n }\n\n &.invalid,\n &.invalid:hover,\n &.invalid:focus {\n box-shadow: inset 0 0 0 2px ", ";\n }\n\n &.disabled {\n ", " {\n pointer-events: none;\n }\n\n cursor: not-allowed;\n box-shadow: inset 0 0 0 1px ", ";\n outline: none;\n color: ", " !important;\n }\n\n\n"])), COLORS.neutral_400, COLORS.white, ComponentMStyling(ComponentTextStyle.Regular, COLORS.black), ChipInputEl, ComponentSStyling(ComponentTextStyle.Italic, COLORS.neutral_600), ChipInputEl, ComponentMStyling(ComponentTextStyle.Italic, COLORS.neutral_600), ChipInputContentContainer, focusStyles, COLORS.primary_700, COLORS.primary_800, COLORS.critical_500, ChipInputContentContainer, COLORS.neutral_100, COLORS.neutral_300);
|
|
24
25
|
export var ChipInputField = /*#__PURE__*/React.forwardRef(function (_ref, ref) {
|
|
25
26
|
var inputId = _ref.inputId,
|
|
26
27
|
items = _ref.items,
|
|
@@ -32,23 +33,21 @@ export var ChipInputField = /*#__PURE__*/React.forwardRef(function (_ref, ref) {
|
|
|
32
33
|
multiLine = _ref$multiLine === void 0 ? true : _ref$multiLine,
|
|
33
34
|
_ref$size = _ref.size,
|
|
34
35
|
size = _ref$size === void 0 ? Size.Medium : _ref$size,
|
|
35
|
-
validationType = _ref.validationType,
|
|
36
36
|
validationMessage = _ref.validationMessage,
|
|
37
37
|
loading = _ref.loading,
|
|
38
38
|
onRemoveItem = _ref.onRemoveItem,
|
|
39
39
|
onInputValueChange = _ref.onInputValueChange,
|
|
40
40
|
onInputKeyDown = _ref.onInputKeyDown,
|
|
41
|
-
|
|
41
|
+
onActivationChange = _ref.onActivationChange,
|
|
42
42
|
inputValue = _ref.inputValue;
|
|
43
43
|
var containerRef = React.useRef(null);
|
|
44
44
|
var inputRef = useFocusVisibleRef([containerRef], ref);
|
|
45
|
-
var clearButtonRef = React.useRef(null);
|
|
46
45
|
/**
|
|
47
46
|
* Scroll container to last item on change
|
|
48
47
|
* */
|
|
49
48
|
|
|
50
49
|
React.useEffect(function () {
|
|
51
|
-
if (
|
|
50
|
+
if (inputRef.current) {
|
|
52
51
|
inputRef.current.scrollIntoView({
|
|
53
52
|
block: 'nearest',
|
|
54
53
|
inline: 'nearest'
|
|
@@ -60,36 +59,55 @@ export var ChipInputField = /*#__PURE__*/React.forwardRef(function (_ref, ref) {
|
|
|
60
59
|
* */
|
|
61
60
|
|
|
62
61
|
var handleInputKeyDown = function handleInputKeyDown(e) {
|
|
63
|
-
|
|
62
|
+
var _inputRef$current;
|
|
63
|
+
|
|
64
|
+
if (e.key === 'Backspace' && !((_inputRef$current = inputRef.current) !== null && _inputRef$current !== void 0 && _inputRef$current.value) && !e.repeat && items.length > 0) {
|
|
65
|
+
onRemoveItem(items[items.length - 1], items.length - 1);
|
|
66
|
+
} else {
|
|
67
|
+
onInputKeyDown(e);
|
|
68
|
+
}
|
|
64
69
|
};
|
|
65
70
|
|
|
66
71
|
var handleItemRemove = function handleItemRemove(event, item, index) {
|
|
67
|
-
var _inputRef$
|
|
72
|
+
var _inputRef$current2;
|
|
68
73
|
|
|
69
74
|
onRemoveItem(item, index);
|
|
70
|
-
(_inputRef$
|
|
75
|
+
(_inputRef$current2 = inputRef.current) === null || _inputRef$current2 === void 0 ? void 0 : _inputRef$current2.focus({
|
|
71
76
|
focusVisible: event.detail !== 1
|
|
72
77
|
});
|
|
73
78
|
};
|
|
74
79
|
|
|
75
80
|
var handleInputClear = function handleInputClear(e) {
|
|
76
|
-
var _inputRef$
|
|
81
|
+
var _inputRef$current3;
|
|
77
82
|
|
|
78
83
|
onInputValueChange('');
|
|
79
|
-
(_inputRef$
|
|
84
|
+
(_inputRef$current3 = inputRef.current) === null || _inputRef$current3 === void 0 ? void 0 : _inputRef$current3.focus({
|
|
80
85
|
focusVisible: (e === null || e === void 0 ? void 0 : e.detail) !== 1
|
|
81
86
|
});
|
|
82
87
|
};
|
|
83
88
|
|
|
84
|
-
var
|
|
89
|
+
var handleContainerKeyDown = function handleContainerKeyDown(e) {
|
|
90
|
+
if (!containerRef.current || e.key !== 'ArrowLeft' && e.key !== 'ArrowRight') return;
|
|
91
|
+
var items = containerRef.current.querySelectorAll('[tabindex="0"]');
|
|
92
|
+
var currentIndex = Array.from(items).indexOf(e.target);
|
|
93
|
+
var direction = e.key === 'ArrowLeft' ? -1 : 1;
|
|
94
|
+
var item = items[currentIndex + direction];
|
|
95
|
+
item === null || item === void 0 ? void 0 : item.focus({
|
|
96
|
+
focusVisible: true
|
|
97
|
+
});
|
|
98
|
+
onActivationChange && onActivationChange(false);
|
|
99
|
+
};
|
|
100
|
+
|
|
101
|
+
var cls = "".concat(multiLine ? 'multiline' : '', " ").concat(validationMessage ? 'invalid' : '', " ").concat(size, " ").concat(loading ? 'loading' : '', " ").concat(disabled ? 'disabled' : '');
|
|
85
102
|
return /*#__PURE__*/_jsxs(Wrapper, {
|
|
86
103
|
children: [/*#__PURE__*/_jsx(ChipInputContainer, {
|
|
87
104
|
ref: containerRef,
|
|
88
105
|
id: inputId,
|
|
106
|
+
onKeyDown: handleContainerKeyDown,
|
|
89
107
|
onClick: function onClick() {
|
|
90
|
-
var _inputRef$
|
|
108
|
+
var _inputRef$current4;
|
|
91
109
|
|
|
92
|
-
return !disabled && ((_inputRef$
|
|
110
|
+
return !disabled && ((_inputRef$current4 = inputRef.current) === null || _inputRef$current4 === void 0 ? void 0 : _inputRef$current4.focus());
|
|
93
111
|
},
|
|
94
112
|
className: cls,
|
|
95
113
|
children: /*#__PURE__*/_jsxs(ChipInputContentContainer, {
|
|
@@ -104,43 +122,43 @@ export var ChipInputField = /*#__PURE__*/React.forwardRef(function (_ref, ref) {
|
|
|
104
122
|
return handleItemRemove(e, chip, index);
|
|
105
123
|
}
|
|
106
124
|
}, "chip_".concat(index));
|
|
107
|
-
}), /*#__PURE__*/
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
e
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
125
|
+
}), /*#__PURE__*/_jsxs(ChipInputBoundItems, {
|
|
126
|
+
children: [/*#__PURE__*/_jsx(ChipInputEl, {
|
|
127
|
+
ref: inputRef,
|
|
128
|
+
type: "text",
|
|
129
|
+
tabIndex: disabled ? -1 : 0,
|
|
130
|
+
value: inputValue,
|
|
131
|
+
onChange: function onChange(e) {
|
|
132
|
+
return onInputValueChange(e.target.value);
|
|
133
|
+
},
|
|
134
|
+
onKeyDown: handleInputKeyDown,
|
|
135
|
+
placeholder: (items === null || items === void 0 ? void 0 : items.length) === 0 ? placeholder : altPlaceholder || '',
|
|
136
|
+
onClick: function onClick(e) {
|
|
137
|
+
e.stopPropagation();
|
|
138
|
+
onActivationChange && onActivationChange(true);
|
|
139
|
+
}
|
|
140
|
+
}), inputValue && !disabled && /*#__PURE__*/_jsx(IconButton, {
|
|
141
|
+
action: handleInputClear,
|
|
142
|
+
ref: function ref(_ref2) {
|
|
143
|
+
_ref2 === null || _ref2 === void 0 ? void 0 : _ref2.scrollIntoView({
|
|
144
|
+
block: 'nearest',
|
|
145
|
+
inline: 'nearest'
|
|
146
|
+
});
|
|
147
|
+
},
|
|
148
|
+
useTransparentBackground: true,
|
|
149
|
+
shape: 'circular',
|
|
150
|
+
variant: 'secondary',
|
|
151
|
+
children: /*#__PURE__*/_jsx(SystemIcons.Clear, {})
|
|
152
|
+
}), loading && /*#__PURE__*/_jsx(Loading, {
|
|
153
|
+
className: size,
|
|
154
|
+
children: /*#__PURE__*/_jsx(LoadingIndicator, {
|
|
155
|
+
size: Size.Small,
|
|
156
|
+
color: COLORS.neutral_600
|
|
157
|
+
})
|
|
158
|
+
})]
|
|
134
159
|
})]
|
|
135
160
|
})
|
|
136
|
-
}), validationMessage &&
|
|
137
|
-
children: [/*#__PURE__*/_jsx(TechnicalWarning, {
|
|
138
|
-
size: "20px",
|
|
139
|
-
color: COLORS.critical_500
|
|
140
|
-
}), /*#__PURE__*/_jsx("span", {
|
|
141
|
-
children: validationMessage
|
|
142
|
-
})]
|
|
143
|
-
}) : validationType === 'error' && /*#__PURE__*/_jsxs(ErrorMessage, {
|
|
161
|
+
}), validationMessage && /*#__PURE__*/_jsxs(ErrorMessage, {
|
|
144
162
|
children: [/*#__PURE__*/_jsx(TechnicalWarning, {
|
|
145
163
|
size: "20px",
|
|
146
164
|
color: COLORS.critical_400
|
|
@@ -158,12 +176,11 @@ ChipInputField.propTypes = {
|
|
|
158
176
|
altPlaceholder: _pt.string,
|
|
159
177
|
multiLine: _pt.bool,
|
|
160
178
|
loading: _pt.bool,
|
|
161
|
-
validationType: _pt.oneOf(['error', 'warning']),
|
|
162
179
|
validationMessage: _pt.string,
|
|
163
180
|
onRemoveItem: _pt.func.isRequired,
|
|
164
181
|
inputValue: _pt.string.isRequired,
|
|
165
182
|
onInputValueChange: _pt.func.isRequired,
|
|
166
183
|
onInputKeyDown: _pt.func.isRequired,
|
|
167
|
-
|
|
184
|
+
onActivationChange: _pt.func
|
|
168
185
|
};
|
|
169
186
|
//# sourceMappingURL=ChipInputField.js.map
|