oolib 2.199.2 → 2.199.3
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/stories/v2/components/List.stories.d.ts +5 -3
- package/dist/stories/v2/components/List.stories.js +2 -1
- package/dist/v2/components/Dropdowns/comps/OptionsMulti/index.js +1 -2
- package/dist/v2/components/Dropdowns/comps/OptionsSingle/index.js +1 -2
- package/dist/v2/components/Dropdowns/utils/getValue.d.ts +0 -1
- package/dist/v2/components/Dropdowns/utils/getValue.js +3 -16
- package/dist/v2/components/List/comps/ListGroup.js +1 -1
- package/dist/v2/components/List/index.d.ts +1 -2
- package/dist/v2/components/List/index.js +14 -2
- package/package.json +1 -1
|
@@ -15,6 +15,7 @@ declare namespace _default {
|
|
|
15
15
|
export let defaultValue: boolean;
|
|
16
16
|
}
|
|
17
17
|
namespace grouped {
|
|
18
|
+
export let name: string;
|
|
18
19
|
let control_1: string;
|
|
19
20
|
export { control_1 as control };
|
|
20
21
|
let description_2: string;
|
|
@@ -70,11 +71,12 @@ export function ListItem_(args: any): import("react").JSX.Element;
|
|
|
70
71
|
export namespace ListItem_ {
|
|
71
72
|
export namespace argTypes_1 {
|
|
72
73
|
namespace desc {
|
|
73
|
-
let name: string;
|
|
74
|
-
}
|
|
75
|
-
namespace icon {
|
|
76
74
|
let name_1: string;
|
|
77
75
|
export { name_1 as name };
|
|
76
|
+
}
|
|
77
|
+
namespace icon {
|
|
78
|
+
let name_2: string;
|
|
79
|
+
export { name_2 as name };
|
|
78
80
|
export { availableIcons as options };
|
|
79
81
|
export namespace control_7 {
|
|
80
82
|
let type: string;
|
|
@@ -112,6 +112,7 @@ exports.default = {
|
|
|
112
112
|
defaultValue: false,
|
|
113
113
|
},
|
|
114
114
|
grouped: {
|
|
115
|
+
name: "grouped options",
|
|
115
116
|
control: "boolean",
|
|
116
117
|
description: "Display options in groups",
|
|
117
118
|
defaultValue: false,
|
|
@@ -185,7 +186,7 @@ var List_ = function (args) {
|
|
|
185
186
|
};
|
|
186
187
|
return (React.createElement(__1.Container, { style: { background: "#eff" } },
|
|
187
188
|
React.createElement(__1.PaddingTop40, null),
|
|
188
|
-
React.createElement(List_1.List, { options: filteredOptions, value: selectedValue, focussedOp: focussedOption, scrollFocussedOpIntoView: scrollFocussedOpIntoView, onChange: handleSelect,
|
|
189
|
+
React.createElement(List_1.List, { options: filteredOptions, value: selectedValue, focussedOp: focussedOption, scrollFocussedOpIntoView: scrollFocussedOpIntoView, onChange: handleSelect, isMulti: args.isMulti, isTagsStyle: args.isTagsStyle, invert: args.invert, disableShadow: args.disableShadow, enableBorder: args.enableBorder, isSearchable: args.isSearchable, searchbarPlaceholder: args.searchbarPlaceholder, searchBarFocus: searchBarFocus, searchString: searchString, setSearchString: setSearchString, setSearchBarFocus: setSearchBarFocus }),
|
|
189
190
|
React.createElement(__1.PaddingBottom40, null)));
|
|
190
191
|
};
|
|
191
192
|
exports.List_ = List_;
|
|
@@ -40,7 +40,6 @@ var useSetYOrientation_1 = require("../../utils/useSetYOrientation");
|
|
|
40
40
|
var useKeyboardControl_1 = require("../../utils/useKeyboardControl");
|
|
41
41
|
var List_1 = require("../../../List");
|
|
42
42
|
var __1 = require("../../../../..");
|
|
43
|
-
var getValue_1 = require("../../utils/getValue");
|
|
44
43
|
var OptionsMulti = function (_a) {
|
|
45
44
|
var
|
|
46
45
|
//from root
|
|
@@ -99,7 +98,7 @@ var OptionsMulti = function (_a) {
|
|
|
99
98
|
react_1.default.createElement(List_1.List, { options: options, value: value, focussedOp: focussedOp, scrollFocussedOpIntoView: scrollFocussedOpIntoView, onChange: function (id, v) {
|
|
100
99
|
console.log({ id: id, v: v });
|
|
101
100
|
handleSelect(v);
|
|
102
|
-
}, optionsClassName: optionsClassName, S: S,
|
|
101
|
+
}, optionsClassName: optionsClassName, S: S, isMulti: true, disableShadow: true, isSearchable: isSearchable, searchbarPlaceholder: searchbarPlaceholder, searchBarFocus: searchBarFocus, searchString: searchString, setSearchString: setSearchString, setSearchBarFocus: setSearchBarFocus, children: !isTagsStyle && createSelectedOptions() }),
|
|
103
102
|
genCreateTagButton && genCreateTagButton(options)));
|
|
104
103
|
};
|
|
105
104
|
exports.OptionsMulti = OptionsMulti;
|
|
@@ -39,7 +39,6 @@ var OptionsShell_1 = require("../OptionsShell");
|
|
|
39
39
|
var useKeyboardControl_1 = require("../../utils/useKeyboardControl");
|
|
40
40
|
var useSetYOrientation_1 = require("../../utils/useSetYOrientation");
|
|
41
41
|
var List_1 = require("../../../List");
|
|
42
|
-
var getValue_1 = require("../../utils/getValue");
|
|
43
42
|
/**
|
|
44
43
|
* if used independently, must be used inside a 'position: relative/absolute' div.
|
|
45
44
|
*/
|
|
@@ -75,7 +74,7 @@ var OptionsSingle = function (_a) {
|
|
|
75
74
|
}, [showOptions]);
|
|
76
75
|
return (react_1.default.createElement(react_1.default.Fragment, null,
|
|
77
76
|
react_1.default.createElement(OptionsShell_1.OptionsShell, { ref: optionsRef, yOrientation: yOrientation, lightboxHeight: lightboxHeight, lightboxStyle: lightboxStyle, options: options, optionsAnchor: optionsAnchor, showOptions: showOptions, SelectComp: SelectComp, handleHideOptions: handleHideOptions, label: label, optionsModalLabel: optionsModalLabel, relativeToRef: relativeToRef, popOutOfOverflowHiddenParent: popOutOfOverflowHiddenParent, alignDropdown: alignDropdown, matchSelectInputWidth: matchSelectInputWidth, S: S },
|
|
78
|
-
react_1.default.createElement(List_1.List, { options: options, value: value, focussedOp: focussedOp, scrollFocussedOpIntoView: scrollFocussedOpIntoView, onChange: function (id, v) { return handleSelect(v); }, optionsClassName: optionsClassName, S: S, observerRef: observerRef,
|
|
77
|
+
react_1.default.createElement(List_1.List, { options: options, value: value, focussedOp: focussedOp, scrollFocussedOpIntoView: scrollFocussedOpIntoView, onChange: function (id, v) { return handleSelect(v); }, optionsClassName: optionsClassName, S: S, observerRef: observerRef, isSearchable: isSearchable, searchbarPlaceholder: searchbarPlaceholder, searchBarFocus: searchBarFocus, searchString: searchString, setSearchString: setSearchString, setSearchBarFocus: setSearchBarFocus }),
|
|
79
78
|
genCreateTagButton && genCreateTagButton(options))));
|
|
80
79
|
};
|
|
81
80
|
exports.OptionsSingle = OptionsSingle;
|
|
@@ -7,7 +7,7 @@
|
|
|
7
7
|
* Because thats the only format our dropdowns understand
|
|
8
8
|
*/
|
|
9
9
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
10
|
-
exports.getValue_MULTI = exports.getValue_SINGLE =
|
|
10
|
+
exports.getValue_MULTI = exports.getValue_SINGLE = void 0;
|
|
11
11
|
var toArray_1 = require("../../../../utils/toArray");
|
|
12
12
|
var getAllOptionsFns_1 = require("./getAllOptionsFns");
|
|
13
13
|
// Note: - saveValueAsString can be misleading here, because the value could be a string, integer, boolean values
|
|
@@ -22,26 +22,13 @@ var getAllOptionsFns_1 = require("./getAllOptionsFns");
|
|
|
22
22
|
// ? valueProp?.map(vProp => (optionsFn ? getAllOptionsFns(theme)[optionsFn.fn](...(toArray(optionsFn.args) || [])) : options).find(d => d.value === vProp))
|
|
23
23
|
// : valueProp
|
|
24
24
|
// }
|
|
25
|
-
var isGroupedData = function (options) {
|
|
26
|
-
// If the data is empty or not an array, return false
|
|
27
|
-
if (!options || !Array.isArray(options) || options.length === 0) {
|
|
28
|
-
return false;
|
|
29
|
-
}
|
|
30
|
-
// Check the first item in the array
|
|
31
|
-
// If it has an 'options' property that is an array, it's grouped data
|
|
32
|
-
return (options[0] &&
|
|
33
|
-
typeof options[0] === "object" &&
|
|
34
|
-
Array.isArray(options[0].options) &&
|
|
35
|
-
options[0].options.length > 0);
|
|
36
|
-
};
|
|
37
|
-
exports.isGroupedData = isGroupedData;
|
|
38
25
|
var getValue_SINGLE = function (_a) {
|
|
39
26
|
var _b;
|
|
40
27
|
var valueProp = _a.valueProp, optionsFn = _a.optionsFn, options = _a.options, theme = _a.theme, saveValueAsString = _a.saveValueAsString;
|
|
41
28
|
if (!saveValueAsString)
|
|
42
29
|
return valueProp;
|
|
43
30
|
var allOptions = optionsFn ? (_b = (0, getAllOptionsFns_1.getAllOptionsFns)(theme))[optionsFn.fn].apply(_b, ((0, toArray_1.toArray)(optionsFn.args) || [])) : options;
|
|
44
|
-
if (
|
|
31
|
+
if (isGroupedData(allOptions)) {
|
|
45
32
|
// For grouped data, search through all options in all groups
|
|
46
33
|
for (var _i = 0, allOptions_1 = allOptions; _i < allOptions_1.length; _i++) {
|
|
47
34
|
var group = allOptions_1[_i];
|
|
@@ -64,7 +51,7 @@ var getValue_MULTI = function (_a) {
|
|
|
64
51
|
return valueProp;
|
|
65
52
|
var allOptions = optionsFn
|
|
66
53
|
? (_b = (0, getAllOptionsFns_1.getAllOptionsFns)(theme))[optionsFn.fn].apply(_b, ((0, toArray_1.toArray)(optionsFn.args) || [])) : options;
|
|
67
|
-
if (
|
|
54
|
+
if (isGroupedData(allOptions)) {
|
|
68
55
|
// For grouped data, map each value and search through all options in all groups
|
|
69
56
|
return valueProp.map(function (vProp) {
|
|
70
57
|
for (var _i = 0, allOptions_2 = allOptions; _i < allOptions_2.length; _i++) {
|
|
@@ -14,7 +14,7 @@ var Divider_1 = require("../../Divider");
|
|
|
14
14
|
var themes_1 = require("../../../themes");
|
|
15
15
|
var styled_components_1 = __importDefault(require("styled-components"));
|
|
16
16
|
var ListItem_1 = require("./ListItem");
|
|
17
|
-
exports.GroupHeader = styled_components_1.default.div(templateObject_1 || (templateObject_1 = __makeTemplateObject(["\n padding: 0.4rem 0.8rem;\n color: ", ";\n"], ["\n padding: 0.4rem 0.8rem;\n color: ", ";\n"])), themes_1.colors.grey50);
|
|
17
|
+
exports.GroupHeader = styled_components_1.default.div(templateObject_1 || (templateObject_1 = __makeTemplateObject(["\n padding: 0.4rem 0.8rem;\n color: ", ";\n position: sticky;\n top: 0;\n width: 100%;\n background: white;\n z-index: 1000;\n"], ["\n padding: 0.4rem 0.8rem;\n color: ", ";\n position: sticky;\n top: 0;\n width: 100%;\n background: white;\n z-index: 1000;\n"])), themes_1.colors.grey50);
|
|
18
18
|
exports.GroupDivider = styled_components_1.default.div(templateObject_2 || (templateObject_2 = __makeTemplateObject(["\n margin: 0.4rem 0 0.8rem 0;\n"], ["\n margin: 0.4rem 0 0.8rem 0;\n"])));
|
|
19
19
|
var ListGroup = function (_a) {
|
|
20
20
|
var id = _a.id, group = _a.group, index = _a.index, value = _a.value, focussedOp = _a.focussedOp, scrollFocussedOpIntoView = _a.scrollFocussedOpIntoView, parentOnChange = _a.onChange, optionsClassName = _a.optionsClassName, invert = _a.invert, S = _a.S, observerRef = _a.observerRef, isMulti = _a.isMulti, isTagsStyle = _a.isTagsStyle, setFocusSelectTagsInput = _a.setFocusSelectTagsInput, setSearchString = _a.setSearchString, setSearchBarFocus = _a.setSearchBarFocus;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
export const StyledListWrapper: import("styled-components").StyledComponent<"div", any, {}, never>;
|
|
2
|
-
export function List({ id, options, value, focussedOp, scrollFocussedOpIntoView, onChange: parentOnChange, optionsClassName, invert, S, observerRef, isMulti, isTagsStyle, setFocusSelectTagsInput,
|
|
2
|
+
export function List({ id, options, value, focussedOp, scrollFocussedOpIntoView, onChange: parentOnChange, optionsClassName, invert, S, observerRef, isMulti, isTagsStyle, setFocusSelectTagsInput, disableShadow, isSearchable, searchbarPlaceholder, searchBarFocus, searchString, setSearchString, setSearchBarFocus, children, enableBorder, style }: {
|
|
3
3
|
id: any;
|
|
4
4
|
options?: any[];
|
|
5
5
|
value: any;
|
|
@@ -13,7 +13,6 @@ export function List({ id, options, value, focussedOp, scrollFocussedOpIntoView,
|
|
|
13
13
|
isMulti?: boolean;
|
|
14
14
|
isTagsStyle: any;
|
|
15
15
|
setFocusSelectTagsInput: any;
|
|
16
|
-
grouped?: boolean;
|
|
17
16
|
disableShadow: any;
|
|
18
17
|
isSearchable: any;
|
|
19
18
|
searchbarPlaceholder: any;
|
|
@@ -55,14 +55,26 @@ exports.StyledListWrapper = styled_components_1.default.div(templateObject_3 ||
|
|
|
55
55
|
var enableBorder = _a.enableBorder;
|
|
56
56
|
return enableBorder && (0, styled_components_1.css)(templateObject_2 || (templateObject_2 = __makeTemplateObject(["\n border: 1px solid ", ";\n "], ["\n border: 1px solid ", ";\n "])), themes_1.colors.grey10);
|
|
57
57
|
});
|
|
58
|
+
var isGroupedData = function (options) {
|
|
59
|
+
// If the data is empty or not an array, return false
|
|
60
|
+
if (!options || !Array.isArray(options) || options.length === 0) {
|
|
61
|
+
return false;
|
|
62
|
+
}
|
|
63
|
+
// Check the first item in the array
|
|
64
|
+
// If it has an 'options' property that is an array, it's grouped data
|
|
65
|
+
return (options[0] &&
|
|
66
|
+
typeof options[0] === "object" &&
|
|
67
|
+
Array.isArray(options[0].options) &&
|
|
68
|
+
options[0].options.length > 0);
|
|
69
|
+
};
|
|
58
70
|
var List = function (_a) {
|
|
59
71
|
// const theme = useTheme();
|
|
60
|
-
var id = _a.id, _b = _a.options, options = _b === void 0 ? [] : _b, value = _a.value, focussedOp = _a.focussedOp, scrollFocussedOpIntoView = _a.scrollFocussedOpIntoView, parentOnChange = _a.onChange, optionsClassName = _a.optionsClassName, invert = _a.invert, S = _a.S, observerRef = _a.observerRef, _c = _a.isMulti, isMulti = _c === void 0 ? false : _c, isTagsStyle = _a.isTagsStyle, setFocusSelectTagsInput = _a.setFocusSelectTagsInput,
|
|
72
|
+
var id = _a.id, _b = _a.options, options = _b === void 0 ? [] : _b, value = _a.value, focussedOp = _a.focussedOp, scrollFocussedOpIntoView = _a.scrollFocussedOpIntoView, parentOnChange = _a.onChange, optionsClassName = _a.optionsClassName, invert = _a.invert, S = _a.S, observerRef = _a.observerRef, _c = _a.isMulti, isMulti = _c === void 0 ? false : _c, isTagsStyle = _a.isTagsStyle, setFocusSelectTagsInput = _a.setFocusSelectTagsInput, disableShadow = _a.disableShadow, isSearchable = _a.isSearchable, searchbarPlaceholder = _a.searchbarPlaceholder, searchBarFocus = _a.searchBarFocus, searchString = _a.searchString, setSearchString = _a.setSearchString, setSearchBarFocus = _a.setSearchBarFocus, children = _a.children, enableBorder = _a.enableBorder, style = _a.style;
|
|
61
73
|
var renderListItems = function () {
|
|
62
74
|
if (options.length === 0) {
|
|
63
75
|
return react_1.default.createElement(NoOptionResultsComp_1.NoOptionResultsComp, { S: S });
|
|
64
76
|
}
|
|
65
|
-
if (
|
|
77
|
+
if (isGroupedData(options)) {
|
|
66
78
|
return (react_1.default.createElement(react_1.Fragment, null, options.map(function (group, index) { return (react_1.default.createElement(ListGroup_1.ListGroup, { id: id, key: "group-".concat(index), group: group, index: index, value: value, focussedOp: focussedOp, scrollFocussedOpIntoView: scrollFocussedOpIntoView, onChange: parentOnChange, optionsClassName: optionsClassName, invert: invert, S: S, observerRef: observerRef, isMulti: isMulti, isTagsStyle: isTagsStyle, setFocusSelectTagsInput: setFocusSelectTagsInput, setSearchString: setSearchString, setSearchBarFocus: setSearchBarFocus, disableShadow: disableShadow })); })));
|
|
67
79
|
}
|
|
68
80
|
return options.map(function (option, index) { return (react_1.default.createElement(ListItem_1.ListItem, { key: option.value, option: option, isSelected: (!option.loading && (value === null || value === void 0 ? void 0 : value.value) === option.value), isFocussed: focussedOp === index, index: index, scrollFocussedOpIntoView: scrollFocussedOpIntoView, onChange: function () {
|