@orfium/ictinus 4.65.0 → 4.66.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/{Select/components/MultiselectTextField/MultiselectTextField.d.ts → MultiSelectBase/MultiSelectBase.d.ts} +6 -2
- package/dist/components/{Select/components/MultiselectTextField/MultiselectTextField.js → MultiSelectBase/MultiSelectBase.js} +48 -71
- package/dist/components/{Select/components/MultiselectTextField/MultiselectTextField.style.d.ts → MultiSelectBase/MultiSelectBase.style.d.ts} +5 -1
- package/dist/components/MultiSelectBase/MultiSelectBase.style.js +156 -0
- package/dist/components/MultiSelectBase/hooks.d.ts +17 -0
- package/dist/components/MultiSelectBase/hooks.js +91 -0
- package/dist/components/MultiSelectBase/index.d.ts +1 -0
- package/dist/components/MultiSelectBase/index.js +10 -0
- package/dist/components/Select/Select.d.ts +4 -0
- package/dist/components/Select/Select.js +7 -5
- 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/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/package.json +1 -1
- package/dist/components/Filter/components/SearchInput/SearchInput.style.js +0 -34
- 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
|
};
|
|
@@ -2,7 +2,7 @@ import React from 'react';
|
|
|
2
2
|
import { TestProps } from 'utils/types';
|
|
3
3
|
import { SelectOption } from 'components/Select/Select';
|
|
4
4
|
import { Props as TextFieldProps } from 'components/TextField/TextField';
|
|
5
|
-
declare const
|
|
5
|
+
declare const MultiSelectBase: React.ForwardRefExoticComponent<{
|
|
6
6
|
/** the values of the MultiSelect if MultiSelect is controlled */
|
|
7
7
|
selectedOptions?: SelectOption[] | undefined;
|
|
8
8
|
/** Callback fired when the `input` value typed is changed */
|
|
@@ -15,5 +15,9 @@ declare const MultiselectTextField: React.ForwardRefExoticComponent<{
|
|
|
15
15
|
onClearAllOptions: () => void;
|
|
16
16
|
/** If the component is loading */
|
|
17
17
|
isLoading?: boolean | undefined;
|
|
18
|
+
/** Whether the Textfield should change its styles when hovered/focused etc */
|
|
19
|
+
isInteractive?: boolean | undefined;
|
|
20
|
+
/** If true, the TextField has a dynamic width, bounded by max and min width values */
|
|
21
|
+
isResponsive?: boolean | undefined;
|
|
18
22
|
} & Omit<TextFieldProps, "size"> & Partial<Omit<React.InputHTMLAttributes<HTMLInputElement>, "size">> & TestProps & React.RefAttributes<HTMLInputElement>>;
|
|
19
|
-
export default
|
|
23
|
+
export default MultiSelectBase;
|
|
@@ -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 _MultiSelectBase = require("./MultiSelectBase.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"];
|
|
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 MultiSelectBase = /*#__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,31 @@ 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,
|
|
61
65
|
rest = _objectWithoutPropertiesLoose(props, _excluded);
|
|
62
66
|
|
|
63
|
-
var TextfieldRef = _react["default"].useRef(null);
|
|
64
|
-
|
|
65
67
|
var theme = (0, _useTheme["default"])();
|
|
66
68
|
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
|
-
}, [hasValue, locked]);
|
|
85
|
-
|
|
86
|
-
var handleKeyDown = function handleKeyDown(event) {
|
|
87
|
-
if (value === '' && event.key === 'Backspace') {
|
|
88
|
-
onOptionDelete();
|
|
89
|
-
}
|
|
90
|
-
};
|
|
69
|
+
|
|
70
|
+
var _useMultiSelectBaseUt = (0, _hooks["default"])({
|
|
71
|
+
label: label,
|
|
72
|
+
placeholder: placeholder,
|
|
73
|
+
required: required,
|
|
74
|
+
locked: locked,
|
|
75
|
+
hasValue: hasValue,
|
|
76
|
+
value: value,
|
|
77
|
+
rightIcon: rightIcon,
|
|
78
|
+
onOptionDelete: onOptionDelete,
|
|
79
|
+
onClearAllOptions: onClearAllOptions
|
|
80
|
+
}),
|
|
81
|
+
inputPlaceholder = _useMultiSelectBaseUt.inputPlaceholder,
|
|
82
|
+
handleKeyDown = _useMultiSelectBaseUt.handleKeyDown,
|
|
83
|
+
icon = _useMultiSelectBaseUt.icon,
|
|
84
|
+
hasLabel = _useMultiSelectBaseUt.hasLabel,
|
|
85
|
+
TextfieldRef = _useMultiSelectBaseUt.TextfieldRef;
|
|
91
86
|
|
|
92
87
|
var chips = (0, _react.useMemo)(function () {
|
|
93
88
|
return (0, _react2.jsx)(_react["default"].Fragment, null, selectedOptions == null ? void 0 : selectedOptions.map(function (option, index) {
|
|
@@ -95,7 +90,7 @@ var MultiselectTextField = /*#__PURE__*/_react["default"].forwardRef(function (p
|
|
|
95
90
|
|
|
96
91
|
return (0, _react2.jsx)("span", {
|
|
97
92
|
key: (0, _helpers.generateUniqueID)('chip' + index),
|
|
98
|
-
css: (0,
|
|
93
|
+
css: (0, _MultiSelectBase.chipStyle)()
|
|
99
94
|
}, (0, _react2.jsx)(_Chip["default"], {
|
|
100
95
|
onClear: !(locked || disabled) ? function () {
|
|
101
96
|
return onOptionDelete(option);
|
|
@@ -104,49 +99,31 @@ var MultiselectTextField = /*#__PURE__*/_react["default"].forwardRef(function (p
|
|
|
104
99
|
dataTestId: "chip_" + index
|
|
105
100
|
}, (0, _react2.jsx)("div", {
|
|
106
101
|
title: option.label,
|
|
107
|
-
css: (0,
|
|
102
|
+
css: (0, _MultiSelectBase.chipContent)({
|
|
108
103
|
maxWidth: (_TextfieldRef$current = TextfieldRef.current) == null ? void 0 : _TextfieldRef$current.getBoundingClientRect().width
|
|
109
104
|
})
|
|
110
105
|
}, option.label)));
|
|
111
106
|
}));
|
|
112
107
|
}, [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
108
|
return (0, _react2.jsx)("div", {
|
|
135
109
|
ref: TextfieldRef
|
|
136
110
|
}, (0, _react2.jsx)(_TextInputBase["default"], _extends({
|
|
137
|
-
disabled: disabled,
|
|
138
|
-
locked: locked,
|
|
139
|
-
status: status,
|
|
111
|
+
disabled: isInteractive && disabled,
|
|
112
|
+
locked: isInteractive && locked,
|
|
113
|
+
status: isInteractive ? status : 'normal',
|
|
140
114
|
lean: lean,
|
|
141
115
|
size: 'md',
|
|
142
116
|
styleType: styleType
|
|
143
117
|
}, rest, {
|
|
144
|
-
|
|
118
|
+
isInteractive: isInteractive,
|
|
119
|
+
sx: (0, _MultiSelectBase.textInputBaseOverrides)({
|
|
145
120
|
hasValue: hasValue,
|
|
146
|
-
isLoading: isLoading
|
|
121
|
+
isLoading: isLoading,
|
|
122
|
+
hasLabel: hasLabel,
|
|
123
|
+
isResponsive: isResponsive
|
|
147
124
|
})(theme)
|
|
148
125
|
}), (0, _react2.jsx)("div", {
|
|
149
|
-
css: (0,
|
|
126
|
+
css: (0, _MultiSelectBase.inputContainer)()
|
|
150
127
|
}, chips, (0, _react2.jsx)("input", _extends({
|
|
151
128
|
readOnly: readOnly,
|
|
152
129
|
onKeyDown: handleKeyDown,
|
|
@@ -156,7 +133,7 @@ var MultiselectTextField = /*#__PURE__*/_react["default"].forwardRef(function (p
|
|
|
156
133
|
label: label,
|
|
157
134
|
dark: dark,
|
|
158
135
|
lean: lean,
|
|
159
|
-
sx: (0,
|
|
136
|
+
sx: (0, _MultiSelectBase.inputOverrides)()
|
|
160
137
|
}),
|
|
161
138
|
placeholder: inputPlaceholder,
|
|
162
139
|
required: required,
|
|
@@ -173,14 +150,14 @@ var MultiselectTextField = /*#__PURE__*/_react["default"].forwardRef(function (p
|
|
|
173
150
|
animateToTop: hasValue,
|
|
174
151
|
error: status === 'error'
|
|
175
152
|
})), !disabled && (0, _react2.jsx)("div", {
|
|
176
|
-
css: (0,
|
|
153
|
+
css: (0, _MultiSelectBase.rightIconsContainer)()
|
|
177
154
|
}, isLoading && (0, _react2.jsx)(_Loader["default"], null), (0, _react2.jsx)("div", {
|
|
178
|
-
css: (0,
|
|
155
|
+
css: (0, _MultiSelectBase.rightIconStyles)({
|
|
179
156
|
isClickable: hasValue && !locked
|
|
180
157
|
})
|
|
181
158
|
}, icon))));
|
|
182
159
|
});
|
|
183
160
|
|
|
184
|
-
|
|
185
|
-
var _default =
|
|
161
|
+
MultiSelectBase.displayName = 'MultiSelectBase';
|
|
162
|
+
var _default = MultiSelectBase;
|
|
186
163
|
exports["default"] = _default;
|
|
@@ -11,9 +11,11 @@ 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, }: {
|
|
15
15
|
hasValue: boolean;
|
|
16
16
|
isLoading?: boolean | undefined;
|
|
17
|
+
hasLabel?: boolean | undefined;
|
|
18
|
+
isResponsive?: boolean | undefined;
|
|
17
19
|
}) => (theme: Theme) => {
|
|
18
20
|
wrapper: {
|
|
19
21
|
label: {
|
|
@@ -38,6 +40,8 @@ export declare const textInputBaseOverrides: ({ hasValue, isLoading }: {
|
|
|
38
40
|
minHeight: string;
|
|
39
41
|
};
|
|
40
42
|
textField: {
|
|
43
|
+
width?: string | undefined;
|
|
44
|
+
minWidth?: string | undefined;
|
|
41
45
|
padding: string;
|
|
42
46
|
};
|
|
43
47
|
};
|