UNPKG

synapse-react-client

Version:

[![npm version](https://badge.fury.io/js/synapse-react-client.svg)](https://badge.fury.io/js/synapse-react-client) [![code style: prettier](https://img.shields.io/badge/code_style-prettier-ff69b4.svg?style=flat-square)](https://github.com/prettier/prettie

129 lines (128 loc) 3.51 kB
import { jsxs as d, jsx as a, Fragment as D } from "react/jsx-runtime"; import { FRIENDLY_VALUE_NOT_SET as I, VALUE_NOT_SET as k } from "../../../utils/SynapseConstants.js"; import { Collapse as y, RadioGroup as C, FormControlLabel as x, Radio as G } from "@mui/material"; import R from "dayjs"; import { useState as T } from "react"; import { Range as b } from "../Range.js"; import O from "../RangeSlider/RangeSlider.js"; import { FacetFilterHeader as V } from "./FacetFilterHeader.js"; var v = /* @__PURE__ */ ((e) => (e.NOT_SET = "org.sagebionetworks.UNDEFINED_NULL_NOTSET", e.RANGE = "RANGE", e.ANY = "", e))(v || {}); const M = [ { label: I, value: "org.sagebionetworks.UNDEFINED_NULL_NOTSET" /* NOT_SET */ }, { label: "Any", value: "" /* ANY */ }, { label: "Range", value: "RANGE" /* RANGE */ } ], w = (e, l) => l ? "" : e === k ? "org.sagebionetworks.UNDEFINED_NULL_NOTSET" : "RANGE"; function P(e) { const { label: l, facetResult: A, hideCollapsible: S = !1, columnType: t, onAnySelected: _, onNotSetSelected: f, onRangeValueSelected: i } = e, [m, L] = T(!1), { columnMin: r, columnMax: o, selectedMin: s, selectedMax: c } = A, F = !s && !c, p = s || r, E = c || o, g = t === "DOUBLE" ? "number" : "date", U = (n) => { switch (h(n), n) { case "RANGE": break; case "org.sagebionetworks.UNDEFINED_NULL_NOTSET": f(); break; case "": { _(); break; } } }, [u, h] = T( w(p, F) ); return /* @__PURE__ */ d("div", { children: [ /* @__PURE__ */ a( V, { isCollapsed: m, label: l, onClick: (n) => L(n), hideCollapsible: S } ), /* @__PURE__ */ d(y, { in: !m, children: [ /* @__PURE__ */ a( C, { value: u, onChange: (n, N) => U(N), children: M.map(({ value: n, label: N }) => /* @__PURE__ */ a( x, { control: /* @__PURE__ */ a(G, {}), label: N, value: n }, n )) } ), u === "RANGE" && (r === o ? /* @__PURE__ */ a("label", { children: o }) : /* @__PURE__ */ d(D, { children: [ t === "INTEGER" && /* @__PURE__ */ a( O, { domain: [r, o], initialValues: { min: parseInt(p), max: parseInt(E) }, step: 1, onApplyClicked: i, children: ">" }, "RangeSlider" ), t === "DATE" && /* @__PURE__ */ a( b, { initialValues: { // From the backend, selectedMin is a formatted date (like "2021-06-15"), but columnMin is a unix timestamp in millis (like "1624651794856") min: s ?? R(parseInt(r)).toString(), max: c ?? R(parseInt(o)).toString() }, type: g, onApplyClicked: i }, "Range" ), t === "DOUBLE" && /* @__PURE__ */ a( b, { initialValues: { min: parseFloat(p), max: parseFloat(E) }, type: g, onApplyClicked: i }, "Range" ) ] })) ] }) ] }); } export { v as RadioValuesEnum, P as RangeFacetFilterUI, w as getRadioValue, M as options }; //# sourceMappingURL=RangeFacetFilterUI.js.map