react-instantsearch
Version:
⚡ Lightning-fast search for React, by Algolia
32 lines (29 loc) • 1.28 kB
JavaScript
import { createComparisonTableToolComponent } from 'instantsearch-ui-components';
import React, { createElement, Fragment } from 'react';
/**
* Grounded comparison-table tool (prototype).
*
* Renders a v2 `markdownTable` display block whose every cell is hydrated from
* the real `algolia_search_index` hits by objectID — the agent supplies only the
* objectIDs and the attribute keys, never the values. See
* `instantsearch-ui-components` `ComparisonTableTool` for the contract.
*
* Register under the display-results tool key (or a dedicated key) in
* `createDefaultTools` to have comparison answers rendered as a grounded table
* instead of the model-authored markdown table.
*/ function createComparisonTableTool(translations) {
var ComparisonTableUIComponent = createComparisonTableToolComponent({
createElement: createElement,
Fragment: Fragment
});
var ComparisonTableLayoutComponent = function ComparisonTableLayoutComponent(toolProps) {
return /*#__PURE__*/ React.createElement(ComparisonTableUIComponent, {
toolProps: toolProps,
translations: translations
});
};
return {
layoutComponent: ComparisonTableLayoutComponent
};
}
export { createComparisonTableTool };