lhcb-ntuple-wizard-test 0.0.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 (41) hide show
  1. package/COPYING +674 -0
  2. package/README.md +79 -0
  3. package/dist/components/App.js +99 -0
  4. package/dist/components/ConfigDict.js +103 -0
  5. package/dist/components/ConfigList.js +94 -0
  6. package/dist/components/ConfigNode.js +323 -0
  7. package/dist/components/ConfigValue.js +85 -0
  8. package/dist/components/Dataset.js +67 -0
  9. package/dist/components/Decay.js +51 -0
  10. package/dist/components/DecayItem.js +101 -0
  11. package/dist/components/DecayTag.js +50 -0
  12. package/dist/components/DecayTree.js +452 -0
  13. package/dist/components/DecaysList.js +108 -0
  14. package/dist/components/DeleteButton.js +56 -0
  15. package/dist/components/DescriptorsSearch.js +351 -0
  16. package/dist/components/EventTypeBadge.js +42 -0
  17. package/dist/components/ItemSearch.js +119 -0
  18. package/dist/components/LinesTable.js +1111 -0
  19. package/dist/components/NtupleWizard.js +141 -0
  20. package/dist/components/ParticleTag.js +52 -0
  21. package/dist/components/PolarityBadge.js +35 -0
  22. package/dist/components/SearchItem.js +100 -0
  23. package/dist/components/SelectParticle.js +61 -0
  24. package/dist/components/SelectTag.js +66 -0
  25. package/dist/components/SelectTool.js +59 -0
  26. package/dist/components/SelectVariables.js +105 -0
  27. package/dist/components/StrippingBadge.js +62 -0
  28. package/dist/components/StrippingLine.js +48 -0
  29. package/dist/components/TupleTool.js +46 -0
  30. package/dist/components/VariablesSearch.js +127 -0
  31. package/dist/components/YearBadge.js +35 -0
  32. package/dist/config.json +70 -0
  33. package/dist/contexts/MetadataContext.js +134 -0
  34. package/dist/index.js +18 -0
  35. package/dist/lib/BKPath.js +58 -0
  36. package/dist/lib/DTTConfig.js +174 -0
  37. package/dist/lib/analysisHelpers.js +30 -0
  38. package/dist/lib/mathjax.js +35 -0
  39. package/dist/lib/utils.js +191 -0
  40. package/dist/style/DecaysList.css +15 -0
  41. package/package.json +66 -0
@@ -0,0 +1,50 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.default = void 0;
7
+ var _react = _interopRequireDefault(require("react"));
8
+ var _propTypes = _interopRequireDefault(require("prop-types"));
9
+ var _reactBootstrap = require("react-bootstrap");
10
+ var _MetadataContext = _interopRequireDefault(require("../contexts/MetadataContext"));
11
+ var _jsxRuntime = require("react/jsx-runtime");
12
+ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
13
+ function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
14
+ function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == typeof i ? i : String(i); }
15
+ 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
+ * (c) Copyright 2021 CERN for the benefit of the LHCb Collaboration *
17
+ * *
18
+ * This software is distributed under the terms of the GNU General Public *
19
+ * Licence version 3 (GPL Version 3), copied verbatim in the file "COPYING". *
20
+ * *
21
+ * In applying this licence, CERN does not waive the privileges and immunities *
22
+ * granted to it by virtue of its status as an Intergovernmental Organization *
23
+ * or submit itself to any jurisdiction. *
24
+ \*****************************************************************************/
25
+ class DecayTag extends _react.default.Component {
26
+ render() {
27
+ const background = this.context.loaded.userHints && this.context.metadata.userHints.decayTags[this.props.tag].warn ? "danger" : "warning";
28
+ const foreground = this.context.loaded.userHints && this.context.metadata.userHints.decayTags[this.props.tag].warn ? "light" : "dark";
29
+ const description = this.context.loaded.userHints ? this.context.metadata.userHints.decayTags[this.props.tag].description : /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactBootstrap.Spinner, {
30
+ animation: "border"
31
+ });
32
+ return /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactBootstrap.OverlayTrigger, {
33
+ overlay: /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactBootstrap.Tooltip, {
34
+ children: description
35
+ }),
36
+ children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactBootstrap.Badge, {
37
+ pill: true,
38
+ bg: background,
39
+ text: foreground,
40
+ ...this.props,
41
+ children: this.props.tag
42
+ })
43
+ });
44
+ }
45
+ }
46
+ _defineProperty(DecayTag, "contextType", _MetadataContext.default);
47
+ DecayTag.propTypes = {
48
+ tag: _propTypes.default.string
49
+ };
50
+ var _default = exports.default = DecayTag;
@@ -0,0 +1,452 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.default = void 0;
7
+ var _react = _interopRequireDefault(require("react"));
8
+ var _propTypes = _interopRequireDefault(require("prop-types"));
9
+ var _reactGraphVis = _interopRequireDefault(require("react-graph-vis"));
10
+ var _ParticleTag = _interopRequireDefault(require("./ParticleTag"));
11
+ var _DecayTag = _interopRequireDefault(require("./DecayTag"));
12
+ var _Decay = _interopRequireDefault(require("./Decay"));
13
+ var _ConfigNode = _interopRequireDefault(require("./ConfigNode"));
14
+ var _MetadataContext = _interopRequireDefault(require("../contexts/MetadataContext"));
15
+ var _reactBootstrap = require("react-bootstrap");
16
+ var _reactBootstrapIcons = require("react-bootstrap-icons");
17
+ var _mathjaxReact = require("mathjax-react");
18
+ var _mathjax = _interopRequireDefault(require("../lib/mathjax"));
19
+ var _config = _interopRequireDefault(require("../config.json"));
20
+ var _DTTConfig = _interopRequireDefault(require("../lib/DTTConfig"));
21
+ var _lodash = _interopRequireDefault(require("lodash"));
22
+ var _jsxRuntime = require("react/jsx-runtime");
23
+ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
24
+ function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
25
+ function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == typeof i ? i : String(i); }
26
+ 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); } /*****************************************************************************\
27
+ * (c) Copyright 2021 CERN for the benefit of the LHCb Collaboration *
28
+ * *
29
+ * This software is distributed under the terms of the GNU General Public *
30
+ * Licence version 3 (GPL Version 3), copied verbatim in the file "COPYING". *
31
+ * *
32
+ * In applying this licence, CERN does not waive the privileges and immunities *
33
+ * granted to it by virtue of its status as an Intergovernmental Organization *
34
+ * or submit itself to any jurisdiction. *
35
+ \*****************************************************************************/
36
+ function htmlTitle(text) {
37
+ const container = document.createElement("span");
38
+ container.innerText = text;
39
+ return container;
40
+ }
41
+ function makeSVG(text) {
42
+ let colour = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : "black";
43
+ const pipes = "\\phantom{{}^{|-}_{|-}}"; // looks weird but helps ensure uniform text scaling
44
+ const texSVG = (0, _mathjax.default)("".concat(pipes).concat(text).concat(pipes)).innerHTML.replaceAll("currentColor", colour);
45
+ return "data:image/svg+xml;charset=utf-8," + encodeURIComponent(texSVG);
46
+ }
47
+ function buildDecayGraph(decay, metadata) {
48
+ const getGraphParams = (term, graph, parentId) => {
49
+ if (!(term instanceof Array)) {
50
+ const {
51
+ branch,
52
+ particle
53
+ } = term;
54
+ return {
55
+ newNode: {
56
+ id: branch,
57
+ label: branch,
58
+ title: htmlTitle(metadata[particle].html),
59
+ image: {
60
+ selected: makeSVG(metadata[particle].latex, "#0d6efd"),
61
+ unselected: makeSVG(metadata[particle].latex, "black")
62
+ }
63
+ },
64
+ newEdge: parentId === 0 ? {} : {
65
+ from: parentId,
66
+ to: branch
67
+ }
68
+ };
69
+ }
70
+ term.forEach(element => {
71
+ if (element instanceof Array) {
72
+ const subParentId = graph.nodes.slice(-1)[0].id;
73
+ graph = getGraphParams(element, graph, subParentId);
74
+ } else {
75
+ const {
76
+ newNode,
77
+ newEdge
78
+ } = getGraphParams(element, graph, parentId);
79
+ graph.nodes.push(newNode);
80
+ graph.edges.push(newEdge);
81
+ }
82
+ });
83
+ return graph;
84
+ };
85
+ let graph = getGraphParams(decay, {
86
+ nodes: [],
87
+ edges: []
88
+ }, 0);
89
+ graph.edges = graph.edges.filter(edge => Object.keys(edge).length !== 0);
90
+ return graph;
91
+ }
92
+ class DecayTree extends _react.default.Component {
93
+ constructor() {
94
+ super(...arguments);
95
+ _defineProperty(this, "state", {
96
+ graph: buildDecayGraph(this.props.decay.descriptors.mapped_list, this.context.metadata.particleProperties),
97
+ dtt: new _DTTConfig.default(_lodash.default.cloneDeep(this.props.dttConfig), this.context.metadata.tupleTools.tupleTools),
98
+ lastSave: _lodash.default.cloneDeep(this.props.dttConfig),
99
+ selectedParticleId: [],
100
+ updated: false,
101
+ lockGraphZoom: !_config.default.dttGraphOptions.interaction.zoomView,
102
+ showNodeModal: false
103
+ });
104
+ _defineProperty(this, "network", null);
105
+ _defineProperty(this, "selectAllByTag", tag => () => {
106
+ const allBranches = this.state.dtt.config.branches;
107
+ const matchingParticles = Object.keys(allBranches).filter(branch => {
108
+ const particle = allBranches[branch].particle;
109
+ const allTags = this.context.metadata.particleProperties[particle].tags;
110
+ return allTags.includes(tag);
111
+ }).sort();
112
+ this.setState({
113
+ selectedParticleId: matchingParticles
114
+ });
115
+ this.network.selectNodes(matchingParticles);
116
+ });
117
+ _defineProperty(this, "selectGroup", group => () => {
118
+ const selection = group.split(",");
119
+ this.setState({
120
+ selectedParticleId: selection
121
+ });
122
+ this.network.selectNodes(selection);
123
+ });
124
+ _defineProperty(this, "countGroupTools", group => {
125
+ const toolList = this.state.dtt.listTools(group);
126
+ const nTools = toolList.length;
127
+ return /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactBootstrap.OverlayTrigger, {
128
+ overlay: /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactBootstrap.Popover, {
129
+ children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactBootstrap.ListGroup, {
130
+ children: toolList.map(tool => /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactBootstrap.ListGroup.Item, {
131
+ children: tool
132
+ }, tool))
133
+ })
134
+ }),
135
+ children: /*#__PURE__*/(0, _jsxRuntime.jsxs)("div", {
136
+ children: [nTools, " TupleTool", nTools === 1 ? "" : "s"]
137
+ })
138
+ });
139
+ });
140
+ _defineProperty(this, "callbackCloseNodeConf", () => {
141
+ this.setState({
142
+ showNodeModal: false
143
+ });
144
+ });
145
+ _defineProperty(this, "callbackSignalUpdated", () => {
146
+ this.setState({
147
+ updated: true
148
+ });
149
+ });
150
+ _defineProperty(this, "sendData", () => {
151
+ const dttConfig = _lodash.default.cloneDeep(this.state.dtt.config);
152
+ this.setState({
153
+ updated: false,
154
+ lastSave: dttConfig
155
+ });
156
+ this.props.parentCallback(dttConfig);
157
+ });
158
+ _defineProperty(this, "revertDTT", () => {
159
+ let dtt = this.state.dtt;
160
+ dtt.config = _lodash.default.cloneDeep(this.state.lastSave);
161
+ this.setState({
162
+ dtt: dtt,
163
+ updated: false
164
+ });
165
+ });
166
+ _defineProperty(this, "displaySelectionDescriptor", decaySelector => {
167
+ // split into an array for easier looping
168
+ // XXX: we could probably use descriptors.list in conjunction with descriptors.mapped_list here...
169
+ const lokiArray = decaySelector.replace(/^\[/, "").replace(/^\^\[/, "^").replace(/\]CC$/, "").split(" ");
170
+ const texArray = lokiArray.map(particle => {
171
+ if (particle === "->") {
172
+ return "\\to";
173
+ } else {
174
+ let name = particle.replace(/^\^/, ""); // name will be used to look up the particle in metadata
175
+ // detect and handle sub-decays (marked with round braces)
176
+ // A -> (B -> C D) E
177
+ // A -> (B -> C (D -> E F)) G
178
+ let braces = ["", ""];
179
+ const numBraces = [/\(/g, /\)/g].map(pattern => (name.match(pattern) || []).length);
180
+ if (name.startsWith("(")) {
181
+ name = name.replace(/^\(/, "");
182
+ braces[0] = "(";
183
+ } else if (name.endsWith(")") && numBraces[1] > numBraces[0]) {
184
+ name = name.replace(/\)+$/, "");
185
+ braces[1] = ")".repeat(numBraces[1] - numBraces[0]);
186
+ }
187
+ // spit edge-cases to the console and handle them somewhat gracefully
188
+ if (!Object.keys(this.context.metadata.particleProperties).includes(name)) {
189
+ console.error("".concat(name, " not found in particle property metadata!"));
190
+ return "\\text{".concat(particle, "}");
191
+ }
192
+ let latex = this.context.metadata.particleProperties[name].latex;
193
+ // mark particles by underlining them
194
+ // TODO: if we can figure out colour with mathjax-react, turn them blue instead
195
+ if (particle.startsWith("^")) {
196
+ latex = "\\underline{".concat(latex, "}");
197
+ }
198
+ // remember to put the braces back
199
+ return "".concat(braces[0]).concat(latex).concat(braces[1]);
200
+ }
201
+ });
202
+ return texArray.join(" ");
203
+ });
204
+ _defineProperty(this, "displaySelection", selection => {
205
+ const decaySelector = this.props.decay.descriptors.template.replace(/\${(\w+)}/g, (_, v) => selection.includes(v) ? "^" : "");
206
+ const latex = this.displaySelectionDescriptor(decaySelector);
207
+ return /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactBootstrap.OverlayTrigger, {
208
+ overlay: /*#__PURE__*/(0, _jsxRuntime.jsxs)(_reactBootstrap.Popover, {
209
+ children: [/*#__PURE__*/(0, _jsxRuntime.jsx)(_reactBootstrap.Popover.Header, {
210
+ children: "LoKi selector"
211
+ }), /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactBootstrap.Popover.Body, {
212
+ children: /*#__PURE__*/(0, _jsxRuntime.jsx)("code", {
213
+ children: decaySelector
214
+ })
215
+ })]
216
+ }),
217
+ children: /*#__PURE__*/(0, _jsxRuntime.jsx)("span", {
218
+ children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_mathjaxReact.MathComponent, {
219
+ tex: "".concat(latex),
220
+ display: false
221
+ })
222
+ })
223
+ });
224
+ });
225
+ _defineProperty(this, "toggleZoomLock", () => {
226
+ this.network.setOptions({
227
+ interaction: {
228
+ zoomView: this.state.lockGraphZoom
229
+ }
230
+ });
231
+ this.setState({
232
+ lockGraphZoom: !this.state.lockGraphZoom
233
+ });
234
+ });
235
+ }
236
+ render() {
237
+ this.state.dtt.pruneGroups(); // Make sure no empty groups
238
+ const selection = this.state.selectedParticleId;
239
+ const tagInfo = this.context.metadata.userHints.particleTags;
240
+ const particleInfo = this.context.metadata.particleProperties;
241
+ const dtt = this.state.dtt.config;
242
+ const nGroups = Object.keys(dtt.groups).length;
243
+ const dttName = this.state.dtt.getSafeName();
244
+ const decayTags = /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactBootstrap.Stack, {
245
+ direction: "horizontal",
246
+ style: {
247
+ flexWrap: "wrap",
248
+ justifyContent: "center"
249
+ },
250
+ gap: 2,
251
+ children: this.props.decay.tags.filter(tag => this.context.metadata.userHints.decayTags[tag].warn).map(tag => /*#__PURE__*/(0, _jsxRuntime.jsx)(_DecayTag.default, {
252
+ tag: tag
253
+ }, tag))
254
+ });
255
+ let selectedName = "";
256
+ let filterToolTags = ["IParticleTupleTool"];
257
+ let particleTags = [];
258
+ let displayedGroups = {};
259
+ if (selection.length > 0) {
260
+ const target = this.state.dtt.getTarget(selection);
261
+ const allParticles = selection.length > 1 ? target.particles.map(particle => particleInfo[particle]) : [particleInfo[target.particle]];
262
+ const allTags = new Set([].concat(...allParticles.map(particle => particle.tags.filter(tag => !tagInfo[tag].hide))));
263
+ particleTags = [...allTags].filter(tag => allParticles.every(particle => particle.tags.includes(tag)));
264
+ selectedName = this.displaySelection(selection);
265
+ if (selection.length === 1) {
266
+ const filteredGroups = Object.entries(dtt.groups).filter(_ref => {
267
+ let [key, _value] = _ref;
268
+ return key.includes(selection[0]);
269
+ });
270
+ displayedGroups = Object.fromEntries(filteredGroups);
271
+ }
272
+ } else {
273
+ filterToolTags.push("IEventTupleTool");
274
+ const allBranches = dtt.branches;
275
+ const allParticles = Object.keys(allBranches).map(branch => particleInfo[allBranches[branch].particle]);
276
+ const uniqueTags = new Set([].concat(...allParticles.map(particle => particle.tags.filter(tag => !tagInfo[tag].hide))));
277
+ particleTags = [...uniqueTags];
278
+ selectedName = /*#__PURE__*/(0, _jsxRuntime.jsx)(_Decay.default, {
279
+ decay: this.props.decay,
280
+ display: false
281
+ });
282
+ displayedGroups = dtt.groups;
283
+ }
284
+ particleTags.sort((a, b) => tagInfo[a].group > tagInfo[b].group);
285
+ const inputList = dtt.inputs.length === 0 ? /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactBootstrap.ListGroup.Item, {
286
+ children: "Choose at least one Stripping line, otherwise no decay candidates will be selected"
287
+ }) : dtt.inputs.map((location, index) => /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactBootstrap.ListGroup.Item, {
288
+ children: /*#__PURE__*/(0, _jsxRuntime.jsx)("code", {
289
+ children: location
290
+ })
291
+ }, index));
292
+ return /*#__PURE__*/(0, _jsxRuntime.jsxs)(_reactBootstrap.Card, {
293
+ children: [/*#__PURE__*/(0, _jsxRuntime.jsxs)(_reactBootstrap.Card.Header, {
294
+ children: [/*#__PURE__*/(0, _jsxRuntime.jsx)(_reactBootstrap.OverlayTrigger, {
295
+ placement: "bottom",
296
+ overlay: /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactBootstrap.Popover, {
297
+ children: /*#__PURE__*/(0, _jsxRuntime.jsxs)(_reactBootstrap.Popover.Body, {
298
+ children: ["The ROOT TTree will be found under ", /*#__PURE__*/(0, _jsxRuntime.jsx)("code", {
299
+ children: "DecayTreeTuple/".concat(dttName)
300
+ }), "."]
301
+ })
302
+ }),
303
+ children: /*#__PURE__*/(0, _jsxRuntime.jsxs)(_reactBootstrap.Card.Title, {
304
+ children: ["Tree name: ", /*#__PURE__*/(0, _jsxRuntime.jsx)("code", {
305
+ children: dttName
306
+ })]
307
+ })
308
+ }), /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactBootstrap.Accordion, {
309
+ children: /*#__PURE__*/(0, _jsxRuntime.jsxs)(_reactBootstrap.Accordion.Item, {
310
+ eventKey: "0",
311
+ children: [/*#__PURE__*/(0, _jsxRuntime.jsxs)(_reactBootstrap.Accordion.Header, {
312
+ children: [dtt.inputs.length, " input location", dtt.inputs.length === 1 ? "" : "s"]
313
+ }), /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactBootstrap.Accordion.Body, {
314
+ children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactBootstrap.ListGroup, {
315
+ variant: "flush",
316
+ children: inputList
317
+ })
318
+ })]
319
+ })
320
+ })]
321
+ }), /*#__PURE__*/(0, _jsxRuntime.jsxs)(_reactBootstrap.Card.Body, {
322
+ children: [/*#__PURE__*/(0, _jsxRuntime.jsxs)(_reactBootstrap.Card.Title, {
323
+ className: "d-flex justify-content-between align-items-start",
324
+ children: [/*#__PURE__*/(0, _jsxRuntime.jsxs)("span", {
325
+ children: [/*#__PURE__*/(0, _jsxRuntime.jsx)(_reactBootstrap.OverlayTrigger, {
326
+ placement: "bottom",
327
+ overlay: /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactBootstrap.Tooltip, {
328
+ children: "Click to select particles to configure. Hold ctrl to select multiple. Clear the selection to configure the entire decay."
329
+ }),
330
+ children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactBootstrapIcons.QuestionCircle, {})
331
+ }), " ", "Configure ", /*#__PURE__*/(0, _jsxRuntime.jsx)(_Decay.default, {
332
+ decay: this.props.decay,
333
+ display: false
334
+ })]
335
+ }), /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactBootstrap.OverlayTrigger, {
336
+ placement: "bottom",
337
+ overlay: /*#__PURE__*/(0, _jsxRuntime.jsxs)(_reactBootstrap.Tooltip, {
338
+ children: ["Click to ", this.state.lockGraphZoom ? "unlock" : "lock", " scroll-to-zoom."]
339
+ }),
340
+ children: /*#__PURE__*/(0, _jsxRuntime.jsxs)(_reactBootstrap.Button, {
341
+ onClick: this.toggleZoomLock,
342
+ variant: "secondary-outline",
343
+ children: [this.state.lockGraphZoom ? /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactBootstrapIcons.Lock, {}) : /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactBootstrapIcons.Unlock, {}), /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactBootstrapIcons.Search, {})]
344
+ })
345
+ })]
346
+ }), decayTags, /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactGraphVis.default, {
347
+ graph: this.state.graph,
348
+ options: DecayTree.options,
349
+ events: {
350
+ selectNode: event => {
351
+ this.setState({
352
+ selectedParticleId: [...event.nodes].sort()
353
+ });
354
+ },
355
+ deselectNode: event => {
356
+ this.setState({
357
+ selectedParticleId: [...event.nodes].sort()
358
+ });
359
+ }
360
+ },
361
+ getNetwork: network => {
362
+ this.network = network;
363
+ }
364
+ }), /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactBootstrap.Card.Title, {
365
+ children: "Select by category"
366
+ }), /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactBootstrap.Card.Body, {
367
+ children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactBootstrap.Stack, {
368
+ direction: "horizontal",
369
+ style: {
370
+ flexWrap: "wrap",
371
+ justifyContent: "center"
372
+ },
373
+ gap: 2,
374
+ children: particleTags.map(tag => /*#__PURE__*/(0, _jsxRuntime.jsx)(_ParticleTag.default, {
375
+ as: "button",
376
+ tag: tag,
377
+ onClick: this.selectAllByTag(tag)
378
+ }, tag))
379
+ })
380
+ }), /*#__PURE__*/(0, _jsxRuntime.jsxs)(_reactBootstrap.Card.Title, {
381
+ children: ["Current selection: ", selectedName]
382
+ }), /*#__PURE__*/(0, _jsxRuntime.jsx)(_ConfigNode.default, {
383
+ dtt: this.state.dtt,
384
+ particleID: selection,
385
+ parentCallbackClose: this.callbackCloseNodeConf,
386
+ parentCallbackUpdated: this.callbackSignalUpdated,
387
+ filterToolTags: filterToolTags,
388
+ updated: this.state.updated
389
+ }), Object.keys(displayedGroups).length > 0 ? /*#__PURE__*/(0, _jsxRuntime.jsxs)(_reactBootstrap.Card, {
390
+ children: [/*#__PURE__*/(0, _jsxRuntime.jsxs)(_reactBootstrap.Card.Header, {
391
+ children: [nGroups, " group", nGroups === 1 ? "" : "s"]
392
+ }), /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactBootstrap.ListGroup, {
393
+ variant: "flush",
394
+ children: Object.keys(displayedGroups).map(sel => /*#__PURE__*/(0, _jsxRuntime.jsxs)(_reactBootstrap.ListGroup.Item, {
395
+ className: "d-flex justify-content-between align-items-start",
396
+ children: [this.displaySelection(sel.split(",")), this.countGroupTools(sel.split(",")), /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactBootstrap.Button, {
397
+ variant: "outline-secondary",
398
+ size: "sm",
399
+ onClick: this.selectGroup(sel),
400
+ children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactBootstrapIcons.PencilSquare, {})
401
+ })]
402
+ }, sel))
403
+ })]
404
+ }) : "", /*#__PURE__*/(0, _jsxRuntime.jsxs)(_reactBootstrap.ButtonGroup, {
405
+ children: [/*#__PURE__*/(0, _jsxRuntime.jsx)(_reactBootstrap.OverlayTrigger, {
406
+ overlay: /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactBootstrap.Tooltip, {
407
+ children: "Save changes to this DecayTreeTuple"
408
+ }),
409
+ children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactBootstrap.Button, {
410
+ type: "submit",
411
+ onClick: this.sendData,
412
+ disabled: !this.state.updated,
413
+ children: "Save"
414
+ })
415
+ }), /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactBootstrap.OverlayTrigger, {
416
+ overlay: /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactBootstrap.Tooltip, {
417
+ children: "Discard changes to this DecayTreeTuple"
418
+ }),
419
+ children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactBootstrap.Button, {
420
+ variant: "outline-danger",
421
+ onClick: this.revertDTT,
422
+ disabled: !this.state.updated,
423
+ children: "Revert"
424
+ })
425
+ })]
426
+ })]
427
+ })]
428
+ });
429
+ }
430
+ }
431
+ _defineProperty(DecayTree, "contextType", _MetadataContext.default);
432
+ _defineProperty(DecayTree, "options", {
433
+ ..._config.default.dttGraphOptions,
434
+ nodes: {
435
+ // need to add a lambda to set the label hover-style
436
+ ..._config.default.dttGraphOptions.nodes,
437
+ chosen: {
438
+ label: (values, id, selected, _hovering) => {
439
+ if (selected) {
440
+ values.mod = "bold";
441
+ values.color = "#0d6efd";
442
+ }
443
+ }
444
+ }
445
+ }
446
+ });
447
+ DecayTree.propTypes = {
448
+ decay: _propTypes.default.object,
449
+ dttConfig: _propTypes.default.object,
450
+ parentCallback: _propTypes.default.func
451
+ };
452
+ var _default = exports.default = DecayTree;
@@ -0,0 +1,108 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.default = void 0;
7
+ require("../style/DecaysList.css");
8
+ var React = _interopRequireWildcard(require("react"));
9
+ var _propTypes = _interopRequireDefault(require("prop-types"));
10
+ var _reactInfiniteScrollComponent = _interopRequireDefault(require("react-infinite-scroll-component"));
11
+ var _DecayItem = _interopRequireDefault(require("./DecayItem"));
12
+ var _reactBootstrap = require("react-bootstrap");
13
+ var _config = _interopRequireDefault(require("../config"));
14
+ var _jsxRuntime = require("react/jsx-runtime");
15
+ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
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 && Object.prototype.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
+ function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
19
+ function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == typeof i ? i : String(i); }
20
+ 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); } /*****************************************************************************\
21
+ * (c) Copyright 2021 CERN for the benefit of the LHCb Collaboration *
22
+ * *
23
+ * This software is distributed under the terms of the GNU General Public *
24
+ * Licence version 3 (GPL Version 3), copied verbatim in the file "COPYING". *
25
+ * *
26
+ * In applying this licence, CERN does not waive the privileges and immunities *
27
+ * granted to it by virtue of its status as an Intergovernmental Organization *
28
+ * or submit itself to any jurisdiction. *
29
+ \*****************************************************************************/
30
+ class DecaysList extends React.Component {
31
+ constructor() {
32
+ super(...arguments);
33
+ _defineProperty(this, "state", {
34
+ items: this.props.decays.length > _config.default.batch_size ? this.props.decays.slice(0, _config.default.batch_size) : this.props.decays,
35
+ index: this.props.decays.length > _config.default.batch_size ? _config.default.batch_size - 1 : this.props.decays.length,
36
+ selectedDecays: this.props.selectedDecays
37
+ });
38
+ _defineProperty(this, "fetchMoreData", () => {
39
+ setTimeout(() => {
40
+ this.setState({
41
+ items: this.state.items.concat(this.props.decays.slice(this.state.index + 1, this.state.index + 1 + _config.default.batch_size)),
42
+ index: this.state.index + _config.default.batch_size < this.props.decays.length ? this.state.index + _config.default.batch_size : this.props.decays.length
43
+ });
44
+ }, 1000);
45
+ });
46
+ _defineProperty(this, "callbackFunction", childData => {
47
+ if (childData.selected) {
48
+ const index = this.state.selectedDecays.indexOf(childData.decay);
49
+ if (index > -1) {
50
+ this.state.selectedDecays.splice(index, 1);
51
+ }
52
+ } else {
53
+ this.state.selectedDecays.push(childData.decay);
54
+ }
55
+ this.props.parentCallback(this.state.selectedDecays);
56
+ });
57
+ _defineProperty(this, "getDecayItem", () => {
58
+ const strippingDecayItem = this.state.items.map(decay => /*#__PURE__*/(0, _jsxRuntime.jsx)(_DecayItem.default, {
59
+ decay: decay,
60
+ selected: this.state.selectedDecays.includes(decay),
61
+ parentCallback: this.callbackFunction
62
+ }, decay.descriptors.plain));
63
+ return strippingDecayItem;
64
+ });
65
+ }
66
+ render() {
67
+ const decayItem = this.getDecayItem();
68
+ const nShown = this.state.items.length;
69
+ const nTotal = this.props.decays.length;
70
+ if (nShown === 0) {
71
+ return /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactBootstrap.Alert, {
72
+ variant: "danger",
73
+ children: "No matching decays"
74
+ });
75
+ } else {
76
+ return /*#__PURE__*/(0, _jsxRuntime.jsxs)(_jsxRuntime.Fragment, {
77
+ children: [/*#__PURE__*/(0, _jsxRuntime.jsx)(_reactBootstrap.ListGroup, {
78
+ variant: "flush",
79
+ id: "scrollableDiv",
80
+ className: "decaysListClass",
81
+ children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactInfiniteScrollComponent.default, {
82
+ dataLength: nShown,
83
+ next: this.fetchMoreData,
84
+ hasMore: nShown < nTotal,
85
+ loader: /*#__PURE__*/(0, _jsxRuntime.jsxs)(_reactBootstrap.Alert, {
86
+ variant: "warning",
87
+ children: [/*#__PURE__*/(0, _jsxRuntime.jsx)(_reactBootstrap.Spinner, {
88
+ size: "sm",
89
+ animation: "border"
90
+ }), " Loading next", " ", Math.min(_config.default.batch_size, nTotal - nShown), " decays..."]
91
+ }),
92
+ scrollableTarget: "scrollableDiv",
93
+ children: decayItem
94
+ })
95
+ }), /*#__PURE__*/(0, _jsxRuntime.jsxs)(_reactBootstrap.Alert, {
96
+ variant: "light",
97
+ children: ["Showing ", nShown, " of ", nTotal, " matching decays"]
98
+ })]
99
+ });
100
+ }
101
+ }
102
+ }
103
+ DecaysList.propTypes = {
104
+ decays: _propTypes.default.arrayOf(_propTypes.default.object),
105
+ selectedDecays: _propTypes.default.arrayOf(_propTypes.default.object),
106
+ parentCallback: _propTypes.default.func
107
+ };
108
+ var _default = exports.default = DecaysList;
@@ -0,0 +1,56 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.default = void 0;
7
+ var _react = _interopRequireDefault(require("react"));
8
+ var _propTypes = _interopRequireDefault(require("prop-types"));
9
+ var _reactBootstrap = require("react-bootstrap");
10
+ var _reactBootstrapIcons = require("react-bootstrap-icons");
11
+ var _jsxRuntime = require("react/jsx-runtime");
12
+ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
13
+ /*****************************************************************************\
14
+ * (c) Copyright 2021-2022 CERN for the benefit of the LHCb Collaboration *
15
+ * *
16
+ * This software is distributed under the terms of the GNU General Public *
17
+ * Licence version 3 (GPL Version 3), copied verbatim in the file "COPYING". *
18
+ * *
19
+ * In applying this licence, CERN does not waive the privileges and immunities *
20
+ * granted to it by virtue of its status as an Intergovernmental Organization *
21
+ * or submit itself to any jurisdiction. *
22
+ \*****************************************************************************/
23
+
24
+ class DeleteButton extends _react.default.Component {
25
+ render() {
26
+ if (this.props.disabled) {
27
+ return null;
28
+ }
29
+ return /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactBootstrap.OverlayTrigger, {
30
+ trigger: "click",
31
+ placement: "right",
32
+ rootClose: true,
33
+ overlay: /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactBootstrap.Popover, {
34
+ children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactBootstrap.Popover.Body, {
35
+ children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactBootstrap.Button, {
36
+ variant: "danger",
37
+ onClick: this.props.action,
38
+ children: "Confirm"
39
+ })
40
+ })
41
+ }),
42
+ children: /*#__PURE__*/(0, _jsxRuntime.jsxs)(_reactBootstrap.Button, {
43
+ variant: this.props.outline ? "outline-danger" : "danger",
44
+ disabled: this.props.disabled,
45
+ children: [/*#__PURE__*/(0, _jsxRuntime.jsx)(_reactBootstrapIcons.Trash, {}), " ", this.props.children]
46
+ })
47
+ });
48
+ }
49
+ }
50
+ DeleteButton.propTypes = {
51
+ action: _propTypes.default.func,
52
+ outline: _propTypes.default.bool,
53
+ disabled: _propTypes.default.bool,
54
+ children: _propTypes.default.node
55
+ };
56
+ var _default = exports.default = DeleteButton;