@vention/machine-ui 5.18.1 → 5.18.3

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
@@ -7283,7 +7283,10 @@ const VentionTextInput = _a => {
7283
7283
  maxLength: maxCharacters
7284
7284
  }),
7285
7285
  onChange: showCharacterCount ? handleChange : props.onChange,
7286
- InputProps: inputProps
7286
+ InputProps: inputProps,
7287
+ InputLabelProps: Object.assign({
7288
+ shrink: true
7289
+ }, props.InputLabelProps)
7287
7290
  }));
7288
7291
  };
7289
7292
  const useStyles$u = tss.withParams().create(({
@@ -12605,6 +12608,7 @@ function getMatchingTagOptions(availableOptions, query, createOption) {
12605
12608
  const VentionTagsInput = ({
12606
12609
  value,
12607
12610
  onChange,
12611
+ onQueryChange,
12608
12612
  suggestions: _suggestions = EMPTY_TAGS,
12609
12613
  label,
12610
12614
  placeholder: _placeholder = "Type or select tags",
@@ -12620,6 +12624,7 @@ const VentionTagsInput = ({
12620
12624
  inputDataTestId
12621
12625
  }) => {
12622
12626
  const [inputValue, setInputValue] = useState("");
12627
+ const reportedQuery = useRef("");
12623
12628
  const theme = useTheme();
12624
12629
  const {
12625
12630
  classes
@@ -12630,39 +12635,43 @@ const VentionTagsInput = ({
12630
12635
  const options = useMemo(() => collectNormalizedTags(selectedTags, collectNormalizedTags(_suggestions, [])), [selectedTags, _suggestions]);
12631
12636
  const query = normalizeTag(inputValue);
12632
12637
  const createOption = query.length > 0 && !options.includes(query) ? query : null;
12638
+ function updateInputValue(nextInputValue) {
12639
+ setInputValue(nextInputValue);
12640
+ const nextQuery = normalizeTag(nextInputValue);
12641
+ if (nextQuery !== reportedQuery.current) {
12642
+ reportedQuery.current = nextQuery;
12643
+ onQueryChange === null || onQueryChange === void 0 ? void 0 : onQueryChange(nextQuery);
12644
+ }
12645
+ }
12633
12646
  function filterTagOptions(availableOptions) {
12634
12647
  return getMatchingTagOptions(availableOptions, query, createOption);
12635
12648
  }
12636
12649
  function groupOptionsBySuggestionsTitle() {
12637
12650
  return _suggestionsTitle;
12638
12651
  }
12639
- function handleChange(_event, newValue) {
12652
+ function handleChange(_event, newValue, reason) {
12640
12653
  const nextTags = collectNormalizedTags(newValue, []);
12641
12654
  onChange(nextTags);
12642
- if (nextTags[nextTags.length - 1] === createOption) {
12643
- setInputValue("");
12655
+ if (reason === "clear" || nextTags[nextTags.length - 1] === createOption) {
12656
+ updateInputValue("");
12644
12657
  }
12645
12658
  }
12646
12659
  function handleBlur() {
12647
- setInputValue("");
12660
+ updateInputValue("");
12648
12661
  }
12649
12662
  function handleInputChange(_event, newInputValue, reason) {
12650
- if (reason === "clear") {
12651
- setInputValue("");
12652
- return;
12653
- }
12654
12663
  if (reason !== "input") {
12655
12664
  return;
12656
12665
  }
12657
12666
  if (!newInputValue.includes(",")) {
12658
- setInputValue(toDisplayedInputValue(newInputValue));
12667
+ updateInputValue(toDisplayedInputValue(newInputValue));
12659
12668
  return;
12660
12669
  }
12661
12670
  const committed = splitTagsAtLastComma(newInputValue, selectedTags);
12662
- setInputValue(committed.inputValue);
12663
12671
  if (committed.tags.length > selectedTags.length) {
12664
12672
  onChange(committed.tags);
12665
12673
  }
12674
+ updateInputValue(committed.inputValue);
12666
12675
  }
12667
12676
  function renderTagPills(tags, getTagProps) {
12668
12677
  const pills = [];
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@vention/machine-ui",
3
- "version": "5.18.1",
3
+ "version": "5.18.3",
4
4
  "repository": {
5
5
  "type": "git",
6
6
  "url": "https://github.com/VentionCo/machine-cloud.git"
@@ -3,6 +3,7 @@ export type { VentionTagsInputSizes };
3
3
  export interface VentionTagsInputProps {
4
4
  value: string[];
5
5
  onChange: (tags: string[]) => void;
6
+ onQueryChange?: (query: string) => void;
6
7
  suggestions?: readonly string[];
7
8
  label?: string;
8
9
  placeholder?: 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;