@cwellt_software/cwellt-reactjs-lib 1.4.6 → 1.4.7
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/index.cjs.js +87 -98
- package/dist/index.css +2 -2
- package/dist/index.d.ts +7 -3
- package/dist/index.es.js +87 -98
- package/dist/src/components/control/choice/multi-filter/CwMultiFilter.d.ts.map +1 -1
- package/dist/src/components/custom/scheduler-new/presentation/logic/getEventSizesTemporal.d.ts +9 -0
- package/dist/src/components/custom/scheduler-new/presentation/logic/getEventSizesTemporal.d.ts.map +1 -0
- package/dist/src/components/layout/card/CwCard.d.ts +5 -2
- package/dist/src/components/layout/card/CwCard.d.ts.map +1 -1
- package/dist/src/components/layout/card/CwCardList.d.ts +3 -1
- package/dist/src/components/layout/card/CwCardList.d.ts.map +1 -1
- package/dist/src/playground/pages/CardListPage.d.ts +3 -0
- package/dist/src/playground/pages/CardListPage.d.ts.map +1 -0
- package/dist/test/components/custom/new-scheduler/presentation/logic/getEventSizesTemporal.test.d.ts +2 -0
- package/dist/test/components/custom/new-scheduler/presentation/logic/getEventSizesTemporal.test.d.ts.map +1 -0
- package/package.json +1 -1
package/dist/index.cjs.js
CHANGED
|
@@ -1757,7 +1757,9 @@ var styles$n = {"card":"cw-card-module__card__HJUT0","clickable":"cw-card-module
|
|
|
1757
1757
|
* <p>This is the main content of the card.</p>
|
|
1758
1758
|
* </CwCard>
|
|
1759
1759
|
**/
|
|
1760
|
-
const CwCard = ({ id, title, subtitle, alignment = 'center', children, footer, onEdit, onDelete, extraActions, className = '', clickable = false, onClick, isLoading = false, disabled = false, style, chips = [], variant = "border", direction = "column", }) => {
|
|
1760
|
+
const CwCard = ({ id, title, subtitle, alignment = 'center', children, footer, onEdit, onDelete, extraActions, className = '', clickable = false, onClick, isLoading = false, disabled = false, style, chips = [], variant = "border", direction = "column", layout, }) => {
|
|
1761
|
+
const resolvedDirection = layout?.direction ?? direction;
|
|
1762
|
+
const resolvedAlign = layout?.align ?? (alignment === 'left' ? 'start' : 'center');
|
|
1761
1763
|
// Construct class names using CSS modules
|
|
1762
1764
|
const cardClassNames = [
|
|
1763
1765
|
'cw-card',
|
|
@@ -1776,23 +1778,77 @@ const CwCard = ({ id, title, subtitle, alignment = 'center', children, footer, o
|
|
|
1776
1778
|
// Determine if actions should be rendered
|
|
1777
1779
|
const hasActions = onEdit || onDelete || extraActions;
|
|
1778
1780
|
// Determine if header should be rendered
|
|
1779
|
-
const hasHeader = title || subtitle || (hasActions &&
|
|
1781
|
+
const hasHeader = title || subtitle || (hasActions && resolvedDirection === "column");
|
|
1780
1782
|
// Determine if chips should be rendered
|
|
1781
1783
|
const hasChips = chips.length > 0;
|
|
1782
1784
|
// Determine if footer should be rendered
|
|
1783
|
-
const hasFooter = hasChips || footer || (hasActions &&
|
|
1785
|
+
const hasFooter = hasChips || footer || (hasActions && resolvedDirection === "row");
|
|
1784
1786
|
// Actions component to reuse
|
|
1785
1787
|
const ActionsComponent = hasActions && !disabled ? (jsxRuntime.jsxs("div", { className: styles$n.actions, children: [extraActions ?? null, onEdit && jsxRuntime.jsx(CwButton, { variant: "icon", icon: "edit", onClick: onEdit }), onDelete && jsxRuntime.jsx(CwButton, { variant: "icon", icon: "delete", color: "danger", onClick: onDelete })] })) : null;
|
|
1786
1788
|
return (jsxRuntime.jsxs("div", { ...(id && { id }), className: cardClassNames, ...(style && { style }), ...(clickable && {
|
|
1787
1789
|
role: 'button',
|
|
1788
1790
|
tabIndex: 0,
|
|
1789
1791
|
onClick: handleClick,
|
|
1790
|
-
}), "data-variant": variant, "data-direction":
|
|
1792
|
+
}), "data-variant": variant, "data-direction": resolvedDirection, children: [hasHeader && (jsxRuntime.jsxs("header", { children: [(title || subtitle) && (jsxRuntime.jsxs("div", { className: styles$n.headerContent, "data-align": resolvedAlign, children: [title && jsxRuntime.jsx("h5", { children: title }), subtitle && jsxRuntime.jsx("strong", { children: subtitle })] })), resolvedDirection === "column" && ActionsComponent] })), jsxRuntime.jsx("div", { className: styles$n.content, children: children }), hasFooter && (jsxRuntime.jsxs("footer", { children: [hasChips && (jsxRuntime.jsx("div", { className: styles$n.footerTags, children: chips.map((chip, index) => (jsxRuntime.jsx(CwChip, { label: chip.label, colorScheme: chip.colorScheme, className: styles$n.chip, ...(chip.customColor && { customColor: chip.customColor }), ...(chip.variant && { variant: chip.variant }), ...(chip.icon && { icon: chip.icon }) }, index))) })), footer && (jsxRuntime.jsx("div", { className: styles$n.footerContent, children: footer }))] })), resolvedDirection === "row" && ActionsComponent, isLoading && (jsxRuntime.jsx("div", { className: styles$n.loadingOverlay, children: jsxRuntime.jsx(CwLoading, { isLoading: isLoading, size: "small" }) }))] }));
|
|
1791
1793
|
};
|
|
1792
1794
|
|
|
1793
|
-
var styles$m = {"cardContainer":"cw-card-list-module__cardContainer__l3YEh","pagination":"cw-card-list-module__pagination__5Ay78","pageInfo":"cw-card-list-module__pageInfo__uiMel","loading":"cw-card-list-module__loading__cYpND","emptyState":"cw-card-list-module__emptyState__RlqiS"
|
|
1795
|
+
var styles$m = {"cardContainer":"cw-card-list-module__cardContainer__l3YEh","pagination":"cw-card-list-module__pagination__5Ay78","pageInfo":"cw-card-list-module__pageInfo__uiMel","loading":"cw-card-list-module__loading__cYpND","emptyState":"cw-card-list-module__emptyState__RlqiS"};
|
|
1794
1796
|
|
|
1795
|
-
|
|
1797
|
+
/**
|
|
1798
|
+
* Option to display in the CwSelect
|
|
1799
|
+
* @remarks
|
|
1800
|
+
* Must be child of CwSelect
|
|
1801
|
+
* @example
|
|
1802
|
+
* <CwSelect>
|
|
1803
|
+
* <CwOption>A</CwOption>
|
|
1804
|
+
* <CwOption color="#4a90d9">Blue option</CwOption>
|
|
1805
|
+
* <CwOption>C</CwOption>
|
|
1806
|
+
* </CwSelect>
|
|
1807
|
+
*/
|
|
1808
|
+
function CwOption(props) {
|
|
1809
|
+
const { text, color, style, ...optionProps } = props;
|
|
1810
|
+
const mergedStyle = color
|
|
1811
|
+
? { ...style, backgroundColor: color, color: getContrastColor(color) }
|
|
1812
|
+
: style;
|
|
1813
|
+
return (jsxRuntime.jsx("option", { className: "cw-option", style: mergedStyle, ...optionProps, children: optionProps.children ?? text }));
|
|
1814
|
+
}
|
|
1815
|
+
|
|
1816
|
+
/**
|
|
1817
|
+
* Input for selecting an option from a list
|
|
1818
|
+
* @remarks
|
|
1819
|
+
* ```txt
|
|
1820
|
+
* CwIcon CwLabel CwSelect CwButton
|
|
1821
|
+
* ↑ ↑ ↑ ↑
|
|
1822
|
+
* ╭────────────────────╮╭════╮
|
|
1823
|
+
* ⌂ Cat: │ Choose a cat ╲╱ │║ Ok ║
|
|
1824
|
+
* ╰────────────────────╯╰════╯
|
|
1825
|
+
* │ Orange │ ← CwOption
|
|
1826
|
+
* ├────────────────────┤
|
|
1827
|
+
* │ Black │ ← CwOption
|
|
1828
|
+
* ├────────────────────┤
|
|
1829
|
+
* │ White │ ← CwOption
|
|
1830
|
+
* ╰────────────────────╯
|
|
1831
|
+
* ```
|
|
1832
|
+
* @example
|
|
1833
|
+
* <CwSelect name="cat" iconProps={{iconId:"pet"}} labelProps={{children:"Cat:"}}>
|
|
1834
|
+
* <CwOption value="" > - Choose a cat - </CwOption>
|
|
1835
|
+
* <CwOption value="o" >Orange</CwOption>
|
|
1836
|
+
* <CwOption value="b" >Black</CwOption>
|
|
1837
|
+
* <CwOption value="w" >White</CwOption>
|
|
1838
|
+
* </CwSelect>
|
|
1839
|
+
*/
|
|
1840
|
+
function CwSelect(props) {
|
|
1841
|
+
const { alignProps, labelProps, buttonProps, iconProps, placeholder, feedback, children, style, className, ...selectProps } = props;
|
|
1842
|
+
const feedbackMessages = feedback
|
|
1843
|
+
? Array.isArray(feedback) ? feedback : [feedback]
|
|
1844
|
+
: [];
|
|
1845
|
+
const flexDirection = alignProps?.flexDirection ?? "row";
|
|
1846
|
+
const dataDirection = { 'data-direction': flexDirection };
|
|
1847
|
+
const { backgroundColor, color: textColor, ...wrapperStyle } = style ?? {};
|
|
1848
|
+
return (jsxRuntime.jsxs("div", { className: `cw-select${className ? ` ${className}` : ''}`, ...dataDirection, style: wrapperStyle, children: [jsxRuntime.jsxs(CwAlign, { ...alignProps, itemProp: selectProps.required === true ? "required" : "", children: [labelProps && (jsxRuntime.jsxs(CwLabel, { ...labelProps, children: [iconProps && jsxRuntime.jsx(CwIcon, { ...iconProps }), labelProps.text] })), jsxRuntime.jsxs("div", { className: "cw-flex-row cw-gap-small cw-flex-grow", children: [jsxRuntime.jsxs("select", { ...selectProps, style: backgroundColor ? { backgroundColor, color: textColor } : undefined, children: [placeholder && jsxRuntime.jsx(CwOption, { value: "", children: placeholder }), children] }), buttonProps && jsxRuntime.jsx(CwButton, { ...buttonProps })] })] }), feedbackMessages.map((feedbackItem, index) => (jsxRuntime.jsx("p", { className: "cw-input-info", "data-color": feedbackItem.type, children: feedbackItem.message }, index)))] }));
|
|
1849
|
+
}
|
|
1850
|
+
|
|
1851
|
+
function CwCardList({ items, renderCard, pageSize = 10, layout = 'grid', defaultCardWidth = 320, cardGap = 16, isLoading = false, emptyState, sortOptions = [], defaultSortKey, keyExtractor, ...htmlProps }) {
|
|
1796
1852
|
const [currentPage, setCurrentPage] = React.useState(1);
|
|
1797
1853
|
const [sortKey, setSortKey] = React.useState(defaultSortKey || sortOptions[0]?.key || '');
|
|
1798
1854
|
const [sortDirection, setSortDirection] = React.useState('asc');
|
|
@@ -1824,7 +1880,12 @@ function CwCardList({ items, renderCard, pageSize = 10, layout = 'grid', default
|
|
|
1824
1880
|
'--card-width': `${defaultCardWidth}px`,
|
|
1825
1881
|
'--card-gap': `${cardGap}px`
|
|
1826
1882
|
};
|
|
1827
|
-
return (jsxRuntime.jsxs("div", { ...htmlProps, children: [sortOptions.length > 0 && (jsxRuntime.
|
|
1883
|
+
return (jsxRuntime.jsxs("div", { ...htmlProps, children: [sortOptions.length > 0 && (jsxRuntime.jsx("header", { className: "cw-flex-row cw-align-right-center cw-margin-bottom-small", children: jsxRuntime.jsx(CwSelect, { labelProps: { text: 'Sort by:', labelWidth: "4rem" }, alignProps: { alignItems: 'center' }, buttonProps: {
|
|
1884
|
+
variant: 'icon',
|
|
1885
|
+
icon: sortDirection === 'asc' ? 'arrow-up' : 'arrow-down',
|
|
1886
|
+
onClick: () => setSortDirection(prev => prev === 'asc' ? 'desc' : 'asc'),
|
|
1887
|
+
title: `Sort ${sortDirection === 'asc' ? 'descending' : 'ascending'}`,
|
|
1888
|
+
}, value: sortKey, onChange: (e) => handleSortChange(e.target.value), children: sortOptions.map(option => (jsxRuntime.jsx(CwOption, { value: option.key, children: option.label }, option.key))) }) })), isLoading ? (jsxRuntime.jsx("div", { className: styles$m.loading, children: jsxRuntime.jsx(CwLoading, { isLoading: isLoading }) })) : sortedItems.length === 0 ? (jsxRuntime.jsx("div", { className: styles$m.emptyState, children: emptyState || jsxRuntime.jsx("p", { children: "No items to display" }) })) : (jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [jsxRuntime.jsx("div", { className: `${styles$m.cardContainer}`, "data-layout": layout, style: gridStyle, children: visibleItems.map((item, index) => (jsxRuntime.jsx(React.Fragment, { children: renderCard(item, index) }, keyExtractor ? keyExtractor(item, index) : index))) }), totalPages > 1 && (jsxRuntime.jsxs("div", { className: styles$m.pagination, children: [jsxRuntime.jsx(CwButton, { variant: "icon", icon: "chevron-left", disabled: currentPage === 1, onClick: () => setCurrentPage(p => Math.max(1, p - 1)) }), jsxRuntime.jsxs("span", { className: styles$m.pageInfo, children: [currentPage, " / ", totalPages] }), jsxRuntime.jsx(CwButton, { variant: "icon", icon: "chevron-right", disabled: currentPage === totalPages, onClick: () => setCurrentPage(p => Math.min(totalPages, p + 1)) })] }))] }))] }));
|
|
1828
1889
|
}
|
|
1829
1890
|
|
|
1830
1891
|
var styles$l = {"cw-accordion":"cw-accordion-module__cw-accordion__ErvlW","cw-accordion-body":"cw-accordion-module__cw-accordion-body__xlI8b"};
|
|
@@ -4257,60 +4318,6 @@ function CwToggle(props) {
|
|
|
4257
4318
|
type: "checkbox", ...inputProps })] }) }));
|
|
4258
4319
|
}
|
|
4259
4320
|
|
|
4260
|
-
/**
|
|
4261
|
-
* Option to display in the CwSelect
|
|
4262
|
-
* @remarks
|
|
4263
|
-
* Must be child of CwSelect
|
|
4264
|
-
* @example
|
|
4265
|
-
* <CwSelect>
|
|
4266
|
-
* <CwOption>A</CwOption>
|
|
4267
|
-
* <CwOption color="#4a90d9">Blue option</CwOption>
|
|
4268
|
-
* <CwOption>C</CwOption>
|
|
4269
|
-
* </CwSelect>
|
|
4270
|
-
*/
|
|
4271
|
-
function CwOption(props) {
|
|
4272
|
-
const { text, color, style, ...optionProps } = props;
|
|
4273
|
-
const mergedStyle = color
|
|
4274
|
-
? { ...style, backgroundColor: color, color: getContrastColor(color) }
|
|
4275
|
-
: style;
|
|
4276
|
-
return (jsxRuntime.jsx("option", { className: "cw-option", style: mergedStyle, ...optionProps, children: optionProps.children ?? text }));
|
|
4277
|
-
}
|
|
4278
|
-
|
|
4279
|
-
/**
|
|
4280
|
-
* Input for selecting an option from a list
|
|
4281
|
-
* @remarks
|
|
4282
|
-
* ```txt
|
|
4283
|
-
* CwIcon CwLabel CwSelect CwButton
|
|
4284
|
-
* ↑ ↑ ↑ ↑
|
|
4285
|
-
* ╭────────────────────╮╭════╮
|
|
4286
|
-
* ⌂ Cat: │ Choose a cat ╲╱ │║ Ok ║
|
|
4287
|
-
* ╰────────────────────╯╰════╯
|
|
4288
|
-
* │ Orange │ ← CwOption
|
|
4289
|
-
* ├────────────────────┤
|
|
4290
|
-
* │ Black │ ← CwOption
|
|
4291
|
-
* ├────────────────────┤
|
|
4292
|
-
* │ White │ ← CwOption
|
|
4293
|
-
* ╰────────────────────╯
|
|
4294
|
-
* ```
|
|
4295
|
-
* @example
|
|
4296
|
-
* <CwSelect name="cat" iconProps={{iconId:"pet"}} labelProps={{children:"Cat:"}}>
|
|
4297
|
-
* <CwOption value="" > - Choose a cat - </CwOption>
|
|
4298
|
-
* <CwOption value="o" >Orange</CwOption>
|
|
4299
|
-
* <CwOption value="b" >Black</CwOption>
|
|
4300
|
-
* <CwOption value="w" >White</CwOption>
|
|
4301
|
-
* </CwSelect>
|
|
4302
|
-
*/
|
|
4303
|
-
function CwSelect(props) {
|
|
4304
|
-
const { alignProps, labelProps, buttonProps, iconProps, placeholder, feedback, children, style, className, ...selectProps } = props;
|
|
4305
|
-
const feedbackMessages = feedback
|
|
4306
|
-
? Array.isArray(feedback) ? feedback : [feedback]
|
|
4307
|
-
: [];
|
|
4308
|
-
const flexDirection = alignProps?.flexDirection ?? "row";
|
|
4309
|
-
const dataDirection = { 'data-direction': flexDirection };
|
|
4310
|
-
const { backgroundColor, color: textColor, ...wrapperStyle } = style ?? {};
|
|
4311
|
-
return (jsxRuntime.jsxs("div", { className: `cw-select${className ? ` ${className}` : ''}`, ...dataDirection, style: wrapperStyle, children: [jsxRuntime.jsxs(CwAlign, { ...alignProps, itemProp: selectProps.required === true ? "required" : "", children: [labelProps && (jsxRuntime.jsxs(CwLabel, { ...labelProps, children: [iconProps && jsxRuntime.jsx(CwIcon, { ...iconProps }), labelProps.text] })), jsxRuntime.jsxs("div", { className: "cw-flex-row cw-gap-small cw-flex-grow", children: [jsxRuntime.jsxs("select", { ...selectProps, style: backgroundColor ? { backgroundColor, color: textColor } : undefined, children: [placeholder && jsxRuntime.jsx(CwOption, { value: "", children: placeholder }), children] }), buttonProps && jsxRuntime.jsx(CwButton, { ...buttonProps })] })] }), feedbackMessages.map((feedbackItem, index) => (jsxRuntime.jsx("p", { className: "cw-input-info", "data-color": feedbackItem.type, children: feedbackItem.message }, index)))] }));
|
|
4312
|
-
}
|
|
4313
|
-
|
|
4314
4321
|
// ─── Default strategy: below anchor, match width, flip above if needed ────────
|
|
4315
4322
|
function defaultPositionStrategy(anchorRect, panelRect) {
|
|
4316
4323
|
const panelH = panelRect?.height ?? 200;
|
|
@@ -4784,7 +4791,6 @@ var styles$8 = {"cw-multi-filter-catalog-container":"cw-multi-filter-module__cw-
|
|
|
4784
4791
|
* @returns Set the `onChange` callback to a function to check for changes in the selected filters
|
|
4785
4792
|
*/
|
|
4786
4793
|
const CwMultiFilter = ({ allTags, id, onChangeSelectedTags, selectedTags, placeholder = "Write to filter", allCategoriesLabel = "ALL CATEGORIES", className, style }) => {
|
|
4787
|
-
const [filteredTags, setFilteredTags] = React.useState(new Set());
|
|
4788
4794
|
const [inputTextValue, setInputTextValue] = React.useState("");
|
|
4789
4795
|
const [isPanelOpen, setIsPanelOpen] = React.useState(false);
|
|
4790
4796
|
const [selectedCategory, setSelectedCategory] = React.useState("All");
|
|
@@ -4794,7 +4800,7 @@ const CwMultiFilter = ({ allTags, id, onChangeSelectedTags, selectedTags, placeh
|
|
|
4794
4800
|
const { panelRef, panelStyle, renderPanel } = useDropdownPortal({
|
|
4795
4801
|
anchorRef: wrapperRef,
|
|
4796
4802
|
isOpen: isPanelOpen,
|
|
4797
|
-
onClose: () => { setIsPanelOpen(false);
|
|
4803
|
+
onClose: () => { setIsPanelOpen(false); setSelectedCategory("All"); setInputTextValue(""); },
|
|
4798
4804
|
});
|
|
4799
4805
|
React.useEffect(() => {
|
|
4800
4806
|
// Outside-click is now handled by useDropdownPortal
|
|
@@ -4808,10 +4814,19 @@ const CwMultiFilter = ({ allTags, id, onChangeSelectedTags, selectedTags, placeh
|
|
|
4808
4814
|
});
|
|
4809
4815
|
return categoriesMap;
|
|
4810
4816
|
};
|
|
4811
|
-
const
|
|
4817
|
+
const displayTags = React.useMemo(() => {
|
|
4818
|
+
let tags = Array.from(allTags);
|
|
4819
|
+
if (selectedCategory !== "All") {
|
|
4820
|
+
tags = tags.filter(t => t.Category === selectedCategory);
|
|
4821
|
+
}
|
|
4822
|
+
if (inputTextValue.trim() !== "") {
|
|
4823
|
+
const input = inputTextValue.trim().replaceAll(" ", "").toLowerCase();
|
|
4824
|
+
tags = tags.filter(t => t.Name.replaceAll(" ", "").toLowerCase().includes(input));
|
|
4825
|
+
}
|
|
4826
|
+
return tags;
|
|
4827
|
+
}, [allTags, selectedCategory, inputTextValue]);
|
|
4812
4828
|
const handleClickCategory = (category) => {
|
|
4813
4829
|
setSelectedCategory(category);
|
|
4814
|
-
setFilteredTags(category !== "All" ? (categoriesMappedToTags().get(category) ?? new Set()) : getUnselectedAll());
|
|
4815
4830
|
};
|
|
4816
4831
|
const rgbAString = (r, g, b) => {
|
|
4817
4832
|
return `rgb(${r}, ${g}, ${b})`;
|
|
@@ -4835,36 +4850,15 @@ const CwMultiFilter = ({ allTags, id, onChangeSelectedTags, selectedTags, placeh
|
|
|
4835
4850
|
const handleInputText = (input) => {
|
|
4836
4851
|
if (selectedCategory !== "All")
|
|
4837
4852
|
setSelectedCategory("All");
|
|
4838
|
-
input
|
|
4839
|
-
setInputTextValue(input);
|
|
4840
|
-
if (input !== "") {
|
|
4841
|
-
const newFilterTags = Array.from(allTags).filter(tag => !Array.from(selectedTags).some(t => t.ID === tag.ID) &&
|
|
4842
|
-
tag.Name.replaceAll(" ", "").toLowerCase().includes(input.replaceAll(" ", "").toLowerCase()));
|
|
4843
|
-
setFilteredTags(new Set(newFilterTags));
|
|
4844
|
-
}
|
|
4845
|
-
else {
|
|
4846
|
-
setFilteredTags(getUnselectedAll());
|
|
4847
|
-
}
|
|
4853
|
+
setInputTextValue(input.trimStart());
|
|
4848
4854
|
};
|
|
4849
4855
|
const addTag = (newTag) => {
|
|
4850
|
-
newTag.Selected = true;
|
|
4851
|
-
newTag.Removable = true;
|
|
4852
|
-
newTag.Selectable = false;
|
|
4853
4856
|
if (selectedTags.has(newTag) || Array.from(selectedTags).some(t => t.ID === newTag.ID)) {
|
|
4854
4857
|
return;
|
|
4855
4858
|
}
|
|
4856
|
-
|
|
4857
|
-
|
|
4858
|
-
|
|
4859
|
-
setInputTextValue("");
|
|
4860
|
-
setFilteredTags(selectedCategory === "All" ? getUnselectedAll(updatedTags) : prev => {
|
|
4861
|
-
const next = new Set(prev);
|
|
4862
|
-
const toRemove = Array.from(next).find(t => t.ID === newTag.ID);
|
|
4863
|
-
if (toRemove)
|
|
4864
|
-
next.delete(toRemove);
|
|
4865
|
-
return next;
|
|
4866
|
-
});
|
|
4867
|
-
}
|
|
4859
|
+
const updatedTags = new Set(selectedTags).add(newTag);
|
|
4860
|
+
onChangeSelectedTags(updatedTags);
|
|
4861
|
+
setInputTextValue("");
|
|
4868
4862
|
};
|
|
4869
4863
|
const removeTag = (id) => {
|
|
4870
4864
|
const updatedTags = new Set(selectedTags);
|
|
@@ -4877,11 +4871,6 @@ const CwMultiFilter = ({ allTags, id, onChangeSelectedTags, selectedTags, placeh
|
|
|
4877
4871
|
}
|
|
4878
4872
|
onChangeSelectedTags(updatedTags);
|
|
4879
4873
|
};
|
|
4880
|
-
React.useEffect(() => {
|
|
4881
|
-
// force to load all tags on first render
|
|
4882
|
-
if (selectedCategory === "All" && filteredTags.size === 0)
|
|
4883
|
-
setFilteredTags(new Set());
|
|
4884
|
-
}, [allTags]);
|
|
4885
4874
|
const handleDivClick = () => {
|
|
4886
4875
|
if (inputRef !== null) {
|
|
4887
4876
|
inputRef.current?.focus();
|
|
@@ -4893,9 +4882,9 @@ const CwMultiFilter = ({ allTags, id, onChangeSelectedTags, selectedTags, placeh
|
|
|
4893
4882
|
switch (e.key) {
|
|
4894
4883
|
case "Enter":
|
|
4895
4884
|
case "Tab": {
|
|
4896
|
-
if (inputTextValue.trim().length > 0 &&
|
|
4885
|
+
if (inputTextValue.trim().length > 0 && displayTags.length > 0) {
|
|
4897
4886
|
const input = inputTextValue.trim().toLowerCase();
|
|
4898
|
-
const tagsArr =
|
|
4887
|
+
const tagsArr = displayTags;
|
|
4899
4888
|
let foundTag = tagsArr.find(tag => tag.Name.trim().toLowerCase() === input);
|
|
4900
4889
|
if (!foundTag) {
|
|
4901
4890
|
foundTag = tagsArr.find(tag => tag.Name.trim().toLowerCase().startsWith(input));
|
|
@@ -4919,7 +4908,7 @@ const CwMultiFilter = ({ allTags, id, onChangeSelectedTags, selectedTags, placeh
|
|
|
4919
4908
|
} })] }), selectedTags.size > 0 && (jsxRuntime.jsx(CwButton, { type: "button", variant: "icon", color: "neutral", icon: "close", onMouseDown: e => e.preventDefault(), onClick: (e) => { e.stopPropagation(); onChangeSelectedTags(new Set()); setIsPanelOpen(false); }, tabIndex: -1, "aria-label": "Clear all" }))] }), renderPanel(jsxRuntime.jsxs("section", { ref: panelRef, className: styles$8["cw-multi-filter-catalog-container"], style: panelStyle, children: [jsxRuntime.jsxs("nav", { children: [jsxRuntime.jsx("button", { className: selectedCategory === "All" ? styles$8["category-selected"] : undefined, onClick: () => handleClickCategory("All"), children: allCategoriesLabel }), Array.from(categoriesMappedToTags().keys()).map(category => (jsxRuntime.jsx("button", { className: selectedCategory === category ? styles$8["category-selected"] : undefined, style: {
|
|
4920
4909
|
backgroundColor: getColor(category).primary,
|
|
4921
4910
|
color: getColor(category).onPrimary,
|
|
4922
|
-
}, onClick: () => handleClickCategory(category), children: category }, category)))] }), jsxRuntime.jsx("ul", { children:
|
|
4911
|
+
}, onClick: () => handleClickCategory(category), children: category }, category)))] }), jsxRuntime.jsx("ul", { children: displayTags
|
|
4923
4912
|
.sort((a, b) => {
|
|
4924
4913
|
const input = inputTextValue.trim().toLowerCase();
|
|
4925
4914
|
const aName = a.Name.trim().toLowerCase();
|