elastic-input 0.3.2 → 0.3.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.
@@ -1180,8 +1180,7 @@ const DEFAULT_COLORS = {
1180
1180
  regexAlternation: "#8250df",
1181
1181
  regexText: "#0a3069",
1182
1182
  matchedParenBg: "#fff3cd",
1183
- warning: "#d4a72c",
1184
- historyDescription: "#656d76"
1183
+ warning: "#d4a72c"
1185
1184
  };
1186
1185
  const DARK_COLORS = {
1187
1186
  fieldName: "#79c0ff",
@@ -1209,8 +1208,7 @@ const DARK_COLORS = {
1209
1208
  regexAlternation: "#d2a8ff",
1210
1209
  regexText: "#a5d6ff",
1211
1210
  matchedParenBg: "#3d3222",
1212
- warning: "#e3b341",
1213
- historyDescription: "#484f58"
1211
+ warning: "#e3b341"
1214
1212
  };
1215
1213
  const DEFAULT_STYLES = {
1216
1214
  fontFamily: "'SF Mono', 'Fira Code', 'Fira Mono', Menlo, Consolas, monospace",
@@ -2801,7 +2799,7 @@ function AutocompleteDropdown({
2801
2799
  whiteSpace: "normal",
2802
2800
  wordBreak: "break-all",
2803
2801
  width: "100%"
2804
- } }, highlightMatch(suggestion.label, suggestion.matchPartial, isSelected)), /* @__PURE__ */ React.createElement("span", { style: { display: "flex", alignItems: "center", gap: "8px", width: "100%" } }, suggestion.description != null && /* @__PURE__ */ React.createElement("span", { className: "ei-dropdown-item-desc", style: { ...getDropdownItemDescStyle(), flex: 1, color: mergedColors.historyDescription, opacity: 1 } }, suggestion.description), /* @__PURE__ */ React.createElement("span", { className: "ei-dropdown-item-type", style: { ...getDropdownItemTypeStyle(isSelected, mergedStyles), marginLeft: "auto" } }, "history")))
2802
+ } }, highlightMatch(suggestion.label, suggestion.matchPartial, isSelected)), /* @__PURE__ */ React.createElement("span", { style: { display: "flex", alignItems: "center", gap: "8px", width: "100%" } }, suggestion.description != null && /* @__PURE__ */ React.createElement("span", { className: "ei-dropdown-item-desc", style: { ...getDropdownItemDescStyle(), flex: 1 } }, suggestion.description), /* @__PURE__ */ React.createElement("span", { className: "ei-dropdown-item-type", style: { ...getDropdownItemTypeStyle(isSelected, mergedStyles), marginLeft: "auto" } }, "history")))
2805
2803
  );
2806
2804
  }
2807
2805
  if (suggestion.type === "savedSearch" && renderSavedSearchItem && suggestion.sourceData) {
@@ -4691,6 +4689,12 @@ function ElasticInput(props) {
4691
4689
  case "Enter":
4692
4690
  if (s.selectedSuggestionIndex >= 0) {
4693
4691
  const selected = s.suggestions[s.selectedSuggestionIndex];
4692
+ if (selected.type === "loading" || selected.type === "error") {
4693
+ e.preventDefault();
4694
+ closeDropdown();
4695
+ if (onSearch) onSearch(currentValueRef.current, s.ast);
4696
+ return;
4697
+ }
4694
4698
  if (selected.type === "hint" && selected.text !== "#" && selected.text !== "!") {
4695
4699
  e.preventDefault();
4696
4700
  closeDropdown();
@@ -4713,7 +4717,10 @@ function ElasticInput(props) {
4713
4717
  acceptSuggestion(selected, "Enter");
4714
4718
  return;
4715
4719
  }
4716
- break;
4720
+ e.preventDefault();
4721
+ closeDropdown();
4722
+ if (onSearch) onSearch(currentValueRef.current, s.ast);
4723
+ return;
4717
4724
  case "Tab": {
4718
4725
  if (onTabProp) {
4719
4726
  e.preventDefault();
package/dist/types.d.ts CHANGED
@@ -140,8 +140,6 @@ export interface ColorConfig {
140
140
  matchedParenBg?: string;
141
141
  /** Warning-severity squiggly underlines (e.g. ambiguous precedence). */
142
142
  warning?: string;
143
- /** Color for history item descriptions. Set to `'transparent'` to hide. */
144
- historyDescription?: string;
145
143
  }
146
144
  /**
147
145
  * Structural and layout style overrides for the input and dropdown.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "elastic-input",
3
- "version": "0.3.2",
3
+ "version": "0.3.3",
4
4
  "description": "Syntax-aware smart autocomplete input for Elastic query syntax",
5
5
  "license": "MIT",
6
6
  "repository": {