lhcb-ntuple-wizard-test 1.3.3 → 2.0.0

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 (39) hide show
  1. package/README.md +1 -2
  2. package/package.json +42 -21
  3. package/dist/components/App.js +0 -99
  4. package/dist/components/ConfigDict.js +0 -103
  5. package/dist/components/ConfigList.js +0 -94
  6. package/dist/components/ConfigNode.js +0 -320
  7. package/dist/components/ConfigValue.js +0 -86
  8. package/dist/components/Dataset.js +0 -67
  9. package/dist/components/Decay.js +0 -50
  10. package/dist/components/DecayItem.js +0 -101
  11. package/dist/components/DecayTag.js +0 -52
  12. package/dist/components/DecayTree.js +0 -451
  13. package/dist/components/DecaysList.js +0 -107
  14. package/dist/components/DeleteButton.js +0 -56
  15. package/dist/components/DescriptorsSearch.js +0 -352
  16. package/dist/components/EventTypeBadge.js +0 -45
  17. package/dist/components/ItemSearch.js +0 -120
  18. package/dist/components/LinesTable.js +0 -1105
  19. package/dist/components/NtupleWizard.js +0 -142
  20. package/dist/components/ParticleTag.js +0 -54
  21. package/dist/components/PolarityBadge.js +0 -35
  22. package/dist/components/SearchItem.js +0 -99
  23. package/dist/components/SelectParticle.js +0 -61
  24. package/dist/components/SelectTag.js +0 -66
  25. package/dist/components/SelectTool.js +0 -59
  26. package/dist/components/SelectVariables.js +0 -106
  27. package/dist/components/StrippingBadge.js +0 -64
  28. package/dist/components/StrippingLine.js +0 -50
  29. package/dist/components/TupleTool.js +0 -46
  30. package/dist/components/VariablesSearch.js +0 -128
  31. package/dist/components/YearBadge.js +0 -35
  32. package/dist/config.json +0 -72
  33. package/dist/contexts/MetadataContext.js +0 -135
  34. package/dist/index.js +0 -20
  35. package/dist/lib/BKPath.js +0 -58
  36. package/dist/lib/DTTConfig.js +0 -178
  37. package/dist/lib/mathjax.js +0 -35
  38. package/dist/lib/utils.js +0 -191
  39. package/dist/style/DecaysList.css +0 -15
@@ -1,352 +0,0 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports.default = void 0;
7
- var _lodash = _interopRequireDefault(require("lodash.memoize"));
8
- var _propTypes = _interopRequireDefault(require("prop-types"));
9
- var _react = _interopRequireDefault(require("react"));
10
- var _reactBootstrap = require("react-bootstrap");
11
- var _reactRouterDom = require("react-router-dom");
12
- var _reactSelect = _interopRequireDefault(require("react-select"));
13
- var _MetadataContext = _interopRequireDefault(require("../contexts/MetadataContext"));
14
- var _DecaysList = _interopRequireDefault(require("./DecaysList"));
15
- var _SelectParticle = _interopRequireDefault(require("./SelectParticle"));
16
- var _SelectTag = _interopRequireDefault(require("./SelectTag"));
17
- var _jsxRuntime = require("react/jsx-runtime");
18
- function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
19
- 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; }
20
- 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; }
21
- 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; }
22
- function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == typeof i ? i : i + ""; }
23
- 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); } /*****************************************************************************\
24
- * (c) Copyright 2021 CERN for the benefit of the LHCb Collaboration *
25
- * *
26
- * This software is distributed under the terms of the GNU General Public *
27
- * Licence version 3 (GPL Version 3), copied verbatim in the file "COPYING". *
28
- * *
29
- * In applying this licence, CERN does not waive the privileges and immunities *
30
- * granted to it by virtue of its status as an Intergovernmental Organization *
31
- * or submit itself to any jurisdiction. *
32
- \*****************************************************************************/
33
- class DescriptorsSearch extends _react.default.Component {
34
- constructor() {
35
- super(...arguments);
36
- _defineProperty(this, "state", {
37
- selectedContains: [],
38
- selectedHead: null,
39
- selectedHeadTags: [],
40
- selectedDecays: this.props.rows.map(row => row.decay),
41
- selectedTags: null,
42
- selectedLine: null,
43
- chargeConjugateContains: true,
44
- chargeConjugateHeads: true,
45
- containsMatchType: "all",
46
- headMatchType: "exactly",
47
- tagMatchType: "none",
48
- headTagMatchType: "all",
49
- onlySelected: false
50
- });
51
- _defineProperty(this, "updateState", key => contents => {
52
- this.setState({
53
- [key]: contents
54
- });
55
- });
56
- _defineProperty(this, "toggleState", key => () => {
57
- this.setState({
58
- [key]: !this.state[key]
59
- });
60
- });
61
- _defineProperty(this, "callbackFunction", childData => {
62
- this.setState({
63
- selectedDecays: childData
64
- });
65
- });
66
- _defineProperty(this, "createRow", (decay, id) => {
67
- return Object({
68
- id: id,
69
- decay: decay,
70
- lines: [],
71
- paths: [],
72
- // Currently-selected paths
73
- pathOptions: [],
74
- // Keep a history of valid paths
75
- dtt: false
76
- });
77
- });
78
- _defineProperty(this, "sendData", () => {
79
- const selectedDecays = this.state.selectedDecays;
80
- const selectedDecayDescriptors = selectedDecays.map(decay => decay.descriptors.plain);
81
- // Loop through rows and remove any not-selected decays
82
- let rows = [...this.props.rows].filter(row => selectedDecayDescriptors.includes(row.decay.descriptors.plain));
83
- const existingDecayDescriptors = rows.map(row => row.decay.descriptors.plain);
84
- // Loop through selected decays and add any new rows
85
- const newDecays = selectedDecays.filter(decay => !existingDecayDescriptors.includes(decay.descriptors.plain));
86
- newDecays.forEach(decay => {
87
- const rowIDs = rows.map(row => row.id);
88
- let newRowID = 0;
89
- while (rowIDs.includes(newRowID)) {
90
- newRowID += 1;
91
- }
92
- rows.push(this.createRow(decay, newRowID));
93
- });
94
- this.props.parentCallback(rows.map(row => _objectSpread(_objectSpread({}, row), {}, {
95
- dtt: {
96
- config: row.dtt
97
- }
98
- }))); // callback expects row.dtt to be a DTTConfig
99
- });
100
- _defineProperty(this, "allStrippingLines", (0, _lodash.default)(() => {
101
- const allLines = [].concat(...Object.values(this.context.metadata.stripping).map(stream => Object.keys(stream)));
102
- const uniqueLines = new Set(allLines);
103
- return [...uniqueLines];
104
- }));
105
- _defineProperty(this, "filterDecays", selectedTags => {
106
- // XXX: selectedTags is passed as an arg because it's the only one with a non-empty default value.
107
- // the value depends on async-loaded metadata, and I don't know how to put it in the state.
108
- // TODO: can probably do some refactoring in here (cf variableMatch)
109
- let newDecays = Object.values(this.context.metadata.decays);
110
- if (this.state.selectedContains) {
111
- newDecays = newDecays.filter(decay => {
112
- const conditions = this.state.selectedContains.map(element => {
113
- const particle = element.value;
114
- const antiparticle = this.context.metadata.particleProperties[particle]["antiparticle"];
115
- return decay.descriptors.plain.includes(particle) || this.state.chargeConjugateContains && decay.descriptors.plain.includes(antiparticle);
116
- });
117
- return DescriptorsSearch.variableMatch(this.state.containsMatchType, conditions);
118
- });
119
- }
120
- if (this.state.headMatchType === "exactly") {
121
- if (this.state.selectedHead) {
122
- const particle = this.state.selectedHead.value;
123
- const antiparticle = this.context.metadata.particleProperties[particle]["antiparticle"];
124
- newDecays = newDecays.filter(decay => {
125
- const head = decay.descriptors.list[0];
126
- return head === particle || this.state.chargeConjugateHeads && head === antiparticle;
127
- });
128
- }
129
- } else if (this.state.headMatchType === "category") {
130
- if (this.state.selectedHeadTags) {
131
- newDecays = newDecays.filter(decay => {
132
- const conditions = this.state.selectedHeadTags.map(element => {
133
- const tag = element.value;
134
- const head = this.context.metadata.particleProperties[decay.descriptors.list[0]];
135
- return head.tags.includes(tag);
136
- });
137
- return DescriptorsSearch.variableMatch(this.state.headTagMatchType, conditions);
138
- });
139
- }
140
- }
141
- if (this.state.onlySelected) {
142
- newDecays = newDecays.filter(decay => this.state.selectedDecays.map(selectedDecay => selectedDecay.descriptors.plain).includes(decay.descriptors.plain));
143
- }
144
- if (selectedTags) {
145
- newDecays = newDecays.filter(decay => {
146
- const conditions = selectedTags.map(element => {
147
- const tag = element.value;
148
- return decay.tags.includes(tag);
149
- });
150
- return DescriptorsSearch.variableMatch(this.state.tagMatchType, conditions);
151
- });
152
- }
153
- if (this.state.selectedLine) {
154
- const line = this.state.selectedLine.value;
155
- newDecays = newDecays.filter(decay => {
156
- const decayStreamLines = Object.keys(decay.lines);
157
- const decayLines = new Set(decayStreamLines.map(streamLine => streamLine.split("/")[1]));
158
- return decayLines.has(line);
159
- });
160
- }
161
- return newDecays;
162
- });
163
- _defineProperty(this, "getDecayList", () => {
164
- const strippingSelectedTags = this.state.selectedTags !== null // If a value has been chosen by the user...
165
- ? this.state.selectedTags // ... then set according to the state.
166
- : this.context.loaded.userHints // Otherwise, if the metadata is loaded, set the default value...
167
- ? _SelectTag.default.createOptions(this.context.metadata.userHints.decayTags, tag => tag.hide) : []; // ... or empty if not loaded yet
168
- const filteredDecays = this.context.loaded.decays ? this.filterDecays(strippingSelectedTags) : [];
169
- const strippingDecayList = /*#__PURE__*/(0, _jsxRuntime.jsx)(_jsxRuntime.Fragment, {
170
- children: this.context.loaded.decays ? /*#__PURE__*/(0, _jsxRuntime.jsx)(_DecaysList.default, {
171
- decays: filteredDecays,
172
- selectedDecays: this.state.selectedDecays,
173
- parentCallback: this.callbackFunction
174
- }, JSON.stringify(filteredDecays)) : /*#__PURE__*/(0, _jsxRuntime.jsxs)(_reactBootstrap.Alert, {
175
- variant: "warning",
176
- children: [/*#__PURE__*/(0, _jsxRuntime.jsx)(_reactBootstrap.Spinner, {
177
- size: "sm",
178
- animation: "border"
179
- }), " Loading decays..."]
180
- })
181
- });
182
- return strippingDecayList;
183
- });
184
- _defineProperty(this, "getExtraInputs", () => {
185
- const strippingSelectedTags = this.state.selectedTags !== null // If a value has been chosen by the user...
186
- ? this.state.selectedTags // ... then set according to the state.
187
- : this.context.loaded.userHints // Otherwise, if the metadata is loaded, set the default value...
188
- ? _SelectTag.default.createOptions(this.context.metadata.userHints.decayTags, tag => tag.hide) : []; // ... or empty if not loaded yet
189
- const strippingExtraInput = /*#__PURE__*/(0, _jsxRuntime.jsx)(_jsxRuntime.Fragment, {
190
- children: /*#__PURE__*/(0, _jsxRuntime.jsxs)(_reactBootstrap.InputGroup, {
191
- size: "sm",
192
- children: [/*#__PURE__*/(0, _jsxRuntime.jsx)(_reactBootstrap.DropdownButton, {
193
- title: "Tags (" + this.state.tagMatchType + " of):",
194
- variant: "outline-secondary",
195
- children: /*#__PURE__*/(0, _jsxRuntime.jsx)(DescriptorsSearch.DropdownMatchTypes, {
196
- parent: this,
197
- stateItem: "tagMatchType",
198
- options: ["any", "all", "none"]
199
- })
200
- }), /*#__PURE__*/(0, _jsxRuntime.jsx)(_SelectTag.default, {
201
- isMulti: true,
202
- type: "decayTags",
203
- placeholder: "Decay tags",
204
- value: strippingSelectedTags,
205
- onChange: this.updateState("selectedTags"),
206
- closeMenuOnSelect: false
207
- }), /*#__PURE__*/(0, _jsxRuntime.jsx)("div", {
208
- className: "react-select form-control p-0",
209
- children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactSelect.default, {
210
- placeholder: "Stripping line",
211
- isClearable: true,
212
- options: this.context.loaded.stripping ? this.allStrippingLines().map(line => Object({
213
- value: line,
214
- label: line
215
- })) : [],
216
- onChange: this.updateState("selectedLine"),
217
- isLoading: !this.context.loaded.stripping
218
- })
219
- })]
220
- })
221
- });
222
- return strippingExtraInput;
223
- });
224
- }
225
- static DropdownMatchTypes(props) {
226
- return /*#__PURE__*/(0, _jsxRuntime.jsx)(_jsxRuntime.Fragment, {
227
- children: props.options.map(option => /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactBootstrap.Dropdown.Item, {
228
- active: props.parent.state[props.stateItem] === option,
229
- onClick: () => props.parent.setState({
230
- [props.stateItem]: option
231
- }),
232
- children: option
233
- }, option))
234
- });
235
- }
236
- static DropdownChargeConjugate(props) {
237
- return /*#__PURE__*/(0, _jsxRuntime.jsxs)(_jsxRuntime.Fragment, {
238
- children: [/*#__PURE__*/(0, _jsxRuntime.jsx)(_reactBootstrap.Dropdown.Item, {
239
- active: props.parent.state[props.stateItem],
240
- onClick: () => props.parent.setState({
241
- [props.stateItem]: true
242
- }),
243
- children: "Include antiparticles"
244
- }), /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactBootstrap.Dropdown.Item, {
245
- active: !props.parent.state[props.stateItem],
246
- onClick: () => props.parent.setState({
247
- [props.stateItem]: false
248
- }),
249
- children: "Exclude antiparticles"
250
- })]
251
- });
252
- }
253
- render() {
254
- const nSelected = this.state.selectedDecays.length;
255
- const {
256
- basePath
257
- } = this.props;
258
- const decayList = this.getDecayList();
259
- const extraInputs = this.getExtraInputs();
260
- return /*#__PURE__*/(0, _jsxRuntime.jsxs)(_jsxRuntime.Fragment, {
261
- children: [/*#__PURE__*/(0, _jsxRuntime.jsx)("h3", {
262
- children: "Decay search"
263
- }), /*#__PURE__*/(0, _jsxRuntime.jsxs)(_reactBootstrap.InputGroup, {
264
- size: "sm",
265
- children: [/*#__PURE__*/(0, _jsxRuntime.jsxs)(_reactBootstrap.DropdownButton, {
266
- title: "Head (" + (this.state.headMatchType === "exactly" ? this.state.headMatchType : this.state.headTagMatchType + " of") + "):",
267
- variant: "outline-secondary",
268
- children: [/*#__PURE__*/(0, _jsxRuntime.jsx)(DescriptorsSearch.DropdownMatchTypes, {
269
- parent: this,
270
- stateItem: "headMatchType",
271
- options: ["exactly", "category"]
272
- }), /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactBootstrap.Dropdown.Divider, {}), this.state.headMatchType === "exactly" ? /*#__PURE__*/(0, _jsxRuntime.jsx)(DescriptorsSearch.DropdownChargeConjugate, {
273
- parent: this,
274
- stateItem: "chargeConjugateHeads"
275
- }) : /*#__PURE__*/(0, _jsxRuntime.jsx)(DescriptorsSearch.DropdownMatchTypes, {
276
- parent: this,
277
- stateItem: "headTagMatchType",
278
- options: ["any", "all", "none"]
279
- })]
280
- }), this.state.headMatchType === "exactly" ? /*#__PURE__*/(0, _jsxRuntime.jsx)(_SelectParticle.default, {
281
- isClearable: true,
282
- onlyHeads: true,
283
- placeholder: "Decay head",
284
- onChange: this.updateState("selectedHead")
285
- }) : /*#__PURE__*/(0, _jsxRuntime.jsx)(_SelectTag.default, {
286
- isMulti: true,
287
- type: "particleTags",
288
- placeholder: "Decay head",
289
- filter: tag => !tag.hide,
290
- onChange: this.updateState("selectedHeadTags")
291
- }), /*#__PURE__*/(0, _jsxRuntime.jsxs)(_reactBootstrap.DropdownButton, {
292
- title: "Contains (" + this.state.containsMatchType + " of):",
293
- variant: "outline-secondary",
294
- children: [/*#__PURE__*/(0, _jsxRuntime.jsx)(DescriptorsSearch.DropdownMatchTypes, {
295
- parent: this,
296
- stateItem: "containsMatchType",
297
- options: ["any", "all", "none"]
298
- }), /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactBootstrap.Dropdown.Divider, {}), /*#__PURE__*/(0, _jsxRuntime.jsx)(DescriptorsSearch.DropdownChargeConjugate, {
299
- parent: this,
300
- stateItem: "chargeConjugateContains"
301
- })]
302
- }), /*#__PURE__*/(0, _jsxRuntime.jsx)(_SelectParticle.default, {
303
- isMulti: true,
304
- onlyKnown: true,
305
- placeholder: "Particles in decay...",
306
- onChange: this.updateState("selectedContains"),
307
- closeMenuOnSelect: false
308
- }), /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactBootstrap.InputGroup.Text, {
309
- children: "Show only selected:"
310
- }), /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactBootstrap.InputGroup.Checkbox, {
311
- onChange: this.toggleState("onlySelected")
312
- })]
313
- }), extraInputs, decayList, /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactRouterDom.Link, {
314
- to: basePath,
315
- children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactBootstrap.OverlayTrigger, {
316
- overlay: /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactBootstrap.Tooltip, {
317
- children: "Return to production configuration"
318
- }),
319
- children: /*#__PURE__*/(0, _jsxRuntime.jsxs)(_reactBootstrap.Button, {
320
- variant: "success",
321
- type: "submit",
322
- onClick: this.sendData,
323
- children: ["Select ", /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactBootstrap.Badge, {
324
- pill: true,
325
- bg: "secondary",
326
- children: nSelected
327
- })]
328
- })
329
- })
330
- })]
331
- });
332
- }
333
- }
334
- _defineProperty(DescriptorsSearch, "contextType", _MetadataContext.default);
335
- _defineProperty(DescriptorsSearch, "variableMatch", (type, conditions) => {
336
- if (type === "all") {
337
- return conditions.every(x => x);
338
- } else if (type === "any") {
339
- return conditions.some(x => x);
340
- } else if (type === "none") {
341
- return !conditions.some(x => x);
342
- } else {
343
- console.error("Unrecognised match type: " + type);
344
- return true;
345
- }
346
- });
347
- DescriptorsSearch.propTypes = {
348
- rows: _propTypes.default.arrayOf(_propTypes.default.object),
349
- parentCallback: _propTypes.default.func,
350
- basePath: _propTypes.default.string.isRequired
351
- };
352
- var _default = exports.default = DescriptorsSearch;
@@ -1,45 +0,0 @@
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 _jsxRuntime = require("react/jsx-runtime");
11
- function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
12
- 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; }
13
- 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; }
14
- 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; }
15
- function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == typeof i ? i : i + ""; }
16
- 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); } /*****************************************************************************\
17
- * (c) Copyright 2021 CERN for the benefit of the LHCb Collaboration *
18
- * *
19
- * This software is distributed under the terms of the GNU General Public *
20
- * Licence version 3 (GPL Version 3), copied verbatim in the file "COPYING". *
21
- * *
22
- * In applying this licence, CERN does not waive the privileges and immunities *
23
- * granted to it by virtue of its status as an Intergovernmental Organization *
24
- * or submit itself to any jurisdiction. *
25
- \*****************************************************************************/
26
- class EventTypeBadge extends _react.default.Component {
27
- render() {
28
- const content = "" + this.props.eventType === "90000000" ? "Data" : "" + this.props.eventType;
29
- const linkProps = content === "Data" ? {} : {
30
- as: "a",
31
- href: "http://lhcbdoc.web.cern.ch/lhcbdoc/decfiles/",
32
- target: "_blank"
33
- };
34
- return /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactBootstrap.Badge, _objectSpread(_objectSpread({
35
- pill: true
36
- }, linkProps), {}, {
37
- bg: "primary",
38
- children: content
39
- }));
40
- }
41
- }
42
- EventTypeBadge.propTypes = {
43
- eventType: _propTypes.default.string
44
- };
45
- var _default = exports.default = EventTypeBadge;
@@ -1,120 +0,0 @@
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 _Tooltip = _interopRequireDefault(require("react-bootstrap/Tooltip"));
10
- var _OverlayTrigger = _interopRequireDefault(require("react-bootstrap/OverlayTrigger"));
11
- var _jsxRuntime = require("react/jsx-runtime");
12
- function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
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); } /*****************************************************************************\
18
- * (c) Copyright 2021 CERN for the benefit of the LHCb Collaboration *
19
- * *
20
- * This software is distributed under the terms of the GNU General Public *
21
- * Licence version 3 (GPL Version 3), copied verbatim in the file "COPYING". *
22
- * *
23
- * In applying this licence, CERN does not waive the privileges and immunities *
24
- * granted to it by virtue of its status as an Intergovernmental Organization *
25
- * or submit itself to any jurisdiction. *
26
- \*****************************************************************************/
27
- const {
28
- search
29
- } = window.location;
30
- const query = new URLSearchParams(search).get("s");
31
- //const [searchQuery, setSearchQuery] = useState(query || '')
32
-
33
- function compare(a, b) {
34
- return Object.keys(a)[0] > Object.keys(b)[0] ? 1 : Object.keys(a)[0] < Object.keys(b)[0] ? -1 : 0;
35
- }
36
- class ItemSearch extends _react.default.Component {
37
- constructor() {
38
- super(...arguments);
39
- _defineProperty(this, "state", {
40
- items: this.props.data,
41
- label: this.props.label,
42
- searchQuery: query || ""
43
- });
44
- }
45
- filterItems(variables, query) {
46
- /*
47
- const nInclOptions = variables.filter(
48
- variable => !Object.keys(variable)[0].toLowerCase().includes(query.toLowerCase())
49
- );
50
- */
51
- const inclOptions = variables.filter(variable => Object.keys(variable)[0].toLowerCase().includes(query.toLowerCase()) && Object.keys(variable)[0].toLowerCase() !== query.toLowerCase());
52
- const matchedOptions = variables.filter(variable => Object.keys(variable)[0].toLowerCase() === query.toLowerCase());
53
- const orderedNewOptions = matchedOptions.sort(compare);
54
- //this.setState({
55
- return orderedNewOptions.concat(inclOptions);
56
- //});
57
- /* if (!query) {
58
- return variables;
59
- }
60
- return variables.filter((variable) => {
61
- const name = Object.keys(variable)[0].toLowerCase();
62
- return name.includes(query.toLowerCase());
63
- });*/
64
- }
65
- render() {
66
- //const {decay} = this.props
67
- const filteredItems = this.filterItems(this.state.items, this.state.searchQuery);
68
- return /*#__PURE__*/(0, _jsxRuntime.jsxs)(_jsxRuntime.Fragment, {
69
- children: [/*#__PURE__*/(0, _jsxRuntime.jsxs)("form", {
70
- action: "/",
71
- method: "get",
72
- children: [/*#__PURE__*/(0, _jsxRuntime.jsx)("label", {
73
- htmlFor: "header-search",
74
- children: /*#__PURE__*/(0, _jsxRuntime.jsx)("span", {
75
- className: "visually-hidden",
76
- children: "Search item"
77
- })
78
- }), /*#__PURE__*/(0, _jsxRuntime.jsx)("input", {
79
- value: this.state.searchQuery,
80
- onInput: e => this.setState({
81
- searchQuery: e.target.value
82
- }),
83
- type: "text",
84
- id: "header-search",
85
- placeholder: this.state.label,
86
- name: "s"
87
- })]
88
- }), /*#__PURE__*/(0, _jsxRuntime.jsx)("div", {
89
- className: "scroll",
90
- children: /*#__PURE__*/(0, _jsxRuntime.jsx)("ul", {
91
- children: filteredItems.map((variable, index) => /*#__PURE__*/(0, _jsxRuntime.jsx)(_OverlayTrigger.default, {
92
- placement: "top",
93
- delay: {
94
- hide: 450,
95
- show: 300
96
- },
97
- overlay: props => /*#__PURE__*/(0, _jsxRuntime.jsx)(_Tooltip.default, _objectSpread(_objectSpread({}, props), {}, {
98
- children: Object.values(variable)[0]
99
- })),
100
- children: /*#__PURE__*/(0, _jsxRuntime.jsx)("p", {
101
- children: Object.keys(variable)[0]
102
- })
103
- }, index))
104
- })
105
- })]
106
- });
107
- }
108
- }
109
- ItemSearch.propTypes = {
110
- data: _propTypes.default.arrayOf(_propTypes.default.object),
111
- label: _propTypes.default.string
112
- };
113
- var _default = exports.default = ItemSearch;
114
- /* <div>
115
- <ul>
116
- {filteredVariables.map(variable => (
117
- <li key={Object.keys(variable)[0]}>{Object.keys(variable)[0]}</li>
118
- ))}
119
- </ul>
120
- </div> */