@vention/machine-ui 5.18.0 → 5.18.2

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/index.esm.js CHANGED
@@ -12605,6 +12605,7 @@ function getMatchingTagOptions(availableOptions, query, createOption) {
12605
12605
  const VentionTagsInput = ({
12606
12606
  value,
12607
12607
  onChange,
12608
+ onQueryChange,
12608
12609
  suggestions: _suggestions = EMPTY_TAGS,
12609
12610
  label,
12610
12611
  placeholder: _placeholder = "Type or select tags",
@@ -12620,6 +12621,7 @@ const VentionTagsInput = ({
12620
12621
  inputDataTestId
12621
12622
  }) => {
12622
12623
  const [inputValue, setInputValue] = useState("");
12624
+ const reportedQuery = useRef("");
12623
12625
  const theme = useTheme();
12624
12626
  const {
12625
12627
  classes
@@ -12630,39 +12632,43 @@ const VentionTagsInput = ({
12630
12632
  const options = useMemo(() => collectNormalizedTags(selectedTags, collectNormalizedTags(_suggestions, [])), [selectedTags, _suggestions]);
12631
12633
  const query = normalizeTag(inputValue);
12632
12634
  const createOption = query.length > 0 && !options.includes(query) ? query : null;
12635
+ function updateInputValue(nextInputValue) {
12636
+ setInputValue(nextInputValue);
12637
+ const nextQuery = normalizeTag(nextInputValue);
12638
+ if (nextQuery !== reportedQuery.current) {
12639
+ reportedQuery.current = nextQuery;
12640
+ onQueryChange === null || onQueryChange === void 0 ? void 0 : onQueryChange(nextQuery);
12641
+ }
12642
+ }
12633
12643
  function filterTagOptions(availableOptions) {
12634
12644
  return getMatchingTagOptions(availableOptions, query, createOption);
12635
12645
  }
12636
12646
  function groupOptionsBySuggestionsTitle() {
12637
12647
  return _suggestionsTitle;
12638
12648
  }
12639
- function handleChange(_event, newValue) {
12649
+ function handleChange(_event, newValue, reason) {
12640
12650
  const nextTags = collectNormalizedTags(newValue, []);
12641
12651
  onChange(nextTags);
12642
- if (nextTags[nextTags.length - 1] === createOption) {
12643
- setInputValue("");
12652
+ if (reason === "clear" || nextTags[nextTags.length - 1] === createOption) {
12653
+ updateInputValue("");
12644
12654
  }
12645
12655
  }
12646
12656
  function handleBlur() {
12647
- setInputValue("");
12657
+ updateInputValue("");
12648
12658
  }
12649
12659
  function handleInputChange(_event, newInputValue, reason) {
12650
- if (reason === "clear") {
12651
- setInputValue("");
12652
- return;
12653
- }
12654
12660
  if (reason !== "input") {
12655
12661
  return;
12656
12662
  }
12657
12663
  if (!newInputValue.includes(",")) {
12658
- setInputValue(toDisplayedInputValue(newInputValue));
12664
+ updateInputValue(toDisplayedInputValue(newInputValue));
12659
12665
  return;
12660
12666
  }
12661
12667
  const committed = splitTagsAtLastComma(newInputValue, selectedTags);
12662
- setInputValue(committed.inputValue);
12663
12668
  if (committed.tags.length > selectedTags.length) {
12664
12669
  onChange(committed.tags);
12665
12670
  }
12671
+ updateInputValue(committed.inputValue);
12666
12672
  }
12667
12673
  function renderTagPills(tags, getTagProps) {
12668
12674
  const pills = [];
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@vention/machine-ui",
3
- "version": "5.18.0",
3
+ "version": "5.18.2",
4
4
  "repository": {
5
5
  "type": "git",
6
6
  "url": "https://github.com/VentionCo/machine-cloud.git"
@@ -3,7 +3,8 @@ export type { VentionTagsInputSizes };
3
3
  export interface VentionTagsInputProps {
4
4
  value: string[];
5
5
  onChange: (tags: string[]) => void;
6
- suggestions?: string[];
6
+ onQueryChange?: (query: string) => void;
7
+ suggestions?: readonly string[];
7
8
  label?: string;
8
9
  placeholder?: string;
9
10
  suggestionsTitle?: string;
@@ -17,4 +18,4 @@ export interface VentionTagsInputProps {
17
18
  className?: string;
18
19
  inputDataTestId?: string;
19
20
  }
20
- export declare const VentionTagsInput: ({ value, onChange, suggestions, label, placeholder, suggestionsTitle, createOptionLabel, noOptionsMessage, removeTagLabel, disabled, size, autoFocus, maxVisibleOptions, className, inputDataTestId, }: VentionTagsInputProps) => import("react/jsx-runtime").JSX.Element;
21
+ export declare const VentionTagsInput: ({ value, onChange, onQueryChange, suggestions, label, placeholder, suggestionsTitle, createOptionLabel, noOptionsMessage, removeTagLabel, disabled, size, autoFocus, maxVisibleOptions, className, inputDataTestId, }: VentionTagsInputProps) => import("react/jsx-runtime").JSX.Element;