iguazio.dashboard-react-controls 0.0.13 → 0.0.16

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.
@@ -0,0 +1,178 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.default = void 0;
7
+
8
+ var _react = _interopRequireDefault(require("react"));
9
+
10
+ var _propTypes = _interopRequireDefault(require("prop-types"));
11
+
12
+ var _FormChip = _interopRequireDefault(require("./FormChip/FormChip"));
13
+
14
+ var _reactFinalFormArrays = require("react-final-form-arrays");
15
+
16
+ var _classnames = _interopRequireDefault(require("classnames"));
17
+
18
+ var _HiddenChipsBlock = _interopRequireDefault(require("../../elements/HiddenChipsBlock/HiddenChipsBlock"));
19
+
20
+ var _components = require("igz-controls/components");
21
+
22
+ var _common = require("../../utils/common.util");
23
+
24
+ var _types = require("../../types");
25
+
26
+ var _add = require("../../images/add.svg");
27
+
28
+ require("./formChipCell.scss");
29
+
30
+ var _jsxRuntime = require("react/jsx-runtime");
31
+
32
+ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
33
+
34
+ var FormChipCellView = /*#__PURE__*/_react.default.forwardRef(function (_ref, _ref2) {
35
+ var chipOptions = _ref.chipOptions,
36
+ chips = _ref.chips,
37
+ className = _ref.className,
38
+ editConfig = _ref.editConfig,
39
+ handleAddNewChip = _ref.handleAddNewChip,
40
+ _handleEditChip = _ref.handleEditChip,
41
+ handleIsEdit = _ref.handleIsEdit,
42
+ _handleRemoveChip = _ref.handleRemoveChip,
43
+ handleShowElements = _ref.handleShowElements,
44
+ isEditMode = _ref.isEditMode,
45
+ name = _ref.name,
46
+ setChipsSizes = _ref.setChipsSizes,
47
+ setEditConfig = _ref.setEditConfig,
48
+ shortChips = _ref.shortChips,
49
+ showChips = _ref.showChips,
50
+ showHiddenChips = _ref.showHiddenChips;
51
+ var chipsCellRef = _ref2.chipsCellRef,
52
+ chipsWrapperRef = _ref2.chipsWrapperRef;
53
+ var buttonAddClassNames = (0, _classnames.default)('button-add', className, chipOptions.background && "button-add-background_".concat(chipOptions.background), chipOptions.borderColor && "button-add-border_".concat(chipOptions.borderColor), chipOptions.font && "button-add-font_".concat(chipOptions.font), chipOptions.density && "button-add-density_".concat(chipOptions.density));
54
+ var wrapperClassNames = (0, _classnames.default)('chips-wrapper', isEditMode && 'fixed-max-width');
55
+ var chipClassNames = (0, _classnames.default)('chip', 'chip__content', isEditMode && 'data-ellipsis', shortChips && 'chip_short', chips.hiddenChips && 'chip_hidden', chipOptions.density && "chip-density_".concat(chipOptions.density), chipOptions.borderRadius && "chip-border_".concat(chipOptions.borderRadius), chipOptions.background && "chip-background_".concat(chipOptions.background), chipOptions.borderColor && "chip-border_".concat(chipOptions.borderColor), chipOptions.font && "chip-font_".concat(chipOptions.font), isEditMode && 'editable', (showChips || isEditMode) && 'chip_visible', className);
56
+ return /*#__PURE__*/(0, _jsxRuntime.jsx)("div", {
57
+ children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactFinalFormArrays.FieldArray, {
58
+ name: name,
59
+ children: function children(_ref3) {
60
+ var fields = _ref3.fields;
61
+ return (isEditMode || !(0, _common.isEveryObjectValueEmpty)(fields)) && /*#__PURE__*/(0, _jsxRuntime.jsx)("div", {
62
+ className: "chips-cell",
63
+ ref: chipsCellRef,
64
+ children: /*#__PURE__*/(0, _jsxRuntime.jsxs)("div", {
65
+ className: wrapperClassNames,
66
+ ref: chipsWrapperRef,
67
+ children: [fields.map(function (contentItem, index) {
68
+ var chipData = fields.value[index];
69
+ return index < chips.visibleChips.length && /*#__PURE__*/(0, _jsxRuntime.jsxs)("div", {
70
+ className: "chip-block",
71
+ children: [/*#__PURE__*/(0, _jsxRuntime.jsx)(_components.Tooltip, {
72
+ hidden: editConfig.isEdit,
73
+ template: /*#__PURE__*/(0, _jsxRuntime.jsx)(_components.TextTooltipTemplate, {
74
+ text: /*#__PURE__*/(0, _jsxRuntime.jsxs)("span", {
75
+ className: "chip__content",
76
+ children: [chipData.key, /*#__PURE__*/(0, _jsxRuntime.jsx)("span", {
77
+ className: "chip__delimiter",
78
+ children: chipData.delimiter ? chipData.delimiter : ':'
79
+ }), chipData.value]
80
+ })
81
+ }),
82
+ children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_FormChip.default, {
83
+ chip: chipData,
84
+ chipClassNames: chipClassNames,
85
+ chipIndex: index,
86
+ chipOptions: chipOptions,
87
+ className: className,
88
+ editConfig: editConfig,
89
+ handleEditChip: function handleEditChip(event, nameEvent) {
90
+ return _handleEditChip(event, fields, nameEvent);
91
+ },
92
+ handleIsEdit: handleIsEdit,
93
+ handleRemoveChip: function handleRemoveChip(event, index) {
94
+ return _handleRemoveChip(event, fields, index);
95
+ },
96
+ isEditMode: isEditMode,
97
+ keyName: "".concat(contentItem, ".key"),
98
+ ref: chipsCellRef,
99
+ setChipsSizes: setChipsSizes,
100
+ setEditConfig: setEditConfig,
101
+ textOverflowEllipsis: true,
102
+ valueName: "".concat(contentItem, ".value")
103
+ })
104
+ }, contentItem), chips.visibleChips.length - 1 === index && showHiddenChips && /*#__PURE__*/(0, _jsxRuntime.jsx)(_HiddenChipsBlock.default, {
105
+ chipClassNames: chipClassNames,
106
+ chipIndex: index,
107
+ chipOptions: chipOptions,
108
+ chips: chips.hiddenChips,
109
+ className: className,
110
+ editConfig: editConfig,
111
+ handleEditChip: function handleEditChip(event, nameEvent) {
112
+ return _handleEditChip(event, fields, nameEvent);
113
+ },
114
+ handleIsEdit: handleIsEdit,
115
+ handleRemoveChip: function handleRemoveChip(event, index) {
116
+ return _handleRemoveChip(event, fields, index);
117
+ },
118
+ handleShowElements: handleShowElements,
119
+ isEditMode: isEditMode,
120
+ ref: chipsCellRef,
121
+ setChipsSizes: setChipsSizes,
122
+ setEditConfig: setEditConfig
123
+ })]
124
+ }, contentItem);
125
+ }), chips.hiddenChipsNumber && /*#__PURE__*/(0, _jsxRuntime.jsx)("span", {
126
+ className: "".concat(chipClassNames, " chips_button"),
127
+ onClick: handleShowElements,
128
+ children: chips.hiddenChipsNumber
129
+ }), isEditMode && /*#__PURE__*/(0, _jsxRuntime.jsx)("button", {
130
+ className: buttonAddClassNames,
131
+ onClick: function onClick(e) {
132
+ return handleAddNewChip(e, fields);
133
+ },
134
+ children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_add.ReactComponent, {})
135
+ })]
136
+ })
137
+ });
138
+ }
139
+ })
140
+ });
141
+ });
142
+
143
+ FormChipCellView.defaultProps = {
144
+ chipOptions: {
145
+ background: 'purple',
146
+ boldValue: false,
147
+ borderRadius: 'primary',
148
+ borderColor: 'transparent',
149
+ density: 'dense',
150
+ font: 'purple'
151
+ },
152
+ isEditMode: false,
153
+ delimiter: null,
154
+ onClick: function onClick() {},
155
+ shortChips: false
156
+ };
157
+ FormChipCellView.propTypes = {
158
+ chipOptions: _types.CHIP_OPTIONS,
159
+ chips: _propTypes.default.object.isRequired,
160
+ className: _propTypes.default.string,
161
+ editConfig: _propTypes.default.object.isRequired,
162
+ handleAddNewChip: _propTypes.default.func.isRequired,
163
+ handleEditChip: _propTypes.default.func.isRequired,
164
+ handleIsEdit: _propTypes.default.func.isRequired,
165
+ handleRemoveChip: _propTypes.default.func.isRequired,
166
+ handleShowElements: _propTypes.default.func.isRequired,
167
+ isEditMode: _propTypes.default.bool,
168
+ name: _propTypes.default.string.isRequired,
169
+ delimiter: _propTypes.default.oneOfType([_propTypes.default.string, _propTypes.default.element]),
170
+ onClick: _propTypes.default.func,
171
+ setChipsSizes: _propTypes.default.func.isRequired,
172
+ setEditConfig: _propTypes.default.func.isRequired,
173
+ shortChips: _propTypes.default.bool,
174
+ showChips: _propTypes.default.bool.isRequired,
175
+ showHiddenChips: _propTypes.default.bool.isRequired
176
+ };
177
+ var _default = FormChipCellView;
178
+ exports.default = _default;
@@ -0,0 +1,244 @@
1
+ "use strict";
2
+
3
+ function _typeof(obj) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (obj) { return typeof obj; } : function (obj) { return obj && "function" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }, _typeof(obj); }
4
+
5
+ Object.defineProperty(exports, "__esModule", {
6
+ value: true
7
+ });
8
+ exports.default = void 0;
9
+
10
+ var _react = _interopRequireWildcard(require("react"));
11
+
12
+ var _propTypes = _interopRequireDefault(require("prop-types"));
13
+
14
+ var _classnames = _interopRequireDefault(require("classnames"));
15
+
16
+ var _NewChipInput = _interopRequireDefault(require("../NewChipInput/NewChipInput"));
17
+
18
+ var _types = require("../../../types");
19
+
20
+ var _constants = require("../../../constants");
21
+
22
+ require("./newChipForm.scss");
23
+
24
+ var _jsxRuntime = require("react/jsx-runtime");
25
+
26
+ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
27
+
28
+ function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
29
+
30
+ function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || _typeof(obj) !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
31
+
32
+ function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
33
+
34
+ function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
35
+
36
+ function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
37
+
38
+ function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
39
+
40
+ function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
41
+
42
+ function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
43
+
44
+ function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) { arr2[i] = arr[i]; } return arr2; }
45
+
46
+ function _iterableToArrayLimit(arr, i) { var _i = arr == null ? null : typeof Symbol !== "undefined" && arr[Symbol.iterator] || arr["@@iterator"]; if (_i == null) return; var _arr = []; var _n = true; var _d = false; var _s, _e; try { for (_i = _i.call(arr); !(_n = (_s = _i.next()).done); _n = true) { _arr.push(_s.value); if (i && _arr.length === i) break; } } catch (err) { _d = true; _e = err; } finally { try { if (!_n && _i["return"] != null) _i["return"](); } finally { if (_d) throw _e; } } return _arr; }
47
+
48
+ function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
49
+
50
+ var NewChipForm = /*#__PURE__*/_react.default.forwardRef(function (_ref, ref) {
51
+ var chip = _ref.chip,
52
+ chipOptions = _ref.chipOptions,
53
+ className = _ref.className,
54
+ editConfig = _ref.editConfig,
55
+ keyName = _ref.keyName,
56
+ onChange = _ref.onChange,
57
+ setEditConfig = _ref.setEditConfig,
58
+ valueName = _ref.valueName;
59
+
60
+ var _useState = (0, _react.useState)({
61
+ key: chip.key,
62
+ value: chip.value,
63
+ keyFieldWidth: 0,
64
+ valueFieldWidth: 0
65
+ }),
66
+ _useState2 = _slicedToArray(_useState, 2),
67
+ chipData = _useState2[0],
68
+ setChipData = _useState2[1];
69
+
70
+ var maxWidthInput = (0, _react.useMemo)(function () {
71
+ var _ref$current;
72
+
73
+ return ((_ref$current = ref.current) === null || _ref$current === void 0 ? void 0 : _ref$current.clientWidth) - 50;
74
+ }, [ref]);
75
+ var background = chipOptions.background,
76
+ borderColor = chipOptions.borderColor,
77
+ borderRadius = chipOptions.borderRadius,
78
+ density = chipOptions.density,
79
+ font = chipOptions.font;
80
+ var minWidthInput = 25;
81
+ var minWidthValueInput = 35;
82
+
83
+ var refInputKey = /*#__PURE__*/_react.default.createRef();
84
+
85
+ var refInputValue = /*#__PURE__*/_react.default.createRef();
86
+
87
+ var refInputContainer = /*#__PURE__*/_react.default.createRef();
88
+
89
+ var labelKeyClassName = (0, _classnames.default)(className, !editConfig.isKeyFocused && 'item_edited');
90
+ var labelContainerClassName = (0, _classnames.default)('edit-chip-container', background && "edit-chip-container-background_".concat(background), borderColor && "edit-chip-container-border_".concat(borderColor), font && "edit-chip-container-font_".concat(font), density && "edit-chip-container-density_".concat(density), borderRadius && "edit-chip-container-border_".concat(borderRadius), (editConfig.isEdit || editConfig.isNewChip) && 'edit-chip-container_edited');
91
+ var labelValueClassName = (0, _classnames.default)((0, _classnames.default)('input-label-value', !editConfig.isValueFocused && 'item_edited'));
92
+ (0, _react.useLayoutEffect)(function () {
93
+ if (!chipData.keyFieldWidth && !chipData.valueFieldWidth) {
94
+ var currentWidthKeyInput = refInputKey.current.scrollWidth + 1;
95
+ var currentWidthValueInput = refInputValue.current.scrollWidth + 1;
96
+
97
+ if (chipData.key && chipData.value) {
98
+ setChipData(function (prevState) {
99
+ return _objectSpread(_objectSpread({}, prevState), {}, {
100
+ keyFieldWidth: currentWidthKeyInput >= maxWidthInput ? maxWidthInput : currentWidthKeyInput,
101
+ valueFieldWidth: currentWidthValueInput >= maxWidthInput ? maxWidthInput : currentWidthValueInput
102
+ });
103
+ });
104
+ } else {
105
+ setChipData(function (prevState) {
106
+ return _objectSpread(_objectSpread({}, prevState), {}, {
107
+ keyFieldWidth: minWidthInput,
108
+ valueFieldWidth: minWidthValueInput
109
+ });
110
+ });
111
+ }
112
+ }
113
+ }, [chipData.key, chipData.value, chipData.keyFieldWidth, chipData.valueFieldWidth, maxWidthInput, refInputKey, refInputValue]);
114
+ (0, _react.useEffect)(function () {
115
+ if (editConfig.isKeyFocused) {
116
+ refInputKey.current.focus();
117
+ } else if (editConfig.isValueFocused) {
118
+ refInputValue.current.focus();
119
+ }
120
+ }, [editConfig.isKeyFocused, editConfig.isValueFocused, refInputKey, refInputValue]);
121
+ var outsideClick = (0, _react.useCallback)(function (event) {
122
+ var _event$path, _event$composedPath;
123
+
124
+ event.stopPropagation();
125
+ var elementPath = (_event$path = event.path) !== null && _event$path !== void 0 ? _event$path : (_event$composedPath = event.composedPath) === null || _event$composedPath === void 0 ? void 0 : _event$composedPath.call(event);
126
+
127
+ if (!elementPath.includes(refInputContainer.current)) {
128
+ onChange(event, _constants.CLICK);
129
+ }
130
+ }, [onChange, refInputContainer]);
131
+ (0, _react.useEffect)(function () {
132
+ if (editConfig.isEdit) {
133
+ document.addEventListener('click', outsideClick, true);
134
+ return function () {
135
+ document.removeEventListener('click', outsideClick, true);
136
+ };
137
+ }
138
+ }, [outsideClick, editConfig.isEdit]);
139
+ var focusChip = (0, _react.useCallback)(function (event) {
140
+ event.stopPropagation();
141
+
142
+ if (!event.shiftKey && event.key === _constants.TAB && editConfig.isValueFocused) {
143
+ onChange(event, _constants.TAB);
144
+ } else if (event.shiftKey && event.key === _constants.TAB && editConfig.isKeyFocused) {
145
+ onChange(event, _constants.TAB_SHIFT);
146
+ }
147
+
148
+ if (event.key === _constants.BACKSPACE || event.key === _constants.DELETE) {
149
+ setChipData(function (prevState) {
150
+ return {
151
+ keyFieldWidth: editConfig.isKeyFocused ? minWidthInput : prevState.keyFieldWidth,
152
+ valueFieldWidth: editConfig.isValueFocused ? minWidthValueInput : prevState.valueFieldWidth
153
+ };
154
+ });
155
+ }
156
+ }, [editConfig, onChange]);
157
+ var handleOnFocus = (0, _react.useCallback)(function (event) {
158
+ if (event.target.name === keyName) {
159
+ refInputKey.current.selectionStart = refInputKey.current.selectionEnd;
160
+ setEditConfig(function (prevState) {
161
+ return _objectSpread(_objectSpread({}, prevState), {}, {
162
+ isKeyFocused: true,
163
+ isValueFocused: false
164
+ });
165
+ });
166
+ } else {
167
+ refInputValue.current.selectionStart = refInputValue.current.selectionEnd;
168
+ setEditConfig(function (prevState) {
169
+ return _objectSpread(_objectSpread({}, prevState), {}, {
170
+ isKeyFocused: false,
171
+ isValueFocused: true
172
+ });
173
+ });
174
+ }
175
+ }, [keyName, refInputKey, refInputValue, setEditConfig]);
176
+ var handleOnChange = (0, _react.useCallback)(function (event) {
177
+ event.preventDefault();
178
+
179
+ if (event.target.name === keyName) {
180
+ var currentWidthKeyInput = refInputKey.current.scrollWidth;
181
+ setChipData(function (prevState) {
182
+ return _objectSpread(_objectSpread({}, prevState), {}, {
183
+ key: refInputKey.current.value,
184
+ keyFieldWidth: refInputKey.current.value.length <= 1 ? minWidthInput : currentWidthKeyInput >= maxWidthInput ? maxWidthInput : currentWidthKeyInput > minWidthInput ? currentWidthKeyInput + 2 : minWidthInput
185
+ });
186
+ });
187
+ } else {
188
+ var currentWidthValueInput = refInputValue.current.scrollWidth;
189
+ setChipData(function (prevState) {
190
+ return _objectSpread(_objectSpread({}, prevState), {}, {
191
+ value: refInputValue.current.value,
192
+ valueFieldWidth: refInputValue.current.value.length <= 1 ? minWidthValueInput : currentWidthValueInput >= maxWidthInput ? maxWidthInput : currentWidthValueInput > minWidthValueInput ? currentWidthValueInput + 2 : minWidthValueInput
193
+ });
194
+ });
195
+ }
196
+ }, [maxWidthInput, refInputKey, refInputValue, keyName]);
197
+ return /*#__PURE__*/(0, _jsxRuntime.jsxs)("div", {
198
+ className: labelContainerClassName,
199
+ onKeyDown: function onKeyDown(event) {
200
+ return editConfig.isEdit && focusChip(event);
201
+ },
202
+ ref: refInputContainer,
203
+ children: [/*#__PURE__*/(0, _jsxRuntime.jsx)(_NewChipInput.default, {
204
+ className: labelKeyClassName,
205
+ name: keyName,
206
+ onChange: handleOnChange,
207
+ onFocus: handleOnFocus,
208
+ placeholder: "key",
209
+ ref: refInputKey,
210
+ style: {
211
+ width: chipData.keyFieldWidth
212
+ }
213
+ }), /*#__PURE__*/(0, _jsxRuntime.jsx)("div", {
214
+ className: "edit-chip-separator",
215
+ children: ":"
216
+ }), /*#__PURE__*/(0, _jsxRuntime.jsx)(_NewChipInput.default, {
217
+ className: labelValueClassName,
218
+ name: valueName,
219
+ onChange: handleOnChange,
220
+ onFocus: handleOnFocus,
221
+ placeholder: "value",
222
+ ref: refInputValue,
223
+ style: {
224
+ width: chipData.valueFieldWidth
225
+ }
226
+ })]
227
+ });
228
+ });
229
+
230
+ NewChipForm.defaultProps = {
231
+ className: ''
232
+ };
233
+ NewChipForm.propTypes = {
234
+ chip: _propTypes.default.object.isRequired,
235
+ chipOptions: _types.CHIP_OPTIONS.isRequired,
236
+ className: _propTypes.default.string,
237
+ editConfig: _propTypes.default.shape({}).isRequired,
238
+ keyName: _propTypes.default.string.isRequired,
239
+ onChange: _propTypes.default.func.isRequired,
240
+ setEditConfig: _propTypes.default.func.isRequired,
241
+ valueName: _propTypes.default.string.isRequired
242
+ };
243
+ var _default = NewChipForm;
244
+ exports.default = _default;
@@ -0,0 +1,62 @@
1
+ @import '../../../scss/colors';
2
+ @import '../../../scss/borders';
3
+ @import '../../../scss/mixins';
4
+
5
+ .edit-chip {
6
+ &-container {
7
+ display: inline-flex;
8
+ max-width: 100%;
9
+ margin: 2px 8px 2px 0;
10
+ padding: 0 8px;
11
+ font-size: 14px;
12
+ line-height: 22px;
13
+
14
+ input {
15
+ display: flex;
16
+ padding: 0;
17
+ font-size: 14px;
18
+ background-color: transparent;
19
+ border: none;
20
+
21
+ &.item_edited {
22
+ &::placeholder {
23
+ color: $spunPearl;
24
+ }
25
+ }
26
+
27
+ &::placeholder {
28
+ color: $primary;
29
+ }
30
+ }
31
+
32
+ &-background {
33
+ @include chipBackground(false);
34
+ }
35
+
36
+ &-border {
37
+ @include chipBorder();
38
+ }
39
+
40
+ &-density {
41
+ @include chipDensity(true, false);
42
+ }
43
+
44
+ &-font {
45
+ @include chipsFont(EditableChip);
46
+ }
47
+ }
48
+
49
+ &-separator {
50
+ margin-right: 5px;
51
+ }
52
+
53
+ &__icon-close {
54
+ display: flex;
55
+ align-items: center;
56
+ justify-content: center;
57
+
58
+ svg {
59
+ transform: scale(0.7);
60
+ }
61
+ }
62
+ }
@@ -0,0 +1,73 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.default = void 0;
7
+
8
+ var _react = _interopRequireDefault(require("react"));
9
+
10
+ var _propTypes = _interopRequireDefault(require("prop-types"));
11
+
12
+ var _reactFinalForm = require("react-final-form");
13
+
14
+ var _jsxRuntime = require("react/jsx-runtime");
15
+
16
+ var _excluded = ["name", "onChange", "onFocus"];
17
+
18
+ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
19
+
20
+ function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
21
+
22
+ function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
23
+
24
+ function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
25
+
26
+ function _objectWithoutProperties(source, excluded) { if (source == null) return {}; var target = _objectWithoutPropertiesLoose(source, excluded); var key, i; if (Object.getOwnPropertySymbols) { var sourceSymbolKeys = Object.getOwnPropertySymbols(source); for (i = 0; i < sourceSymbolKeys.length; i++) { key = sourceSymbolKeys[i]; if (excluded.indexOf(key) >= 0) continue; if (!Object.prototype.propertyIsEnumerable.call(source, key)) continue; target[key] = source[key]; } } return target; }
27
+
28
+ function _objectWithoutPropertiesLoose(source, excluded) { if (source == null) return {}; var target = {}; var sourceKeys = Object.keys(source); var key, i; for (i = 0; i < sourceKeys.length; i++) { key = sourceKeys[i]; if (excluded.indexOf(key) >= 0) continue; target[key] = source[key]; } return target; }
29
+
30
+ var NewChipInput = /*#__PURE__*/_react.default.forwardRef(function (_ref, ref) {
31
+ var name = _ref.name,
32
+ onChange = _ref.onChange,
33
+ onFocus = _ref.onFocus,
34
+ inputProps = _objectWithoutProperties(_ref, _excluded);
35
+
36
+ var _useField = (0, _reactFinalForm.useField)(name),
37
+ input = _useField.input;
38
+
39
+ var handleInputChange = function handleInputChange(event) {
40
+ input.onChange(event);
41
+ onChange(event);
42
+ };
43
+
44
+ var handleInputFocus = function handleInputFocus(event) {
45
+ input.onFocus(event);
46
+ onFocus(event);
47
+ };
48
+
49
+ return /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactFinalForm.Field, {
50
+ name: name,
51
+ children: function children(_ref2) {
52
+ var input = _ref2.input;
53
+ return /*#__PURE__*/(0, _jsxRuntime.jsx)("input", _objectSpread(_objectSpread({
54
+ autoComplete: "off",
55
+ "data-testid": "input",
56
+ ref: ref,
57
+ type: "text",
58
+ id: input.name
59
+ }, _objectSpread(_objectSpread({}, inputProps), input)), {}, {
60
+ onChange: handleInputChange,
61
+ onFocus: handleInputFocus
62
+ }));
63
+ }
64
+ });
65
+ });
66
+
67
+ NewChipInput.propTypes = {
68
+ name: _propTypes.default.string.isRequired,
69
+ onChange: _propTypes.default.func.isRequired,
70
+ onFocus: _propTypes.default.func.isRequired
71
+ };
72
+ var _default = NewChipInput;
73
+ exports.default = _default;
@@ -0,0 +1,52 @@
1
+ @import '../../scss/colors';
2
+ @import '../../scss/borders';
3
+ @import '../../scss/mixins';
4
+
5
+ .chips {
6
+ &-wrapper {
7
+ display: flex;
8
+ align-items: center;
9
+ }
10
+
11
+ &-cell {
12
+ display: flex;
13
+ flex: 1;
14
+ align-items: center;
15
+ max-width: 100%;
16
+
17
+ .fixed-max-width {
18
+ max-width: 100%;
19
+ }
20
+
21
+ .chip {
22
+ &-block {
23
+ position: relative;
24
+ max-width: 100%;
25
+ }
26
+ }
27
+
28
+ .button-add {
29
+ display: flex;
30
+ align-items: center;
31
+ justify-content: center;
32
+ margin: 2px 0 2px 0;
33
+ border-radius: 32px;
34
+
35
+ &-background {
36
+ @include chipBackground(true);
37
+ }
38
+
39
+ &_border {
40
+ @include chipBorder();
41
+ }
42
+
43
+ &-density {
44
+ @include chipDensity(false, true);
45
+ }
46
+
47
+ &-font {
48
+ @include chipsFont(ButtonAddChip);
49
+ }
50
+ }
51
+ }
52
+ }
@@ -7,7 +7,7 @@
7
7
  width: 100%;
8
8
 
9
9
  .form-field {
10
- @include formField;
10
+ @include inputSelectField;
11
11
 
12
12
  &__icons {
13
13
  .form-field-combobox__icon {
@@ -231,7 +231,7 @@ var FormInput = /*#__PURE__*/_react.default.forwardRef(function (_ref, ref) {
231
231
 
232
232
  var validateField = function validateField(value) {
233
233
  var valueToValidate = (0, _lodash.isNil)(value) ? '' : String(value);
234
- if (!valueToValidate && !required) return;
234
+ if (!valueToValidate && !required || disabled) return;
235
235
  var validationError = null;
236
236
 
237
237
  if (!(0, _lodash.isEmpty)(validationRules)) {
@@ -57,16 +57,16 @@ var Modal = function Modal(_ref) {
57
57
  show = _ref.show,
58
58
  title = _ref.title;
59
59
 
60
- var _useState = (0, _react.useState)(location),
60
+ var _useState = (0, _react.useState)(location.pathname),
61
61
  _useState2 = _slicedToArray(_useState, 2),
62
62
  currentLocation = _useState2[0],
63
63
  setCurrentLocation = _useState2[1];
64
64
 
65
65
  var modalClassNames = (0, _classnames.default)('modal', className, size && "modal-".concat(size));
66
66
  (0, _react.useEffect)(function () {
67
- setCurrentLocation(location);
67
+ setCurrentLocation(location.pathname);
68
68
  return function () {
69
- if (location !== currentLocation) {
69
+ if (location.pathname !== currentLocation) {
70
70
  onClose();
71
71
  }
72
72
  };
@@ -128,7 +128,7 @@ Modal.defaultProps = {
128
128
  Modal.propTypes = {
129
129
  actions: _propTypes.default.array,
130
130
  children: _propTypes.default.oneOfType([_propTypes.default.element, _propTypes.default.object, _propTypes.default.node, _propTypes.default.string]).isRequired,
131
- location: _propTypes.default.string.isRequired,
131
+ location: _propTypes.default.object.isRequired,
132
132
  onClose: _propTypes.default.func.isRequired,
133
133
  show: _propTypes.default.bool.isRequired,
134
134
  size: _types.MODAL_SIZES,