@seekora-ai/ui-sdk-react 0.2.9 → 0.2.10

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/src/index.js CHANGED
@@ -7113,10 +7113,45 @@ function DropdownPanel({ children, position = 'absolute', top = '100%', left = 0
7113
7113
  return (React.createElement("div", { ref: panelRef, role: "listbox", className: clsx('seekora-suggestions-dropdown-panel', className), style: { ...panelStyle, ...style } }, children));
7114
7114
  }
7115
7115
 
7116
+ /**
7117
+ * Parses suggestion text containing <mark>...</mark> and returns React nodes
7118
+ * with the marked segments rendered as <mark> elements. Safe: inner content
7119
+ * is rendered as text, not HTML.
7120
+ */
7121
+ const defaultMarkStyle = {
7122
+ backgroundColor: 'var(--seekora-highlight-bg, rgba(251, 191, 36, 0.4))',
7123
+ fontWeight: 500,
7124
+ borderRadius: '2px',
7125
+ padding: '0 2px',
7126
+ };
7127
+ /**
7128
+ * Converts a string like "lined <mark>blue</mark>" into React nodes with
7129
+ * the marked part rendered as a <mark> element. When no <mark> tags are
7130
+ * present, returns the string as-is.
7131
+ */
7132
+ function parseHighlightMarkup(text, options = {}) {
7133
+ if (text == null || typeof text !== 'string')
7134
+ return text;
7135
+ const parts = text.split(/(<mark>[\s\S]*?<\/mark>)/g);
7136
+ if (parts.length <= 1)
7137
+ return text;
7138
+ const { markClassName, markStyle } = options;
7139
+ return (React.createElement(React.Fragment, null, parts.map((part, i) => {
7140
+ const m = part.match(/^<mark>([\s\S]*)<\/mark>$/);
7141
+ if (m) {
7142
+ return (React.createElement("mark", { key: i, className: markClassName, style: { ...defaultMarkStyle, ...markStyle } }, m[1]));
7143
+ }
7144
+ return part;
7145
+ })));
7146
+ }
7147
+
7116
7148
  /**
7117
7149
  * SuggestionItem – single text suggestion row (primitive)
7118
7150
  *
7119
- * Highlights when isActive; onClick calls context selectSuggestion. Overridable via className/style.
7151
+ * Highlights when isActive; onClick calls context selectSuggestion.
7152
+ * When enableHighlightMarkup is true (default), parses <mark>...</mark> in
7153
+ * suggestion text and renders as highlighted <mark> elements. Overridable via
7154
+ * renderHighlight, className/style.
7120
7155
  */
7121
7156
  const defaultItemStyle = {
7122
7157
  padding: '10px 12px',
@@ -7131,9 +7166,13 @@ const defaultItemStyle = {
7131
7166
  color: 'var(--seekora-text-primary, #111827)',
7132
7167
  transition: 'background-color 120ms ease',
7133
7168
  };
7134
- function SuggestionItem({ suggestion, index, isActive, onSelect, className, style, renderHighlight, }) {
7169
+ function SuggestionItem({ suggestion, index, isActive, onSelect, className, style, enableHighlightMarkup = true, highlightMarkupOptions, renderHighlight, }) {
7135
7170
  const displayText = suggestion.highlightedQuery ?? suggestion.query;
7136
- const content = renderHighlight ? renderHighlight(displayText) : displayText;
7171
+ const content = renderHighlight != null
7172
+ ? renderHighlight(displayText)
7173
+ : enableHighlightMarkup
7174
+ ? parseHighlightMarkup(displayText ?? '', highlightMarkupOptions)
7175
+ : (suggestion.query ?? displayText ?? '');
7137
7176
  return (React.createElement("li", { role: "option", "aria-selected": isActive, id: `seekora-suggestion-${index}`, className: clsx('seekora-suggestions-item', isActive && 'seekora-suggestions-item--active', className), style: {
7138
7177
  ...defaultItemStyle,
7139
7178
  ...(isActive ? { backgroundColor: 'var(--seekora-bg-hover, #f3f4f6)' } : {}),
@@ -7164,13 +7203,15 @@ function SuggestionsLoading({ className, style, text = 'Loading...' }) {
7164
7203
  /**
7165
7204
  * SuggestionList – container for text suggestions (primitive)
7166
7205
  *
7167
- * Renders list of SuggestionItem from context; uses activeIndex for highlight. Optional renderItem.
7206
+ * Renders list of SuggestionItem from context; uses activeIndex for highlight.
7207
+ * Optional renderItem. When not using renderItem, enableHighlightMarkup and
7208
+ * highlightMarkupOptions control parsing of <mark>...</mark> in suggestion text.
7168
7209
  */
7169
7210
  const listStyle = {
7170
7211
  margin: 0,
7171
7212
  padding: '4px 0',
7172
7213
  };
7173
- function SuggestionList({ maxItems = 10, className, style, listClassName, renderItem, }) {
7214
+ function SuggestionList({ maxItems = 10, className, style, listClassName, enableHighlightMarkup = true, highlightMarkupOptions, renderItem, }) {
7174
7215
  const { suggestions, activeIndex, loading, selectSuggestion, getAllNavigableItems, } = useSuggestionsContext();
7175
7216
  const items = suggestions.slice(0, maxItems);
7176
7217
  const navigableItems = getAllNavigableItems();
@@ -7189,7 +7230,7 @@ function SuggestionList({ maxItems = 10, className, style, listClassName, render
7189
7230
  if (renderItem) {
7190
7231
  return (React.createElement("li", { key: suggestion.objectID ?? suggestion.query ?? i, role: "option" }, renderItem(suggestion, globalIndex, isActive, onSelect)));
7191
7232
  }
7192
- return (React.createElement(SuggestionItem, { key: suggestion.objectID ?? suggestion.query ?? i, suggestion: suggestion, index: globalIndex, isActive: isActive, onSelect: onSelect }));
7233
+ return (React.createElement(SuggestionItem, { key: suggestion.objectID ?? suggestion.query ?? i, suggestion: suggestion, index: globalIndex, isActive: isActive, onSelect: onSelect, enableHighlightMarkup: enableHighlightMarkup, highlightMarkupOptions: highlightMarkupOptions }));
7193
7234
  }))));
7194
7235
  }
7195
7236
 
@@ -14470,6 +14511,7 @@ exports.mediaQueries = mediaQueries;
14470
14511
  exports.mergeThemes = mergeThemes;
14471
14512
  exports.minimalTheme = minimalTheme;
14472
14513
  exports.minimalThemeVariables = minimalThemeVariables;
14514
+ exports.parseHighlightMarkup = parseHighlightMarkup;
14473
14515
  exports.removeRecentSearch = removeRecentSearch;
14474
14516
  exports.touchTargets = touchTargets;
14475
14517
  exports.updateSuggestionsStyles = updateSuggestionsStyles;