@cwellt_software/cwellt-reactjs-lib 1.5.3 → 1.5.4

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.
Files changed (26) hide show
  1. package/dist/index.cjs.js +20 -6
  2. package/dist/index.css +1 -1
  3. package/dist/index.d.ts +11 -0
  4. package/dist/index.es.js +20 -6
  5. package/dist/src/components/control/action/button/CwButton.stories.d.ts +28 -0
  6. package/dist/src/components/control/action/button/CwButton.stories.d.ts.map +1 -0
  7. package/dist/src/components/control/choice/multi-filter/CwMultiFilter.d.ts +11 -0
  8. package/dist/src/components/control/choice/multi-filter/CwMultiFilter.d.ts.map +1 -1
  9. package/dist/src/components/control/input/text/CwInputText.stories.d.ts +840 -0
  10. package/dist/src/components/control/input/text/CwInputText.stories.d.ts.map +1 -0
  11. package/dist/src/components/display/text/note/CwNote.stories.d.ts +51 -0
  12. package/dist/src/components/display/text/note/CwNote.stories.d.ts.map +1 -0
  13. package/dist/src/components/display/text/tag/CwChip.stories.d.ts +29 -0
  14. package/dist/src/components/display/text/tag/CwChip.stories.d.ts.map +1 -0
  15. package/dist/src/playground/pages/SelectorsPage.d.ts.map +1 -1
  16. package/dist/src/storybook/inputStoryArgs.d.ts +68 -0
  17. package/dist/src/storybook/inputStoryArgs.d.ts.map +1 -0
  18. package/dist/src/storybook/layoutStoryArgs.d.ts +60 -0
  19. package/dist/src/storybook/layoutStoryArgs.d.ts.map +1 -0
  20. package/dist/src/storybook/storySource.d.ts +22 -0
  21. package/dist/src/storybook/storySource.d.ts.map +1 -0
  22. package/dist/test/storybook/inputStoryArgs.test.d.ts +2 -0
  23. package/dist/test/storybook/inputStoryArgs.test.d.ts.map +1 -0
  24. package/dist/test/storybook/layoutStoryArgs.test.d.ts +2 -0
  25. package/dist/test/storybook/layoutStoryArgs.test.d.ts.map +1 -0
  26. package/package.json +1 -1
package/dist/index.cjs.js CHANGED
@@ -4986,21 +4986,29 @@ var styles$b = {"cw-multi-filter-catalog-container":"cw-multi-filter-module__cw-
4986
4986
  * @param {CwMultiFilterProps} props
4987
4987
  * @returns Set the `onChange` callback to a function to check for changes in the selected filters
4988
4988
  */
4989
- const CwMultiFilter = ({ allTags, id, onChangeSelectedTags, selectedTags, placeholder = "Write to filter", allCategoriesLabel = "ALL CATEGORIES", className, style }) => {
4989
+ const CwMultiFilter = ({ allTags, id, onChangeSelectedTags, selectedTags, placeholder = "Write to filter", allCategoriesLabel = "ALL CATEGORIES", className, style, testId, initialTagVisibility = "all" }) => {
4990
4990
  const [inputTextValue, setInputTextValue] = React.useState("");
4991
4991
  const [isPanelOpen, setIsPanelOpen] = React.useState(false);
4992
4992
  const [selectedCategory, setSelectedCategory] = React.useState("All");
4993
+ // True once the user touches the current opening (any category click or a search); gates the cascade.
4994
+ const [hasInteracted, setHasInteracted] = React.useState(false);
4993
4995
  const componentRef = React.useRef(null);
4994
4996
  const inputRef = React.useRef(null);
4995
4997
  const wrapperRef = React.useRef(null);
4996
4998
  const { panelRef, panelStyle, renderPanel } = useDropdownPortal({
4997
4999
  anchorRef: wrapperRef,
4998
5000
  isOpen: isPanelOpen,
4999
- onClose: () => { setIsPanelOpen(false); setSelectedCategory("All"); setInputTextValue(""); },
5001
+ onClose: () => setIsPanelOpen(false),
5000
5002
  });
5003
+ // Single reset point for all transient panel state on close, whatever closed it - the clear-all
5004
+ // button closes the panel directly and bypasses onClose, so resetting here covers every path.
5001
5005
  React.useEffect(() => {
5002
- // Outside-click is now handled by useDropdownPortal
5003
- }, []);
5006
+ if (!isPanelOpen) {
5007
+ setHasInteracted(false);
5008
+ setSelectedCategory("All");
5009
+ setInputTextValue("");
5010
+ }
5011
+ }, [isPanelOpen]);
5004
5012
  const categoriesMappedToTags = () => {
5005
5013
  const categoriesMap = new Map();
5006
5014
  allTags.forEach(tag => {
@@ -5011,6 +5019,9 @@ const CwMultiFilter = ({ allTags, id, onChangeSelectedTags, selectedTags, placeh
5011
5019
  return categoriesMap;
5012
5020
  };
5013
5021
  const displayTags = React.useMemo(() => {
5022
+ if (initialTagVisibility === "afterCategoryOrSearch" && !hasInteracted) {
5023
+ return [];
5024
+ }
5014
5025
  let tags = Array.from(allTags);
5015
5026
  if (selectedCategory !== "All") {
5016
5027
  tags = tags.filter(t => t.Category === selectedCategory);
@@ -5020,8 +5031,9 @@ const CwMultiFilter = ({ allTags, id, onChangeSelectedTags, selectedTags, placeh
5020
5031
  tags = tags.filter(t => t.Name.replaceAll(" ", "").toLowerCase().includes(input));
5021
5032
  }
5022
5033
  return tags;
5023
- }, [allTags, selectedCategory, inputTextValue]);
5034
+ }, [allTags, selectedCategory, inputTextValue, initialTagVisibility, hasInteracted]);
5024
5035
  const handleClickCategory = (category) => {
5036
+ setHasInteracted(true);
5025
5037
  setSelectedCategory(category);
5026
5038
  };
5027
5039
  const rgbAString = (r, g, b) => {
@@ -5046,6 +5058,8 @@ const CwMultiFilter = ({ allTags, id, onChangeSelectedTags, selectedTags, placeh
5046
5058
  const handleInputText = (input) => {
5047
5059
  if (selectedCategory !== "All")
5048
5060
  setSelectedCategory("All");
5061
+ if (input.trim() !== "")
5062
+ setHasInteracted(true);
5049
5063
  setInputTextValue(input.trimStart());
5050
5064
  };
5051
5065
  const addTag = (newTag) => {
@@ -5072,7 +5086,7 @@ const CwMultiFilter = ({ allTags, id, onChangeSelectedTags, selectedTags, placeh
5072
5086
  inputRef.current?.focus();
5073
5087
  }
5074
5088
  };
5075
- return (jsxRuntime.jsxs("form", { ref: componentRef, id: id, className: `${styles$b["cw-multi-filter"]}${className ? ` ${className}` : ""}`, style: style, onSubmit: (e) => {
5089
+ return (jsxRuntime.jsxs("form", { ref: componentRef, id: id, "data-testid": testId, className: `${styles$b["cw-multi-filter"]}${className ? ` ${className}` : ""}`, style: style, onSubmit: (e) => {
5076
5090
  e.preventDefault();
5077
5091
  }, children: [jsxRuntime.jsxs("div", { onClick: handleDivClick, ref: wrapperRef, className: styles$b["cw-multi-filter-search"], style: isPanelOpen ? { outline: "1px solid var(--cw-color-outline-variant)" } : {}, children: [jsxRuntime.jsxs("ul", { id: id + "_selected_filters", children: [Array.from(selectedTags).map(tag => (React.createElement(CwMultiFilterTag, { ...tag, key: tag.ID, Selectable: false, Removable: true, OnRemove: () => removeTag(tag.ID) }))), jsxRuntime.jsx("input", { type: "text", id: id + "_input", ref: inputRef, value: inputTextValue, spellCheck: false, onFocus: () => setIsPanelOpen(true), onChange: e => handleInputText(e.currentTarget.value), autoComplete: "off", placeholder: selectedTags.size === 0 ? placeholder : "", onKeyDown: e => {
5078
5092
  switch (e.key) {