@orfium/ictinus 4.65.0 → 4.67.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/components/Filter/Filter.js +117 -46
- package/dist/components/Filter/Filter.style.d.ts +1 -1
- package/dist/components/Filter/Filter.style.js +5 -2
- package/dist/components/Filter/components/FilterBase/FilterBase.d.ts +1 -1
- package/dist/components/Filter/components/FilterBase/FilterBase.js +8 -4
- package/dist/components/Filter/components/MultiFilter/MultiFilter.d.ts +11 -0
- package/dist/components/Filter/components/MultiFilter/MultiFilter.js +57 -0
- package/dist/components/Filter/components/MultiFilter/MultiFilter.style.d.ts +3 -0
- package/dist/components/Filter/components/MultiFilter/MultiFilter.style.js +42 -0
- package/dist/components/Filter/components/MultiFilter/index.d.ts +1 -0
- package/dist/components/Filter/components/MultiFilter/index.js +10 -0
- package/dist/components/Filter/components/SingleFilter/SingleFilter.d.ts +12 -0
- package/dist/components/Filter/components/SingleFilter/SingleFilter.js +53 -0
- package/dist/components/Filter/components/{SearchInput → SingleFilter/components/SearchInput}/SearchInput.d.ts +1 -1
- package/dist/components/Filter/components/{SearchInput → SingleFilter/components/SearchInput}/SearchInput.js +6 -6
- package/dist/components/Filter/components/SingleFilter/components/SearchInput/SearchInput.style.js +34 -0
- package/dist/components/Filter/components/SingleFilter/components/SearchInput/index.d.ts +1 -0
- package/dist/components/Filter/components/SingleFilter/components/SearchInput/index.js +10 -0
- package/dist/components/Filter/components/SingleFilter/index.d.ts +1 -0
- package/dist/components/Filter/components/SingleFilter/index.js +10 -0
- package/dist/components/Filter/hooks/useMultiFilterUtils.d.ts +18 -0
- package/dist/components/Filter/hooks/useMultiFilterUtils.js +124 -0
- package/dist/components/Filter/types.d.ts +13 -1
- package/dist/components/MultiTextFieldBase/MultiTextFieldBase.d.ts +43 -0
- package/dist/components/{Select/components/MultiselectTextField/MultiselectTextField.js → MultiTextFieldBase/MultiTextFieldBase.js} +55 -74
- package/dist/components/{Select/components/MultiselectTextField/MultiselectTextField.style.d.ts → MultiTextFieldBase/MultiTextFieldBase.style.d.ts} +6 -1
- package/dist/components/MultiTextFieldBase/MultiTextFieldBase.style.js +159 -0
- package/dist/components/MultiTextFieldBase/hooks.d.ts +15 -0
- package/dist/components/MultiTextFieldBase/hooks.js +108 -0
- package/dist/components/MultiTextFieldBase/index.d.ts +1 -0
- package/dist/components/MultiTextFieldBase/index.js +10 -0
- package/dist/components/SearchField/SearchField.d.ts +6 -0
- package/dist/components/SearchField/SearchFieldShowcase.d.ts +6 -0
- package/dist/components/Select/Select.d.ts +10 -0
- package/dist/components/Select/Select.js +7 -5
- package/dist/components/Select/components/SelectMenu/SelectMenu.style.d.ts +6 -0
- package/dist/components/TextField/TextField.d.ts +24 -0
- package/dist/components/TextField/TextField.js +44 -6
- package/dist/components/TextField/hooks/useMultiTextFieldUtils.d.ts +11 -0
- package/dist/components/TextField/hooks/useMultiTextFieldUtils.js +97 -0
- package/dist/components/TextInputBase/TextInputBase.d.ts +2 -0
- package/dist/components/TextInputBase/TextInputBase.js +4 -1
- package/dist/components/TextInputBase/TextInputBase.style.d.ts +1 -1
- package/dist/components/TextInputBase/TextInputBase.style.js +7 -6
- package/dist/components/TextInputBase/config.d.ts +4 -3
- package/dist/components/TextInputBase/config.js +3 -1
- package/dist/components/utils/PositionInScreen/PositionInScreen.d.ts +6 -0
- package/dist/components/utils/PositionInScreen/PositionInScreen.js +3 -2
- package/dist/components/utils/PositionInScreen/PositionInScreen.style.d.ts +9 -2
- package/dist/components/utils/PositionInScreen/PositionInScreen.style.js +23 -4
- package/dist/utils/size-utils.d.ts +2 -1
- package/dist/utils/size-utils.js +11 -3
- package/package.json +1 -1
- package/dist/components/Filter/components/SearchInput/SearchInput.style.js +0 -34
- package/dist/components/Select/components/MultiselectTextField/MultiselectTextField.d.ts +0 -19
- package/dist/components/Select/components/MultiselectTextField/MultiselectTextField.style.js +0 -149
- package/dist/components/Select/components/MultiselectTextField/index.d.ts +0 -1
- package/dist/components/Select/components/MultiselectTextField/index.js +0 -10
- /package/dist/components/Filter/components/{SearchInput → SingleFilter/components/SearchInput}/SearchInput.style.d.ts +0 -0
package/dist/components/Filter/components/SingleFilter/components/SearchInput/SearchInput.style.js
ADDED
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
exports.__esModule = true;
|
|
4
|
+
exports.iconWrapper = exports.textFieldWrapper = void 0;
|
|
5
|
+
|
|
6
|
+
var _react = require("@emotion/react");
|
|
7
|
+
|
|
8
|
+
var _utils = require("../../../../../../theme/utils");
|
|
9
|
+
|
|
10
|
+
var textFieldWrapper = function textFieldWrapper() {
|
|
11
|
+
return function (theme) {
|
|
12
|
+
return (
|
|
13
|
+
/*#__PURE__*/
|
|
14
|
+
|
|
15
|
+
/*#__PURE__*/
|
|
16
|
+
(0, _react.css)("border-bottom:1px solid ", theme.utils.getColor('lightGrey', 250), ";div:first-of-type{outline:none;border:none;box-shadow:none;background-color:white;}input{border:none;&:focus{outline:none;border:none;box-shadow:none;}}" + (process.env.NODE_ENV === "production" ? "" : ";label:textFieldWrapper;"), process.env.NODE_ENV === "production" ? "" : "/*# sourceMappingURL=data:application/json;charset=utf-8;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbIi4uLy4uLy4uLy4uLy4uLy4uLy4uL3NyYy9jb21wb25lbnRzL0ZpbHRlci9jb21wb25lbnRzL1NpbmdsZUZpbHRlci9jb21wb25lbnRzL1NlYXJjaElucHV0L1NlYXJjaElucHV0LnN0eWxlLnRzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiJBQUkyRCIsImZpbGUiOiIuLi8uLi8uLi8uLi8uLi8uLi8uLi9zcmMvY29tcG9uZW50cy9GaWx0ZXIvY29tcG9uZW50cy9TaW5nbGVGaWx0ZXIvY29tcG9uZW50cy9TZWFyY2hJbnB1dC9TZWFyY2hJbnB1dC5zdHlsZS50cyIsInNvdXJjZXNDb250ZW50IjpbImltcG9ydCB7IGNzcyB9IGZyb20gJ0BlbW90aW9uL3JlYWN0JztcbmltcG9ydCB7IFRoZW1lIH0gZnJvbSAndGhlbWUnO1xuaW1wb3J0IHsgcmVtIH0gZnJvbSAndGhlbWUvdXRpbHMnO1xuXG5leHBvcnQgY29uc3QgdGV4dEZpZWxkV3JhcHBlciA9ICgpID0+ICh0aGVtZTogVGhlbWUpID0+IGNzc2BcbiAgYm9yZGVyLWJvdHRvbTogMXB4IHNvbGlkICR7dGhlbWUudXRpbHMuZ2V0Q29sb3IoJ2xpZ2h0R3JleScsIDI1MCl9O1xuXG4gIGRpdjpmaXJzdC1vZi10eXBlIHtcbiAgICBvdXRsaW5lOiBub25lO1xuICAgIGJvcmRlcjogbm9uZTtcbiAgICBib3gtc2hhZG93OiBub25lO1xuICAgIGJhY2tncm91bmQtY29sb3I6IHdoaXRlO1xuICB9XG5cbiAgaW5wdXQge1xuICAgIGJvcmRlcjogbm9uZTtcblxuICAgICY6Zm9jdXMge1xuICAgICAgb3V0bGluZTogbm9uZTtcbiAgICAgIGJvcmRlcjogbm9uZTtcbiAgICAgIGJveC1zaGFkb3c6IG5vbmU7XG4gICAgfVxuICB9XG5gO1xuXG5leHBvcnQgY29uc3QgaWNvbldyYXBwZXIgPSAoKSA9PiAoKSA9PiBjc3NgXG4gIGRpc3BsYXk6IGZsZXg7XG4gIGdhcDogJHtyZW0oMjUpfTtcbmA7XG4iXX0= */", process.env.NODE_ENV === "production" ? "" : ";label:textFieldWrapper;")
|
|
17
|
+
);
|
|
18
|
+
};
|
|
19
|
+
};
|
|
20
|
+
|
|
21
|
+
exports.textFieldWrapper = textFieldWrapper;
|
|
22
|
+
|
|
23
|
+
var iconWrapper = function iconWrapper() {
|
|
24
|
+
return function () {
|
|
25
|
+
return (
|
|
26
|
+
/*#__PURE__*/
|
|
27
|
+
|
|
28
|
+
/*#__PURE__*/
|
|
29
|
+
(0, _react.css)("display:flex;gap:", (0, _utils.rem)(25), ";" + (process.env.NODE_ENV === "production" ? "" : ";label:iconWrapper;"), process.env.NODE_ENV === "production" ? "" : "/*# sourceMappingURL=data:application/json;charset=utf-8;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbIi4uLy4uLy4uLy4uLy4uLy4uLy4uL3NyYy9jb21wb25lbnRzL0ZpbHRlci9jb21wb25lbnRzL1NpbmdsZUZpbHRlci9jb21wb25lbnRzL1NlYXJjaElucHV0L1NlYXJjaElucHV0LnN0eWxlLnRzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiJBQXlCMEMiLCJmaWxlIjoiLi4vLi4vLi4vLi4vLi4vLi4vLi4vc3JjL2NvbXBvbmVudHMvRmlsdGVyL2NvbXBvbmVudHMvU2luZ2xlRmlsdGVyL2NvbXBvbmVudHMvU2VhcmNoSW5wdXQvU2VhcmNoSW5wdXQuc3R5bGUudHMiLCJzb3VyY2VzQ29udGVudCI6WyJpbXBvcnQgeyBjc3MgfSBmcm9tICdAZW1vdGlvbi9yZWFjdCc7XG5pbXBvcnQgeyBUaGVtZSB9IGZyb20gJ3RoZW1lJztcbmltcG9ydCB7IHJlbSB9IGZyb20gJ3RoZW1lL3V0aWxzJztcblxuZXhwb3J0IGNvbnN0IHRleHRGaWVsZFdyYXBwZXIgPSAoKSA9PiAodGhlbWU6IFRoZW1lKSA9PiBjc3NgXG4gIGJvcmRlci1ib3R0b206IDFweCBzb2xpZCAke3RoZW1lLnV0aWxzLmdldENvbG9yKCdsaWdodEdyZXknLCAyNTApfTtcblxuICBkaXY6Zmlyc3Qtb2YtdHlwZSB7XG4gICAgb3V0bGluZTogbm9uZTtcbiAgICBib3JkZXI6IG5vbmU7XG4gICAgYm94LXNoYWRvdzogbm9uZTtcbiAgICBiYWNrZ3JvdW5kLWNvbG9yOiB3aGl0ZTtcbiAgfVxuXG4gIGlucHV0IHtcbiAgICBib3JkZXI6IG5vbmU7XG5cbiAgICAmOmZvY3VzIHtcbiAgICAgIG91dGxpbmU6IG5vbmU7XG4gICAgICBib3JkZXI6IG5vbmU7XG4gICAgICBib3gtc2hhZG93OiBub25lO1xuICAgIH1cbiAgfVxuYDtcblxuZXhwb3J0IGNvbnN0IGljb25XcmFwcGVyID0gKCkgPT4gKCkgPT4gY3NzYFxuICBkaXNwbGF5OiBmbGV4O1xuICBnYXA6ICR7cmVtKDI1KX07XG5gO1xuIl19 */", process.env.NODE_ENV === "production" ? "" : ";label:iconWrapper;")
|
|
30
|
+
);
|
|
31
|
+
};
|
|
32
|
+
};
|
|
33
|
+
|
|
34
|
+
exports.iconWrapper = iconWrapper;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { default } from './SearchInput';
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
exports.__esModule = true;
|
|
4
|
+
exports["default"] = void 0;
|
|
5
|
+
|
|
6
|
+
var _SearchInput = _interopRequireDefault(require("./SearchInput"));
|
|
7
|
+
|
|
8
|
+
exports["default"] = _SearchInput["default"];
|
|
9
|
+
|
|
10
|
+
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { default } from './SingleFilter';
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
exports.__esModule = true;
|
|
4
|
+
exports["default"] = void 0;
|
|
5
|
+
|
|
6
|
+
var _SingleFilter = _interopRequireDefault(require("./SingleFilter"));
|
|
7
|
+
|
|
8
|
+
exports["default"] = _SingleFilter["default"];
|
|
9
|
+
|
|
10
|
+
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
/// <reference types="react" />
|
|
2
|
+
import { FilterOption } from '../types';
|
|
3
|
+
import { Props as FilterProps } from '../types';
|
|
4
|
+
declare type Props = Pick<FilterProps, 'multi' | 'selectedItems' | 'items' | 'defaultValue' | 'onClear' | 'onFilterDelete'> & {
|
|
5
|
+
setFilterLabel: (value: string) => void;
|
|
6
|
+
setIsOpen: (value: boolean) => void;
|
|
7
|
+
setSearchValue: (value: string) => void;
|
|
8
|
+
};
|
|
9
|
+
declare const useMultiFilterUtils: ({ multi, selectedItems, items, defaultValue, setFilterLabel, setIsOpen, onClear, setSearchValue, onFilterDelete, }: Props) => {
|
|
10
|
+
availableMultiFilters: import("../../Select/Select").SelectOptionValues[];
|
|
11
|
+
setAvailableMultiFilters: import("react").Dispatch<import("react").SetStateAction<import("../../Select/Select").SelectOptionValues[]>>;
|
|
12
|
+
multiFilters: import("../../Select/Select").SelectOptionValues[];
|
|
13
|
+
setMultiFilters: import("react").Dispatch<import("react").SetStateAction<import("../../Select/Select").SelectOptionValues[]>>;
|
|
14
|
+
handleOptionDelete: (option?: import("../../Select/Select").SelectOptionValues | undefined) => void;
|
|
15
|
+
handleClearAllOptions: () => void;
|
|
16
|
+
handleMultiSelectOptionClick: (option: FilterOption) => void;
|
|
17
|
+
};
|
|
18
|
+
export default useMultiFilterUtils;
|
|
@@ -0,0 +1,124 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
exports.__esModule = true;
|
|
4
|
+
exports["default"] = void 0;
|
|
5
|
+
|
|
6
|
+
var _lodash = require("lodash");
|
|
7
|
+
|
|
8
|
+
var _react = require("react");
|
|
9
|
+
|
|
10
|
+
var _constants = require("../../Select/constants");
|
|
11
|
+
|
|
12
|
+
var useMultiFilterUtils = function useMultiFilterUtils(_ref) {
|
|
13
|
+
var multi = _ref.multi,
|
|
14
|
+
_ref$selectedItems = _ref.selectedItems,
|
|
15
|
+
selectedItems = _ref$selectedItems === void 0 ? [] : _ref$selectedItems,
|
|
16
|
+
items = _ref.items,
|
|
17
|
+
defaultValue = _ref.defaultValue,
|
|
18
|
+
setFilterLabel = _ref.setFilterLabel,
|
|
19
|
+
setIsOpen = _ref.setIsOpen,
|
|
20
|
+
onClear = _ref.onClear,
|
|
21
|
+
setSearchValue = _ref.setSearchValue,
|
|
22
|
+
_ref$onFilterDelete = _ref.onFilterDelete,
|
|
23
|
+
onFilterDelete = _ref$onFilterDelete === void 0 ? function () {} : _ref$onFilterDelete;
|
|
24
|
+
|
|
25
|
+
var _useState = (0, _react.useState)([]),
|
|
26
|
+
availableMultiFilters = _useState[0],
|
|
27
|
+
setAvailableMultiFilters = _useState[1];
|
|
28
|
+
|
|
29
|
+
var _useState2 = (0, _react.useState)(selectedItems),
|
|
30
|
+
multiFilters = _useState2[0],
|
|
31
|
+
setMultiFilters = _useState2[1];
|
|
32
|
+
|
|
33
|
+
(0, _react.useEffect)(function () {
|
|
34
|
+
if (multi) {
|
|
35
|
+
var _multiFilters$map, _items$filter;
|
|
36
|
+
|
|
37
|
+
var selectedFilterValues = (_multiFilters$map = multiFilters == null ? void 0 : multiFilters.map(function (_ref2) {
|
|
38
|
+
var value = _ref2.value;
|
|
39
|
+
return value;
|
|
40
|
+
})) != null ? _multiFilters$map : [];
|
|
41
|
+
setAvailableMultiFilters((_items$filter = items == null ? void 0 : items.filter(function (item) {
|
|
42
|
+
return !selectedFilterValues.includes(item.value);
|
|
43
|
+
})) != null ? _items$filter : []);
|
|
44
|
+
}
|
|
45
|
+
}, [items, multiFilters, multi]);
|
|
46
|
+
var updateMultiFilterLabel = (0, _react.useCallback)(function (items) {
|
|
47
|
+
if (items.length > 0) {
|
|
48
|
+
if (items.length === 1) {
|
|
49
|
+
setFilterLabel(items[0].label);
|
|
50
|
+
} else {
|
|
51
|
+
setFilterLabel(items[0].label + " + " + (items.length - 1) + " more");
|
|
52
|
+
}
|
|
53
|
+
} else {
|
|
54
|
+
setFilterLabel(defaultValue.label);
|
|
55
|
+
}
|
|
56
|
+
}, [defaultValue.label, setFilterLabel]);
|
|
57
|
+
var handleOptionDelete = (0, _react.useCallback)(function (option) {
|
|
58
|
+
if (option) {
|
|
59
|
+
var newItems = multiFilters.filter(function (opt) {
|
|
60
|
+
return opt.value !== (option == null ? void 0 : option.value);
|
|
61
|
+
});
|
|
62
|
+
setMultiFilters(newItems);
|
|
63
|
+
setAvailableMultiFilters([].concat(availableMultiFilters, [option]));
|
|
64
|
+
onFilterDelete(option);
|
|
65
|
+
updateMultiFilterLabel(newItems);
|
|
66
|
+
} else {
|
|
67
|
+
if (multiFilters.length > 0) {
|
|
68
|
+
var lastItem = multiFilters[multiFilters.length - 1];
|
|
69
|
+
|
|
70
|
+
var _newItems = multiFilters.filter(function (opt) {
|
|
71
|
+
return opt.value !== lastItem.value;
|
|
72
|
+
});
|
|
73
|
+
|
|
74
|
+
setMultiFilters(_newItems);
|
|
75
|
+
setAvailableMultiFilters([].concat(availableMultiFilters, [lastItem]));
|
|
76
|
+
updateMultiFilterLabel(_newItems);
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
}, [availableMultiFilters, multiFilters, onFilterDelete, updateMultiFilterLabel]);
|
|
80
|
+
|
|
81
|
+
var handleMultiSelectOptionClick = function handleMultiSelectOptionClick(option) {
|
|
82
|
+
var newItems = [];
|
|
83
|
+
|
|
84
|
+
if ((0, _lodash.isEqual)(option, _constants.SELECT_ALL_OPTION)) {
|
|
85
|
+
newItems = [].concat(multiFilters, availableMultiFilters);
|
|
86
|
+
setMultiFilters(newItems);
|
|
87
|
+
setAvailableMultiFilters([]);
|
|
88
|
+
setIsOpen(false);
|
|
89
|
+
} else {
|
|
90
|
+
newItems = [].concat(multiFilters, [option]);
|
|
91
|
+
setMultiFilters(newItems);
|
|
92
|
+
setAvailableMultiFilters(availableMultiFilters.filter(function (opt) {
|
|
93
|
+
return opt.value !== option.value;
|
|
94
|
+
}));
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
updateMultiFilterLabel(newItems);
|
|
98
|
+
};
|
|
99
|
+
|
|
100
|
+
var handleClearAllOptions = function handleClearAllOptions() {
|
|
101
|
+
setAvailableMultiFilters([].concat(availableMultiFilters, multiFilters));
|
|
102
|
+
setMultiFilters([]);
|
|
103
|
+
|
|
104
|
+
if (onClear) {
|
|
105
|
+
onClear();
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
setSearchValue('');
|
|
109
|
+
setFilterLabel(defaultValue.label);
|
|
110
|
+
};
|
|
111
|
+
|
|
112
|
+
return {
|
|
113
|
+
availableMultiFilters: availableMultiFilters,
|
|
114
|
+
setAvailableMultiFilters: setAvailableMultiFilters,
|
|
115
|
+
multiFilters: multiFilters,
|
|
116
|
+
setMultiFilters: setMultiFilters,
|
|
117
|
+
handleOptionDelete: handleOptionDelete,
|
|
118
|
+
handleClearAllOptions: handleClearAllOptions,
|
|
119
|
+
handleMultiSelectOptionClick: handleMultiSelectOptionClick
|
|
120
|
+
};
|
|
121
|
+
};
|
|
122
|
+
|
|
123
|
+
var _default = useMultiFilterUtils;
|
|
124
|
+
exports["default"] = _default;
|
|
@@ -15,8 +15,13 @@ export declare type Props = {
|
|
|
15
15
|
defaultValue: FilterOption;
|
|
16
16
|
/** A callback that is being triggered when an items has been clicked */
|
|
17
17
|
onSelect: (option: FilterOption) => void;
|
|
18
|
-
/**
|
|
18
|
+
/**
|
|
19
|
+
* For SingleFilter: callback for the X button of the 'added' type filter
|
|
20
|
+
* For MultiFilter: callback for the Clear All button
|
|
21
|
+
*/
|
|
19
22
|
onClear?: () => void;
|
|
23
|
+
/** A callback that's called when the user clicks the 'clear' icon of a specific Chip in MultiFilter */
|
|
24
|
+
onFilterDelete?: (option: FilterOption) => void;
|
|
20
25
|
/** The text of the button to show */
|
|
21
26
|
label: React.ReactNode;
|
|
22
27
|
/** Defines the style type of the button */
|
|
@@ -37,6 +42,13 @@ export declare type Props = {
|
|
|
37
42
|
isLoading?: boolean;
|
|
38
43
|
/** Whether the Options List is Virtualized or not */
|
|
39
44
|
isVirtualized?: boolean;
|
|
45
|
+
/** If true the user can select multiple filters */
|
|
46
|
+
multi?: boolean;
|
|
47
|
+
/** The selected filters in case of MultiFilter */
|
|
48
|
+
/** @TODO merge selectedItem with selectedItems in v5 */
|
|
49
|
+
selectedItems?: FilterOption[];
|
|
50
|
+
/** Whether the MultiFilter should have a Select All option*/
|
|
51
|
+
hasSelectAllOption?: boolean;
|
|
40
52
|
/** data-testid suffix */
|
|
41
53
|
dataTestId?: string;
|
|
42
54
|
};
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { TestProps } from 'utils/types';
|
|
3
|
+
import { SelectOption } from 'components/Select/Select';
|
|
4
|
+
import { Props as TextFieldProps } from 'components/TextField/TextField';
|
|
5
|
+
export declare type Props = {
|
|
6
|
+
/** the values of the MultiTextField if MultiTextField is controlled */
|
|
7
|
+
selectedOptions?: SelectOption[] | string[];
|
|
8
|
+
/** Callback fired when the `input` value typed is changed */
|
|
9
|
+
onInput?: React.EventHandler<any>;
|
|
10
|
+
/** Value of the `input` element */
|
|
11
|
+
value?: string | number;
|
|
12
|
+
/** Callback fired when the Delete button of each Chip is clicked */
|
|
13
|
+
onOptionDelete: (option?: SelectOption | string) => void;
|
|
14
|
+
/** Callback fired when the Delete button of the whole MultiSelect is clicked */
|
|
15
|
+
onClearAllOptions: () => void;
|
|
16
|
+
/** If the component is loading */
|
|
17
|
+
isLoading?: boolean;
|
|
18
|
+
/** Whether the Textfield should change its styles when hovered/focused etc */
|
|
19
|
+
isInteractive?: boolean;
|
|
20
|
+
/** If true, the TextField has a dynamic width, bounded by max and min width values */
|
|
21
|
+
isResponsive?: boolean;
|
|
22
|
+
isTextfield?: boolean;
|
|
23
|
+
} & Omit<TextFieldProps, 'size'>;
|
|
24
|
+
declare const MultiTextFieldBase: React.ForwardRefExoticComponent<{
|
|
25
|
+
/** the values of the MultiTextField if MultiTextField is controlled */
|
|
26
|
+
selectedOptions?: string[] | SelectOption[] | undefined;
|
|
27
|
+
/** Callback fired when the `input` value typed is changed */
|
|
28
|
+
onInput?: ((event: any) => void) | undefined;
|
|
29
|
+
/** Value of the `input` element */
|
|
30
|
+
value?: string | number | undefined;
|
|
31
|
+
/** Callback fired when the Delete button of each Chip is clicked */
|
|
32
|
+
onOptionDelete: (option?: string | SelectOption | undefined) => void;
|
|
33
|
+
/** Callback fired when the Delete button of the whole MultiSelect is clicked */
|
|
34
|
+
onClearAllOptions: () => void;
|
|
35
|
+
/** If the component is loading */
|
|
36
|
+
isLoading?: boolean | undefined;
|
|
37
|
+
/** Whether the Textfield should change its styles when hovered/focused etc */
|
|
38
|
+
isInteractive?: boolean | undefined;
|
|
39
|
+
/** If true, the TextField has a dynamic width, bounded by max and min width values */
|
|
40
|
+
isResponsive?: boolean | undefined;
|
|
41
|
+
isTextfield?: boolean | undefined;
|
|
42
|
+
} & Omit<TextFieldProps, "size"> & Partial<Omit<React.InputHTMLAttributes<HTMLInputElement>, "size">> & TestProps & React.RefAttributes<HTMLInputElement>>;
|
|
43
|
+
export default MultiTextFieldBase;
|
|
@@ -3,31 +3,31 @@
|
|
|
3
3
|
exports.__esModule = true;
|
|
4
4
|
exports["default"] = void 0;
|
|
5
5
|
|
|
6
|
-
var _useTheme = _interopRequireDefault(require("
|
|
6
|
+
var _useTheme = _interopRequireDefault(require("../../hooks/useTheme"));
|
|
7
7
|
|
|
8
8
|
var _omit = _interopRequireDefault(require("lodash/omit"));
|
|
9
9
|
|
|
10
10
|
var _react = _interopRequireWildcard(require("react"));
|
|
11
11
|
|
|
12
|
-
var _helpers = require("
|
|
12
|
+
var _helpers = require("../../utils/helpers");
|
|
13
13
|
|
|
14
|
-
var
|
|
14
|
+
var _hooks = _interopRequireDefault(require("./hooks"));
|
|
15
15
|
|
|
16
|
-
var
|
|
16
|
+
var _MultiTextFieldBase = require("./MultiTextFieldBase.style");
|
|
17
17
|
|
|
18
|
-
var
|
|
18
|
+
var _Chip = _interopRequireDefault(require("../Chip"));
|
|
19
19
|
|
|
20
|
-
var _Label = _interopRequireDefault(require("
|
|
20
|
+
var _Label = _interopRequireDefault(require("../Label"));
|
|
21
21
|
|
|
22
|
-
var _Loader = _interopRequireDefault(require("
|
|
22
|
+
var _Loader = _interopRequireDefault(require("../Loader"));
|
|
23
23
|
|
|
24
|
-
var _TextInputBase = _interopRequireDefault(require("
|
|
24
|
+
var _TextInputBase = _interopRequireDefault(require("../TextInputBase"));
|
|
25
25
|
|
|
26
|
-
var _TextInputBase2 = require("
|
|
26
|
+
var _TextInputBase2 = require("../TextInputBase/TextInputBase.style");
|
|
27
27
|
|
|
28
28
|
var _react2 = require("@emotion/react");
|
|
29
29
|
|
|
30
|
-
var _excluded = ["selectedOptions", "value", "disabled", "locked", "status", "lean", "dark", "readOnly", "label", "id", "placeholder", "required", "styleType", "onOptionDelete", "onClearAllOptions", "isLoading", "rightIcon"];
|
|
30
|
+
var _excluded = ["selectedOptions", "value", "disabled", "locked", "status", "lean", "dark", "readOnly", "label", "id", "placeholder", "required", "styleType", "onOptionDelete", "onClearAllOptions", "isLoading", "rightIcon", "isInteractive", "isResponsive", "isTextfield"];
|
|
31
31
|
|
|
32
32
|
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); }
|
|
33
33
|
|
|
@@ -39,7 +39,7 @@ function _extends() { _extends = Object.assign || function (target) { for (var i
|
|
|
39
39
|
|
|
40
40
|
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; }
|
|
41
41
|
|
|
42
|
-
var
|
|
42
|
+
var MultiTextFieldBase = /*#__PURE__*/_react["default"].forwardRef(function (props, ref) {
|
|
43
43
|
var selectedOptions = props.selectedOptions,
|
|
44
44
|
value = props.value,
|
|
45
45
|
disabled = props.disabled,
|
|
@@ -58,36 +58,34 @@ var MultiselectTextField = /*#__PURE__*/_react["default"].forwardRef(function (p
|
|
|
58
58
|
onClearAllOptions = props.onClearAllOptions,
|
|
59
59
|
isLoading = props.isLoading,
|
|
60
60
|
rightIcon = props.rightIcon,
|
|
61
|
+
_props$isInteractive = props.isInteractive,
|
|
62
|
+
isInteractive = _props$isInteractive === void 0 ? true : _props$isInteractive,
|
|
63
|
+
_props$isResponsive = props.isResponsive,
|
|
64
|
+
isResponsive = _props$isResponsive === void 0 ? false : _props$isResponsive,
|
|
65
|
+
_props$isTextfield = props.isTextfield,
|
|
66
|
+
isTextfield = _props$isTextfield === void 0 ? false : _props$isTextfield,
|
|
61
67
|
rest = _objectWithoutPropertiesLoose(props, _excluded);
|
|
62
68
|
|
|
63
|
-
var TextfieldRef = _react["default"].useRef(null);
|
|
64
|
-
|
|
65
69
|
var theme = (0, _useTheme["default"])();
|
|
66
70
|
var hasValue = Boolean(value || (selectedOptions == null ? void 0 : selectedOptions.length) && (selectedOptions == null ? void 0 : selectedOptions.length) > 0);
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
var handleKeyDown = function handleKeyDown(event) {
|
|
87
|
-
if (value === '' && event.key === 'Backspace') {
|
|
88
|
-
onOptionDelete();
|
|
89
|
-
}
|
|
90
|
-
};
|
|
71
|
+
|
|
72
|
+
var _useMultiTextFieldBas = (0, _hooks["default"])({
|
|
73
|
+
isTextfield: isTextfield,
|
|
74
|
+
label: label,
|
|
75
|
+
placeholder: placeholder,
|
|
76
|
+
required: required,
|
|
77
|
+
locked: locked,
|
|
78
|
+
hasValue: hasValue,
|
|
79
|
+
value: value,
|
|
80
|
+
rightIcon: rightIcon,
|
|
81
|
+
onOptionDelete: onOptionDelete,
|
|
82
|
+
onClearAllOptions: onClearAllOptions
|
|
83
|
+
}),
|
|
84
|
+
inputPlaceholder = _useMultiTextFieldBas.inputPlaceholder,
|
|
85
|
+
handleKeyDown = _useMultiTextFieldBas.handleKeyDown,
|
|
86
|
+
icon = _useMultiTextFieldBas.icon,
|
|
87
|
+
hasLabel = _useMultiTextFieldBas.hasLabel,
|
|
88
|
+
TextfieldRef = _useMultiTextFieldBas.TextfieldRef;
|
|
91
89
|
|
|
92
90
|
var chips = (0, _react.useMemo)(function () {
|
|
93
91
|
return (0, _react2.jsx)(_react["default"].Fragment, null, selectedOptions == null ? void 0 : selectedOptions.map(function (option, index) {
|
|
@@ -95,7 +93,7 @@ var MultiselectTextField = /*#__PURE__*/_react["default"].forwardRef(function (p
|
|
|
95
93
|
|
|
96
94
|
return (0, _react2.jsx)("span", {
|
|
97
95
|
key: (0, _helpers.generateUniqueID)('chip' + index),
|
|
98
|
-
css: (0,
|
|
96
|
+
css: (0, _MultiTextFieldBase.chipStyle)()
|
|
99
97
|
}, (0, _react2.jsx)(_Chip["default"], {
|
|
100
98
|
onClear: !(locked || disabled) ? function () {
|
|
101
99
|
return onOptionDelete(option);
|
|
@@ -103,50 +101,33 @@ var MultiselectTextField = /*#__PURE__*/_react["default"].forwardRef(function (p
|
|
|
103
101
|
fill: "lightGrey",
|
|
104
102
|
dataTestId: "chip_" + index
|
|
105
103
|
}, (0, _react2.jsx)("div", {
|
|
106
|
-
title: option.label,
|
|
107
|
-
css: (0,
|
|
104
|
+
title: typeof option === 'string' ? option : option.label,
|
|
105
|
+
css: (0, _MultiTextFieldBase.chipContent)({
|
|
108
106
|
maxWidth: (_TextfieldRef$current = TextfieldRef.current) == null ? void 0 : _TextfieldRef$current.getBoundingClientRect().width
|
|
109
107
|
})
|
|
110
|
-
}, option.label)));
|
|
108
|
+
}, typeof option === 'string' ? option : option.label)));
|
|
111
109
|
}));
|
|
112
110
|
}, [disabled, locked, onOptionDelete, selectedOptions]);
|
|
113
|
-
var icon = (0, _react.useMemo)(function () {
|
|
114
|
-
if (rightIcon) {
|
|
115
|
-
if (typeof rightIcon === 'string') {
|
|
116
|
-
return (0, _react2.jsx)(_Icon["default"], {
|
|
117
|
-
name: rightIcon,
|
|
118
|
-
size: 20,
|
|
119
|
-
color: theme.utils.getColor('lightGrey', 650)
|
|
120
|
-
});
|
|
121
|
-
}
|
|
122
|
-
|
|
123
|
-
return rightIcon;
|
|
124
|
-
}
|
|
125
|
-
|
|
126
|
-
return (0, _react2.jsx)(_Icon["default"], {
|
|
127
|
-
size: 20,
|
|
128
|
-
name: iconName,
|
|
129
|
-
color: theme.utils.getColor('lightGrey', 650),
|
|
130
|
-
onClick: hasValue && !locked ? onClearAllOptions : undefined,
|
|
131
|
-
dataTestId: "select-right-icon"
|
|
132
|
-
});
|
|
133
|
-
}, [hasValue, iconName, locked, onClearAllOptions, rightIcon, theme.utils]);
|
|
134
111
|
return (0, _react2.jsx)("div", {
|
|
135
112
|
ref: TextfieldRef
|
|
136
113
|
}, (0, _react2.jsx)(_TextInputBase["default"], _extends({
|
|
137
|
-
disabled: disabled,
|
|
138
|
-
locked: locked,
|
|
139
|
-
status: status,
|
|
114
|
+
disabled: isInteractive && disabled,
|
|
115
|
+
locked: isInteractive && locked,
|
|
116
|
+
status: isInteractive ? status : 'normal',
|
|
140
117
|
lean: lean,
|
|
141
118
|
size: 'md',
|
|
142
119
|
styleType: styleType
|
|
143
120
|
}, rest, {
|
|
144
|
-
|
|
121
|
+
isInteractive: isInteractive,
|
|
122
|
+
sx: (0, _MultiTextFieldBase.textInputBaseOverrides)({
|
|
145
123
|
hasValue: hasValue,
|
|
146
|
-
isLoading: isLoading
|
|
124
|
+
isLoading: isLoading,
|
|
125
|
+
hasLabel: hasLabel,
|
|
126
|
+
isResponsive: isResponsive,
|
|
127
|
+
isTextfield: isTextfield
|
|
147
128
|
})(theme)
|
|
148
129
|
}), (0, _react2.jsx)("div", {
|
|
149
|
-
css: (0,
|
|
130
|
+
css: (0, _MultiTextFieldBase.inputContainer)()
|
|
150
131
|
}, chips, (0, _react2.jsx)("input", _extends({
|
|
151
132
|
readOnly: readOnly,
|
|
152
133
|
onKeyDown: handleKeyDown,
|
|
@@ -156,7 +137,7 @@ var MultiselectTextField = /*#__PURE__*/_react["default"].forwardRef(function (p
|
|
|
156
137
|
label: label,
|
|
157
138
|
dark: dark,
|
|
158
139
|
lean: lean,
|
|
159
|
-
sx: (0,
|
|
140
|
+
sx: (0, _MultiTextFieldBase.inputOverrides)()
|
|
160
141
|
}),
|
|
161
142
|
placeholder: inputPlaceholder,
|
|
162
143
|
required: required,
|
|
@@ -173,14 +154,14 @@ var MultiselectTextField = /*#__PURE__*/_react["default"].forwardRef(function (p
|
|
|
173
154
|
animateToTop: hasValue,
|
|
174
155
|
error: status === 'error'
|
|
175
156
|
})), !disabled && (0, _react2.jsx)("div", {
|
|
176
|
-
css: (0,
|
|
177
|
-
}, isLoading && (0, _react2.jsx)(_Loader["default"], null), (0, _react2.jsx)("div", {
|
|
178
|
-
css: (0,
|
|
157
|
+
css: (0, _MultiTextFieldBase.rightIconsContainer)()
|
|
158
|
+
}, isLoading && (0, _react2.jsx)(_Loader["default"], null), icon && (0, _react2.jsx)("div", {
|
|
159
|
+
css: (0, _MultiTextFieldBase.rightIconStyles)({
|
|
179
160
|
isClickable: hasValue && !locked
|
|
180
161
|
})
|
|
181
162
|
}, icon))));
|
|
182
163
|
});
|
|
183
164
|
|
|
184
|
-
|
|
185
|
-
var _default =
|
|
165
|
+
MultiTextFieldBase.displayName = 'MultiTextFieldBase';
|
|
166
|
+
var _default = MultiTextFieldBase;
|
|
186
167
|
exports["default"] = _default;
|
|
@@ -11,9 +11,12 @@ export declare const rightIconStyles: ({ isClickable }: {
|
|
|
11
11
|
export declare const chipStyle: () => (theme: Theme) => SerializedStyles;
|
|
12
12
|
export declare const inputContainer: () => (theme: Theme) => SerializedStyles;
|
|
13
13
|
/** TextField overrides */
|
|
14
|
-
export declare const textInputBaseOverrides: ({ hasValue, isLoading }: {
|
|
14
|
+
export declare const textInputBaseOverrides: ({ hasValue, isLoading, hasLabel, isResponsive, isTextfield, }: {
|
|
15
15
|
hasValue: boolean;
|
|
16
16
|
isLoading?: boolean | undefined;
|
|
17
|
+
hasLabel?: boolean | undefined;
|
|
18
|
+
isResponsive?: boolean | undefined;
|
|
19
|
+
isTextfield?: boolean | undefined;
|
|
17
20
|
}) => (theme: Theme) => {
|
|
18
21
|
wrapper: {
|
|
19
22
|
label: {
|
|
@@ -38,6 +41,8 @@ export declare const textInputBaseOverrides: ({ hasValue, isLoading }: {
|
|
|
38
41
|
minHeight: string;
|
|
39
42
|
};
|
|
40
43
|
textField: {
|
|
44
|
+
width?: string | undefined;
|
|
45
|
+
minWidth?: string | undefined;
|
|
41
46
|
padding: string;
|
|
42
47
|
};
|
|
43
48
|
};
|