lhcb-ntuple-wizard-test 1.1.14 → 1.2.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.
Files changed (35) hide show
  1. package/dist/components/ConfigDict.js +39 -38
  2. package/dist/components/ConfigList.js +33 -29
  3. package/dist/components/ConfigNode.js +135 -132
  4. package/dist/components/ConfigValue.js +22 -18
  5. package/dist/components/Dataset.js +7 -3
  6. package/dist/components/Decay.js +1 -2
  7. package/dist/components/DecayItem.js +49 -45
  8. package/dist/components/DecayTag.js +10 -7
  9. package/dist/components/DecayTree.js +153 -146
  10. package/dist/components/DecaysList.js +38 -35
  11. package/dist/components/DescriptorsSearch.js +192 -187
  12. package/dist/components/EventTypeBadge.js +9 -6
  13. package/dist/components/ItemSearch.js +15 -10
  14. package/dist/components/LinesTable.js +464 -462
  15. package/dist/components/NtupleWizard.js +32 -27
  16. package/dist/components/ParticleTag.js +10 -7
  17. package/dist/components/SearchItem.js +34 -31
  18. package/dist/components/SelectParticle.js +14 -10
  19. package/dist/components/SelectTag.js +10 -9
  20. package/dist/components/SelectTool.js +10 -9
  21. package/dist/components/SelectVariables.js +24 -22
  22. package/dist/components/StrippingBadge.js +10 -7
  23. package/dist/components/StrippingLine.js +8 -6
  24. package/dist/components/TupleTool.js +4 -3
  25. package/dist/components/VariablesSearch.js +15 -10
  26. package/dist/components/loki/LokiDict.js +184 -0
  27. package/dist/components/loki/LokiEditor.js +199 -0
  28. package/dist/components/loki/LokiForm.js +116 -0
  29. package/dist/components/semantic.js +97 -0
  30. package/dist/components/semform.js +184 -0
  31. package/dist/components/worker.js +196 -0
  32. package/dist/config.json +1 -1
  33. package/dist/contexts/MetadataContext.js +8 -7
  34. package/dist/lib/DTTConfig.js +8 -8
  35. package/package.json +25 -2
@@ -12,7 +12,9 @@ var _Decay = _interopRequireDefault(require("./Decay"));
12
12
  var _DecayTag = _interopRequireDefault(require("./DecayTag"));
13
13
  var _jsxRuntime = require("react/jsx-runtime");
14
14
  function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
15
- /*****************************************************************************\
15
+ function _defineProperty(e, r, t) { return (r = _toPropertyKey(r)) in e ? Object.defineProperty(e, r, { value: t, enumerable: !0, configurable: !0, writable: !0 }) : e[r] = t, e; }
16
+ function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == typeof i ? i : i + ""; }
17
+ function _toPrimitive(t, r) { if ("object" != typeof t || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != typeof i) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); } /*****************************************************************************\
16
18
  * (c) Copyright 2021 CERN for the benefit of the LHCb Collaboration *
17
19
  * *
18
20
  * This software is distributed under the terms of the GNU General Public *
@@ -22,53 +24,55 @@ function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e
22
24
  * granted to it by virtue of its status as an Intergovernmental Organization *
23
25
  * or submit itself to any jurisdiction. *
24
26
  \*****************************************************************************/
25
-
26
27
  class DecayItem extends _react.default.Component {
27
- state = {
28
- selected: this.props.selected,
29
- decay: this.props.decay
30
- };
31
- sendData = () => {
32
- this.props.parentCallback(this.state);
33
- };
34
- select = () => {
35
- this.setState({
36
- selected: this.state.selected ? false : true
28
+ constructor() {
29
+ super(...arguments);
30
+ _defineProperty(this, "state", {
31
+ selected: this.props.selected,
32
+ decay: this.props.decay
33
+ });
34
+ _defineProperty(this, "sendData", () => {
35
+ this.props.parentCallback(this.state);
37
36
  });
38
- this.sendData();
39
- };
40
- getExtraInfo = () => {
41
- const nLines = Object.keys(this.props.decay.lines).length;
42
- const nTags = this.props.decay.tags.length;
43
- const tagInfo = this.props.decay.tags.map(tag => /*#__PURE__*/(0, _jsxRuntime.jsx)(_DecayTag.default, {
44
- tag: tag
45
- }, tag));
46
- const strippingInfo = /*#__PURE__*/(0, _jsxRuntime.jsxs)(_jsxRuntime.Fragment, {
47
- children: [/*#__PURE__*/(0, _jsxRuntime.jsx)(_reactBootstrap.OverlayTrigger, {
48
- placement: "right",
49
- overlay: /*#__PURE__*/(0, _jsxRuntime.jsxs)(_reactBootstrap.Popover, {
50
- children: [/*#__PURE__*/(0, _jsxRuntime.jsx)(_reactBootstrap.Popover.Header, {
51
- children: "Stripping lines"
52
- }), /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactBootstrap.Popover.Body, {
53
- children: Object.keys(this.props.decay.lines).map(line => {
54
- const [stream, name] = line.split("/");
55
- return /*#__PURE__*/(0, _jsxRuntime.jsx)(_StrippingLine.default, {
56
- line: name,
57
- stream: stream,
58
- versions: this.props.decay.lines[line]
59
- }, line);
60
- })
61
- })]
62
- }),
63
- children: /*#__PURE__*/(0, _jsxRuntime.jsxs)(_reactBootstrap.Badge, {
64
- pill: true,
65
- bg: this.state.selected ? "primary" : "secondary",
66
- children: [nLines, " Stripping line", nLines === 1 ? "" : "s"]
67
- })
68
- }), nTags > 0 ? tagInfo : ""]
37
+ _defineProperty(this, "select", () => {
38
+ this.setState({
39
+ selected: this.state.selected ? false : true
40
+ });
41
+ this.sendData();
69
42
  });
70
- return strippingInfo;
71
- };
43
+ _defineProperty(this, "getExtraInfo", () => {
44
+ const nLines = Object.keys(this.props.decay.lines).length;
45
+ const nTags = this.props.decay.tags.length;
46
+ const tagInfo = this.props.decay.tags.map(tag => /*#__PURE__*/(0, _jsxRuntime.jsx)(_DecayTag.default, {
47
+ tag: tag
48
+ }, tag));
49
+ const strippingInfo = /*#__PURE__*/(0, _jsxRuntime.jsxs)(_jsxRuntime.Fragment, {
50
+ children: [/*#__PURE__*/(0, _jsxRuntime.jsx)(_reactBootstrap.OverlayTrigger, {
51
+ placement: "right",
52
+ overlay: /*#__PURE__*/(0, _jsxRuntime.jsxs)(_reactBootstrap.Popover, {
53
+ children: [/*#__PURE__*/(0, _jsxRuntime.jsx)(_reactBootstrap.Popover.Header, {
54
+ children: "Stripping lines"
55
+ }), /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactBootstrap.Popover.Body, {
56
+ children: Object.keys(this.props.decay.lines).map(line => {
57
+ const [stream, name] = line.split("/");
58
+ return /*#__PURE__*/(0, _jsxRuntime.jsx)(_StrippingLine.default, {
59
+ line: name,
60
+ stream: stream,
61
+ versions: this.props.decay.lines[line]
62
+ }, line);
63
+ })
64
+ })]
65
+ }),
66
+ children: /*#__PURE__*/(0, _jsxRuntime.jsxs)(_reactBootstrap.Badge, {
67
+ pill: true,
68
+ bg: this.state.selected ? "primary" : "secondary",
69
+ children: [nLines, " Stripping line", nLines === 1 ? "" : "s"]
70
+ })
71
+ }), nTags > 0 ? tagInfo : ""]
72
+ });
73
+ return strippingInfo;
74
+ });
75
+ }
72
76
  render() {
73
77
  const extraInfo = this.getExtraInfo();
74
78
  return /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactBootstrap.ListGroup.Item, {
@@ -10,7 +10,11 @@ var _reactBootstrap = require("react-bootstrap");
10
10
  var _MetadataContext = _interopRequireDefault(require("../contexts/MetadataContext"));
11
11
  var _jsxRuntime = require("react/jsx-runtime");
12
12
  function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
13
- /*****************************************************************************\
13
+ function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
14
+ function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
15
+ function _defineProperty(e, r, t) { return (r = _toPropertyKey(r)) in e ? Object.defineProperty(e, r, { value: t, enumerable: !0, configurable: !0, writable: !0 }) : e[r] = t, e; }
16
+ function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == typeof i ? i : i + ""; }
17
+ function _toPrimitive(t, r) { if ("object" != typeof t || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != typeof i) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); } /*****************************************************************************\
14
18
  * (c) Copyright 2021 CERN for the benefit of the LHCb Collaboration *
15
19
  * *
16
20
  * This software is distributed under the terms of the GNU General Public *
@@ -20,9 +24,7 @@ function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e
20
24
  * granted to it by virtue of its status as an Intergovernmental Organization *
21
25
  * or submit itself to any jurisdiction. *
22
26
  \*****************************************************************************/
23
-
24
27
  class DecayTag extends _react.default.Component {
25
- static contextType = (() => _MetadataContext.default)();
26
28
  render() {
27
29
  const background = this.context.loaded.userHints && this.context.metadata.userHints.decayTags[this.props.tag].warn ? "danger" : "warning";
28
30
  const foreground = this.context.loaded.userHints && this.context.metadata.userHints.decayTags[this.props.tag].warn ? "light" : "dark";
@@ -33,16 +35,17 @@ class DecayTag extends _react.default.Component {
33
35
  overlay: /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactBootstrap.Tooltip, {
34
36
  children: description
35
37
  }),
36
- children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactBootstrap.Badge, {
38
+ children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactBootstrap.Badge, _objectSpread(_objectSpread({
37
39
  pill: true,
38
40
  bg: background,
39
- text: foreground,
40
- ...this.props,
41
+ text: foreground
42
+ }, this.props), {}, {
41
43
  children: this.props.tag
42
- })
44
+ }))
43
45
  });
44
46
  }
45
47
  }
48
+ _defineProperty(DecayTag, "contextType", _MetadataContext.default);
46
49
  DecayTag.propTypes = {
47
50
  tag: _propTypes.default.string
48
51
  };
@@ -19,9 +19,14 @@ var _mathjax = _interopRequireDefault(require("../lib/mathjax"));
19
19
  var _config = _interopRequireDefault(require("../config.json"));
20
20
  var _DTTConfig = _interopRequireDefault(require("../lib/DTTConfig"));
21
21
  var _lodash = _interopRequireDefault(require("lodash"));
22
+ var _semform = _interopRequireDefault(require("./semform"));
22
23
  var _jsxRuntime = require("react/jsx-runtime");
23
24
  function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
24
- /*****************************************************************************\
25
+ function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
26
+ function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
27
+ function _defineProperty(e, r, t) { return (r = _toPropertyKey(r)) in e ? Object.defineProperty(e, r, { value: t, enumerable: !0, configurable: !0, writable: !0 }) : e[r] = t, e; }
28
+ function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == typeof i ? i : i + ""; }
29
+ function _toPrimitive(t, r) { if ("object" != typeof t || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != typeof i) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); } /*****************************************************************************\
25
30
  * (c) Copyright 2021 CERN for the benefit of the LHCb Collaboration *
26
31
  * *
27
32
  * This software is distributed under the terms of the GNU General Public *
@@ -31,7 +36,6 @@ function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e
31
36
  * granted to it by virtue of its status as an Intergovernmental Organization *
32
37
  * or submit itself to any jurisdiction. *
33
38
  \*****************************************************************************/
34
-
35
39
  function htmlTitle(text) {
36
40
  const container = document.createElement("span");
37
41
  container.innerText = text;
@@ -40,7 +44,7 @@ function htmlTitle(text) {
40
44
  function makeSVG(text) {
41
45
  let colour = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : "black";
42
46
  const pipes = "\\phantom{{}^{|-}_{|-}}"; // looks weird but helps ensure uniform text scaling
43
- const texSVG = (0, _mathjax.default)(`${pipes}${text}${pipes}`).innerHTML.replaceAll("currentColor", colour);
47
+ const texSVG = (0, _mathjax.default)("".concat(pipes).concat(text).concat(pipes)).innerHTML.replaceAll("currentColor", colour);
44
48
  return "data:image/svg+xml;charset=utf-8," + encodeURIComponent(texSVG);
45
49
  }
46
50
  function buildDecayGraph(decay, metadata) {
@@ -89,162 +93,149 @@ function buildDecayGraph(decay, metadata) {
89
93
  return graph;
90
94
  }
91
95
  class DecayTree extends _react.default.Component {
92
- static contextType = (() => _MetadataContext.default)();
93
- static options = {
94
- ..._config.default.dttGraphOptions,
95
- nodes: {
96
- // need to add a lambda to set the label hover-style
97
- ..._config.default.dttGraphOptions.nodes,
98
- chosen: {
99
- label: (values, id, selected, _hovering) => {
100
- if (selected) {
101
- values.mod = "bold";
102
- values.color = "#0d6efd";
103
- }
104
- }
105
- }
106
- }
107
- };
108
- state = (() => ({
109
- graph: buildDecayGraph(this.props.decay.descriptors.mapped_list, this.context.metadata.particleProperties),
110
- dtt: new _DTTConfig.default(_lodash.default.cloneDeep(this.props.dttConfig), this.context.metadata.tupleTools.tupleTools),
111
- lastSave: _lodash.default.cloneDeep(this.props.dttConfig),
112
- selectedParticleId: [],
113
- updated: false,
114
- lockGraphZoom: !_config.default.dttGraphOptions.interaction.zoomView,
115
- showNodeModal: false
116
- }))();
117
- network = null;
118
- selectAllByTag = tag => () => {
119
- const allBranches = this.state.dtt.config.branches;
120
- const matchingParticles = Object.keys(allBranches).filter(branch => {
121
- const particle = allBranches[branch].particle;
122
- const allTags = this.context.metadata.particleProperties[particle].tags;
123
- return allTags.includes(tag);
124
- }).sort();
125
- this.setState({
126
- selectedParticleId: matchingParticles
96
+ constructor() {
97
+ super(...arguments);
98
+ _defineProperty(this, "state", {
99
+ graph: buildDecayGraph(this.props.decay.descriptors.mapped_list, this.context.metadata.particleProperties),
100
+ dtt: new _DTTConfig.default(_lodash.default.cloneDeep(this.props.dttConfig), this.context.metadata.tupleTools.tupleTools),
101
+ lastSave: _lodash.default.cloneDeep(this.props.dttConfig),
102
+ selectedParticleId: [],
103
+ updated: false,
104
+ lockGraphZoom: !_config.default.dttGraphOptions.interaction.zoomView,
105
+ showNodeModal: false
127
106
  });
128
- this.network.selectNodes(matchingParticles);
129
- };
130
- selectGroup = group => () => {
131
- const selection = group.split(",");
132
- this.setState({
133
- selectedParticleId: selection
107
+ _defineProperty(this, "network", null);
108
+ _defineProperty(this, "selectAllByTag", tag => () => {
109
+ const allBranches = this.state.dtt.config.branches;
110
+ const matchingParticles = Object.keys(allBranches).filter(branch => {
111
+ const particle = allBranches[branch].particle;
112
+ const allTags = this.context.metadata.particleProperties[particle].tags;
113
+ return allTags.includes(tag);
114
+ }).sort();
115
+ this.setState({
116
+ selectedParticleId: matchingParticles
117
+ });
118
+ this.network.selectNodes(matchingParticles);
134
119
  });
135
- this.network.selectNodes(selection);
136
- };
137
- countGroupTools = group => {
138
- const toolList = this.state.dtt.listTools(group);
139
- const nTools = toolList.length;
140
- return /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactBootstrap.OverlayTrigger, {
141
- overlay: /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactBootstrap.Popover, {
142
- children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactBootstrap.ListGroup, {
143
- children: toolList.map(tool => /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactBootstrap.ListGroup.Item, {
144
- children: tool
145
- }, tool))
120
+ _defineProperty(this, "selectGroup", group => () => {
121
+ const selection = group.split(",");
122
+ this.setState({
123
+ selectedParticleId: selection
124
+ });
125
+ this.network.selectNodes(selection);
126
+ });
127
+ _defineProperty(this, "countGroupTools", group => {
128
+ const toolList = this.state.dtt.listTools(group);
129
+ const nTools = toolList.length;
130
+ return /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactBootstrap.OverlayTrigger, {
131
+ overlay: /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactBootstrap.Popover, {
132
+ children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactBootstrap.ListGroup, {
133
+ children: toolList.map(tool => /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactBootstrap.ListGroup.Item, {
134
+ children: tool
135
+ }, tool))
136
+ })
137
+ }),
138
+ children: /*#__PURE__*/(0, _jsxRuntime.jsxs)("div", {
139
+ children: [nTools, " TupleTool", nTools === 1 ? "" : "s"]
146
140
  })
147
- }),
148
- children: /*#__PURE__*/(0, _jsxRuntime.jsxs)("div", {
149
- children: [nTools, " TupleTool", nTools === 1 ? "" : "s"]
150
- })
141
+ });
151
142
  });
152
- };
153
- callbackCloseNodeConf = () => {
154
- this.setState({
155
- showNodeModal: false
143
+ _defineProperty(this, "callbackCloseNodeConf", () => {
144
+ this.setState({
145
+ showNodeModal: false
146
+ });
156
147
  });
157
- };
158
- callbackSignalUpdated = () => {
159
- this.setState({
160
- updated: true
148
+ _defineProperty(this, "callbackSignalUpdated", () => {
149
+ this.setState({
150
+ updated: true
151
+ });
161
152
  });
162
- };
163
- sendData = () => {
164
- const dttConfig = _lodash.default.cloneDeep(this.state.dtt.config);
165
- this.setState({
166
- updated: false,
167
- lastSave: dttConfig
153
+ _defineProperty(this, "sendData", () => {
154
+ const dttConfig = _lodash.default.cloneDeep(this.state.dtt.config);
155
+ this.setState({
156
+ updated: false,
157
+ lastSave: dttConfig
158
+ });
159
+ this.props.parentCallback(dttConfig);
168
160
  });
169
- this.props.parentCallback(dttConfig);
170
- };
171
- revertDTT = () => {
172
- let dtt = this.state.dtt;
173
- dtt.config = _lodash.default.cloneDeep(this.state.lastSave);
174
- this.setState({
175
- dtt: dtt,
176
- updated: false
161
+ _defineProperty(this, "revertDTT", () => {
162
+ let dtt = this.state.dtt;
163
+ dtt.config = _lodash.default.cloneDeep(this.state.lastSave);
164
+ this.setState({
165
+ dtt: dtt,
166
+ updated: false
167
+ });
177
168
  });
178
- };
179
- displaySelectionDescriptor = decaySelector => {
180
- // split into an array for easier looping
181
- // XXX: we could probably use descriptors.list in conjunction with descriptors.mapped_list here...
182
- const lokiArray = decaySelector.replace(/^\[/, "").replace(/^\^\[/, "^").replace(/\]CC$/, "").split(" ");
183
- const texArray = lokiArray.map(particle => {
184
- if (particle === "->") {
185
- return "\\to";
186
- } else {
187
- let name = particle.replace(/^\^/, ""); // name will be used to look up the particle in metadata
188
- // detect and handle sub-decays (marked with round braces)
189
- // A -> (B -> C D) E
190
- // A -> (B -> C (D -> E F)) G
191
- let braces = ["", ""];
192
- const numBraces = [/\(/g, /\)/g].map(pattern => (name.match(pattern) || []).length);
193
- if (name.startsWith("(")) {
194
- name = name.replace(/^\(/, "");
195
- braces[0] = "(";
196
- } else if (name.endsWith(")") && numBraces[1] > numBraces[0]) {
197
- name = name.replace(/\)+$/, "");
198
- braces[1] = ")".repeat(numBraces[1] - numBraces[0]);
199
- }
200
- // spit edge-cases to the console and handle them somewhat gracefully
201
- if (!Object.keys(this.context.metadata.particleProperties).includes(name)) {
202
- console.error(`${name} not found in particle property metadata!`);
203
- return `\\text{${particle}}`;
204
- }
205
- let latex = this.context.metadata.particleProperties[name].latex;
206
- // mark particles by underlining them
207
- // TODO: if we can figure out colour with mathjax-react, turn them blue instead
208
- if (particle.startsWith("^")) {
209
- latex = `\\underline{${latex}}`;
169
+ _defineProperty(this, "displaySelectionDescriptor", decaySelector => {
170
+ // split into an array for easier looping
171
+ // XXX: we could probably use descriptors.list in conjunction with descriptors.mapped_list here...
172
+ const lokiArray = decaySelector.replace(/^\[/, "").replace(/^\^\[/, "^").replace(/\]CC$/, "").split(" ");
173
+ const texArray = lokiArray.map(particle => {
174
+ if (particle === "->") {
175
+ return "\\to";
176
+ } else {
177
+ let name = particle.replace(/^\^/, ""); // name will be used to look up the particle in metadata
178
+ // detect and handle sub-decays (marked with round braces)
179
+ // A -> (B -> C D) E
180
+ // A -> (B -> C (D -> E F)) G
181
+ let braces = ["", ""];
182
+ const numBraces = [/\(/g, /\)/g].map(pattern => (name.match(pattern) || []).length);
183
+ if (name.startsWith("(")) {
184
+ name = name.replace(/^\(/, "");
185
+ braces[0] = "(";
186
+ } else if (name.endsWith(")") && numBraces[1] > numBraces[0]) {
187
+ name = name.replace(/\)+$/, "");
188
+ braces[1] = ")".repeat(numBraces[1] - numBraces[0]);
189
+ }
190
+ // spit edge-cases to the console and handle them somewhat gracefully
191
+ if (!Object.keys(this.context.metadata.particleProperties).includes(name)) {
192
+ console.error("".concat(name, " not found in particle property metadata!"));
193
+ return "\\text{".concat(particle, "}");
194
+ }
195
+ let latex = this.context.metadata.particleProperties[name].latex;
196
+ // mark particles by underlining them
197
+ // TODO: if we can figure out colour with mathjax-react, turn them blue instead
198
+ if (particle.startsWith("^")) {
199
+ latex = "\\underline{".concat(latex, "}");
200
+ }
201
+ // remember to put the braces back
202
+ return "".concat(braces[0]).concat(latex).concat(braces[1]);
210
203
  }
211
- // remember to put the braces back
212
- return `${braces[0]}${latex}${braces[1]}`;
213
- }
204
+ });
205
+ return texArray.join(" ");
214
206
  });
215
- return texArray.join(" ");
216
- };
217
- displaySelection = selection => {
218
- const decaySelector = this.props.decay.descriptors.template.replace(/\${(\w+)}/g, (_, v) => selection.includes(v) ? "^" : "");
219
- const latex = this.displaySelectionDescriptor(decaySelector);
220
- return /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactBootstrap.OverlayTrigger, {
221
- overlay: /*#__PURE__*/(0, _jsxRuntime.jsxs)(_reactBootstrap.Popover, {
222
- children: [/*#__PURE__*/(0, _jsxRuntime.jsx)(_reactBootstrap.Popover.Header, {
223
- children: "LoKi selector"
224
- }), /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactBootstrap.Popover.Body, {
225
- children: /*#__PURE__*/(0, _jsxRuntime.jsx)("code", {
226
- children: decaySelector
207
+ _defineProperty(this, "displaySelection", selection => {
208
+ const decaySelector = this.props.decay.descriptors.template.replace(/\${(\w+)}/g, (_, v) => selection.includes(v) ? "^" : "");
209
+ const latex = this.displaySelectionDescriptor(decaySelector);
210
+ return /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactBootstrap.OverlayTrigger, {
211
+ overlay: /*#__PURE__*/(0, _jsxRuntime.jsxs)(_reactBootstrap.Popover, {
212
+ children: [/*#__PURE__*/(0, _jsxRuntime.jsx)(_reactBootstrap.Popover.Header, {
213
+ children: "LoKi selector"
214
+ }), /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactBootstrap.Popover.Body, {
215
+ children: /*#__PURE__*/(0, _jsxRuntime.jsx)("code", {
216
+ children: decaySelector
217
+ })
218
+ })]
219
+ }),
220
+ children: /*#__PURE__*/(0, _jsxRuntime.jsx)("span", {
221
+ children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_mathjaxReact.MathComponent, {
222
+ tex: "".concat(latex),
223
+ display: false
227
224
  })
228
- })]
229
- }),
230
- children: /*#__PURE__*/(0, _jsxRuntime.jsx)("span", {
231
- children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_mathjaxReact.MathComponent, {
232
- tex: `${latex}`,
233
- display: false
234
225
  })
235
- })
236
- });
237
- };
238
- toggleZoomLock = () => {
239
- this.network.setOptions({
240
- interaction: {
241
- zoomView: this.state.lockGraphZoom
242
- }
226
+ });
243
227
  });
244
- this.setState({
245
- lockGraphZoom: !this.state.lockGraphZoom
228
+ _defineProperty(this, "toggleZoomLock", () => {
229
+ this.network.setOptions({
230
+ interaction: {
231
+ zoomView: this.state.lockGraphZoom
232
+ }
233
+ });
234
+ this.setState({
235
+ lockGraphZoom: !this.state.lockGraphZoom
236
+ });
246
237
  });
247
- };
238
+ }
248
239
  render() {
249
240
  this.state.dtt.pruneGroups(); // Make sure no empty groups
250
241
  const selection = this.state.selectedParticleId;
@@ -308,7 +299,7 @@ class DecayTree extends _react.default.Component {
308
299
  overlay: /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactBootstrap.Popover, {
309
300
  children: /*#__PURE__*/(0, _jsxRuntime.jsxs)(_reactBootstrap.Popover.Body, {
310
301
  children: ["The ROOT TTree will be found under ", /*#__PURE__*/(0, _jsxRuntime.jsx)("code", {
311
- children: `DecayTreeTuple/${dttName}`
302
+ children: "DecayTreeTuple/".concat(dttName)
312
303
  }), "."]
313
304
  })
314
305
  }),
@@ -391,6 +382,9 @@ class DecayTree extends _react.default.Component {
391
382
  })
392
383
  }), /*#__PURE__*/(0, _jsxRuntime.jsxs)(_reactBootstrap.Card.Title, {
393
384
  children: ["Current selection: ", selectedName]
385
+ }), /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactBootstrap.Card.Title, {
386
+ className: "d-flex justify-content-between align-items-center flex-column",
387
+ children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_semform.default, {})
394
388
  }), /*#__PURE__*/(0, _jsxRuntime.jsx)(_ConfigNode.default, {
395
389
  dtt: this.state.dtt,
396
390
  particleID: selection,
@@ -440,6 +434,19 @@ class DecayTree extends _react.default.Component {
440
434
  });
441
435
  }
442
436
  }
437
+ _defineProperty(DecayTree, "contextType", _MetadataContext.default);
438
+ _defineProperty(DecayTree, "options", _objectSpread(_objectSpread({}, _config.default.dttGraphOptions), {}, {
439
+ nodes: _objectSpread(_objectSpread({}, _config.default.dttGraphOptions.nodes), {}, {
440
+ chosen: {
441
+ label: (values, id, selected, _hovering) => {
442
+ if (selected) {
443
+ values.mod = "bold";
444
+ values.color = "#0d6efd";
445
+ }
446
+ }
447
+ }
448
+ })
449
+ }));
443
450
  DecayTree.propTypes = {
444
451
  decay: _propTypes.default.object,
445
452
  dttConfig: _propTypes.default.object,
@@ -13,9 +13,10 @@ var _reactBootstrap = require("react-bootstrap");
13
13
  var _config = _interopRequireDefault(require("../config"));
14
14
  var _jsxRuntime = require("react/jsx-runtime");
15
15
  function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
16
- function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function (e) { return e ? t : r; })(e); }
17
- function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != typeof e && "function" != typeof e) return { default: e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && {}.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n.default = e, t && t.set(e, n), n; }
18
- /*****************************************************************************\
16
+ function _interopRequireWildcard(e, t) { if ("function" == typeof WeakMap) var r = new WeakMap(), n = new WeakMap(); return (_interopRequireWildcard = function (e, t) { if (!t && e && e.__esModule) return e; var o, i, f = { __proto__: null, default: e }; if (null === e || "object" != typeof e && "function" != typeof e) return f; if (o = t ? n : r) { if (o.has(e)) return o.get(e); o.set(e, f); } for (const t in e) "default" !== t && {}.hasOwnProperty.call(e, t) && ((i = (o = Object.defineProperty) && Object.getOwnPropertyDescriptor(e, t)) && (i.get || i.set) ? o(f, t, i) : f[t] = e[t]); return f; })(e, t); }
17
+ function _defineProperty(e, r, t) { return (r = _toPropertyKey(r)) in e ? Object.defineProperty(e, r, { value: t, enumerable: !0, configurable: !0, writable: !0 }) : e[r] = t, e; }
18
+ function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == typeof i ? i : i + ""; }
19
+ function _toPrimitive(t, r) { if ("object" != typeof t || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != typeof i) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); } /*****************************************************************************\
19
20
  * (c) Copyright 2021 CERN for the benefit of the LHCb Collaboration *
20
21
  * *
21
22
  * This software is distributed under the terms of the GNU General Public *
@@ -25,40 +26,42 @@ function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e;
25
26
  * granted to it by virtue of its status as an Intergovernmental Organization *
26
27
  * or submit itself to any jurisdiction. *
27
28
  \*****************************************************************************/
28
-
29
29
  class DecaysList extends React.Component {
30
- state = (() => ({
31
- items: this.props.decays.length > _config.default.batch_size ? this.props.decays.slice(0, _config.default.batch_size) : this.props.decays,
32
- index: this.props.decays.length > _config.default.batch_size ? _config.default.batch_size - 1 : this.props.decays.length,
33
- selectedDecays: this.props.selectedDecays
34
- }))();
35
- fetchMoreData = () => {
36
- setTimeout(() => {
37
- this.setState({
38
- items: this.state.items.concat(this.props.decays.slice(this.state.index + 1, this.state.index + 1 + _config.default.batch_size)),
39
- index: this.state.index + _config.default.batch_size < this.props.decays.length ? this.state.index + _config.default.batch_size : this.props.decays.length
40
- });
41
- }, 1000);
42
- };
43
- callbackFunction = childData => {
44
- if (childData.selected) {
45
- const index = this.state.selectedDecays.indexOf(childData.decay);
46
- if (index > -1) {
47
- this.state.selectedDecays.splice(index, 1);
30
+ constructor() {
31
+ super(...arguments);
32
+ _defineProperty(this, "state", {
33
+ items: this.props.decays.length > _config.default.batch_size ? this.props.decays.slice(0, _config.default.batch_size) : this.props.decays,
34
+ index: this.props.decays.length > _config.default.batch_size ? _config.default.batch_size - 1 : this.props.decays.length,
35
+ selectedDecays: this.props.selectedDecays
36
+ });
37
+ _defineProperty(this, "fetchMoreData", () => {
38
+ setTimeout(() => {
39
+ this.setState({
40
+ items: this.state.items.concat(this.props.decays.slice(this.state.index + 1, this.state.index + 1 + _config.default.batch_size)),
41
+ index: this.state.index + _config.default.batch_size < this.props.decays.length ? this.state.index + _config.default.batch_size : this.props.decays.length
42
+ });
43
+ }, 1000);
44
+ });
45
+ _defineProperty(this, "callbackFunction", childData => {
46
+ if (childData.selected) {
47
+ const index = this.state.selectedDecays.indexOf(childData.decay);
48
+ if (index > -1) {
49
+ this.state.selectedDecays.splice(index, 1);
50
+ }
51
+ } else {
52
+ this.state.selectedDecays.push(childData.decay);
48
53
  }
49
- } else {
50
- this.state.selectedDecays.push(childData.decay);
51
- }
52
- this.props.parentCallback(this.state.selectedDecays);
53
- };
54
- getDecayItem = () => {
55
- const strippingDecayItem = this.state.items.map(decay => /*#__PURE__*/(0, _jsxRuntime.jsx)(_DecayItem.default, {
56
- decay: decay,
57
- selected: this.state.selectedDecays.some(selected => selected.descriptors.plain === decay.descriptors.plain),
58
- parentCallback: this.callbackFunction
59
- }, decay.descriptors.plain));
60
- return strippingDecayItem;
61
- };
54
+ this.props.parentCallback(this.state.selectedDecays);
55
+ });
56
+ _defineProperty(this, "getDecayItem", () => {
57
+ const strippingDecayItem = this.state.items.map(decay => /*#__PURE__*/(0, _jsxRuntime.jsx)(_DecayItem.default, {
58
+ decay: decay,
59
+ selected: this.state.selectedDecays.some(selected => selected.descriptors.plain === decay.descriptors.plain),
60
+ parentCallback: this.callbackFunction
61
+ }, decay.descriptors.plain));
62
+ return strippingDecayItem;
63
+ });
64
+ }
62
65
  render() {
63
66
  const decayItem = this.getDecayItem();
64
67
  const nShown = this.state.items.length;