@pythia-software/query-table-ui 0.4.0 → 0.4.1

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/index.d.ts CHANGED
@@ -183,9 +183,10 @@ interface FilterValuePresentation {
183
183
  render?: (field: string, value: string) => ReactNode;
184
184
  }
185
185
  declare const FilterValueProvider: react.Provider<FilterValuePresentation>;
186
- declare function PresentedFilterValue({ field, value }: {
186
+ declare function PresentedFilterValue({ field, value, label }: {
187
187
  field: string;
188
188
  value: string;
189
+ label?: string;
189
190
  }): react_jsx_runtime.JSX.Element;
190
191
 
191
192
  export { type CellContext, CellMenu, type CellMenuProps, type CellRenderer, DataTable, type DataTableProps, FieldPicker, type FieldPickerProps, type FilterValuePresentation, FilterValueProvider, type MenuClassNames, MetricsPanel, type MetricsPanelProps, PresentedFilterValue, QueryBuilder, type QueryBuilderClassNames, type QueryBuilderProps, type RenderRegistry, SavedQueriesModal, type SavedQueriesModalProps, SelectColumnEditor, type SelectColumnEditorProps, SelectionToolbar, type SelectionToolbarProps, type TableClassNames, defaultRenderers, resolveRenderer, safeLinkHref };
package/dist/index.js CHANGED
@@ -151,9 +151,9 @@ var FilterValueProvider = Context.Provider;
151
151
  function useFilterValuePresentation() {
152
152
  return useContext(Context);
153
153
  }
154
- function PresentedFilterValue({ field, value }) {
154
+ function PresentedFilterValue({ field, value, label }) {
155
155
  const presentation = useContext(Context);
156
- return /* @__PURE__ */ jsx(Fragment, { children: presentation.render?.(field, value) ?? presentation.label?.(field, value) ?? value });
156
+ return /* @__PURE__ */ jsx(Fragment, { children: presentation.render?.(field, value) ?? presentation.label?.(field, value) ?? label ?? value });
157
157
  }
158
158
  function PresentedValueInput({ field, value, options, onChange }) {
159
159
  const presentation = useContext(Context);
@@ -162,7 +162,7 @@ function PresentedValueInput({ field, value, options, onChange }) {
162
162
  const visible = choices.filter((option) => `${option.value} ${option.label}`.toLowerCase().includes(search.toLowerCase()));
163
163
  return /* @__PURE__ */ jsxs("span", { style: { position: "relative" }, children: [
164
164
  /* @__PURE__ */ jsxs("button", { type: "button", "aria-label": `Edit ${field} filter value`, "aria-expanded": open, onClick: () => setOpen(!open), children: [
165
- /* @__PURE__ */ jsx(PresentedFilterValue, { field, value }),
165
+ /* @__PURE__ */ jsx(PresentedFilterValue, { field, value, label: choices.find((option) => option.value === value)?.label ?? value }),
166
166
  !value && "Choose value"
167
167
  ] }),
168
168
  open && /* @__PURE__ */ jsxs("span", { style: { position: "absolute", top: "100%", left: 0, zIndex: 30, background: "var(--qt-bg, #fff)", padding: 8, minWidth: 220, maxHeight: 300, overflowY: "auto" }, onKeyDown: (e) => {
@@ -171,7 +171,7 @@ function PresentedValueInput({ field, value, options, onChange }) {
171
171
  /* @__PURE__ */ jsx("input", { autoFocus: true, "aria-label": `Search ${field} values`, value: search, onChange: (e) => setSearch(e.target.value), onKeyDown: (e) => {
172
172
  if (e.key === "Enter" && search) {
173
173
  e.preventDefault();
174
- onChange(search);
174
+ onChange(visible[0]?.value ?? search);
175
175
  setOpen(false);
176
176
  }
177
177
  } }),
@@ -179,7 +179,7 @@ function PresentedValueInput({ field, value, options, onChange }) {
179
179
  onChange(option.value);
180
180
  setOpen(false);
181
181
  }, children: [
182
- /* @__PURE__ */ jsx(PresentedFilterValue, { field, value: option.value }),
182
+ /* @__PURE__ */ jsx(PresentedFilterValue, { field, value: option.value, label: option.label }),
183
183
  option.label !== option.value && /* @__PURE__ */ jsxs("small", { children: [
184
184
  " ",
185
185
  option.value