@laerdal/life-react-components 1.7.0-dev.20.full → 1.7.0-dev.22

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (58) hide show
  1. package/dist/Chips/InputChip.cjs +16 -7
  2. package/dist/Chips/InputChip.cjs.map +1 -1
  3. package/dist/Chips/InputChip.js +15 -7
  4. package/dist/Chips/InputChip.js.map +1 -1
  5. package/dist/ChipsInput/ChipDropdownInput.cjs +2 -2
  6. package/dist/ChipsInput/ChipDropdownInput.cjs.map +1 -1
  7. package/dist/ChipsInput/ChipDropdownInput.js +2 -2
  8. package/dist/ChipsInput/ChipDropdownInput.js.map +1 -1
  9. package/dist/ChipsInput/ChipInputField.cjs +77 -50
  10. package/dist/ChipsInput/ChipInputField.cjs.map +1 -1
  11. package/dist/ChipsInput/ChipInputField.d.ts +3 -2
  12. package/dist/ChipsInput/ChipInputField.js +72 -46
  13. package/dist/ChipsInput/ChipInputField.js.map +1 -1
  14. package/dist/MenuItem/MenuItem.cjs +1 -1
  15. package/dist/MenuItem/MenuItem.cjs.map +1 -1
  16. package/dist/MenuItem/MenuItem.js +1 -1
  17. package/dist/MenuItem/MenuItem.js.map +1 -1
  18. package/dist/Tile/Tile.cjs +61 -0
  19. package/dist/Tile/Tile.cjs.map +1 -0
  20. package/dist/Tile/Tile.d.ts +4 -0
  21. package/dist/Tile/Tile.js +43 -0
  22. package/dist/Tile/Tile.js.map +1 -0
  23. package/dist/Tile/TileBody.cjs +37 -0
  24. package/dist/Tile/TileBody.cjs.map +1 -0
  25. package/dist/Tile/TileBody.d.ts +6 -0
  26. package/dist/Tile/TileBody.js +22 -0
  27. package/dist/Tile/TileBody.js.map +1 -0
  28. package/dist/Tile/TileCommonItems.cjs +164 -0
  29. package/dist/Tile/TileCommonItems.cjs.map +1 -0
  30. package/dist/Tile/TileCommonItems.d.ts +9 -0
  31. package/dist/Tile/TileCommonItems.js +125 -0
  32. package/dist/Tile/TileCommonItems.js.map +1 -0
  33. package/dist/Tile/TileFooter.cjs +48 -0
  34. package/dist/Tile/TileFooter.cjs.map +1 -0
  35. package/dist/Tile/TileFooter.d.ts +7 -0
  36. package/dist/Tile/TileFooter.js +32 -0
  37. package/dist/Tile/TileFooter.js.map +1 -0
  38. package/dist/Tile/TileHeader.cjs +90 -0
  39. package/dist/Tile/TileHeader.cjs.map +1 -0
  40. package/dist/Tile/TileHeader.d.ts +7 -0
  41. package/dist/Tile/TileHeader.js +68 -0
  42. package/dist/Tile/TileHeader.js.map +1 -0
  43. package/dist/Tile/TileTypes.cjs +6 -0
  44. package/dist/Tile/TileTypes.cjs.map +1 -0
  45. package/dist/Tile/TileTypes.d.ts +57 -0
  46. package/dist/Tile/TileTypes.js +2 -0
  47. package/dist/Tile/TileTypes.js.map +1 -0
  48. package/dist/Tile/index.cjs +33 -0
  49. package/dist/Tile/index.cjs.map +1 -0
  50. package/dist/Tile/index.d.ts +3 -0
  51. package/dist/Tile/index.js +4 -0
  52. package/dist/Tile/index.js.map +1 -0
  53. package/dist/index.cjs +14 -0
  54. package/dist/index.cjs.map +1 -1
  55. package/dist/index.d.ts +1 -0
  56. package/dist/index.js +1 -0
  57. package/dist/index.js.map +1 -1
  58. 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 ChipInputContentContainer = _styledComponents.default.div(_templateObject3 || (_templateObject3 = (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));
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.ChipInputContentContainer = ChipInputContentContainer;
46
+ exports.ChipInputBoundItems = ChipInputBoundItems;
47
47
 
48
- var ChipInputContainer = _styledComponents.default.div(_templateObject4 || (_templateObject4 = (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\n &.medium {\n padding: 4px 0;\n min-height: 56px;\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 &.warning,\n &.warning:hover,\n &.warning:focus {\n box-shadow: inset 0 0 0 2px ", ";\n }\n\n &.error,\n &.error:hover,\n &.error: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), ChipInputContentContainer, _styles.focusStyles, _styles.COLORS.primary_700, _styles.COLORS.primary_800, _styles.COLORS.warning_500, _styles.COLORS.critical_500, ChipInputContentContainer, _styles.COLORS.neutral_100, _styles.COLORS.neutral_300);
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.ChipInputContainer = ChipInputContainer;
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 &.warning,\n &.warning:hover,\n &.warning:focus {\n box-shadow: inset 0 0 0 2px ", ";\n }\n\n &.error,\n &.error:hover,\n &.error: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.warning_500, _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,
@@ -70,21 +74,18 @@ var ChipInputField = /*#__PURE__*/_react.default.forwardRef(function (_ref, ref)
70
74
  onRemoveItem = _ref.onRemoveItem,
71
75
  onInputValueChange = _ref.onInputValueChange,
72
76
  onInputKeyDown = _ref.onInputKeyDown,
73
- onActivation = _ref.onActivation,
77
+ onActivationChange = _ref.onActivationChange,
74
78
  inputValue = _ref.inputValue;
75
79
 
76
80
  var containerRef = _react.default.useRef(null);
77
81
 
78
82
  var inputRef = (0, _common.useFocusVisibleRef)([containerRef], ref);
79
-
80
- var clearButtonRef = _react.default.useRef(null);
81
83
  /**
82
84
  * Scroll container to last item on change
83
85
  * */
84
86
 
85
-
86
87
  _react.default.useEffect(function () {
87
- if (containerRef.current) {
88
+ if (inputRef.current) {
88
89
  inputRef.current.scrollIntoView({
89
90
  block: 'nearest',
90
91
  inline: 'nearest'
@@ -97,36 +98,55 @@ var ChipInputField = /*#__PURE__*/_react.default.forwardRef(function (_ref, ref)
97
98
 
98
99
 
99
100
  var handleInputKeyDown = function handleInputKeyDown(e) {
100
- onInputKeyDown(e);
101
+ var _inputRef$current;
102
+
103
+ if (e.key === 'Backspace' && !((_inputRef$current = inputRef.current) !== null && _inputRef$current !== void 0 && _inputRef$current.value) && !e.repeat && items.length > 0) {
104
+ onRemoveItem(items[items.length - 1], items.length - 1);
105
+ } else {
106
+ onInputKeyDown(e);
107
+ }
101
108
  };
102
109
 
103
110
  var handleItemRemove = function handleItemRemove(event, item, index) {
104
- var _inputRef$current;
111
+ var _inputRef$current2;
105
112
 
106
113
  onRemoveItem(item, index);
107
- (_inputRef$current = inputRef.current) === null || _inputRef$current === void 0 ? void 0 : _inputRef$current.focus({
114
+ (_inputRef$current2 = inputRef.current) === null || _inputRef$current2 === void 0 ? void 0 : _inputRef$current2.focus({
108
115
  focusVisible: event.detail !== 1
109
116
  });
110
117
  };
111
118
 
112
119
  var handleInputClear = function handleInputClear(e) {
113
- var _inputRef$current2;
120
+ var _inputRef$current3;
114
121
 
115
122
  onInputValueChange('');
116
- (_inputRef$current2 = inputRef.current) === null || _inputRef$current2 === void 0 ? void 0 : _inputRef$current2.focus({
123
+ (_inputRef$current3 = inputRef.current) === null || _inputRef$current3 === void 0 ? void 0 : _inputRef$current3.focus({
117
124
  focusVisible: (e === null || e === void 0 ? void 0 : e.detail) !== 1
118
125
  });
119
126
  };
120
127
 
128
+ var handleContainerKeyDown = function handleContainerKeyDown(e) {
129
+ if (!containerRef.current || e.key !== 'ArrowLeft' && e.key !== 'ArrowRight') return;
130
+ var items = containerRef.current.querySelectorAll('[tabindex="0"]');
131
+ var currentIndex = Array.from(items).indexOf(e.target);
132
+ var direction = e.key === 'ArrowLeft' ? -1 : 1;
133
+ var item = items[currentIndex + direction];
134
+ item === null || item === void 0 ? void 0 : item.focus({
135
+ focusVisible: true
136
+ });
137
+ onActivationChange && onActivationChange(false);
138
+ };
139
+
121
140
  var cls = "".concat(multiLine ? 'multiline' : '', " ").concat(validationType || '', " ").concat(size, " ").concat(loading ? 'loading' : '', " ").concat(disabled ? 'disabled' : '');
122
141
  return /*#__PURE__*/(0, _jsxRuntime.jsxs)(Wrapper, {
123
142
  children: [/*#__PURE__*/(0, _jsxRuntime.jsx)(ChipInputContainer, {
124
143
  ref: containerRef,
125
144
  id: inputId,
145
+ onKeyDown: handleContainerKeyDown,
126
146
  onClick: function onClick() {
127
- var _inputRef$current3;
147
+ var _inputRef$current4;
128
148
 
129
- return !disabled && ((_inputRef$current3 = inputRef.current) === null || _inputRef$current3 === void 0 ? void 0 : _inputRef$current3.focus());
149
+ return !disabled && ((_inputRef$current4 = inputRef.current) === null || _inputRef$current4 === void 0 ? void 0 : _inputRef$current4.focus());
130
150
  },
131
151
  className: cls,
132
152
  children: /*#__PURE__*/(0, _jsxRuntime.jsxs)(ChipInputContentContainer, {
@@ -141,36 +161,43 @@ var ChipInputField = /*#__PURE__*/_react.default.forwardRef(function (_ref, ref)
141
161
  return handleItemRemove(e, chip, index);
142
162
  }
143
163
  }, "chip_".concat(index));
144
- }), /*#__PURE__*/(0, _jsxRuntime.jsx)(ChipInputEl, {
145
- ref: inputRef,
146
- type: "text",
147
- tabIndex: disabled ? -1 : 0,
148
- value: inputValue,
149
- onChange: function onChange(e) {
150
- return onInputValueChange(e.target.value);
151
- },
152
- onKeyDown: handleInputKeyDown,
153
- placeholder: (items === null || items === void 0 ? void 0 : items.length) === 0 ? placeholder : altPlaceholder || '',
154
- onClick: function onClick(e) {
155
- e.stopPropagation();
156
- onActivation && onActivation();
157
- }
158
- }), inputValue && !disabled && /*#__PURE__*/(0, _jsxRuntime.jsx)(_Button.IconButton, {
159
- action: handleInputClear,
160
- ref: clearButtonRef,
161
- useTransparentBackground: true,
162
- shape: 'circular',
163
- style: {
164
- marginLeft: '-8px'
165
- },
166
- variant: 'secondary',
167
- children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_icons.SystemIcons.Clear, {})
168
- }), loading && /*#__PURE__*/(0, _jsxRuntime.jsx)(Loading, {
169
- className: size,
170
- children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_LoadingIndicator.LoadingIndicator, {
171
- size: _types.Size.Small,
172
- color: _styles.COLORS.neutral_600
173
- })
164
+ }), /*#__PURE__*/(0, _jsxRuntime.jsxs)(ChipInputBoundItems, {
165
+ children: [/*#__PURE__*/(0, _jsxRuntime.jsx)(ChipInputEl, {
166
+ ref: inputRef,
167
+ type: "text",
168
+ tabIndex: disabled ? -1 : 0,
169
+ value: inputValue,
170
+ onChange: function onChange(e) {
171
+ return onInputValueChange(e.target.value);
172
+ },
173
+ onKeyDown: handleInputKeyDown,
174
+ placeholder: (items === null || items === void 0 ? void 0 : items.length) === 0 ? placeholder : altPlaceholder || '',
175
+ onClick: function onClick(e) {
176
+ e.stopPropagation();
177
+ onActivationChange && onActivationChange(true);
178
+ }
179
+ }), inputValue && !disabled && /*#__PURE__*/(0, _jsxRuntime.jsx)(_Button.IconButton, {
180
+ action: handleInputClear,
181
+ ref: function ref(_ref2) {
182
+ _ref2 === null || _ref2 === void 0 ? void 0 : _ref2.scrollIntoView({
183
+ block: 'nearest',
184
+ inline: 'nearest'
185
+ });
186
+ },
187
+ useTransparentBackground: true,
188
+ shape: 'circular',
189
+ style: {
190
+ marginLeft: '-8px'
191
+ },
192
+ variant: 'secondary',
193
+ children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_icons.SystemIcons.Clear, {})
194
+ }), loading && /*#__PURE__*/(0, _jsxRuntime.jsx)(Loading, {
195
+ className: size,
196
+ children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_LoadingIndicator.LoadingIndicator, {
197
+ size: _types.Size.Small,
198
+ color: _styles.COLORS.neutral_600
199
+ })
200
+ })]
174
201
  })]
175
202
  })
176
203
  }), validationMessage && validationType === 'warning' ? /*#__PURE__*/(0, _jsxRuntime.jsxs)(_styling.WarningMessage, {
@@ -206,6 +233,6 @@ ChipInputField.propTypes = {
206
233
  inputValue: _propTypes.default.string.isRequired,
207
234
  onInputValueChange: _propTypes.default.func.isRequired,
208
235
  onInputKeyDown: _propTypes.default.func.isRequired,
209
- onActivation: _propTypes.default.func
236
+ onActivationChange: _propTypes.default.func
210
237
  };
211
238
  //# 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","marginLeft","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,KAXM,CAAjB;;;;AAmCA,IAAMU,cAAc,gBAAGC,eAAMC,UAAN,CAA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Ab,WAJnB;AAKY,UAAA,OAAO,EAAE,WALrB;AAAA,iCAME,qBAAC,kBAAD,CAAa,KAAb;AANF,UAxBJ,EAkCGnC,OAAO,iBACN,qBAAC,OAAD;AAAS,UAAA,SAAS,EAAEJ,IAApB;AAAA,iCACE,qBAAC,kCAAD;AAAkB,YAAA,IAAI,EAAE5B,YAAKC,KAA7B;AAAoC,YAAA,KAAK,EAAEE,eAAOiE;AAAlD;AADF,UAnCJ;AAAA;AAJF,MADF,EAgDGrC,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,eAAOkE;AAA5C,QADF,eAEE;AAAA,kBAAOtC;AAAP,QAFF;AAAA,MAvDN;AAAA,IADF;AAgED,CArH6B,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 style={{marginLeft: '-8px'}}\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","warning_500","critical_500","neutral_100","neutral_300","ChipInputField","React","forwardRef","ref","inputId","items","disabled","placeholder","altPlaceholder","multiLine","size","Medium","validationType","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","marginLeft","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,gvCAICU,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,eAAO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A,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, WarningMessage} 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 {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 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 &.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\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 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 validationType,\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' : ''} ${validationType || ''} ${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 style={{marginLeft: '-8px'}}\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 {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,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[];
@@ -19,6 +20,6 @@ export interface ChipInputFieldProps {
19
20
  inputValue: string;
20
21
  onInputValueChange: (value: string) => void;
21
22
  onInputKeyDown: (event: React.KeyboardEvent<HTMLInputElement>) => void;
22
- onActivation?: () => void;
23
+ onActivationChange?: (active: boolean) => void;
23
24
  }
24
25
  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
9
  import { ErrorMessage, WarningMessage } 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 ChipInputContentContainer = styled.div(_templateObject3 || (_templateObject3 = _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));
22
- export var ChipInputContainer = styled.div(_templateObject4 || (_templateObject4 = _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\n &.medium {\n padding: 4px 0;\n min-height: 56px;\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 &.warning,\n &.warning:hover,\n &.warning:focus {\n box-shadow: inset 0 0 0 2px ", ";\n }\n\n &.error,\n &.error:hover,\n &.error: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), ChipInputContentContainer, focusStyles, COLORS.primary_700, COLORS.primary_800, COLORS.warning_500, COLORS.critical_500, ChipInputContentContainer, COLORS.neutral_100, COLORS.neutral_300);
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 &.warning,\n &.warning:hover,\n &.warning:focus {\n box-shadow: inset 0 0 0 2px ", ";\n }\n\n &.error,\n &.error:hover,\n &.error: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.warning_500, 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,
@@ -38,17 +39,16 @@ export var ChipInputField = /*#__PURE__*/React.forwardRef(function (_ref, ref) {
38
39
  onRemoveItem = _ref.onRemoveItem,
39
40
  onInputValueChange = _ref.onInputValueChange,
40
41
  onInputKeyDown = _ref.onInputKeyDown,
41
- onActivation = _ref.onActivation,
42
+ onActivationChange = _ref.onActivationChange,
42
43
  inputValue = _ref.inputValue;
43
44
  var containerRef = React.useRef(null);
44
45
  var inputRef = useFocusVisibleRef([containerRef], ref);
45
- var clearButtonRef = React.useRef(null);
46
46
  /**
47
47
  * Scroll container to last item on change
48
48
  * */
49
49
 
50
50
  React.useEffect(function () {
51
- if (containerRef.current) {
51
+ if (inputRef.current) {
52
52
  inputRef.current.scrollIntoView({
53
53
  block: 'nearest',
54
54
  inline: 'nearest'
@@ -60,36 +60,55 @@ export var ChipInputField = /*#__PURE__*/React.forwardRef(function (_ref, ref) {
60
60
  * */
61
61
 
62
62
  var handleInputKeyDown = function handleInputKeyDown(e) {
63
- onInputKeyDown(e);
63
+ var _inputRef$current;
64
+
65
+ if (e.key === 'Backspace' && !((_inputRef$current = inputRef.current) !== null && _inputRef$current !== void 0 && _inputRef$current.value) && !e.repeat && items.length > 0) {
66
+ onRemoveItem(items[items.length - 1], items.length - 1);
67
+ } else {
68
+ onInputKeyDown(e);
69
+ }
64
70
  };
65
71
 
66
72
  var handleItemRemove = function handleItemRemove(event, item, index) {
67
- var _inputRef$current;
73
+ var _inputRef$current2;
68
74
 
69
75
  onRemoveItem(item, index);
70
- (_inputRef$current = inputRef.current) === null || _inputRef$current === void 0 ? void 0 : _inputRef$current.focus({
76
+ (_inputRef$current2 = inputRef.current) === null || _inputRef$current2 === void 0 ? void 0 : _inputRef$current2.focus({
71
77
  focusVisible: event.detail !== 1
72
78
  });
73
79
  };
74
80
 
75
81
  var handleInputClear = function handleInputClear(e) {
76
- var _inputRef$current2;
82
+ var _inputRef$current3;
77
83
 
78
84
  onInputValueChange('');
79
- (_inputRef$current2 = inputRef.current) === null || _inputRef$current2 === void 0 ? void 0 : _inputRef$current2.focus({
85
+ (_inputRef$current3 = inputRef.current) === null || _inputRef$current3 === void 0 ? void 0 : _inputRef$current3.focus({
80
86
  focusVisible: (e === null || e === void 0 ? void 0 : e.detail) !== 1
81
87
  });
82
88
  };
83
89
 
90
+ var handleContainerKeyDown = function handleContainerKeyDown(e) {
91
+ if (!containerRef.current || e.key !== 'ArrowLeft' && e.key !== 'ArrowRight') return;
92
+ var items = containerRef.current.querySelectorAll('[tabindex="0"]');
93
+ var currentIndex = Array.from(items).indexOf(e.target);
94
+ var direction = e.key === 'ArrowLeft' ? -1 : 1;
95
+ var item = items[currentIndex + direction];
96
+ item === null || item === void 0 ? void 0 : item.focus({
97
+ focusVisible: true
98
+ });
99
+ onActivationChange && onActivationChange(false);
100
+ };
101
+
84
102
  var cls = "".concat(multiLine ? 'multiline' : '', " ").concat(validationType || '', " ").concat(size, " ").concat(loading ? 'loading' : '', " ").concat(disabled ? 'disabled' : '');
85
103
  return /*#__PURE__*/_jsxs(Wrapper, {
86
104
  children: [/*#__PURE__*/_jsx(ChipInputContainer, {
87
105
  ref: containerRef,
88
106
  id: inputId,
107
+ onKeyDown: handleContainerKeyDown,
89
108
  onClick: function onClick() {
90
- var _inputRef$current3;
109
+ var _inputRef$current4;
91
110
 
92
- return !disabled && ((_inputRef$current3 = inputRef.current) === null || _inputRef$current3 === void 0 ? void 0 : _inputRef$current3.focus());
111
+ return !disabled && ((_inputRef$current4 = inputRef.current) === null || _inputRef$current4 === void 0 ? void 0 : _inputRef$current4.focus());
93
112
  },
94
113
  className: cls,
95
114
  children: /*#__PURE__*/_jsxs(ChipInputContentContainer, {
@@ -104,36 +123,43 @@ export var ChipInputField = /*#__PURE__*/React.forwardRef(function (_ref, ref) {
104
123
  return handleItemRemove(e, chip, index);
105
124
  }
106
125
  }, "chip_".concat(index));
107
- }), /*#__PURE__*/_jsx(ChipInputEl, {
108
- ref: inputRef,
109
- type: "text",
110
- tabIndex: disabled ? -1 : 0,
111
- value: inputValue,
112
- onChange: function onChange(e) {
113
- return onInputValueChange(e.target.value);
114
- },
115
- onKeyDown: handleInputKeyDown,
116
- placeholder: (items === null || items === void 0 ? void 0 : items.length) === 0 ? placeholder : altPlaceholder || '',
117
- onClick: function onClick(e) {
118
- e.stopPropagation();
119
- onActivation && onActivation();
120
- }
121
- }), inputValue && !disabled && /*#__PURE__*/_jsx(IconButton, {
122
- action: handleInputClear,
123
- ref: clearButtonRef,
124
- useTransparentBackground: true,
125
- shape: 'circular',
126
- style: {
127
- marginLeft: '-8px'
128
- },
129
- variant: 'secondary',
130
- children: /*#__PURE__*/_jsx(SystemIcons.Clear, {})
131
- }), loading && /*#__PURE__*/_jsx(Loading, {
132
- className: size,
133
- children: /*#__PURE__*/_jsx(LoadingIndicator, {
134
- size: Size.Small,
135
- color: COLORS.neutral_600
136
- })
126
+ }), /*#__PURE__*/_jsxs(ChipInputBoundItems, {
127
+ children: [/*#__PURE__*/_jsx(ChipInputEl, {
128
+ ref: inputRef,
129
+ type: "text",
130
+ tabIndex: disabled ? -1 : 0,
131
+ value: inputValue,
132
+ onChange: function onChange(e) {
133
+ return onInputValueChange(e.target.value);
134
+ },
135
+ onKeyDown: handleInputKeyDown,
136
+ placeholder: (items === null || items === void 0 ? void 0 : items.length) === 0 ? placeholder : altPlaceholder || '',
137
+ onClick: function onClick(e) {
138
+ e.stopPropagation();
139
+ onActivationChange && onActivationChange(true);
140
+ }
141
+ }), inputValue && !disabled && /*#__PURE__*/_jsx(IconButton, {
142
+ action: handleInputClear,
143
+ ref: function ref(_ref2) {
144
+ _ref2 === null || _ref2 === void 0 ? void 0 : _ref2.scrollIntoView({
145
+ block: 'nearest',
146
+ inline: 'nearest'
147
+ });
148
+ },
149
+ useTransparentBackground: true,
150
+ shape: 'circular',
151
+ style: {
152
+ marginLeft: '-8px'
153
+ },
154
+ variant: 'secondary',
155
+ children: /*#__PURE__*/_jsx(SystemIcons.Clear, {})
156
+ }), loading && /*#__PURE__*/_jsx(Loading, {
157
+ className: size,
158
+ children: /*#__PURE__*/_jsx(LoadingIndicator, {
159
+ size: Size.Small,
160
+ color: COLORS.neutral_600
161
+ })
162
+ })]
137
163
  })]
138
164
  })
139
165
  }), validationMessage && validationType === 'warning' ? /*#__PURE__*/_jsxs(WarningMessage, {
@@ -167,6 +193,6 @@ ChipInputField.propTypes = {
167
193
  inputValue: _pt.string.isRequired,
168
194
  onInputValueChange: _pt.func.isRequired,
169
195
  onInputKeyDown: _pt.func.isRequired,
170
- onActivation: _pt.func
196
+ onActivationChange: _pt.func
171
197
  };
172
198
  //# sourceMappingURL=ChipInputField.js.map