@laerdal/life-react-components 1.7.0-dev.7 → 1.7.0-dev.8.full

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 (103) hide show
  1. package/dist/Card/Card.cjs +28 -44
  2. package/dist/Card/Card.cjs.map +1 -1
  3. package/dist/Card/Card.d.ts +3 -11
  4. package/dist/Card/Card.js +26 -44
  5. package/dist/Card/Card.js.map +1 -1
  6. package/dist/Card/CardBottomSection.cjs +2 -9
  7. package/dist/Card/CardBottomSection.cjs.map +1 -1
  8. package/dist/Card/CardBottomSection.d.ts +1 -2
  9. package/dist/Card/CardBottomSection.js +3 -10
  10. package/dist/Card/CardBottomSection.js.map +1 -1
  11. package/dist/Card/CardMiddleSection.cjs +2 -7
  12. package/dist/Card/CardMiddleSection.cjs.map +1 -1
  13. package/dist/Card/CardMiddleSection.d.ts +0 -2
  14. package/dist/Card/CardMiddleSection.js +3 -8
  15. package/dist/Card/CardMiddleSection.js.map +1 -1
  16. package/dist/Card/CardTopSection.cjs +9 -12
  17. package/dist/Card/CardTopSection.cjs.map +1 -1
  18. package/dist/Card/CardTopSection.d.ts +2 -4
  19. package/dist/Card/CardTopSection.js +10 -13
  20. package/dist/Card/CardTopSection.js.map +1 -1
  21. package/dist/Card/index.cjs +1 -13
  22. package/dist/Card/index.cjs.map +1 -1
  23. package/dist/Card/index.d.ts +0 -1
  24. package/dist/Card/index.js +0 -1
  25. package/dist/Card/index.js.map +1 -1
  26. package/dist/Chips/ActionChip.cjs +4 -4
  27. package/dist/Chips/ActionChip.cjs.map +1 -1
  28. package/dist/Chips/ActionChip.js +4 -4
  29. package/dist/Chips/ActionChip.js.map +1 -1
  30. package/dist/Chips/ChipStyles.cjs +3 -15
  31. package/dist/Chips/ChipStyles.cjs.map +1 -1
  32. package/dist/Chips/ChipStyles.d.ts +0 -3
  33. package/dist/Chips/ChipStyles.js +2 -5
  34. package/dist/Chips/ChipStyles.js.map +1 -1
  35. package/dist/Chips/ChipTypes.d.ts +6 -18
  36. package/dist/Chips/ChoiceChips.cjs +2 -2
  37. package/dist/Chips/ChoiceChips.cjs.map +1 -1
  38. package/dist/Chips/ChoiceChips.js +2 -2
  39. package/dist/Chips/ChoiceChips.js.map +1 -1
  40. package/dist/Chips/FilterChip.cjs +3 -3
  41. package/dist/Chips/FilterChip.cjs.map +1 -1
  42. package/dist/Chips/FilterChip.js +3 -3
  43. package/dist/Chips/FilterChip.js.map +1 -1
  44. package/dist/Chips/InputChip.cjs +4 -4
  45. package/dist/Chips/InputChip.cjs.map +1 -1
  46. package/dist/Chips/InputChip.js +4 -4
  47. package/dist/Chips/InputChip.js.map +1 -1
  48. package/dist/Chips/index.cjs +1 -1
  49. package/dist/Chips/index.cjs.map +1 -1
  50. package/dist/Chips/index.d.ts +1 -1
  51. package/dist/Chips/index.js +1 -1
  52. package/dist/Chips/index.js.map +1 -1
  53. package/dist/ChipsInput/ChipDropdownInput.cjs +398 -0
  54. package/dist/ChipsInput/ChipDropdownInput.cjs.map +1 -0
  55. package/dist/ChipsInput/ChipDropdownInput.d.ts +22 -0
  56. package/dist/ChipsInput/ChipDropdownInput.js +382 -0
  57. package/dist/ChipsInput/ChipDropdownInput.js.map +1 -0
  58. package/dist/ChipsInput/ChipInput.cjs +141 -0
  59. package/dist/ChipsInput/ChipInput.cjs.map +1 -0
  60. package/dist/{Chips → ChipsInput}/ChipInput.d.ts +1 -4
  61. package/dist/ChipsInput/ChipInput.js +122 -0
  62. package/dist/ChipsInput/ChipInput.js.map +1 -0
  63. package/dist/ChipsInput/ChipInputField.cjs +193 -0
  64. package/dist/ChipsInput/ChipInputField.cjs.map +1 -0
  65. package/dist/ChipsInput/ChipInputField.d.ts +24 -0
  66. package/dist/ChipsInput/ChipInputField.js +158 -0
  67. package/dist/ChipsInput/ChipInputField.js.map +1 -0
  68. package/dist/ChipsInput/ChipInputTypes.cjs +6 -0
  69. package/dist/ChipsInput/ChipInputTypes.cjs.map +1 -0
  70. package/dist/ChipsInput/ChipInputTypes.d.ts +22 -0
  71. package/dist/ChipsInput/ChipInputTypes.js +2 -0
  72. package/dist/ChipsInput/ChipInputTypes.js.map +1 -0
  73. package/dist/ChipsInput/index.cjs +19 -0
  74. package/dist/ChipsInput/index.cjs.map +1 -0
  75. package/dist/ChipsInput/index.d.ts +1 -0
  76. package/dist/ChipsInput/index.js +2 -0
  77. package/dist/ChipsInput/index.js.map +1 -0
  78. package/dist/Dropdown/DropdownContent.cjs +14 -21
  79. package/dist/Dropdown/DropdownContent.cjs.map +1 -1
  80. package/dist/Dropdown/DropdownContent.js +14 -21
  81. package/dist/Dropdown/DropdownContent.js.map +1 -1
  82. package/dist/Dropdown/index.cjs +0 -8
  83. package/dist/Dropdown/index.cjs.map +1 -1
  84. package/dist/Dropdown/index.d.ts +1 -2
  85. package/dist/Dropdown/index.js +1 -2
  86. package/dist/Dropdown/index.js.map +1 -1
  87. package/dist/InputFields/styling.cjs.map +1 -1
  88. package/dist/InputFields/styling.js.map +1 -1
  89. package/dist/index.cjs +14 -0
  90. package/dist/index.cjs.map +1 -1
  91. package/dist/index.d.ts +1 -0
  92. package/dist/index.js +1 -0
  93. package/dist/index.js.map +1 -1
  94. package/package.json +1 -1
  95. package/dist/Chips/ChipInput.cjs +0 -199
  96. package/dist/Chips/ChipInput.cjs.map +0 -1
  97. package/dist/Chips/ChipInput.js +0 -182
  98. package/dist/Chips/ChipInput.js.map +0 -1
  99. package/dist/Dropdown/ChipDropdownInput.cjs +0 -431
  100. package/dist/Dropdown/ChipDropdownInput.cjs.map +0 -1
  101. package/dist/Dropdown/ChipDropdownInput.d.ts +0 -24
  102. package/dist/Dropdown/ChipDropdownInput.js +0 -418
  103. package/dist/Dropdown/ChipDropdownInput.js.map +0 -1
@@ -0,0 +1,122 @@
1
+ import _toConsumableArray from "@babel/runtime/helpers/esm/toConsumableArray";
2
+ import _slicedToArray from "@babel/runtime/helpers/esm/slicedToArray";
3
+
4
+ /**
5
+ * Import React libraries.
6
+ */
7
+ import * as React from 'react';
8
+ /**
9
+ * Import custom components.
10
+ */
11
+
12
+ import { Size } from '../types';
13
+ import { ChipInputField } from './ChipInputField';
14
+ import { jsx as _jsx } from "react/jsx-runtime";
15
+
16
+ var ChipInput = function ChipInput(_ref) {
17
+ var values = _ref.values,
18
+ inputId = _ref.inputId,
19
+ variants = _ref.variants,
20
+ icon = _ref.icon,
21
+ placeholder = _ref.placeholder,
22
+ disabled = _ref.disabled,
23
+ altPlaceholder = _ref.altPlaceholder,
24
+ validationType = _ref.validationType,
25
+ validationMessage = _ref.validationMessage,
26
+ onValueChange = _ref.onValueChange,
27
+ _ref$multiLine = _ref.multiLine,
28
+ multiLine = _ref$multiLine === void 0 ? true : _ref$multiLine,
29
+ _ref$size = _ref.size,
30
+ size = _ref$size === void 0 ? Size.Medium : _ref$size;
31
+
32
+ var _React$useState = React.useState([]),
33
+ _React$useState2 = _slicedToArray(_React$useState, 2),
34
+ chips = _React$useState2[0],
35
+ setChips = _React$useState2[1];
36
+
37
+ var _React$useState3 = React.useState(''),
38
+ _React$useState4 = _slicedToArray(_React$useState3, 2),
39
+ value = _React$useState4[0],
40
+ setValue = _React$useState4[1];
41
+
42
+ var _React$useState5 = React.useState([]),
43
+ _React$useState6 = _slicedToArray(_React$useState5, 2),
44
+ chipItems = _React$useState6[0],
45
+ setChipItems = _React$useState6[1];
46
+ /**
47
+ * Sets initial values for the chips.
48
+ */
49
+
50
+
51
+ React.useEffect(function () {
52
+ // Let's add initial chip values
53
+ setChips(values);
54
+ }, [values]);
55
+ /**
56
+ * Set chip items for chip input field
57
+ * */
58
+
59
+ React.useEffect(function () {
60
+ setChipItems(chips.map(function (chip, index) {
61
+ return {
62
+ label: chip,
63
+ icon: icon,
64
+ disabled: false,
65
+ variant: variants && variants[index]
66
+ };
67
+ }));
68
+ }, [chips, variants, icon, size]);
69
+ /**
70
+ * Adds a chip to the chip list.
71
+ * @param event - Event handler from the key down event.
72
+ */
73
+
74
+ var handleInputKeyDown = function handleInputKeyDown(event) {
75
+ if ((event.key === 'Enter' || event.key === 'Space' || event.key === 'Comma') && value) {
76
+ event.preventDefault();
77
+ setChips([].concat(_toConsumableArray(chips), [value]));
78
+ onValueChange([].concat(_toConsumableArray(chips), [value]));
79
+ setValue('');
80
+ }
81
+ };
82
+ /**
83
+ * Removes a specific chip from the chip list.
84
+ * @param index - Index of the chip that needs to be removed.
85
+ */
86
+
87
+
88
+ var onRemoveChip = function onRemoveChip(index) {
89
+ var newChips = _toConsumableArray(chips);
90
+
91
+ newChips.splice(index, 1);
92
+ setChips(newChips);
93
+ onValueChange(newChips);
94
+ };
95
+ /**
96
+ * Return Chip Input component.
97
+ */
98
+
99
+
100
+ return /*#__PURE__*/_jsx(ChipInputField, {
101
+ inputId: inputId,
102
+ items: chipItems,
103
+ onRemoveItem: function onRemoveItem(item, index) {
104
+ return onRemoveChip(index);
105
+ },
106
+ inputValue: value,
107
+ onInputValueChange: function onInputValueChange(value) {
108
+ return setValue(value);
109
+ },
110
+ onInputKeyDown: handleInputKeyDown,
111
+ placeholder: placeholder,
112
+ altPlaceholder: altPlaceholder,
113
+ validationType: validationType,
114
+ disabled: disabled,
115
+ validationMessage: validationMessage,
116
+ multiLine: multiLine,
117
+ size: size
118
+ });
119
+ };
120
+
121
+ export default ChipInput;
122
+ //# sourceMappingURL=ChipInput.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../src/ChipsInput/ChipInput.tsx"],"names":["React","Size","ChipInputField","ChipInput","values","inputId","variants","icon","placeholder","disabled","altPlaceholder","validationType","validationMessage","onValueChange","multiLine","size","Medium","useState","chips","setChips","value","setValue","chipItems","setChipItems","useEffect","map","chip","index","label","variant","handleInputKeyDown","event","key","preventDefault","onRemoveChip","newChips","splice","item"],"mappings":";;;AAAA;AACA;AACA;AACA,OAAO,KAAKA,KAAZ,MAAuB,OAAvB;AAEA;AACA;AACA;;AACA,SAAQC,IAAR,QAAmB,UAAnB;AACA,SAAQC,cAAR,QAA6B,kBA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CAACD,KAAD,CAAZ;AAAA,KAJzC;AAKgB,IAAA,cAAc,EAAEU,kBALhC;AAMgB,IAAA,WAAW,EAAEtB,WAN7B;AAOgB,IAAA,cAAc,EAAEE,cAPhC;AAQgB,IAAA,cAAc,EAAEC,cARhC;AASgB,IAAA,QAAQ,EAAEF,QAT1B;AAUgB,IAAA,iBAAiB,EAAEG,iBAVnC;AAWgB,IAAA,SAAS,EAAEE,SAX3B;AAYgB,IAAA,IAAI,EAAEC;AAZtB,IADF;AAgBD,CArFD;;AAuFA,eAAeZ,SAAf","sourcesContent":["/**\n * Import React libraries.\n */\nimport * as React from 'react';\n\n/**\n * Import custom components.\n */\nimport {Size} from '../types';\nimport {ChipInputField} from './ChipInputField';\nimport {ChipInputProps, ChipItem} from './ChipInputTypes';\n\n\nconst ChipInput: React.FunctionComponent<ChipInputProps> = ({\n values,\n inputId,\n variants,\n icon,\n placeholder,\n disabled,\n altPlaceholder,\n validationType,\n validationMessage,\n onValueChange,\n multiLine = true,\n size = Size.Medium,\n }: ChipInputProps) => {\n\n const [chips, setChips] = React.useState<string[]>([]);\n const [value, setValue] = React.useState<string>('');\n const [chipItems, setChipItems] = React.useState<ChipItem[]>([]);\n\n /**\n * Sets initial values for the chips.\n */\n React.useEffect(() => {\n // Let's add initial chip values\n setChips(values);\n }, [values]);\n\n /**\n * Set chip items for chip input field\n * */\n React.useEffect(() => {\n setChipItems(chips.map((chip, index) => ({\n label: chip,\n icon: icon,\n disabled: false,\n variant: variants && variants[index],\n })));\n }, [chips, variants, icon, size]);\n\n /**\n * Adds a chip to the chip list.\n * @param event - Event handler from the key down event.\n */\n const handleInputKeyDown = (event: React.KeyboardEvent<HTMLInputElement>): void => {\n if ((event.key === 'Enter' || event.key === 'Space' || event.key === 'Comma') && value) {\n event.preventDefault();\n\n setChips([...chips, value]);\n onValueChange([...chips, value]);\n\n setValue('');\n }\n };\n\n /**\n * Removes a specific chip from the chip list.\n * @param index - Index of the chip that needs to be removed.\n */\n const onRemoveChip = (index: number): void => {\n const newChips = [...chips];\n newChips.splice(index, 1);\n\n setChips(newChips);\n onValueChange(newChips);\n };\n\n /**\n * Return Chip Input component.\n */\n return (\n <ChipInputField inputId={inputId}\n items={chipItems}\n onRemoveItem={(item, index) => onRemoveChip(index)}\n inputValue={value}\n onInputValueChange={value => setValue(value)}\n onInputKeyDown={handleInputKeyDown}\n placeholder={placeholder}\n altPlaceholder={altPlaceholder}\n validationType={validationType}\n disabled={disabled}\n validationMessage={validationMessage}\n multiLine={multiLine}\n size={size}\n />\n );\n};\n\nexport default ChipInput;\n"],"file":"ChipInput.js"}
@@ -0,0 +1,193 @@
1
+ "use strict";
2
+
3
+ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
4
+
5
+ Object.defineProperty(exports, "__esModule", {
6
+ value: true
7
+ });
8
+ exports.ChipInputField = exports.ChipInputEl = exports.ChipInputContentContainer = exports.ChipInputContainer = void 0;
9
+
10
+ var _taggedTemplateLiteral2 = _interopRequireDefault(require("@babel/runtime/helpers/taggedTemplateLiteral"));
11
+
12
+ var _propTypes = _interopRequireDefault(require("prop-types"));
13
+
14
+ var _react = _interopRequireDefault(require("react"));
15
+
16
+ var _types = require("../types");
17
+
18
+ var _Chips = require("../Chips");
19
+
20
+ var _styling = require("../InputFields/styling");
21
+
22
+ var _SystemIcons = require("../icons/systemicons/SystemIcons");
23
+
24
+ var _styles = require("../styles");
25
+
26
+ var _styledComponents = _interopRequireDefault(require("styled-components"));
27
+
28
+ var _LoadingIndicator = require("../LoadingIndicator");
29
+
30
+ var _common = require("../common");
31
+
32
+ var _jsxRuntime = require("react/jsx-runtime");
33
+
34
+ var _templateObject, _templateObject2, _templateObject3, _templateObject4, _templateObject5;
35
+
36
+ var Wrapper = _styledComponents.default.div(_templateObject || (_templateObject = (0, _taggedTemplateLiteral2.default)(["\n position: relative;\n"])));
37
+
38
+ var Loading = _styledComponents.default.div(_templateObject2 || (_templateObject2 = (0, _taggedTemplateLiteral2.default)(["\n position: absolute;\n height: 20px;\n\n &.small {\n right: 8px;\n bottom: 14px;\n }\n\n &.medium {\n bottom: 18px;\n }\n"])));
39
+
40
+ 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\n ", "\n ::-webkit-scrollbar:horizontal {\n display: none;\n }\n\n .action-right:focus {\n outline-offset: -4px;\n }\n"])), (0, _styles.scrollBarStyling)(_types.Size.Small));
41
+
42
+ exports.ChipInputContentContainer = ChipInputContentContainer;
43
+
44
+ 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);
45
+
46
+ exports.ChipInputContainer = ChipInputContainer;
47
+
48
+ 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);
49
+
50
+ exports.ChipInputEl = ChipInputEl;
51
+
52
+ var ChipInputField = /*#__PURE__*/_react.default.forwardRef(function (_ref, ref) {
53
+ var inputId = _ref.inputId,
54
+ items = _ref.items,
55
+ _ref$disabled = _ref.disabled,
56
+ disabled = _ref$disabled === void 0 ? false : _ref$disabled,
57
+ placeholder = _ref.placeholder,
58
+ altPlaceholder = _ref.altPlaceholder,
59
+ _ref$multiLine = _ref.multiLine,
60
+ multiLine = _ref$multiLine === void 0 ? true : _ref$multiLine,
61
+ _ref$size = _ref.size,
62
+ size = _ref$size === void 0 ? _types.Size.Medium : _ref$size,
63
+ validationType = _ref.validationType,
64
+ validationMessage = _ref.validationMessage,
65
+ loading = _ref.loading,
66
+ onRemoveItem = _ref.onRemoveItem,
67
+ onInputValueChange = _ref.onInputValueChange,
68
+ onInputKeyDown = _ref.onInputKeyDown,
69
+ onActivation = _ref.onActivation,
70
+ inputValue = _ref.inputValue;
71
+
72
+ var containerRef = _react.default.useRef(null);
73
+
74
+ var inputRef = (0, _common.useFocusVisibleRef)([containerRef], ref);
75
+ /**
76
+ * Scroll container to last item on change
77
+ * */
78
+
79
+ _react.default.useEffect(function () {
80
+ if (containerRef.current) {
81
+ containerRef.current.scrollTop = containerRef.current.scrollHeight;
82
+ containerRef.current.scrollLeft = containerRef.current.scrollWidth;
83
+ }
84
+ }, [containerRef, items]);
85
+ /**
86
+ * Remove last cheap on backspace
87
+ * */
88
+
89
+
90
+ var handleInputKeyDown = function handleInputKeyDown(e) {
91
+ var _inputRef$current;
92
+
93
+ if (e.key === 'Backspace' && (inputRef === null || inputRef === void 0 ? void 0 : (_inputRef$current = inputRef.current) === null || _inputRef$current === void 0 ? void 0 : _inputRef$current.value) === '') {
94
+ e.stopPropagation();
95
+ onRemoveItem(items[items.length - 1], items.length - 1);
96
+ return;
97
+ }
98
+
99
+ onInputKeyDown(e);
100
+ };
101
+
102
+ var cls = "".concat(multiLine ? 'multiline' : '', " ").concat(validationType || '', " ").concat(size, " ").concat(loading ? 'loading' : '', " ").concat(disabled ? 'disabled' : '');
103
+ return /*#__PURE__*/(0, _jsxRuntime.jsxs)(Wrapper, {
104
+ children: [/*#__PURE__*/(0, _jsxRuntime.jsx)(ChipInputContainer, {
105
+ ref: containerRef,
106
+ id: inputId,
107
+ tabIndex: disabled ? -1 : 0,
108
+ onKeyDown: function onKeyDown(e) {
109
+ var _inputRef$current2;
110
+
111
+ return e.key === 'Enter' && ((_inputRef$current2 = inputRef.current) === null || _inputRef$current2 === void 0 ? void 0 : _inputRef$current2.focus({
112
+ focusVisible: true
113
+ }));
114
+ },
115
+ onClick: function onClick() {
116
+ var _inputRef$current3;
117
+
118
+ return !disabled && ((_inputRef$current3 = inputRef.current) === null || _inputRef$current3 === void 0 ? void 0 : _inputRef$current3.focus());
119
+ },
120
+ className: cls,
121
+ children: /*#__PURE__*/(0, _jsxRuntime.jsxs)(ChipInputContentContainer, {
122
+ children: [items === null || items === void 0 ? void 0 : items.map(function (chip, index) {
123
+ return /*#__PURE__*/(0, _jsxRuntime.jsx)(_Chips.InputChip, {
124
+ icon: chip === null || chip === void 0 ? void 0 : chip.icon,
125
+ size: size,
126
+ disabled: chip.disabled || disabled,
127
+ variant: chip.variant || 'normal',
128
+ text: chip.label,
129
+ onRemove: function onRemove() {
130
+ return onRemoveItem(chip, index);
131
+ }
132
+ }, "chip_".concat(index));
133
+ }), /*#__PURE__*/(0, _jsxRuntime.jsx)(ChipInputEl, {
134
+ ref: inputRef,
135
+ type: "text",
136
+ tabIndex: -1,
137
+ value: inputValue,
138
+ onChange: function onChange(e) {
139
+ return onInputValueChange(e.target.value);
140
+ },
141
+ onKeyDown: handleInputKeyDown,
142
+ placeholder: (items === null || items === void 0 ? void 0 : items.length) === 0 ? placeholder : altPlaceholder || '',
143
+ onClick: function onClick(e) {
144
+ e.stopPropagation();
145
+ onActivation && onActivation();
146
+ },
147
+ onFocus: function onFocus(e) {
148
+ return onActivation && onActivation();
149
+ }
150
+ })]
151
+ })
152
+ }), loading && /*#__PURE__*/(0, _jsxRuntime.jsx)(Loading, {
153
+ className: size,
154
+ children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_LoadingIndicator.LoadingIndicator, {
155
+ size: _types.Size.Small,
156
+ color: _styles.COLORS.neutral_600
157
+ })
158
+ }), validationMessage && validationType === 'warning' ? /*#__PURE__*/(0, _jsxRuntime.jsxs)(_styling.WarningMessage, {
159
+ children: [/*#__PURE__*/(0, _jsxRuntime.jsx)(_SystemIcons.TechnicalWarning, {
160
+ size: "20px",
161
+ color: _styles.COLORS.critical_500
162
+ }), /*#__PURE__*/(0, _jsxRuntime.jsx)("span", {
163
+ children: validationMessage
164
+ })]
165
+ }) : validationType === 'error' && /*#__PURE__*/(0, _jsxRuntime.jsxs)(_styling.ErrorMessage, {
166
+ children: [/*#__PURE__*/(0, _jsxRuntime.jsx)(_SystemIcons.TechnicalWarning, {
167
+ size: "20px",
168
+ color: _styles.COLORS.critical_400
169
+ }), /*#__PURE__*/(0, _jsxRuntime.jsx)("span", {
170
+ children: validationMessage
171
+ })]
172
+ })]
173
+ });
174
+ });
175
+
176
+ exports.ChipInputField = ChipInputField;
177
+ ChipInputField.propTypes = {
178
+ inputId: _propTypes.default.string.isRequired,
179
+ items: _propTypes.default.array.isRequired,
180
+ disabled: _propTypes.default.bool,
181
+ placeholder: _propTypes.default.string,
182
+ altPlaceholder: _propTypes.default.string,
183
+ multiLine: _propTypes.default.bool,
184
+ loading: _propTypes.default.bool,
185
+ validationType: _propTypes.default.oneOf(['error', 'warning']),
186
+ validationMessage: _propTypes.default.string,
187
+ onRemoveItem: _propTypes.default.func.isRequired,
188
+ inputValue: _propTypes.default.string.isRequired,
189
+ onInputValueChange: _propTypes.default.func.isRequired,
190
+ onInputKeyDown: _propTypes.default.func.isRequired,
191
+ onActivation: _propTypes.default.func
192
+ };
193
+ //# sourceMappingURL=ChipInputField.cjs.map
@@ -0,0 +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","useEffect","current","scrollTop","scrollHeight","scrollLeft","scrollWidth","handleInputKeyDown","e","key","value","stopPropagation","length","cls","focus","focusVisible","map","chip","index","icon","variant","label","target","neutral_600","critical_400"],"mappings":";;;;;;;;;;;;;AAAA;;AAEA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;;;;;AAEA,IAAMA,OAAO,GAAGC,0BAAOC,GAAV,4GAAb;;AAIA,IAAMC,OAAO,GAAGF,0BAAOC,GAAV,+NAAb;;AAeO,IAAME,yBAAyB,GAAGH,0BAAOC,GAAV,8cAalC,8BAAiBG,YAAKC,KAAtB,CAbkC,CAA/B;;;;AAuBA,IAAMC,kBAAkB,GAAGN,0BAAOC,GAAV,opCAICM,eAAOC,WAJR,EAKTD,eAAOE,KALE,EAY3B,+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,IAAI,EANjF;AAOa,UAAA,OAAO,EAAE,iBAAAsB,CAAC,EAAI;AACZA,YAAAA,CAAC,CAACG,eAAF;AACAf,YAAAA,YAAY,IAAIA,YAAY,EAA5B;AACD,WAVd;AAWa,UAAA,OAAO,EAAE,iBAAAY,CAAC;AAAA,mBAAIZ,YAAY,IAAIA,YAAY,EAAhC;AAAA;AAXvB,UAXF;AAAA;AANF,MADF,EAiCGJ,OAAO,iBACN,qBAAC,OAAD;AAAS,MAAA,SAAS,EAAEJ,IAApB;AAAA,6BACE,qBAAC,kCAAD;AAAkB,QAAA,IAAI,EAAE5B,YAAKC,KAA7B;AAAoC,QAAA,KAAK,EAAEE,eAAO4D;AAAlD;AADF,MAlCJ,EAuCGhC,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,eAAO6D;AAA5C,QADF,eAEE;AAAA,kBAAOjC;AAAP,QAFF;AAAA,MA9CN;AAAA,IADF;AAuDD,CApG6B,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 {useFocusVisibleRef} from '../common';\n\nconst Wrapper = styled.div`\n position: relative;\n`;\n\nconst Loading = styled.div`\n position: absolute;\n height: 20px;\n\n &.small {\n right: 8px;\n bottom: 14px;\n }\n\n &.medium {\n bottom: 18px;\n }\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\n ${scrollBarStyling(Size.Small)}\n ::-webkit-scrollbar:horizontal {\n display: none;\n }\n\n .action-right:focus {\n outline-offset: -4px;\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 /**\n * Scroll container to last item on change\n * */\n React.useEffect(() => {\n if (containerRef.current) {\n containerRef.current!.scrollTop = containerRef.current!.scrollHeight;\n containerRef.current!.scrollLeft = containerRef.current!.scrollWidth;\n }\n }, [containerRef, 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 === '') {\n e.stopPropagation();\n onRemoveItem(items[items.length - 1], items.length - 1);\n return;\n }\n\n onInputKeyDown(e);\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 tabIndex={disabled ? -1 : 0}\n onKeyDown={e => e.key === 'Enter' && inputRef.current?.focus({focusVisible: true})}\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={() => onRemoveItem(chip, index)}/>\n ))}\n\n <ChipInputEl ref={inputRef}\n type=\"text\"\n tabIndex={-1}\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 onFocus={e => onActivation && onActivation()}/>\n </ChipInputContentContainer>\n </ChipInputContainer>\n\n {loading &&\n <Loading className={size}>\n <LoadingIndicator size={Size.Small} color={COLORS.neutral_600}/>\n </Loading>\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"}
@@ -0,0 +1,24 @@
1
+ import React from 'react';
2
+ import { ChipItem } from './ChipInputTypes';
3
+ import { Size } from '../types';
4
+ export declare const ChipInputContentContainer: import("styled-components").StyledComponent<"div", any, {}, never>;
5
+ export declare const ChipInputContainer: import("styled-components").StyledComponent<"div", any, {}, never>;
6
+ export declare const ChipInputEl: import("styled-components").StyledComponent<"input", any, {}, never>;
7
+ export interface ChipInputFieldProps {
8
+ inputId: string;
9
+ items: ChipItem[];
10
+ disabled?: boolean;
11
+ placeholder?: string;
12
+ altPlaceholder?: string;
13
+ multiLine?: boolean;
14
+ size?: Size.Large | Size.Medium | Size.Small;
15
+ loading?: boolean;
16
+ validationType?: 'error' | 'warning';
17
+ validationMessage?: string;
18
+ onRemoveItem: (item: ChipItem, index: number) => void;
19
+ inputValue: string;
20
+ onInputValueChange: (value: string) => void;
21
+ onInputKeyDown: (event: React.KeyboardEvent<HTMLInputElement>) => void;
22
+ onActivation?: () => void;
23
+ }
24
+ export declare const ChipInputField: React.ForwardRefExoticComponent<ChipInputFieldProps & React.RefAttributes<HTMLInputElement>>;
@@ -0,0 +1,158 @@
1
+ import _taggedTemplateLiteral from "@babel/runtime/helpers/esm/taggedTemplateLiteral";
2
+ import _pt from "prop-types";
3
+
4
+ var _templateObject, _templateObject2, _templateObject3, _templateObject4, _templateObject5;
5
+
6
+ import React from 'react';
7
+ import { Size } from '../types';
8
+ import { InputChip } from '../Chips';
9
+ import { ErrorMessage, WarningMessage } from '../InputFields/styling';
10
+ import { TechnicalWarning } from '../icons/systemicons/SystemIcons';
11
+ import { COLORS, ComponentMStyling, ComponentTextStyle, focusStyles, scrollBarStyling } from '../styles';
12
+ import styled from 'styled-components';
13
+ import { LoadingIndicator } from '../LoadingIndicator';
14
+ import { useFocusVisibleRef } from '../common';
15
+ import { jsx as _jsx } from "react/jsx-runtime";
16
+ import { jsxs as _jsxs } from "react/jsx-runtime";
17
+ var Wrapper = styled.div(_templateObject || (_templateObject = _taggedTemplateLiteral(["\n position: relative;\n"])));
18
+ var Loading = styled.div(_templateObject2 || (_templateObject2 = _taggedTemplateLiteral(["\n position: absolute;\n height: 20px;\n\n &.small {\n right: 8px;\n bottom: 14px;\n }\n\n &.medium {\n bottom: 18px;\n }\n"])));
19
+ 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\n ", "\n ::-webkit-scrollbar:horizontal {\n display: none;\n }\n\n .action-right:focus {\n outline-offset: -4px;\n }\n"])), scrollBarStyling(Size.Small));
20
+ 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);
21
+ 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);
22
+ export var ChipInputField = /*#__PURE__*/React.forwardRef(function (_ref, ref) {
23
+ var inputId = _ref.inputId,
24
+ items = _ref.items,
25
+ _ref$disabled = _ref.disabled,
26
+ disabled = _ref$disabled === void 0 ? false : _ref$disabled,
27
+ placeholder = _ref.placeholder,
28
+ altPlaceholder = _ref.altPlaceholder,
29
+ _ref$multiLine = _ref.multiLine,
30
+ multiLine = _ref$multiLine === void 0 ? true : _ref$multiLine,
31
+ _ref$size = _ref.size,
32
+ size = _ref$size === void 0 ? Size.Medium : _ref$size,
33
+ validationType = _ref.validationType,
34
+ validationMessage = _ref.validationMessage,
35
+ loading = _ref.loading,
36
+ onRemoveItem = _ref.onRemoveItem,
37
+ onInputValueChange = _ref.onInputValueChange,
38
+ onInputKeyDown = _ref.onInputKeyDown,
39
+ onActivation = _ref.onActivation,
40
+ inputValue = _ref.inputValue;
41
+ var containerRef = React.useRef(null);
42
+ var inputRef = useFocusVisibleRef([containerRef], ref);
43
+ /**
44
+ * Scroll container to last item on change
45
+ * */
46
+
47
+ React.useEffect(function () {
48
+ if (containerRef.current) {
49
+ containerRef.current.scrollTop = containerRef.current.scrollHeight;
50
+ containerRef.current.scrollLeft = containerRef.current.scrollWidth;
51
+ }
52
+ }, [containerRef, items]);
53
+ /**
54
+ * Remove last cheap on backspace
55
+ * */
56
+
57
+ var handleInputKeyDown = function handleInputKeyDown(e) {
58
+ var _inputRef$current;
59
+
60
+ if (e.key === 'Backspace' && (inputRef === null || inputRef === void 0 ? void 0 : (_inputRef$current = inputRef.current) === null || _inputRef$current === void 0 ? void 0 : _inputRef$current.value) === '') {
61
+ e.stopPropagation();
62
+ onRemoveItem(items[items.length - 1], items.length - 1);
63
+ return;
64
+ }
65
+
66
+ onInputKeyDown(e);
67
+ };
68
+
69
+ var cls = "".concat(multiLine ? 'multiline' : '', " ").concat(validationType || '', " ").concat(size, " ").concat(loading ? 'loading' : '', " ").concat(disabled ? 'disabled' : '');
70
+ return /*#__PURE__*/_jsxs(Wrapper, {
71
+ children: [/*#__PURE__*/_jsx(ChipInputContainer, {
72
+ ref: containerRef,
73
+ id: inputId,
74
+ tabIndex: disabled ? -1 : 0,
75
+ onKeyDown: function onKeyDown(e) {
76
+ var _inputRef$current2;
77
+
78
+ return e.key === 'Enter' && ((_inputRef$current2 = inputRef.current) === null || _inputRef$current2 === void 0 ? void 0 : _inputRef$current2.focus({
79
+ focusVisible: true
80
+ }));
81
+ },
82
+ onClick: function onClick() {
83
+ var _inputRef$current3;
84
+
85
+ return !disabled && ((_inputRef$current3 = inputRef.current) === null || _inputRef$current3 === void 0 ? void 0 : _inputRef$current3.focus());
86
+ },
87
+ className: cls,
88
+ children: /*#__PURE__*/_jsxs(ChipInputContentContainer, {
89
+ children: [items === null || items === void 0 ? void 0 : items.map(function (chip, index) {
90
+ return /*#__PURE__*/_jsx(InputChip, {
91
+ icon: chip === null || chip === void 0 ? void 0 : chip.icon,
92
+ size: size,
93
+ disabled: chip.disabled || disabled,
94
+ variant: chip.variant || 'normal',
95
+ text: chip.label,
96
+ onRemove: function onRemove() {
97
+ return onRemoveItem(chip, index);
98
+ }
99
+ }, "chip_".concat(index));
100
+ }), /*#__PURE__*/_jsx(ChipInputEl, {
101
+ ref: inputRef,
102
+ type: "text",
103
+ tabIndex: -1,
104
+ value: inputValue,
105
+ onChange: function onChange(e) {
106
+ return onInputValueChange(e.target.value);
107
+ },
108
+ onKeyDown: handleInputKeyDown,
109
+ placeholder: (items === null || items === void 0 ? void 0 : items.length) === 0 ? placeholder : altPlaceholder || '',
110
+ onClick: function onClick(e) {
111
+ e.stopPropagation();
112
+ onActivation && onActivation();
113
+ },
114
+ onFocus: function onFocus(e) {
115
+ return onActivation && onActivation();
116
+ }
117
+ })]
118
+ })
119
+ }), loading && /*#__PURE__*/_jsx(Loading, {
120
+ className: size,
121
+ children: /*#__PURE__*/_jsx(LoadingIndicator, {
122
+ size: Size.Small,
123
+ color: COLORS.neutral_600
124
+ })
125
+ }), validationMessage && validationType === 'warning' ? /*#__PURE__*/_jsxs(WarningMessage, {
126
+ children: [/*#__PURE__*/_jsx(TechnicalWarning, {
127
+ size: "20px",
128
+ color: COLORS.critical_500
129
+ }), /*#__PURE__*/_jsx("span", {
130
+ children: validationMessage
131
+ })]
132
+ }) : validationType === 'error' && /*#__PURE__*/_jsxs(ErrorMessage, {
133
+ children: [/*#__PURE__*/_jsx(TechnicalWarning, {
134
+ size: "20px",
135
+ color: COLORS.critical_400
136
+ }), /*#__PURE__*/_jsx("span", {
137
+ children: validationMessage
138
+ })]
139
+ })]
140
+ });
141
+ });
142
+ ChipInputField.propTypes = {
143
+ inputId: _pt.string.isRequired,
144
+ items: _pt.array.isRequired,
145
+ disabled: _pt.bool,
146
+ placeholder: _pt.string,
147
+ altPlaceholder: _pt.string,
148
+ multiLine: _pt.bool,
149
+ loading: _pt.bool,
150
+ validationType: _pt.oneOf(['error', 'warning']),
151
+ validationMessage: _pt.string,
152
+ onRemoveItem: _pt.func.isRequired,
153
+ inputValue: _pt.string.isRequired,
154
+ onInputValueChange: _pt.func.isRequired,
155
+ onInputKeyDown: _pt.func.isRequired,
156
+ onActivation: _pt.func
157
+ };
158
+ //# sourceMappingURL=ChipInputField.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../src/ChipsInput/ChipInputField.tsx"],"names":["React","Size","InputChip","ErrorMessage","WarningMessage","TechnicalWarning","COLORS","ComponentMStyling","ComponentTextStyle","focusStyles","scrollBarStyling","styled","LoadingIndicator","useFocusVisibleRef","Wrapper","div","Loading","ChipInputContentContainer","Small","ChipInputContainer","neutral_400","white","Regular","black","primary_700","primary_800","warning_500","critical_500","neutral_100","neutral_300","ChipInputEl","input","ChipInputField","forwardRef","ref","inputId","items","disabled","placeholder","altPlaceholder","multiLine","size","Medium","validationType","validationMessage","loading","onRemoveItem","onInputValueChange","onInputKeyDown","onActivation","inputValue","containerRef","useRef","inputRef","useEffect","current","scrollTop","scrollHeight","scrollLeft","scrollWidth","handleInputKeyDown","e","key","value","stopPropagation","length","cls","focus","focusVisible","map","chip","index","icon","variant","label","target","neutral_600","critical_400"],"mappings":";;;;;AAAA,OAAOA,KAAP,MAAkB,OAAlB;AAEA,SAAQC,IAAR,QAAmB,UAAnB;AACA,SAAQC,SAAR,QAAwB,UAAxB;AACA,SAAQC,YAAR,EAAsBC,cAAtB,QAA2C,wBAA3C;AACA,SAAQC,gBAAR,QAA+B,kCAA/B;AACA,SAAQC,MAAR,EAAgBC,iBAAhB,EAAmCC,kBAAnC,EAAuDC,WAAvD,EAAoEC,gBAApE,QAA2F,WAA3F;AACA,OAAOC,MAAP,MAAmB,mBAAnB;AACA,SAAQC,gBAAR,QAA+B,qBAA/B;AACA,SAAQC,kBAAR,QAAiC,WAAjC;;;AAEA,IAAMC,OAAO,GAAGH,MAAM,CAACI,GAAV,8FAAb;AAIA,IAAMC,OAAO,GAAGL,MAAM,CAACI,GAAV,iNAAb;AAeA,OAAO,IAAME,yBAAyB,GAAGN,MAAM,CAACI,GAAV,gcAalCL,gBAAgB,CAACT,IAAI,CAACiB,KAAN,CAbkB,CAA/B;AAuBP,OAAO,IAAMC,kBAAkB,GAAGR,MAAM,CAACI,GAAV,soCAICT,MAAM,CAACc,WAJR,EAKTd,MAAM,CAACe,KALE,EAY3Bd,iBAAiB,CAACC,kBAAkB,CAACc,OAApB,EAA6BhB,MAAM,CAACiB,KAApC,CAZU,EAyBzBN,yBAzByB,EAkCzBR,WAlCyB,EAsCGH,MAAM,CAACkB,WAtCV,EA0CGlB,MAAM,CAACmB,WA1CV,EAgDGnB,MAAM,CAACoB,WAhDV,EAsDGpB,MAAM,CAACqB,YAtDV,EA0DzBV,yBA1DyB,EA+DGX,MAAM,CAACsB,WA/DV,EAiElBtB,MAAM,CAACuB,WAjEW,CAAxB;AA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AAY,EAAhC;AAAA;AAXvB,UAXF;AAAA;AANF,MADF,EAiCGJ,OAAO,iBACN,KAAC,OAAD;AAAS,MAAA,SAAS,EAAEJ,IAApB;AAAA,6BACE,KAAC,gBAAD;AAAkB,QAAA,IAAI,EAAExC,IAAI,CAACiB,KAA7B;AAAoC,QAAA,KAAK,EAAEZ,MAAM,CAACsE;AAAlD;AADF,MAlCJ,EAuCGhC,iBAAiB,IAAID,cAAc,KAAK,SAAxC,gBACC,MAAC,cAAD;AAAA,8BACE,KAAC,gBAAD;AAAkB,QAAA,IAAI,EAAC,MAAvB;AAA8B,QAAA,KAAK,EAAErC,MAAM,CAACqB;AAA5C,QADF,eAEE;AAAA,kBAAOiB;AAAP,QAFF;AAAA,MADD,GAMCD,cAAc,KAAK,OAAnB,iBACE,MAAC,YAAD;AAAA,8BACE,KAAC,gBAAD;AAAkB,QAAA,IAAI,EAAC,MAAvB;AAA8B,QAAA,KAAK,EAAErC,MAAM,CAACuE;AAA5C,QADF,eAEE;AAAA,kBAAOjC;AAAP,QAFF;AAAA,MA9CN;AAAA,IADF;AAuDD,CApG6B,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,aAAiB,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 {useFocusVisibleRef} from '../common';\n\nconst Wrapper = styled.div`\n position: relative;\n`;\n\nconst Loading = styled.div`\n position: absolute;\n height: 20px;\n\n &.small {\n right: 8px;\n bottom: 14px;\n }\n\n &.medium {\n bottom: 18px;\n }\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\n ${scrollBarStyling(Size.Small)}\n ::-webkit-scrollbar:horizontal {\n display: none;\n }\n\n .action-right:focus {\n outline-offset: -4px;\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 /**\n * Scroll container to last item on change\n * */\n React.useEffect(() => {\n if (containerRef.current) {\n containerRef.current!.scrollTop = containerRef.current!.scrollHeight;\n containerRef.current!.scrollLeft = containerRef.current!.scrollWidth;\n }\n }, [containerRef, 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 === '') {\n e.stopPropagation();\n onRemoveItem(items[items.length - 1], items.length - 1);\n return;\n }\n\n onInputKeyDown(e);\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 tabIndex={disabled ? -1 : 0}\n onKeyDown={e => e.key === 'Enter' && inputRef.current?.focus({focusVisible: true})}\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={() => onRemoveItem(chip, index)}/>\n ))}\n\n <ChipInputEl ref={inputRef}\n type=\"text\"\n tabIndex={-1}\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 onFocus={e => onActivation && onActivation()}/>\n </ChipInputContentContainer>\n </ChipInputContainer>\n\n {loading &&\n <Loading className={size}>\n <LoadingIndicator size={Size.Small} color={COLORS.neutral_600}/>\n </Loading>\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.js"}
@@ -0,0 +1,6 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ //# sourceMappingURL=ChipInputTypes.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":[],"names":[],"mappings":"","sourcesContent":[],"file":"ChipInputTypes.cjs"}
@@ -0,0 +1,22 @@
1
+ import { Size } from '../types';
2
+ import { ChipIcons, ChipVariant } from '../Chips/ChipTypes';
3
+ export interface ChipInputProps {
4
+ inputId: string;
5
+ values: string[];
6
+ icon?: ChipIcons;
7
+ variants?: ChipVariant[];
8
+ placeholder?: string;
9
+ altPlaceholder?: string;
10
+ onValueChange: (chips: string[]) => void;
11
+ multiLine?: boolean;
12
+ disabled?: boolean;
13
+ size?: Size.Medium | Size.Small;
14
+ validationType?: 'error' | 'warning';
15
+ validationMessage?: string;
16
+ }
17
+ export interface ChipItem {
18
+ label: string;
19
+ icon?: ChipIcons;
20
+ disabled?: boolean;
21
+ variant?: ChipVariant;
22
+ }
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=ChipInputTypes.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":[],"names":[],"mappings":"","sourcesContent":[],"file":"ChipInputTypes.js"}
@@ -0,0 +1,19 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+
7
+ var _ChipDropdownInput = require("./ChipDropdownInput");
8
+
9
+ Object.keys(_ChipDropdownInput).forEach(function (key) {
10
+ if (key === "default" || key === "__esModule") return;
11
+ if (key in exports && exports[key] === _ChipDropdownInput[key]) return;
12
+ Object.defineProperty(exports, key, {
13
+ enumerable: true,
14
+ get: function get() {
15
+ return _ChipDropdownInput[key];
16
+ }
17
+ });
18
+ });
19
+ //# sourceMappingURL=index.cjs.map