@agilant/toga-blox 1.0.120 → 1.0.121
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.
|
@@ -6,28 +6,24 @@ const MultiSelectInput = ({ id, name, options = [], selectedValue = [], onChange
|
|
|
6
6
|
icon: "",
|
|
7
7
|
iconStyle: "regular",
|
|
8
8
|
}, isSearchable = true, isOpen, hasSelectAll = false, disabled = false, isLoading = false, onMenuToggle, overrideStrings, className, width = "w-72", isBoolean = false, otherProps, setInputSearchValue, }) => {
|
|
9
|
-
// Convert your incoming options to the shape expected by react-multi-select-component
|
|
10
9
|
const multiSelectOptions = options.map((option) => ({
|
|
11
|
-
label: option.
|
|
10
|
+
label: option.label,
|
|
12
11
|
value: option.value,
|
|
13
12
|
}));
|
|
14
|
-
// Convert the "selectedValue" prop similarly
|
|
15
13
|
const multiSelectValue = selectedValue.map((item) => ({
|
|
16
|
-
label: item.
|
|
14
|
+
label: item.label,
|
|
17
15
|
value: item.value,
|
|
18
16
|
}));
|
|
19
17
|
function filterOptions(baseOptions, searchText) {
|
|
20
18
|
const footer = baseOptions.find((option) => option.value === "__footer__");
|
|
21
19
|
if (!searchText) {
|
|
22
|
-
// If the parent is already 0, don't set it again
|
|
23
20
|
setInputSearchValue?.((prevCount) => {
|
|
24
21
|
if (prevCount !== 0)
|
|
25
22
|
return 0;
|
|
26
|
-
return prevCount;
|
|
23
|
+
return prevCount;
|
|
27
24
|
});
|
|
28
25
|
return baseOptions;
|
|
29
26
|
}
|
|
30
|
-
// Normal filter
|
|
31
27
|
const filtered = baseOptions.filter((option) => {
|
|
32
28
|
if (option.value === "__footer__")
|
|
33
29
|
return false;
|
|
@@ -35,7 +31,6 @@ const MultiSelectInput = ({ id, name, options = [], selectedValue = [], onChange
|
|
|
35
31
|
.toLowerCase()
|
|
36
32
|
.includes(searchText.toLowerCase());
|
|
37
33
|
});
|
|
38
|
-
// Only update if it's different from current
|
|
39
34
|
setInputSearchValue?.((prevCount) => {
|
|
40
35
|
const newCount = filtered.length;
|
|
41
36
|
if (newCount !== prevCount)
|
|
@@ -59,14 +54,10 @@ const MultiSelectInput = ({ id, name, options = [], selectedValue = [], onChange
|
|
|
59
54
|
return selected.map((s) => s.label).join(", ");
|
|
60
55
|
};
|
|
61
56
|
const handleSelectionChange = (selectedOptions) => {
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
// If isBoolean is true, only allow one selection (last one clicked)
|
|
65
|
-
finalSelection = [selectedOptions[selectedOptions.length - 1]];
|
|
66
|
-
}
|
|
67
|
-
const mapped = finalSelection.map((opt) => ({
|
|
68
|
-
name: opt.label,
|
|
57
|
+
const mapped = selectedOptions.map((opt) => ({
|
|
58
|
+
label: opt.label,
|
|
69
59
|
value: opt.value,
|
|
60
|
+
name: opt.label,
|
|
70
61
|
}));
|
|
71
62
|
onChange(mapped);
|
|
72
63
|
};
|
|
@@ -111,6 +111,7 @@ const SearchDropdownInput = ({ options = [], selectedValue = [], onChange, place
|
|
|
111
111
|
// Normal item
|
|
112
112
|
return (_jsxs("div", { className: "item px-4 py-1 cursor-pointer flex items-center", onClick: (e) => onClick(option, e), children: [_jsx("input", { type: "checkbox", checked: checked, readOnly: true, disabled: disabled }), _jsx("span", { className: "ml-2", children: option.label })] }));
|
|
113
113
|
};
|
|
114
|
+
console.log(selectedValue, "LOOK HERE");
|
|
114
115
|
return (_jsx(MultiSelectInput, { options: extendedOptions, selectedValue: selectedValue, onChange: onChange, placeholder: {
|
|
115
116
|
text: placeholder,
|
|
116
117
|
icon: "magnifyingGlass",
|
|
@@ -14,6 +14,7 @@ const SearchInput = ({ textHighlight = "text-sky-500", inputType = "text", dropd
|
|
|
14
14
|
useEffect(() => {
|
|
15
15
|
inputRef.current?.focus();
|
|
16
16
|
}, []);
|
|
17
|
+
console.log(selectedValue, "selectedValue");
|
|
17
18
|
return (_jsx("div", { ref: containerRef, className: "w-max", children: (() => {
|
|
18
19
|
switch (inputType) {
|
|
19
20
|
case "text":
|
|
@@ -1,12 +1,10 @@
|
|
|
1
1
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
2
|
import SearchInput from "./SearchInput";
|
|
3
3
|
import { useState, useCallback, useMemo } from "react";
|
|
4
|
-
// 1) Provide a stable "mock column"
|
|
5
4
|
const mockColumn = {
|
|
6
5
|
id: "mockColumn",
|
|
7
6
|
Header: "Mock Column",
|
|
8
7
|
};
|
|
9
|
-
// 2) We define stable arrays for the controls to avoid re-creating them
|
|
10
8
|
const textDropdownOptions = [
|
|
11
9
|
{ label: "Starts with", value: "startsWith" },
|
|
12
10
|
{ label: "Ends With", value: "endsWith" },
|
|
@@ -15,11 +13,10 @@ const textDropdownOptions = [
|
|
|
15
13
|
{ label: "Excludes", value: "excludes" },
|
|
16
14
|
];
|
|
17
15
|
const multiSelectOptions = [
|
|
18
|
-
{ uuid: "1",
|
|
19
|
-
{ uuid: "2",
|
|
20
|
-
{ uuid: "3",
|
|
16
|
+
{ uuid: "1", label: "Option 1", value: "option1" },
|
|
17
|
+
{ uuid: "2", label: "Option 2", value: "option2" },
|
|
18
|
+
{ uuid: "3", label: "Option 3", value: "option3" },
|
|
21
19
|
];
|
|
22
|
-
// 3) Standard default export
|
|
23
20
|
export default {
|
|
24
21
|
title: "Components/SearchInput",
|
|
25
22
|
component: SearchInput,
|