@agilant/toga-blox 1.0.88 → 1.0.90
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/HeaderFilterIcon/HeaderFilterIcon.stories.js +1 -1
- package/dist/components/SearchInput/SearchInput.d.ts +1 -1
- package/dist/components/SearchInput/SearchInput.js +5 -3
- package/dist/components/SearchInput/SearchInput.types.d.ts +1 -0
- package/dist/components/SearchInput/SearchInputDatePicker.js +16 -12
- package/dist/components/SearchInput/SearchTextInput.d.ts +6 -1
- package/dist/components/SearchInput/SearchTextInput.js +15 -11
- package/dist/utils/getCleanedText.d.ts +9 -0
- package/dist/utils/getCleanedText.js +20 -0
- package/package.json +1 -1
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
import { SearchInputProps } from "./SearchInput.types";
|
|
2
|
-
declare const SearchInput: <T extends object>({ bgColor, textHighlight, inputType, dropdownIconProp, dropdownOptions, selectedDropdownOption, onDropdownOptionSelect, searchItems, setSearchItems, toggleStatus, setToggleStatus, minValue, setMinValue, maxValue, setMaxValue, onChange, selectedValue, selectedDate, onDateSelect, selectedStartDate, onStartDateSelect, selectedEndDate, onEndDateSelect, handleFilter, column, setSearchCriteria, setEditingHeader, pillColor, firstIconClasses, dataPickerThemeColor, dataPickerThemeColorAccent, isBoolean, toggleColor, toggleTextColor, fontFamily, }: SearchInputProps<T>) => import("react/jsx-runtime").JSX.Element;
|
|
2
|
+
declare const SearchInput: <T extends object>({ bgColor, textHighlight, inputType, dropdownIconProp, dropdownOptions, selectedDropdownOption, onDropdownOptionSelect, searchItems, setSearchItems, toggleStatus, setToggleStatus, minValue, setMinValue, maxValue, setMaxValue, onChange, selectedValue, selectedDate, onDateSelect, selectedStartDate, onStartDateSelect, selectedEndDate, onEndDateSelect, handleFilter, column, setSearchCriteria, setEditingHeader, pillColor, firstIconClasses, dataPickerThemeColor, dataPickerThemeColorAccent, isBoolean, toggleColor, toggleTextColor, fontFamily, removePattern, }: SearchInputProps<T>) => import("react/jsx-runtime").JSX.Element;
|
|
3
3
|
export default SearchInput;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
2
|
import { useEffect, useRef } from "react";
|
|
3
|
-
import SearchTextInput from "./SearchTextInput";
|
|
3
|
+
import SearchTextInput from "./SearchTextInput";
|
|
4
4
|
import SearchNumberInput from "./SearchNumberInput";
|
|
5
5
|
import SearchDropdownInput from "./SearchDropdownInput";
|
|
6
6
|
import SearchDatePickerInput from "./SearchInputDatePicker";
|
|
@@ -8,7 +8,7 @@ const SearchInput = ({ bgColor = "bg-sky-500", textHighlight = "text-sky-500", i
|
|
|
8
8
|
name: "chevronDown",
|
|
9
9
|
weight: "bold",
|
|
10
10
|
iconClasses: "text-black",
|
|
11
|
-
}, dropdownOptions = [], selectedDropdownOption = "", onDropdownOptionSelect, searchItems = [], setSearchItems, toggleStatus = false, setToggleStatus, minValue, setMinValue, maxValue, setMaxValue, onChange, selectedValue, selectedDate, onDateSelect, selectedStartDate, onStartDateSelect, selectedEndDate, onEndDateSelect, handleFilter, column, setSearchCriteria, setEditingHeader, pillColor, firstIconClasses, dataPickerThemeColor, dataPickerThemeColorAccent, isBoolean = false, toggleColor = "bg-sky-500", toggleTextColor = "text-black", fontFamily, }) => {
|
|
11
|
+
}, dropdownOptions = [], selectedDropdownOption = "", onDropdownOptionSelect, searchItems = [], setSearchItems, toggleStatus = false, setToggleStatus, minValue, setMinValue, maxValue, setMaxValue, onChange, selectedValue, selectedDate, onDateSelect, selectedStartDate, onStartDateSelect, selectedEndDate, onEndDateSelect, handleFilter, column, setSearchCriteria, setEditingHeader, pillColor, firstIconClasses, dataPickerThemeColor, dataPickerThemeColorAccent, isBoolean = false, toggleColor = "bg-sky-500", toggleTextColor = "text-black", fontFamily, removePattern, }) => {
|
|
12
12
|
const containerRef = useRef(null);
|
|
13
13
|
const inputRef = useRef(null);
|
|
14
14
|
useEffect(() => {
|
|
@@ -17,7 +17,9 @@ const SearchInput = ({ bgColor = "bg-sky-500", textHighlight = "text-sky-500", i
|
|
|
17
17
|
return (_jsx("div", { ref: containerRef, className: "w-max", children: (() => {
|
|
18
18
|
switch (inputType) {
|
|
19
19
|
case "text":
|
|
20
|
-
return (_jsx(SearchTextInput, { dropdownIconProp: dropdownIconProp, dropdownOptions: dropdownOptions, selectedDropdownOption: selectedDropdownOption, onDropdownOptionSelect: onDropdownOptionSelect, searchItems: searchItems, setSearchItems: setSearchItems, handleFilter: handleFilter, setSearchCriteria: setSearchCriteria, column: column, setEditingHeader: setEditingHeader, pillColor: pillColor, firstIconClasses: firstIconClasses, fontFamily: fontFamily
|
|
20
|
+
return (_jsx(SearchTextInput, { dropdownIconProp: dropdownIconProp, dropdownOptions: dropdownOptions, selectedDropdownOption: selectedDropdownOption, onDropdownOptionSelect: onDropdownOptionSelect, searchItems: searchItems, setSearchItems: setSearchItems, handleFilter: handleFilter, setSearchCriteria: setSearchCriteria, column: column, setEditingHeader: setEditingHeader, pillColor: pillColor, firstIconClasses: firstIconClasses, fontFamily: fontFamily,
|
|
21
|
+
//will remove the filter options from the badge shown in the input
|
|
22
|
+
removePattern: removePattern }));
|
|
21
23
|
case "number":
|
|
22
24
|
return (_jsx(SearchNumberInput, { dropdownIconProp: dropdownIconProp, dropdownOptions: dropdownOptions, selectedDropdownOption: selectedDropdownOption, onDropdownOptionSelect: onDropdownOptionSelect, toggleStatus: toggleStatus, setToggleStatus: setToggleStatus, minValue: minValue, maxValue: maxValue, setMinValue: setMinValue, setMaxValue: setMaxValue, handleFilter: handleFilter, setSearchCriteria: setSearchCriteria, column: column, themeBgColor: dataPickerThemeColor }));
|
|
23
25
|
case "multiSelect":
|
|
@@ -9,6 +9,7 @@ import Badge from "../Badge/Badge";
|
|
|
9
9
|
import Text from "../Text";
|
|
10
10
|
import { getFontAwesomeIcon } from "../../utils/getFontAwesomeIcon";
|
|
11
11
|
import updateLocalStorage from "../../utils/updateLocalStorage";
|
|
12
|
+
import { getCleanedText } from "../../utils/getCleanedText";
|
|
12
13
|
function formatAsYMD(date) {
|
|
13
14
|
if (!date)
|
|
14
15
|
return "";
|
|
@@ -128,17 +129,20 @@ const SearchDatePickerInput = ({ themeBgColor = "bg-sky-500", lightThemeBg = "bg
|
|
|
128
129
|
}, modifiersClassNames: modifiersClassNames })) }))) : isDatePickerOpen ? (_jsx("div", { className: "absolute p-4 top-16 w-auto z-50 shadow-lg bg-white", children: _jsx(DayPicker, { mode: "single", selected: selectedDate, onSelect: (day) => {
|
|
129
130
|
onDateSelect?.(day || undefined);
|
|
130
131
|
setIsDatePickerOpen(false);
|
|
131
|
-
}, modifiersClassNames: modifiersClassNames }) })) : null, searchItems?.length ? (_jsx("div", { className: "flex flex-wrap bg-white py-2 px-2 mt-2 rounded-md", children: searchItems.map((item, index) =>
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
132
|
+
}, modifiersClassNames: modifiersClassNames }) })) : null, searchItems?.length ? (_jsx("div", { className: "flex flex-wrap bg-white py-2 px-2 mt-2 rounded-md", children: searchItems.map((item, index) => {
|
|
133
|
+
const cleanedText = getCleanedText(item);
|
|
134
|
+
return (_jsx(Badge, { backgroundColor: pillColor, borderRadius: "rounded-full", hasRightIcon: true, icon: _jsx("div", { className: "text-white text-xxs", "data-testid": "item-clear-icon", children: getFontAwesomeIcon("xmark", "solid") }), iconSize: "text-sm", mobileIconLabel: item, onClick: () => {
|
|
135
|
+
const newSearchItems = searchItems.filter((searchItem) => searchItem !== item);
|
|
136
|
+
setSearchItems?.(newSearchItems);
|
|
137
|
+
if (canStore) {
|
|
138
|
+
setSearchCriteria?.((prev) => {
|
|
139
|
+
const filtered = prev.filter((crit) => crit.submittedSearchText !==
|
|
140
|
+
item);
|
|
141
|
+
updateLocalStorage(filtered, localStorageKey);
|
|
142
|
+
return filtered;
|
|
143
|
+
});
|
|
144
|
+
}
|
|
145
|
+
}, text: _jsx(Text, { color: "text-white", fontFamily: fontFamily, size: "text-sm", tag: "span", text: cleanedText }), badgeContainerClasses: `${pillColor} p-1 max-w-fit min-w-20 rounded-full flex justify-between items-center text-white text-xs px-4 border-none mr-4 mb-1`, type: "span" }, index));
|
|
146
|
+
}) })) : null, _jsxs("div", { className: "flex justify-between items-end bg-white px-2 rounded-md mt-4", children: [_jsx(ToggleButton, { initialStatus: toggleStatus, onClick: () => setToggleStatus(!toggleStatus), activeColorBackground: toggleColor, activeColorBorder: "border-sky-500", activeLabel: "Range", activeTextColor: toggleTextColor, additionalClasses: "flex items-center", inactiveColorBackground: "bg-gray-300", inactiveColorBorder: "border-gray-300", inactiveLabel: "Range", inactiveTextColor: "text-gray-500", pillHeight: "h-8", textPosition: "right", textSize: "text-sm", smallToggle: false, borderStyle: false }), _jsx(BaseButton, { text: buttonText, backgroundColor: themeBgColor, additionalClasses: "py-1.5 px-6 text-white", borderColor: "border-none", onClick: handleFilterClick, shape: "rounded-full" })] })] }));
|
|
143
147
|
};
|
|
144
148
|
export default SearchDatePickerInput;
|
|
@@ -17,6 +17,11 @@ type SearchTextInputProps<T extends object> = {
|
|
|
17
17
|
localStorageKey?: string;
|
|
18
18
|
firstIconClasses?: string;
|
|
19
19
|
fontFamily?: string;
|
|
20
|
+
/**
|
|
21
|
+
* An optional pattern to remove from the front of the displayed text
|
|
22
|
+
* (e.g., "eq:" or a regular expression like /^[^:]*:/ ).
|
|
23
|
+
*/
|
|
24
|
+
removePattern?: RegExp | string;
|
|
20
25
|
};
|
|
21
|
-
declare const SearchTextInput: <T extends object>({ pillColor, textHighlight, dropdownIconProp, dropdownOptions, selectedDropdownOption, onDropdownOptionSelect, searchItems, setSearchItems, handleFilter, setSearchCriteria, column, setEditingHeader, localStorageKey, firstIconClasses, fontFamily, }: SearchTextInputProps<T>) => import("react/jsx-runtime").JSX.Element;
|
|
26
|
+
declare const SearchTextInput: <T extends object>({ pillColor, textHighlight, dropdownIconProp, dropdownOptions, selectedDropdownOption, onDropdownOptionSelect, searchItems, setSearchItems, handleFilter, setSearchCriteria, column, setEditingHeader, localStorageKey, firstIconClasses, fontFamily, removePattern, }: SearchTextInputProps<T>) => import("react/jsx-runtime").JSX.Element;
|
|
22
27
|
export default SearchTextInput;
|
|
@@ -7,16 +7,16 @@ import Dropdown from "../Dropdown/Dropdown";
|
|
|
7
7
|
import Badge from "../Badge/Badge";
|
|
8
8
|
import Text from "../Text";
|
|
9
9
|
import updateLocalStorage from "../../utils/updateLocalStorage";
|
|
10
|
+
import { getCleanedText } from "../../utils/getCleanedText";
|
|
10
11
|
const SearchTextInput = ({ pillColor = "bg-sky-500", textHighlight = "text-sky-500", dropdownIconProp = {
|
|
11
12
|
iconClasses: textHighlight,
|
|
12
13
|
name: "chevronDown",
|
|
13
14
|
weight: "solid",
|
|
14
|
-
}, dropdownOptions = [], selectedDropdownOption = { label: "", value: "" }, onDropdownOptionSelect, searchItems = [], setSearchItems, handleFilter, setSearchCriteria, column, setEditingHeader, localStorageKey = "searchCriteria", firstIconClasses, fontFamily, }) => {
|
|
15
|
+
}, dropdownOptions = [], selectedDropdownOption = { label: "", value: "" }, onDropdownOptionSelect, searchItems = [], setSearchItems, handleFilter, setSearchCriteria, column, setEditingHeader, localStorageKey = "searchCriteria", firstIconClasses, fontFamily, removePattern, }) => {
|
|
15
16
|
const containerRef = useRef(null);
|
|
16
17
|
const [localSearchText, setLocalSearchText] = useState("");
|
|
17
18
|
const inputRef = useRef(null);
|
|
18
|
-
|
|
19
|
-
// On mount: focus input and load persisted search for this column if it exists.
|
|
19
|
+
// On mount: focus input & load persisted search for this column
|
|
20
20
|
useEffect(() => {
|
|
21
21
|
inputRef.current?.focus();
|
|
22
22
|
const stored = localStorage.getItem(localStorageKey);
|
|
@@ -36,7 +36,7 @@ const SearchTextInput = ({ pillColor = "bg-sky-500", textHighlight = "text-sky-5
|
|
|
36
36
|
const handleInputChange = (event) => {
|
|
37
37
|
setLocalSearchText(event.target.value);
|
|
38
38
|
};
|
|
39
|
-
// When a badge is clicked, remove it
|
|
39
|
+
// When a badge is clicked, remove it from search items & local storage
|
|
40
40
|
const handleSearchBadgeClick = (item) => {
|
|
41
41
|
const newSearchItems = searchItems.filter((ele) => ele !== item);
|
|
42
42
|
setSearchItems && setSearchItems(newSearchItems);
|
|
@@ -47,7 +47,7 @@ const SearchTextInput = ({ pillColor = "bg-sky-500", textHighlight = "text-sky-5
|
|
|
47
47
|
return newCriteria;
|
|
48
48
|
});
|
|
49
49
|
};
|
|
50
|
-
// On Enter: append new search
|
|
50
|
+
// On Enter: append new search
|
|
51
51
|
const handleKeyDown = (e) => {
|
|
52
52
|
console.log("handleKeyDown triggered, localSearchText:", localSearchText);
|
|
53
53
|
if (e.key === "Enter" && localSearchText.length > 0) {
|
|
@@ -57,17 +57,16 @@ const SearchTextInput = ({ pillColor = "bg-sky-500", textHighlight = "text-sky-5
|
|
|
57
57
|
handleSubmit();
|
|
58
58
|
}
|
|
59
59
|
};
|
|
60
|
-
// Append a new criterion for this column
|
|
61
|
-
// Here we combine the drop-down value (if provided) with the input text.
|
|
60
|
+
// Append a new criterion for this column
|
|
62
61
|
const handleSubmit = () => {
|
|
63
62
|
const trimmed = localSearchText.trim();
|
|
64
|
-
// Combine the drop-down option value (if
|
|
63
|
+
// Combine the drop-down option value (if any) with the text
|
|
65
64
|
const combinedText = selectedDropdownOption && selectedDropdownOption.value
|
|
66
65
|
? `${selectedDropdownOption.value}${trimmed}`
|
|
67
66
|
: trimmed;
|
|
68
67
|
console.log("handleSubmit triggered, combinedText:", combinedText);
|
|
69
68
|
if (!combinedText) {
|
|
70
|
-
// Remove any criteria for this column
|
|
69
|
+
// Remove any criteria for this column
|
|
71
70
|
setSearchCriteria((prev) => {
|
|
72
71
|
const newCriteria = prev.filter((c) => c.searchColumn.id !== column.id);
|
|
73
72
|
updateLocalStorage(newCriteria, localStorageKey);
|
|
@@ -76,7 +75,7 @@ const SearchTextInput = ({ pillColor = "bg-sky-500", textHighlight = "text-sky-5
|
|
|
76
75
|
});
|
|
77
76
|
}
|
|
78
77
|
else {
|
|
79
|
-
// Append a new criterion
|
|
78
|
+
// Append a new criterion
|
|
80
79
|
setSearchCriteria((prev) => {
|
|
81
80
|
const newCriteria = [
|
|
82
81
|
...prev,
|
|
@@ -90,6 +89,11 @@ const SearchTextInput = ({ pillColor = "bg-sky-500", textHighlight = "text-sky-5
|
|
|
90
89
|
setEditingHeader(null);
|
|
91
90
|
setLocalSearchText("");
|
|
92
91
|
};
|
|
93
|
-
return (_jsx("div", { ref: containerRef, className: "w-[425px]", children: _jsxs("div", { className: "flex flex-col border-2 border-navy-200 rounded-md", children: [_jsxs("div", { className: `flex ${searchItems.length ? "border-b-2" : ""} h-full`, children: [_jsx(Dropdown, { options: dropdownOptions, selectedOption: selectedDropdownOption || { label: "", value: "" }, onOptionSelect: onDropdownOptionSelect, optionClasses: "px-4 py-1 h-full flex items-center", menuClasses: "bg-white min-w-32xw rounded-md shadow-md", icon: dropdownIconProp, dropdownClasses: "border-0 border-r-2 w-auto " }), _jsx(Input, { focusRingColor: "focus:ring-transparent", hasAutoFocus: true, value: localSearchText, iconColor: "text-navy-400", onKeyDown: handleKeyDown, required: false, id: "", name: "", type: "text", firstIconClasses: firstIconClasses, onChange: handleInputChange, additionalClasses: "min-w-[250px] min-h-full text-gray flex", placeholder: "Search", hasIcons: true, firstIcon: localSearchText === "" ? (_jsx(AnimatePresence, { children: _jsx(motion.div, { initial: "initial", animate: "animate", exit: "exit", className: "text-navy-400", children: getFontAwesomeIcon("search", "regular") }) })) : undefined, iconPosition: "both", secondIcon: _jsx("div", { className: "border-transparent text-white min-w-9", children: _jsx(AnimatePresence, { children: localSearchText !== "" && (_jsxs(motion.div, { className: "flex justify-between items-center min-w-4 text-navy-400 hover:cursor-pointer hover:text-primary", initial: "initial", animate: "animate", exit: "exit", children: [_jsx("div", { className: "bg-navy-50 pr-2 pl-1 text-gray-500", onClick: () => setLocalSearchText(""), "data-testid": "clear-icon", children: getFontAwesomeIcon("xmark", "regular") }), _jsx("div", { className: `${textHighlight} text-sm hover:text-primary`, children: getFontAwesomeIcon("search", "solid") })] })) }) }), onIconClick: () => setLocalSearchText("") })] }), searchItems?.length ? (_jsx("div", { className: "flex flex-wrap bg-white py-2 px-2 rounded-md", children: searchItems.map((item, index) =>
|
|
92
|
+
return (_jsx("div", { ref: containerRef, className: "w-[425px]", children: _jsxs("div", { className: "flex flex-col border-2 border-navy-200 rounded-md", children: [_jsxs("div", { className: `flex ${searchItems.length ? "border-b-2" : ""} h-full`, children: [_jsx(Dropdown, { options: dropdownOptions, selectedOption: selectedDropdownOption || { label: "", value: "" }, onOptionSelect: onDropdownOptionSelect, optionClasses: "px-4 py-1 h-full flex items-center", menuClasses: "bg-white min-w-32xw rounded-md shadow-md", icon: dropdownIconProp, dropdownClasses: "border-0 border-r-2 w-auto " }), _jsx(Input, { focusRingColor: "focus:ring-transparent", hasAutoFocus: true, value: getCleanedText(localSearchText, removePattern), iconColor: "text-navy-400", onKeyDown: handleKeyDown, required: false, id: "", name: "", type: "text", firstIconClasses: firstIconClasses, onChange: handleInputChange, additionalClasses: "min-w-[250px] min-h-full text-gray flex", placeholder: "Search", hasIcons: true, firstIcon: localSearchText === "" ? (_jsx(AnimatePresence, { children: _jsx(motion.div, { initial: "initial", animate: "animate", exit: "exit", className: "text-navy-400", children: getFontAwesomeIcon("search", "regular") }) })) : undefined, iconPosition: "both", secondIcon: _jsx("div", { className: "border-transparent text-white min-w-9", children: _jsx(AnimatePresence, { children: localSearchText !== "" && (_jsxs(motion.div, { className: "flex justify-between items-center min-w-4 text-navy-400 hover:cursor-pointer hover:text-primary", initial: "initial", animate: "animate", exit: "exit", children: [_jsx("div", { className: "bg-navy-50 pr-2 pl-1 text-gray-500", onClick: () => setLocalSearchText(""), "data-testid": "clear-icon", children: getFontAwesomeIcon("xmark", "regular") }), _jsx("div", { className: `${textHighlight} text-sm hover:text-primary`, children: getFontAwesomeIcon("search", "solid") })] })) }) }), onIconClick: () => setLocalSearchText("") })] }), searchItems?.length ? (_jsx("div", { className: "flex flex-wrap bg-white py-2 px-2 rounded-md", children: searchItems.map((item, index) => {
|
|
93
|
+
const cleanedText = getCleanedText(item);
|
|
94
|
+
return (_jsx(Badge, { backgroundColor: pillColor, borderRadius: "rounded-full", hasRightIcon: true, icon: _jsx("div", { className: "text-white text-xxs", "data-testid": "item-clear-icon", children: getFontAwesomeIcon("xmark", "solid") }), iconSize: "text-sm", mobileIconLabel: item, onClick: () => handleSearchBadgeClick(item), text: _jsx(Text, { color: "text-white", fontFamily: fontFamily, size: "text-sm", tag: "span",
|
|
95
|
+
// Render only the cleaned text
|
|
96
|
+
text: cleanedText }), badgeContainerClasses: `${pillColor} p-1 max-w-fit min-w-20 rounded-full flex justify-between items-center text-white text-xs px-4 border-none mr-4 mb-1`, type: "span" }, index));
|
|
97
|
+
}) })) : null] }) }));
|
|
94
98
|
};
|
|
95
99
|
export default SearchTextInput;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Removes a specified pattern from the beginning of the string.
|
|
3
|
+
*
|
|
4
|
+
* @param item - The string to be cleaned.
|
|
5
|
+
* @param removePattern - The pattern to remove. This can be a string or a RegExp.
|
|
6
|
+
* If not provided, the original string is returned.
|
|
7
|
+
* @returns The cleaned string.
|
|
8
|
+
*/
|
|
9
|
+
export declare const getCleanedText: (item: string, removePattern?: RegExp | string) => string;
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
// utils/getCleanedText.ts
|
|
2
|
+
/**
|
|
3
|
+
* Removes a specified pattern from the beginning of the string.
|
|
4
|
+
*
|
|
5
|
+
* @param item - The string to be cleaned.
|
|
6
|
+
* @param removePattern - The pattern to remove. This can be a string or a RegExp.
|
|
7
|
+
* If not provided, the original string is returned.
|
|
8
|
+
* @returns The cleaned string.
|
|
9
|
+
*/
|
|
10
|
+
export const getCleanedText = (item, removePattern) => {
|
|
11
|
+
if (!removePattern)
|
|
12
|
+
return item;
|
|
13
|
+
if (removePattern instanceof RegExp) {
|
|
14
|
+
return item.replace(removePattern, "");
|
|
15
|
+
}
|
|
16
|
+
else {
|
|
17
|
+
const pattern = new RegExp(`^${removePattern}`);
|
|
18
|
+
return item.replace(pattern, "");
|
|
19
|
+
}
|
|
20
|
+
};
|