elastic-input 0.3.6 → 0.3.7
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.
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { Suggestion } from '../autocomplete/suggestionTypes';
|
|
2
|
-
import { ColorConfig, StyleConfig, HistoryEntry, SavedSearch } from '../types';
|
|
2
|
+
import { ColorConfig, StyleConfig, HistoryEntry, SavedSearch, SuggestionItem } from '../types';
|
|
3
3
|
import { CursorContext } from '../parser/Parser';
|
|
4
4
|
import * as React from 'react';
|
|
5
5
|
interface AutocompleteDropdownProps {
|
|
@@ -21,6 +21,8 @@ interface AutocompleteDropdownProps {
|
|
|
21
21
|
cursorContext?: CursorContext | null;
|
|
22
22
|
/** Ref callback to expose the dropdown list element for page-size calculations. */
|
|
23
23
|
listRefCallback?: (el: HTMLDivElement | null) => void;
|
|
24
|
+
/** Controls the type badge in dropdown items. false=hide, true=default, callback=custom. */
|
|
25
|
+
renderType?: boolean | ((type: string, suggestion: SuggestionItem) => React.ReactNode | null | undefined);
|
|
24
26
|
/** Custom class names for dropdown elements. */
|
|
25
27
|
classNames?: {
|
|
26
28
|
dropdown?: string;
|
|
@@ -28,5 +30,5 @@ interface AutocompleteDropdownProps {
|
|
|
28
30
|
dropdownItem?: string;
|
|
29
31
|
};
|
|
30
32
|
}
|
|
31
|
-
export declare function AutocompleteDropdown({ suggestions, selectedIndex, onSelect, position, colors, styles, visible, fixedWidth, renderHistoryItem, renderSavedSearchItem, renderDropdownHeader, cursorContext, listRefCallback, classNames, }: AutocompleteDropdownProps): React.ReactPortal | null;
|
|
33
|
+
export declare function AutocompleteDropdown({ suggestions, selectedIndex, onSelect, position, colors, styles, visible, fixedWidth, renderHistoryItem, renderSavedSearchItem, renderDropdownHeader, cursorContext, listRefCallback, renderType, classNames, }: AutocompleteDropdownProps): React.ReactPortal | null;
|
|
32
34
|
export {};
|
package/dist/elastic-input.es.js
CHANGED
|
@@ -1217,6 +1217,7 @@ const DARK_COLORS = {
|
|
|
1217
1217
|
const DEFAULT_STYLES = {
|
|
1218
1218
|
fontFamily: "'SF Mono', 'Fira Code', 'Fira Mono', Menlo, Consolas, monospace",
|
|
1219
1219
|
fontSize: "14px",
|
|
1220
|
+
lineHeight: "1.5",
|
|
1220
1221
|
inputMinHeight: "40px",
|
|
1221
1222
|
inputPadding: "8px 12px",
|
|
1222
1223
|
inputBorderWidth: "2px",
|
|
@@ -2127,7 +2128,7 @@ function getEditableStyle(colors, styles) {
|
|
|
2127
2128
|
outline: "none",
|
|
2128
2129
|
fontSize: styles.fontSize,
|
|
2129
2130
|
fontFamily: styles.fontFamily,
|
|
2130
|
-
lineHeight:
|
|
2131
|
+
lineHeight: styles.lineHeight,
|
|
2131
2132
|
backgroundColor: colors.background,
|
|
2132
2133
|
color: colors.text,
|
|
2133
2134
|
caretColor: colors.cursor,
|
|
@@ -2155,7 +2156,7 @@ function getPlaceholderStyle(colors, styles) {
|
|
|
2155
2156
|
pointerEvents: "none",
|
|
2156
2157
|
fontSize: styles.fontSize,
|
|
2157
2158
|
fontFamily: styles.fontFamily,
|
|
2158
|
-
lineHeight:
|
|
2159
|
+
lineHeight: styles.lineHeight,
|
|
2159
2160
|
userSelect: "none"
|
|
2160
2161
|
};
|
|
2161
2162
|
}
|
|
@@ -2752,6 +2753,7 @@ function AutocompleteDropdown({
|
|
|
2752
2753
|
renderDropdownHeader,
|
|
2753
2754
|
cursorContext,
|
|
2754
2755
|
listRefCallback,
|
|
2756
|
+
renderType,
|
|
2755
2757
|
classNames
|
|
2756
2758
|
}) {
|
|
2757
2759
|
const portalRef = React.useRef(null);
|
|
@@ -2902,7 +2904,10 @@ function AutocompleteDropdown({
|
|
|
2902
2904
|
},
|
|
2903
2905
|
/* @__PURE__ */ React.createElement("span", { className: "ei-dropdown-item-label", style: getDropdownItemLabelStyle() }, highlightMatch(suggestion.label, suggestion.matchPartial, isSelected)),
|
|
2904
2906
|
suggestion.description && /* @__PURE__ */ React.createElement("span", { className: "ei-dropdown-item-desc", style: getDropdownItemDescStyle() }, suggestion.description),
|
|
2905
|
-
suggestion.type && suggestion.type !== "hint" &&
|
|
2907
|
+
renderType !== false && suggestion.type && suggestion.type !== "hint" && (() => {
|
|
2908
|
+
const content2 = typeof renderType === "function" ? renderType(suggestion.type, { text: suggestion.text, label: suggestion.label, description: suggestion.description, type: suggestion.type }) : suggestion.type;
|
|
2909
|
+
return content2 != null ? /* @__PURE__ */ React.createElement("span", { className: "ei-dropdown-item-type", style: getDropdownItemTypeStyle(isSelected, mergedStyles) }, content2) : null;
|
|
2910
|
+
})()
|
|
2906
2911
|
);
|
|
2907
2912
|
}));
|
|
2908
2913
|
return ReactDOM.createPortal(content, portalRef.current);
|
|
@@ -3961,6 +3966,7 @@ function ElasticInput(props) {
|
|
|
3961
3966
|
const renderSavedSearchItem = dropdownConfig == null ? void 0 : dropdownConfig.renderSavedSearchItem;
|
|
3962
3967
|
const renderDropdownHeader = dropdownConfig == null ? void 0 : dropdownConfig.renderHeader;
|
|
3963
3968
|
const renderNoResults = dropdownConfig == null ? void 0 : dropdownConfig.renderNoResults;
|
|
3969
|
+
const renderType = dropdownConfig == null ? void 0 : dropdownConfig.renderType;
|
|
3964
3970
|
const autoSelect = (dropdownConfig == null ? void 0 : dropdownConfig.autoSelect) ?? false;
|
|
3965
3971
|
const homeEndKeys = (dropdownConfig == null ? void 0 : dropdownConfig.homeEndKeys) ?? false;
|
|
3966
3972
|
const multiline = (featuresConfig == null ? void 0 : featuresConfig.multiline) !== false;
|
|
@@ -5271,6 +5277,7 @@ function ElasticInput(props) {
|
|
|
5271
5277
|
listRefCallback: (el) => {
|
|
5272
5278
|
dropdownListRef.current = el;
|
|
5273
5279
|
},
|
|
5280
|
+
renderType,
|
|
5274
5281
|
classNames: classNames ? { dropdown: classNames.dropdown, dropdownHeader: classNames.dropdownHeader, dropdownItem: classNames.dropdownItem } : void 0
|
|
5275
5282
|
}
|
|
5276
5283
|
), showDatePicker && dropdownPosition ? /* @__PURE__ */ React.createElement(
|
package/dist/types.d.ts
CHANGED
|
@@ -158,6 +158,8 @@ export interface StyleConfig {
|
|
|
158
158
|
fontFamily?: string;
|
|
159
159
|
/** Base font size for the input. */
|
|
160
160
|
fontSize?: string;
|
|
161
|
+
/** Line height for the input text and placeholder. @default '1.5' */
|
|
162
|
+
lineHeight?: string;
|
|
161
163
|
/** Minimum height of the input element. */
|
|
162
164
|
inputMinHeight?: string;
|
|
163
165
|
/** Padding inside the input element. */
|
|
@@ -280,6 +282,12 @@ export interface DropdownConfig {
|
|
|
280
282
|
cursorContext: CursorContext;
|
|
281
283
|
partial: string;
|
|
282
284
|
}) => React.ReactNode | null | undefined;
|
|
285
|
+
/** Controls the type badge shown in dropdown items.
|
|
286
|
+
* - `false` — hide the badge entirely
|
|
287
|
+
* - `true` (default) — show the raw `suggestion.type` string
|
|
288
|
+
* - callback `(type, suggestion) => ReactNode` — custom render per item; return null to hide
|
|
289
|
+
*/
|
|
290
|
+
renderType?: boolean | ((type: string, suggestion: SuggestionItem) => React.ReactNode | null | undefined);
|
|
283
291
|
}
|
|
284
292
|
/**
|
|
285
293
|
* Feature toggles for optional editing behaviors. All default to false except `multiline`.
|