@rufous/ui 0.2.85 → 0.2.86

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/main.cjs CHANGED
@@ -2079,17 +2079,17 @@ function AutocompleteInner(props, _ref) {
2079
2079
  setInputStr(v != null ? getOptionLabel(v) : "");
2080
2080
  }
2081
2081
  }, [value, multiple, getOptionLabel, controlledInput]);
2082
- const selectOption = (opt) => {
2082
+ const selectOption = (opt, event) => {
2083
2083
  if (getOptionDisabled?.(opt)) return;
2084
2084
  if (multiple) {
2085
2085
  const already = isSelected(opt);
2086
2086
  const next = already ? selectedValues.filter((v) => !isEqual(v, opt)) : [...selectedValues, opt];
2087
- onChange?.(next);
2087
+ onChange?.(event, next, already ? "removeOption" : "selectOption");
2088
2088
  setInputStr("");
2089
2089
  onInputChange?.("");
2090
2090
  inputRef.current?.focus();
2091
2091
  } else {
2092
- onChange?.(opt);
2092
+ onChange?.(event, opt, "selectOption");
2093
2093
  setInputStr(getOptionLabel(opt));
2094
2094
  onInputChange?.(getOptionLabel(opt));
2095
2095
  closePopup(true);
@@ -2098,7 +2098,7 @@ function AutocompleteInner(props, _ref) {
2098
2098
  };
2099
2099
  const clearAll = (e) => {
2100
2100
  e.stopPropagation();
2101
- onChange?.(multiple ? [] : null);
2101
+ onChange?.(e, multiple ? [] : null, "clear");
2102
2102
  setInputStr("");
2103
2103
  onInputChange?.("");
2104
2104
  inputRef.current?.focus();
@@ -2106,7 +2106,7 @@ function AutocompleteInner(props, _ref) {
2106
2106
  const removeTag = (opt, e) => {
2107
2107
  e.stopPropagation();
2108
2108
  const next = selectedValues.filter((v) => !isEqual(v, opt));
2109
- onChange?.(next);
2109
+ onChange?.(e, next, "removeOption");
2110
2110
  };
2111
2111
  const handleInputChange = (e) => {
2112
2112
  const v = e.target.value;
@@ -2144,9 +2144,9 @@ function AutocompleteInner(props, _ref) {
2144
2144
  return;
2145
2145
  }
2146
2146
  if (focusedIdx >= 0 && focusedIdx < selectableOptions.length) {
2147
- selectOption(selectableOptions[focusedIdx].option);
2147
+ selectOption(selectableOptions[focusedIdx].option, e);
2148
2148
  } else if (freeSolo && activeInput) {
2149
- onChange?.(activeInput);
2149
+ onChange?.(e, activeInput, "freeSolo");
2150
2150
  if (!multiple) closePopup();
2151
2151
  }
2152
2152
  } else if (e.key === "Escape") {
@@ -2309,7 +2309,7 @@ function AutocompleteInner(props, _ref) {
2309
2309
  onMouseEnter: () => setFocusedIdx(flatIdx),
2310
2310
  onMouseLeave: () => setFocusedIdx(-1),
2311
2311
  onMouseDown: (e) => e.preventDefault(),
2312
- onClick: () => selectOption(option)
2312
+ onClick: (e) => selectOption(option, e)
2313
2313
  },
2314
2314
  renderOption ? renderOption(option, { selected, focused, index: flatIdx }) : /* @__PURE__ */ import_react18.default.createElement("span", { style: { flex: 1, overflow: "hidden", textOverflow: "ellipsis", whiteSpace: "nowrap" } }, label2),
2315
2315
  !renderOption && /* @__PURE__ */ import_react18.default.createElement("span", { className: "rf-autocomplete__option-check" }, /* @__PURE__ */ import_react18.default.createElement(CheckIcon, null))
@@ -2537,7 +2537,7 @@ var AddressLookup = ({
2537
2537
  {
2538
2538
  options: countries.map((c) => c.name),
2539
2539
  value: value.country || null,
2540
- onChange: (v) => handleCountryChange(v || ""),
2540
+ onChange: (_e, v) => handleCountryChange(v || ""),
2541
2541
  label: "Country",
2542
2542
  fullWidth: true,
2543
2543
  required,
@@ -2548,7 +2548,7 @@ var AddressLookup = ({
2548
2548
  {
2549
2549
  options: states.map((s2) => s2.name),
2550
2550
  value: value.state || null,
2551
- onChange: (v) => handleStateChange(v || ""),
2551
+ onChange: (_e, v) => handleStateChange(v || ""),
2552
2552
  label: "State",
2553
2553
  fullWidth: true,
2554
2554
  required,
@@ -2559,7 +2559,7 @@ var AddressLookup = ({
2559
2559
  {
2560
2560
  options: cities.map((c) => c.name),
2561
2561
  value: value.city || null,
2562
- onChange: (v) => handleChange("city", v || ""),
2562
+ onChange: (_e, v) => handleChange("city", v || ""),
2563
2563
  label: "City",
2564
2564
  fullWidth: true,
2565
2565
  required,
package/dist/main.d.cts CHANGED
@@ -674,7 +674,7 @@ interface AutocompleteProps<T = string> {
674
674
  /** Controlled value — T for single, T[] for multiple, null to clear */
675
675
  value?: T | T[] | null;
676
676
  /** Called when the value changes */
677
- onChange?: (value: T | T[] | null) => void;
677
+ onChange?: (event: React__default.SyntheticEvent, value: T | T[] | null, reason: 'selectOption' | 'removeOption' | 'clear' | 'freeSolo') => void;
678
678
  /** Controlled text in the input */
679
679
  inputValue?: string;
680
680
  /** Called on every keystroke */
package/dist/main.d.ts CHANGED
@@ -674,7 +674,7 @@ interface AutocompleteProps<T = string> {
674
674
  /** Controlled value — T for single, T[] for multiple, null to clear */
675
675
  value?: T | T[] | null;
676
676
  /** Called when the value changes */
677
- onChange?: (value: T | T[] | null) => void;
677
+ onChange?: (event: React__default.SyntheticEvent, value: T | T[] | null, reason: 'selectOption' | 'removeOption' | 'clear' | 'freeSolo') => void;
678
678
  /** Controlled text in the input */
679
679
  inputValue?: string;
680
680
  /** Called on every keystroke */
package/dist/main.js CHANGED
@@ -1918,17 +1918,17 @@ function AutocompleteInner(props, _ref) {
1918
1918
  setInputStr(v != null ? getOptionLabel(v) : "");
1919
1919
  }
1920
1920
  }, [value, multiple, getOptionLabel, controlledInput]);
1921
- const selectOption = (opt) => {
1921
+ const selectOption = (opt, event) => {
1922
1922
  if (getOptionDisabled?.(opt)) return;
1923
1923
  if (multiple) {
1924
1924
  const already = isSelected(opt);
1925
1925
  const next = already ? selectedValues.filter((v) => !isEqual(v, opt)) : [...selectedValues, opt];
1926
- onChange?.(next);
1926
+ onChange?.(event, next, already ? "removeOption" : "selectOption");
1927
1927
  setInputStr("");
1928
1928
  onInputChange?.("");
1929
1929
  inputRef.current?.focus();
1930
1930
  } else {
1931
- onChange?.(opt);
1931
+ onChange?.(event, opt, "selectOption");
1932
1932
  setInputStr(getOptionLabel(opt));
1933
1933
  onInputChange?.(getOptionLabel(opt));
1934
1934
  closePopup(true);
@@ -1937,7 +1937,7 @@ function AutocompleteInner(props, _ref) {
1937
1937
  };
1938
1938
  const clearAll = (e) => {
1939
1939
  e.stopPropagation();
1940
- onChange?.(multiple ? [] : null);
1940
+ onChange?.(e, multiple ? [] : null, "clear");
1941
1941
  setInputStr("");
1942
1942
  onInputChange?.("");
1943
1943
  inputRef.current?.focus();
@@ -1945,7 +1945,7 @@ function AutocompleteInner(props, _ref) {
1945
1945
  const removeTag = (opt, e) => {
1946
1946
  e.stopPropagation();
1947
1947
  const next = selectedValues.filter((v) => !isEqual(v, opt));
1948
- onChange?.(next);
1948
+ onChange?.(e, next, "removeOption");
1949
1949
  };
1950
1950
  const handleInputChange = (e) => {
1951
1951
  const v = e.target.value;
@@ -1983,9 +1983,9 @@ function AutocompleteInner(props, _ref) {
1983
1983
  return;
1984
1984
  }
1985
1985
  if (focusedIdx >= 0 && focusedIdx < selectableOptions.length) {
1986
- selectOption(selectableOptions[focusedIdx].option);
1986
+ selectOption(selectableOptions[focusedIdx].option, e);
1987
1987
  } else if (freeSolo && activeInput) {
1988
- onChange?.(activeInput);
1988
+ onChange?.(e, activeInput, "freeSolo");
1989
1989
  if (!multiple) closePopup();
1990
1990
  }
1991
1991
  } else if (e.key === "Escape") {
@@ -2148,7 +2148,7 @@ function AutocompleteInner(props, _ref) {
2148
2148
  onMouseEnter: () => setFocusedIdx(flatIdx),
2149
2149
  onMouseLeave: () => setFocusedIdx(-1),
2150
2150
  onMouseDown: (e) => e.preventDefault(),
2151
- onClick: () => selectOption(option)
2151
+ onClick: (e) => selectOption(option, e)
2152
2152
  },
2153
2153
  renderOption ? renderOption(option, { selected, focused, index: flatIdx }) : /* @__PURE__ */ React69.createElement("span", { style: { flex: 1, overflow: "hidden", textOverflow: "ellipsis", whiteSpace: "nowrap" } }, label2),
2154
2154
  !renderOption && /* @__PURE__ */ React69.createElement("span", { className: "rf-autocomplete__option-check" }, /* @__PURE__ */ React69.createElement(CheckIcon, null))
@@ -2376,7 +2376,7 @@ var AddressLookup = ({
2376
2376
  {
2377
2377
  options: countries.map((c) => c.name),
2378
2378
  value: value.country || null,
2379
- onChange: (v) => handleCountryChange(v || ""),
2379
+ onChange: (_e, v) => handleCountryChange(v || ""),
2380
2380
  label: "Country",
2381
2381
  fullWidth: true,
2382
2382
  required,
@@ -2387,7 +2387,7 @@ var AddressLookup = ({
2387
2387
  {
2388
2388
  options: states.map((s2) => s2.name),
2389
2389
  value: value.state || null,
2390
- onChange: (v) => handleStateChange(v || ""),
2390
+ onChange: (_e, v) => handleStateChange(v || ""),
2391
2391
  label: "State",
2392
2392
  fullWidth: true,
2393
2393
  required,
@@ -2398,7 +2398,7 @@ var AddressLookup = ({
2398
2398
  {
2399
2399
  options: cities.map((c) => c.name),
2400
2400
  value: value.city || null,
2401
- onChange: (v) => handleChange("city", v || ""),
2401
+ onChange: (_e, v) => handleChange("city", v || ""),
2402
2402
  label: "City",
2403
2403
  fullWidth: true,
2404
2404
  required,
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@rufous/ui",
3
3
  "private": false,
4
- "version": "0.2.85",
4
+ "version": "0.2.86",
5
5
  "type": "module",
6
6
  "description": "Experimental: A lightweight React UI component library (Beta)",
7
7
  "style": "./dist/main.css",