@qualtrics/plugin-ui-react 1.4.0-alpha.0 → 1.4.0-alpha.11

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 (59) hide show
  1. package/.eslintignore +3 -0
  2. package/CHANGELOG.md +20 -0
  3. package/dist/common/capture-event/capture-event.d.ts +10 -6
  4. package/dist/common/field-mapper/field-mapper-key/field-mapper-key.d.ts +4 -3
  5. package/dist/common/field-mapper/field-mapper-row/field-mapper-row.d.ts +3 -4
  6. package/dist/common/field-mapper/field-mapper-value/field-mapper-value.d.ts +7 -3
  7. package/dist/common/field-mapper/field-mapper.d.ts +3 -5
  8. package/dist/common/piped-text-select/piped-text-menu/embedded-data-menu/embedded-data-input/embedded-data-input.d.ts +10 -0
  9. package/dist/common/piped-text-select/piped-text-menu/embedded-data-menu/embedded-data-menu.d.ts +15 -2
  10. package/dist/common/piped-text-select/piped-text-menu/piped-text-menu-item/piped-text-menu-item.d.ts +10 -7
  11. package/dist/common/piped-text-select/piped-text-menu/piped-text-menu-item-service.d.ts +7 -0
  12. package/dist/common/piped-text-select/piped-text-menu/piped-text-menu-keyboard-ctrl.d.ts +27 -0
  13. package/dist/common/piped-text-select/piped-text-menu/piped-text-menu-list/piped-text-menu-list.d.ts +24 -0
  14. package/dist/common/piped-text-select/piped-text-menu/piped-text-menu-list/piped-text-menu-load-error/piped-text-menu-load-error.d.ts +7 -0
  15. package/dist/common/piped-text-select/piped-text-menu/piped-text-menu-list/piped-text-search-input/piped-text-search-input.d.ts +10 -0
  16. package/dist/common/piped-text-select/piped-text-menu/piped-text-menu.d.ts +26 -4
  17. package/dist/common/piped-text-select/piped-text-menu/piped-text-submenu-item/piped-text-submenu-item.d.ts +7 -4
  18. package/dist/common/popover/popover-options.d.ts +3 -0
  19. package/dist/index.d.ts +1 -0
  20. package/dist/index.es.js +48 -0
  21. package/dist/index.js +48 -0
  22. package/dist/lib/merge-refs.d.ts +2 -0
  23. package/package.json +35 -33
  24. package/tsconfig.json +7 -1
  25. package/.dockerignore +0 -10
  26. package/Dockerfile +0 -18
  27. package/Makefile +0 -33
  28. package/dist/common/capture-event/capture-event.test.d.ts +0 -1
  29. package/dist/common/copy-text/copy-text.test.d.ts +0 -1
  30. package/dist/common/dynamic-search-input/dynamic-search-input.d.ts +0 -1
  31. package/dist/common/dynamic-search-input/dynamic-search-input.test.d.ts +0 -1
  32. package/dist/common/event-registry.d.ts +0 -9
  33. package/dist/common/language-service.d.ts +0 -1
  34. package/dist/common/multiselect-dropdown/multiselect-dropdown.d.ts +0 -1
  35. package/dist/common/multiselect-dropdown/multiselect-dropdown.test.d.ts +0 -1
  36. package/dist/common/multiselect-dropdown/select-item/select-item.d.ts +0 -1
  37. package/dist/common/multiselect-dropdown/select-item/select-item.test.d.ts +0 -1
  38. package/dist/common/piped-text-input/piped-text-input.test.d.ts +0 -1
  39. package/dist/common/piped-text-select/piped-text-select.d.ts +0 -1
  40. package/dist/common/piped-text-select/piped-text-select.test.d.ts +0 -1
  41. package/dist/common/plugin-sdk-service.d.ts +0 -5
  42. package/dist/common/popover/popover.d.ts +0 -1
  43. package/dist/common/portal.d.ts +0 -10
  44. package/dist/common/task-fields/field-item/field-item.d.ts +0 -1
  45. package/dist/common/task-fields/field-item/field-item.test.d.ts +0 -1
  46. package/dist/common/task-fields/field-row/field-row.d.ts +0 -1
  47. package/dist/common/task-fields/field-row/field-row.test.d.ts +0 -1
  48. package/dist/common/task-fields/task-fields.d.ts +0 -1
  49. package/dist/common/task-fields/task-fields.test.d.ts +0 -1
  50. package/dist/main.es.js +0 -3126
  51. package/dist/main.js +0 -3154
  52. package/dist/plugin-app/example-data.d.ts +0 -102
  53. package/dist/plugin-app/plugin-app.d.ts +0 -1
  54. package/jenkins.groovy +0 -284
  55. package/jenkinsPipelineUtils/jira.groovy +0 -84
  56. package/jenkinsPipelineUtils/notifications.groovy +0 -34
  57. package/jenkinsPipelineUtils/pipelineControls.groovy +0 -56
  58. package/jenkinsPipelineUtils/trs.groovy +0 -30
  59. package/test_results/junit.xml +0 -101
package/dist/main.es.js DELETED
@@ -1,3126 +0,0 @@
1
- /*! @license @qualtrics/plugin-ui-react 1.4.0-alpha.0
2
- Qualtrics Software License Agreement
3
-
4
- 1. General.
5
- 1.1 Introduction. The software, programs, files, and/or code provided to you hereunder (collectively, the ?Software?) is hereby licensed to you subject to the terms of this License Agreement (this ?Agreement?). This Agreement forms a legally binding contract between you and Qualtrics, LLC (?Qualtrics?) in relation to your use of the Software. This Agreement relates solely to the Software provided under this Agreement and does not extend to, or provide any rights in connection with, any other products or services, including without limitation Qualtrics? software-as-a-service offerings and related services and products provided by Qualtrics to you or third parties (collectively, the ?Qualtrics Services?).
6
- 1.2 Acceptance of Agreement. By accessing or using the Software, you acknowledge and agree to all of the terms and conditions of this Agreement. You may not access or use the Software if you do not accept this Agreement. You may not use the Software and may not accept this Agreement if you are a person barred from receiving the Software under the laws or regulations of the United States or other countries, including the country in which you are resident or from which you use the Software. If you are agreeing to be bound by this Agreement on behalf of your employer or other organization, you represent and warrant that you have full legal authority to bind your employer or such organization to this Agreement. If you do not have the requisite authority, you may not accept this Agreement or use the Software on behalf of your employer or organization.
7
-
8
- 2. License and Use.
9
- 2.1 Grant of License. Subject to the terms of this Agreement, Qualtrics grants you a limited, worldwide, royalty-free, non-assignable, non-exclusive, non-sublicensable, and revocable license to use the Software solely to interface or interact with, or to develop applications that interface or interact with, the Qualtrics Services. Qualtrics reserves the right to revoke this license at any time for any reason.
10
- 2.2 Acceptable Use. You may not use the Software for any purpose not expressly permitted by this Agreement. You may not use the Software in connection with any activity, including the development or distribution of an application, that interferes with, disrupts, damages, or accesses in an unauthorized manner the servers, networks, or other properties or services of Qualtrics or any third party. Except to the extent explicitly authorized by the Software or as otherwise required by applicable third party licenses, you may not copy (except for routine backup purposes), modify, adapt, redistribute, decompile, reverse engineer, disassemble, or create derivative works of the Software or any part of the Software. You agree to use the Software only for purposes that are permitted by (a) this Agreement and (b) any applicable law, regulation or generally accepted practices or guidelines in the relevant jurisdictions (including any laws regarding the export of data or software to and from the United States or other relevant countries). You may not use this Software in connection with applications that are competitive with or disparaging toward Qualtrics or Qualtrics Services or that interface or interact with products or services that are competitive with Qualtrics Services.
11
- 2.3 Responsibility for Use. You agree that you are solely responsible for (and that Qualtrics has no responsibility to you or to any third party for) any data, content, or resources that you create, transmit or display and for the consequences of your actions (including any loss or damage which Qualtrics may suffer) by doing so. You agree that you are solely responsible for (and that Qualtrics has no responsibility to you or to any third party for) any breach of your obligations under this Agreement, any applicable third party contract or terms of service, or any applicable law or regulation, and for the consequences (including any loss or damage that Qualtrics or any third party may suffer) of any such breach.
12
-
13
- 3 IP Ownership.
14
- 3.1 Qualtrics IP. You agree that as between you and Qualtrics, Qualtrics owns all legal right, title and interest in and to the Software and related materials, including any Intellectual Property Rights in the Software. Qualtrics reserves all rights not expressly granted to you. As used herein, ?Intellectual Property Rights? means any and all rights under patent law, copyright law, trade secret law, trademark law, and/or any other intellectual property or proprietary rights.
15
- 3.2 Your IP. Subject to the preceding subsection and other terms of this Agreement, Qualtrics agrees that it obtains no right, title or interest from you (or your licensors) under this Agreement in or to any software applications that you develop using the Software, including any Intellectual Property Rights in those applications.
16
- 3.3 Trademarks. Nothing in this Agreement gives you a right to use any of Qualtrics? trade names, trademarks, service marks, logos, domain names, or other distinctive brand features. You agree that you will not remove, obscure, or alter any proprietary rights notices (including copyright and trademark notices) that may be affixed to or contained within the Software.
17
- 3.4 Open Source. Use, reproduction and distribution of components of the Software licensed under an open source software license, if any, are governed solely by the terms of the applicable open source software license.
18
-
19
- 4. Privacy and Information.
20
- 4.1 Your Privacy Responsibilities. You agree that if you use the Software to develop applications for users, you will protect the privacy and legal rights of those users. If you use any Software or Qualtrics Service to retrieve a user?s data, you acknowledge and agree that you will retrieve data only with the user?s consent and in accordance with applicable laws. If your application stores personal or sensitive information provided by users, it must do so securely and in accordance with applicable law. If a user provides your application with Qualtrics account information, your application may only use that information to access the user?s Qualtrics account when, and for the limited purposes for which, the user has given you permission to do so.
21
- 4.2 Qualtrics Privacy Responsibilities. In order to innovate on and improve the Software, Qualtrics may collect certain usage information and statistics from your use of thereof. The data collected will be anonymized and/or maintained in accordance with the Qualtrics Privacy Statement available online.
22
-
23
- 5. Term
24
- 5.1 Term; Termination. This Agreement will commence on the earlier of when you click through to accept its terms or when you access or use the Software. This Agreement will continue in effect until terminated by either you or Qualtrics. You may terminate this Agreement at any time by ceasing to access and use the Software and returning or destroying all copies and portions of the Software and related materials. Qualtrics may terminate this Agreement at any time by ceasing to make the Software available to you or by providing notice of termination to you in any reasonable form.
25
- 5.2 Effect of Termination. Upon termination of this Agreement for any reason, all of your rights hereunder will immediately terminate, and you must immediately cease to access and use the Software and return or destroy all copies and portions of the Software and related materials. Sectionsˇ3, 5, 6, 7, 8, 9, and 10 will survive indefinitely notwithstanding the termination of this Agreement.
26
-
27
- 6. DISCLAIMER OF WARRANTIES. YOU EXPRESSLY UNDERSTAND AND AGREE THAT YOUR USE OF THE SOFTWARE AND ANY MATERIAL DOWNLOADED OR OTHERWISE OBTAINED IN CONNECTION WITH USE OF THE SOFTWARE IS AT YOUR OWN DISCRETION AND AT YOUR SOLE RISK. YOU ARE SOLELY RESPONSIBLE FOR ANY DAMAGE TO YOUR COMPUTER SYSTEM OR OTHER DEVICE OR LOSS OF DATA THAT RESULTS FORM SUCH USE. THE SOFTWARE IS PROVIDED ?AS IS? AND ?AS AVAILABLE? WITHOUT WARRANTY OF ANY KIND FROM QUALTRICS OR ANY OTHER PERSON. QUALTRICS EXPRESSLY DISCLAIMS ALL REPRESENTATIONS, WARRANTIES AND CONDITIONS OF ANY KIND, WHETHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO ANY IMPLIED WARRANTIES AND CONDITIONS OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, AND NON-INFRINGEMENT.
28
-
29
- 7. LIMITATION OF LIABILITY. YOU EXPRESSLY UNDERSTAND AND AGREE THAT NEITHER QUALTRICS NOR ITS AFFILIATES NOR THEIR RESPECTIVE DIRECTORS, OFFICERS, EMPLOYEES, OR AGENTS SHALL BE LIABLE TO YOU UNDER ANY THEORY OF LIABILITY FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, CONSEQUENTIAL OR EXEMPLARY DAMAGES THAT MAY BE INCURRED BY YOU ARISING FROM OR RELATING TO THE SOFTWARE OR THIS AGREEMENT, INCLUDING WITHOUT LIMITATION ANY LOSS OF DATA, WHETHER OR NOT QUALTRICS OR ITS REPRESENTATIVES HAVE BEEN ADVISED OF OR SHOULD HAVE BEEN AWARE OF THE POSSIBILITY OF ANY SUCH LOSSES ARISING.
30
-
31
- 8. Indemnification. To the maximum extent permitted by law, you agree to defend, indemnify and hold harmless Qualtrics, its affiliates and their respective directors, officers, employees and agents from and against any and all claims, actions, suits or proceedings, as well as any and all losses, liabilities, damages, costs and expenses (including reasonable attorneys? fees) arising out of or relating to (a) your use of the Software, (b) any application or work you develop with the Software that infringes any Intellectual Property Right of any person or defames any person or violates their rights of publicity or privacy, and/or (c) any breach or non-compliance by you of this Agreement.
32
-
33
- 9. Modification.
34
- 9.1 Modification of Software. You understand and agree that the substance, form, and nature of the Software that Qualtrics provides may change without prior notice to you and that future versions of the Software may be incompatible with applications developed on previous versions of the Software. You agree that Qualtrics may stop (permanently or temporarily) providing the Software or any features within the Software to you or to users generally at Qualtrics? sole discretion, without prior notice to you.
35
- 9.2 Modification of Agreement. Qualtrics may modify this Agreement at any time by posting a revised version or by providing notice to you in any reasonable form. The modified Agreement will become effective immediately upon such posting or notification. By continuing to use the Software after the effective date of any modifications to this Agreement, you agree to be bound by the modified terms. It is your responsibility to check the online location of this Agreement regularly for modifications. Qualtrics last modified this Agreement on the date listed at the end of this Agreement.
36
-
37
- 10. Miscellaneous
38
- 10.1 Export Restrictions. The Software may be subject to United States export laws and regulations. You acknowledge and agree that you will comply with all domestic and international export laws and regulations that apply to the Software. These laws include restrictions on destinations, end users, and end use.
39
- 10.2 Waiver. You agree that if Qualtrics does not exercise or enforce any legal right or remedy that is contained in this Agreement (or that Qualtrics has the benefit of under any applicable law), then this will not result in a waiver of Qualtrics? rights and those rights or remedies will still be available to Qualtrics.
40
- 10.3 Severability. If any court of law rules that any provision of this Agreement is invalid, then that provision will be removed from this Agreement without affecting the rest of this Agreement. The remaining provisions of this Agreement will continue to be valid and enforceable to the maximum extent possible under applicable law.
41
- 10.4 Third-Party Beneficiaries. You acknowledge and agree that each of Qualtrics? affiliates is a third-party beneficiary to this Agreement and shall be entitled to directly enforce, and rely upon, any provision of this Agreement that confers a benefit on (or rights in favor of) it. Other than this, no other person or company shall be third party beneficiaries to this Agreement.
42
- 10.5 Assignment. You may not assign, delegate, or transfer this Agreement or your rights, duties, or obligations under this Agreement without the prior written consent of Qualtrics. Qualtrics may freely assign this Agreement or its rights, duties, or obligations hereunder, without consent, including without limitation in the event of a merger, acquisition, corporate reorganization, or sale of all or substantially all of its assets.
43
- 10.6 Choice of Law; Jurisdiction. This Agreement, and your relationship with Qualtrics under this Agreement, shall be governed by the laws of the State of Utah without regard to its conflict of laws provisions. You and Qualtrics agree to submit to the exclusive jurisdiction of the courts located within Salt Lake County, Utah to resolve any legal matter arising from this Agreement. Notwithstanding the foregoing, you agree that Qualtrics shall still be allowed to apply for injunctive remedies (or an equivalent type of urgent legal relief) in any jurisdiction.
44
- 10.7 Headings; Entire Agreement. The headings contained in this Agreement are for convenience only and shall not be interpreted to limit or otherwise affect any provision of this Agreement. This Agreement constitutes the entire agreement between you and Qualtrics in relation to the Software. This Agreement completely replaces and supersedes any prior agreements between you and Qualtrics in relation to the Software. For the avoidance of doubt, and if applicable, your general use of Qualtrics Services will continue to be governed by the applicable, separate agreement between Qualtrics and you or your organization.
45
-
46
- Last updated August 28, 2019
47
- */
48
-
49
- import 'core-js/modules/es.object.to-string.js';
50
- import 'core-js/modules/es.promise.js';
51
- import 'core-js/modules/es.object.keys.js';
52
- import 'core-js/modules/es.array.includes.js';
53
- import 'core-js/modules/es.string.includes.js';
54
- import 'core-js/modules/es.array.find-index.js';
55
- import 'core-js/modules/es.array.splice.js';
56
- import 'core-js/modules/es.array.for-each.js';
57
- import 'core-js/modules/web.dom-collections.for-each.js';
58
- import React, { Component, useState, useEffect, useRef, useCallback } from 'react';
59
- import _get from 'lodash.get';
60
- import { Button, InputGroup, Input, Icon, IconTypes, LoadingSpinner, IconButton, Tooltip, SelectMenu, MenuItem, Label, Dropdown, DropdownButton, DropdownList, DropdownOption } from '@qualtrics/ui-react';
61
- import { ErrorIcon, PipedTextIcon, RemoveItemIcon, CheckIcon, AddIcon } from '@qualtrics/ui-react/icons';
62
- import 'core-js/modules/es.string.anchor.js';
63
- import 'core-js/modules/es.array.filter.js';
64
- import 'core-js/modules/es.string.trim.js';
65
- import 'core-js/modules/es.array.map.js';
66
- import 'core-js/modules/es.array.concat.js';
67
- import _cloneDeep from 'lodash.clonedeep';
68
- import 'core-js/modules/es.array.is-array.js';
69
- import { Manager, Reference, Popper } from 'react-popper';
70
- import ReactDOM from 'react-dom';
71
- import 'core-js/modules/web.timers.js';
72
- import uuid, { v4 } from 'uuid';
73
- import 'core-js/modules/es.function.name.js';
74
- import 'core-js/modules/es.array.slice.js';
75
- import 'core-js/modules/es.array.iterator.js';
76
- import 'core-js/modules/web.dom-collections.iterator.js';
77
- import 'core-js/modules/es.array.find.js';
78
- import 'core-js/modules/es.object.assign.js';
79
- import _cloneDeepWith from 'lodash.clonedeepwith';
80
- import 'core-js/modules/es.regexp.exec.js';
81
- import 'core-js/modules/es.string.search.js';
82
-
83
- function styleInject(css, ref) {
84
- if ( ref === void 0 ) ref = {};
85
- var insertAt = ref.insertAt;
86
-
87
- if (!css || typeof document === 'undefined') { return; }
88
-
89
- var head = document.head || document.getElementsByTagName('head')[0];
90
- var style = document.createElement('style');
91
- style.type = 'text/css';
92
-
93
- if (insertAt === 'top') {
94
- if (head.firstChild) {
95
- head.insertBefore(style, head.firstChild);
96
- } else {
97
- head.appendChild(style);
98
- }
99
- } else {
100
- head.appendChild(style);
101
- }
102
-
103
- if (style.styleSheet) {
104
- style.styleSheet.cssText = css;
105
- } else {
106
- style.appendChild(document.createTextNode(css));
107
- }
108
- }
109
-
110
- var css_248z$j = ".react-app {\n background-color: RGBA(0, 0, 0, 0.1); }\n";
111
- styleInject(css_248z$j);
112
-
113
- function ownKeys(object, enumerableOnly) {
114
- var keys = Object.keys(object);
115
-
116
- if (Object.getOwnPropertySymbols) {
117
- var symbols = Object.getOwnPropertySymbols(object);
118
- enumerableOnly && (symbols = symbols.filter(function (sym) {
119
- return Object.getOwnPropertyDescriptor(object, sym).enumerable;
120
- })), keys.push.apply(keys, symbols);
121
- }
122
-
123
- return keys;
124
- }
125
-
126
- function _objectSpread2(target) {
127
- for (var i = 1; i < arguments.length; i++) {
128
- var source = null != arguments[i] ? arguments[i] : {};
129
- i % 2 ? ownKeys(Object(source), !0).forEach(function (key) {
130
- _defineProperty(target, key, source[key]);
131
- }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) {
132
- Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key));
133
- });
134
- }
135
-
136
- return target;
137
- }
138
-
139
- function _regeneratorRuntime() {
140
- /*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/facebook/regenerator/blob/main/LICENSE */
141
-
142
- _regeneratorRuntime = function () {
143
- return exports;
144
- };
145
-
146
- var exports = {},
147
- Op = Object.prototype,
148
- hasOwn = Op.hasOwnProperty,
149
- $Symbol = "function" == typeof Symbol ? Symbol : {},
150
- iteratorSymbol = $Symbol.iterator || "@@iterator",
151
- asyncIteratorSymbol = $Symbol.asyncIterator || "@@asyncIterator",
152
- toStringTagSymbol = $Symbol.toStringTag || "@@toStringTag";
153
-
154
- function define(obj, key, value) {
155
- return Object.defineProperty(obj, key, {
156
- value: value,
157
- enumerable: !0,
158
- configurable: !0,
159
- writable: !0
160
- }), obj[key];
161
- }
162
-
163
- try {
164
- define({}, "");
165
- } catch (err) {
166
- define = function (obj, key, value) {
167
- return obj[key] = value;
168
- };
169
- }
170
-
171
- function wrap(innerFn, outerFn, self, tryLocsList) {
172
- var protoGenerator = outerFn && outerFn.prototype instanceof Generator ? outerFn : Generator,
173
- generator = Object.create(protoGenerator.prototype),
174
- context = new Context(tryLocsList || []);
175
- return generator._invoke = function (innerFn, self, context) {
176
- var state = "suspendedStart";
177
- return function (method, arg) {
178
- if ("executing" === state) throw new Error("Generator is already running");
179
-
180
- if ("completed" === state) {
181
- if ("throw" === method) throw arg;
182
- return doneResult();
183
- }
184
-
185
- for (context.method = method, context.arg = arg;;) {
186
- var delegate = context.delegate;
187
-
188
- if (delegate) {
189
- var delegateResult = maybeInvokeDelegate(delegate, context);
190
-
191
- if (delegateResult) {
192
- if (delegateResult === ContinueSentinel) continue;
193
- return delegateResult;
194
- }
195
- }
196
-
197
- if ("next" === context.method) context.sent = context._sent = context.arg;else if ("throw" === context.method) {
198
- if ("suspendedStart" === state) throw state = "completed", context.arg;
199
- context.dispatchException(context.arg);
200
- } else "return" === context.method && context.abrupt("return", context.arg);
201
- state = "executing";
202
- var record = tryCatch(innerFn, self, context);
203
-
204
- if ("normal" === record.type) {
205
- if (state = context.done ? "completed" : "suspendedYield", record.arg === ContinueSentinel) continue;
206
- return {
207
- value: record.arg,
208
- done: context.done
209
- };
210
- }
211
-
212
- "throw" === record.type && (state = "completed", context.method = "throw", context.arg = record.arg);
213
- }
214
- };
215
- }(innerFn, self, context), generator;
216
- }
217
-
218
- function tryCatch(fn, obj, arg) {
219
- try {
220
- return {
221
- type: "normal",
222
- arg: fn.call(obj, arg)
223
- };
224
- } catch (err) {
225
- return {
226
- type: "throw",
227
- arg: err
228
- };
229
- }
230
- }
231
-
232
- exports.wrap = wrap;
233
- var ContinueSentinel = {};
234
-
235
- function Generator() {}
236
-
237
- function GeneratorFunction() {}
238
-
239
- function GeneratorFunctionPrototype() {}
240
-
241
- var IteratorPrototype = {};
242
- define(IteratorPrototype, iteratorSymbol, function () {
243
- return this;
244
- });
245
- var getProto = Object.getPrototypeOf,
246
- NativeIteratorPrototype = getProto && getProto(getProto(values([])));
247
- NativeIteratorPrototype && NativeIteratorPrototype !== Op && hasOwn.call(NativeIteratorPrototype, iteratorSymbol) && (IteratorPrototype = NativeIteratorPrototype);
248
- var Gp = GeneratorFunctionPrototype.prototype = Generator.prototype = Object.create(IteratorPrototype);
249
-
250
- function defineIteratorMethods(prototype) {
251
- ["next", "throw", "return"].forEach(function (method) {
252
- define(prototype, method, function (arg) {
253
- return this._invoke(method, arg);
254
- });
255
- });
256
- }
257
-
258
- function AsyncIterator(generator, PromiseImpl) {
259
- function invoke(method, arg, resolve, reject) {
260
- var record = tryCatch(generator[method], generator, arg);
261
-
262
- if ("throw" !== record.type) {
263
- var result = record.arg,
264
- value = result.value;
265
- return value && "object" == typeof value && hasOwn.call(value, "__await") ? PromiseImpl.resolve(value.__await).then(function (value) {
266
- invoke("next", value, resolve, reject);
267
- }, function (err) {
268
- invoke("throw", err, resolve, reject);
269
- }) : PromiseImpl.resolve(value).then(function (unwrapped) {
270
- result.value = unwrapped, resolve(result);
271
- }, function (error) {
272
- return invoke("throw", error, resolve, reject);
273
- });
274
- }
275
-
276
- reject(record.arg);
277
- }
278
-
279
- var previousPromise;
280
-
281
- this._invoke = function (method, arg) {
282
- function callInvokeWithMethodAndArg() {
283
- return new PromiseImpl(function (resolve, reject) {
284
- invoke(method, arg, resolve, reject);
285
- });
286
- }
287
-
288
- return previousPromise = previousPromise ? previousPromise.then(callInvokeWithMethodAndArg, callInvokeWithMethodAndArg) : callInvokeWithMethodAndArg();
289
- };
290
- }
291
-
292
- function maybeInvokeDelegate(delegate, context) {
293
- var method = delegate.iterator[context.method];
294
-
295
- if (undefined === method) {
296
- if (context.delegate = null, "throw" === context.method) {
297
- if (delegate.iterator.return && (context.method = "return", context.arg = undefined, maybeInvokeDelegate(delegate, context), "throw" === context.method)) return ContinueSentinel;
298
- context.method = "throw", context.arg = new TypeError("The iterator does not provide a 'throw' method");
299
- }
300
-
301
- return ContinueSentinel;
302
- }
303
-
304
- var record = tryCatch(method, delegate.iterator, context.arg);
305
- if ("throw" === record.type) return context.method = "throw", context.arg = record.arg, context.delegate = null, ContinueSentinel;
306
- var info = record.arg;
307
- return info ? info.done ? (context[delegate.resultName] = info.value, context.next = delegate.nextLoc, "return" !== context.method && (context.method = "next", context.arg = undefined), context.delegate = null, ContinueSentinel) : info : (context.method = "throw", context.arg = new TypeError("iterator result is not an object"), context.delegate = null, ContinueSentinel);
308
- }
309
-
310
- function pushTryEntry(locs) {
311
- var entry = {
312
- tryLoc: locs[0]
313
- };
314
- 1 in locs && (entry.catchLoc = locs[1]), 2 in locs && (entry.finallyLoc = locs[2], entry.afterLoc = locs[3]), this.tryEntries.push(entry);
315
- }
316
-
317
- function resetTryEntry(entry) {
318
- var record = entry.completion || {};
319
- record.type = "normal", delete record.arg, entry.completion = record;
320
- }
321
-
322
- function Context(tryLocsList) {
323
- this.tryEntries = [{
324
- tryLoc: "root"
325
- }], tryLocsList.forEach(pushTryEntry, this), this.reset(!0);
326
- }
327
-
328
- function values(iterable) {
329
- if (iterable) {
330
- var iteratorMethod = iterable[iteratorSymbol];
331
- if (iteratorMethod) return iteratorMethod.call(iterable);
332
- if ("function" == typeof iterable.next) return iterable;
333
-
334
- if (!isNaN(iterable.length)) {
335
- var i = -1,
336
- next = function next() {
337
- for (; ++i < iterable.length;) if (hasOwn.call(iterable, i)) return next.value = iterable[i], next.done = !1, next;
338
-
339
- return next.value = undefined, next.done = !0, next;
340
- };
341
-
342
- return next.next = next;
343
- }
344
- }
345
-
346
- return {
347
- next: doneResult
348
- };
349
- }
350
-
351
- function doneResult() {
352
- return {
353
- value: undefined,
354
- done: !0
355
- };
356
- }
357
-
358
- return GeneratorFunction.prototype = GeneratorFunctionPrototype, define(Gp, "constructor", GeneratorFunctionPrototype), define(GeneratorFunctionPrototype, "constructor", GeneratorFunction), GeneratorFunction.displayName = define(GeneratorFunctionPrototype, toStringTagSymbol, "GeneratorFunction"), exports.isGeneratorFunction = function (genFun) {
359
- var ctor = "function" == typeof genFun && genFun.constructor;
360
- return !!ctor && (ctor === GeneratorFunction || "GeneratorFunction" === (ctor.displayName || ctor.name));
361
- }, exports.mark = function (genFun) {
362
- return Object.setPrototypeOf ? Object.setPrototypeOf(genFun, GeneratorFunctionPrototype) : (genFun.__proto__ = GeneratorFunctionPrototype, define(genFun, toStringTagSymbol, "GeneratorFunction")), genFun.prototype = Object.create(Gp), genFun;
363
- }, exports.awrap = function (arg) {
364
- return {
365
- __await: arg
366
- };
367
- }, defineIteratorMethods(AsyncIterator.prototype), define(AsyncIterator.prototype, asyncIteratorSymbol, function () {
368
- return this;
369
- }), exports.AsyncIterator = AsyncIterator, exports.async = function (innerFn, outerFn, self, tryLocsList, PromiseImpl) {
370
- void 0 === PromiseImpl && (PromiseImpl = Promise);
371
- var iter = new AsyncIterator(wrap(innerFn, outerFn, self, tryLocsList), PromiseImpl);
372
- return exports.isGeneratorFunction(outerFn) ? iter : iter.next().then(function (result) {
373
- return result.done ? result.value : iter.next();
374
- });
375
- }, defineIteratorMethods(Gp), define(Gp, toStringTagSymbol, "Generator"), define(Gp, iteratorSymbol, function () {
376
- return this;
377
- }), define(Gp, "toString", function () {
378
- return "[object Generator]";
379
- }), exports.keys = function (object) {
380
- var keys = [];
381
-
382
- for (var key in object) keys.push(key);
383
-
384
- return keys.reverse(), function next() {
385
- for (; keys.length;) {
386
- var key = keys.pop();
387
- if (key in object) return next.value = key, next.done = !1, next;
388
- }
389
-
390
- return next.done = !0, next;
391
- };
392
- }, exports.values = values, Context.prototype = {
393
- constructor: Context,
394
- reset: function (skipTempReset) {
395
- if (this.prev = 0, this.next = 0, this.sent = this._sent = undefined, this.done = !1, this.delegate = null, this.method = "next", this.arg = undefined, this.tryEntries.forEach(resetTryEntry), !skipTempReset) for (var name in this) "t" === name.charAt(0) && hasOwn.call(this, name) && !isNaN(+name.slice(1)) && (this[name] = undefined);
396
- },
397
- stop: function () {
398
- this.done = !0;
399
- var rootRecord = this.tryEntries[0].completion;
400
- if ("throw" === rootRecord.type) throw rootRecord.arg;
401
- return this.rval;
402
- },
403
- dispatchException: function (exception) {
404
- if (this.done) throw exception;
405
- var context = this;
406
-
407
- function handle(loc, caught) {
408
- return record.type = "throw", record.arg = exception, context.next = loc, caught && (context.method = "next", context.arg = undefined), !!caught;
409
- }
410
-
411
- for (var i = this.tryEntries.length - 1; i >= 0; --i) {
412
- var entry = this.tryEntries[i],
413
- record = entry.completion;
414
- if ("root" === entry.tryLoc) return handle("end");
415
-
416
- if (entry.tryLoc <= this.prev) {
417
- var hasCatch = hasOwn.call(entry, "catchLoc"),
418
- hasFinally = hasOwn.call(entry, "finallyLoc");
419
-
420
- if (hasCatch && hasFinally) {
421
- if (this.prev < entry.catchLoc) return handle(entry.catchLoc, !0);
422
- if (this.prev < entry.finallyLoc) return handle(entry.finallyLoc);
423
- } else if (hasCatch) {
424
- if (this.prev < entry.catchLoc) return handle(entry.catchLoc, !0);
425
- } else {
426
- if (!hasFinally) throw new Error("try statement without catch or finally");
427
- if (this.prev < entry.finallyLoc) return handle(entry.finallyLoc);
428
- }
429
- }
430
- }
431
- },
432
- abrupt: function (type, arg) {
433
- for (var i = this.tryEntries.length - 1; i >= 0; --i) {
434
- var entry = this.tryEntries[i];
435
-
436
- if (entry.tryLoc <= this.prev && hasOwn.call(entry, "finallyLoc") && this.prev < entry.finallyLoc) {
437
- var finallyEntry = entry;
438
- break;
439
- }
440
- }
441
-
442
- finallyEntry && ("break" === type || "continue" === type) && finallyEntry.tryLoc <= arg && arg <= finallyEntry.finallyLoc && (finallyEntry = null);
443
- var record = finallyEntry ? finallyEntry.completion : {};
444
- return record.type = type, record.arg = arg, finallyEntry ? (this.method = "next", this.next = finallyEntry.finallyLoc, ContinueSentinel) : this.complete(record);
445
- },
446
- complete: function (record, afterLoc) {
447
- if ("throw" === record.type) throw record.arg;
448
- return "break" === record.type || "continue" === record.type ? this.next = record.arg : "return" === record.type ? (this.rval = this.arg = record.arg, this.method = "return", this.next = "end") : "normal" === record.type && afterLoc && (this.next = afterLoc), ContinueSentinel;
449
- },
450
- finish: function (finallyLoc) {
451
- for (var i = this.tryEntries.length - 1; i >= 0; --i) {
452
- var entry = this.tryEntries[i];
453
- if (entry.finallyLoc === finallyLoc) return this.complete(entry.completion, entry.afterLoc), resetTryEntry(entry), ContinueSentinel;
454
- }
455
- },
456
- catch: function (tryLoc) {
457
- for (var i = this.tryEntries.length - 1; i >= 0; --i) {
458
- var entry = this.tryEntries[i];
459
-
460
- if (entry.tryLoc === tryLoc) {
461
- var record = entry.completion;
462
-
463
- if ("throw" === record.type) {
464
- var thrown = record.arg;
465
- resetTryEntry(entry);
466
- }
467
-
468
- return thrown;
469
- }
470
- }
471
-
472
- throw new Error("illegal catch attempt");
473
- },
474
- delegateYield: function (iterable, resultName, nextLoc) {
475
- return this.delegate = {
476
- iterator: values(iterable),
477
- resultName: resultName,
478
- nextLoc: nextLoc
479
- }, "next" === this.method && (this.arg = undefined), ContinueSentinel;
480
- }
481
- }, exports;
482
- }
483
-
484
- function _typeof(obj) {
485
- "@babel/helpers - typeof";
486
-
487
- return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (obj) {
488
- return typeof obj;
489
- } : function (obj) {
490
- return obj && "function" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj;
491
- }, _typeof(obj);
492
- }
493
-
494
- function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) {
495
- try {
496
- var info = gen[key](arg);
497
- var value = info.value;
498
- } catch (error) {
499
- reject(error);
500
- return;
501
- }
502
-
503
- if (info.done) {
504
- resolve(value);
505
- } else {
506
- Promise.resolve(value).then(_next, _throw);
507
- }
508
- }
509
-
510
- function _asyncToGenerator(fn) {
511
- return function () {
512
- var self = this,
513
- args = arguments;
514
- return new Promise(function (resolve, reject) {
515
- var gen = fn.apply(self, args);
516
-
517
- function _next(value) {
518
- asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value);
519
- }
520
-
521
- function _throw(err) {
522
- asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err);
523
- }
524
-
525
- _next(undefined);
526
- });
527
- };
528
- }
529
-
530
- function _classCallCheck(instance, Constructor) {
531
- if (!(instance instanceof Constructor)) {
532
- throw new TypeError("Cannot call a class as a function");
533
- }
534
- }
535
-
536
- function _defineProperties(target, props) {
537
- for (var i = 0; i < props.length; i++) {
538
- var descriptor = props[i];
539
- descriptor.enumerable = descriptor.enumerable || false;
540
- descriptor.configurable = true;
541
- if ("value" in descriptor) descriptor.writable = true;
542
- Object.defineProperty(target, descriptor.key, descriptor);
543
- }
544
- }
545
-
546
- function _createClass(Constructor, protoProps, staticProps) {
547
- if (protoProps) _defineProperties(Constructor.prototype, protoProps);
548
- if (staticProps) _defineProperties(Constructor, staticProps);
549
- Object.defineProperty(Constructor, "prototype", {
550
- writable: false
551
- });
552
- return Constructor;
553
- }
554
-
555
- function _defineProperty(obj, key, value) {
556
- if (key in obj) {
557
- Object.defineProperty(obj, key, {
558
- value: value,
559
- enumerable: true,
560
- configurable: true,
561
- writable: true
562
- });
563
- } else {
564
- obj[key] = value;
565
- }
566
-
567
- return obj;
568
- }
569
-
570
- function _inherits(subClass, superClass) {
571
- if (typeof superClass !== "function" && superClass !== null) {
572
- throw new TypeError("Super expression must either be null or a function");
573
- }
574
-
575
- subClass.prototype = Object.create(superClass && superClass.prototype, {
576
- constructor: {
577
- value: subClass,
578
- writable: true,
579
- configurable: true
580
- }
581
- });
582
- Object.defineProperty(subClass, "prototype", {
583
- writable: false
584
- });
585
- if (superClass) _setPrototypeOf(subClass, superClass);
586
- }
587
-
588
- function _getPrototypeOf(o) {
589
- _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf.bind() : function _getPrototypeOf(o) {
590
- return o.__proto__ || Object.getPrototypeOf(o);
591
- };
592
- return _getPrototypeOf(o);
593
- }
594
-
595
- function _setPrototypeOf(o, p) {
596
- _setPrototypeOf = Object.setPrototypeOf ? Object.setPrototypeOf.bind() : function _setPrototypeOf(o, p) {
597
- o.__proto__ = p;
598
- return o;
599
- };
600
- return _setPrototypeOf(o, p);
601
- }
602
-
603
- function _isNativeReflectConstruct() {
604
- if (typeof Reflect === "undefined" || !Reflect.construct) return false;
605
- if (Reflect.construct.sham) return false;
606
- if (typeof Proxy === "function") return true;
607
-
608
- try {
609
- Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {}));
610
- return true;
611
- } catch (e) {
612
- return false;
613
- }
614
- }
615
-
616
- function _assertThisInitialized(self) {
617
- if (self === void 0) {
618
- throw new ReferenceError("this hasn't been initialised - super() hasn't been called");
619
- }
620
-
621
- return self;
622
- }
623
-
624
- function _possibleConstructorReturn(self, call) {
625
- if (call && (typeof call === "object" || typeof call === "function")) {
626
- return call;
627
- } else if (call !== void 0) {
628
- throw new TypeError("Derived constructors may only return object or undefined");
629
- }
630
-
631
- return _assertThisInitialized(self);
632
- }
633
-
634
- function _createSuper(Derived) {
635
- var hasNativeReflectConstruct = _isNativeReflectConstruct();
636
-
637
- return function _createSuperInternal() {
638
- var Super = _getPrototypeOf(Derived),
639
- result;
640
-
641
- if (hasNativeReflectConstruct) {
642
- var NewTarget = _getPrototypeOf(this).constructor;
643
-
644
- result = Reflect.construct(Super, arguments, NewTarget);
645
- } else {
646
- result = Super.apply(this, arguments);
647
- }
648
-
649
- return _possibleConstructorReturn(this, result);
650
- };
651
- }
652
-
653
- function _slicedToArray(arr, i) {
654
- return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest();
655
- }
656
-
657
- function _toConsumableArray(arr) {
658
- return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread();
659
- }
660
-
661
- function _arrayWithoutHoles(arr) {
662
- if (Array.isArray(arr)) return _arrayLikeToArray(arr);
663
- }
664
-
665
- function _arrayWithHoles(arr) {
666
- if (Array.isArray(arr)) return arr;
667
- }
668
-
669
- function _iterableToArray(iter) {
670
- if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter);
671
- }
672
-
673
- function _iterableToArrayLimit(arr, i) {
674
- var _i = arr == null ? null : typeof Symbol !== "undefined" && arr[Symbol.iterator] || arr["@@iterator"];
675
-
676
- if (_i == null) return;
677
- var _arr = [];
678
- var _n = true;
679
- var _d = false;
680
-
681
- var _s, _e;
682
-
683
- try {
684
- for (_i = _i.call(arr); !(_n = (_s = _i.next()).done); _n = true) {
685
- _arr.push(_s.value);
686
-
687
- if (i && _arr.length === i) break;
688
- }
689
- } catch (err) {
690
- _d = true;
691
- _e = err;
692
- } finally {
693
- try {
694
- if (!_n && _i["return"] != null) _i["return"]();
695
- } finally {
696
- if (_d) throw _e;
697
- }
698
- }
699
-
700
- return _arr;
701
- }
702
-
703
- function _unsupportedIterableToArray(o, minLen) {
704
- if (!o) return;
705
- if (typeof o === "string") return _arrayLikeToArray(o, minLen);
706
- var n = Object.prototype.toString.call(o).slice(8, -1);
707
- if (n === "Object" && o.constructor) n = o.constructor.name;
708
- if (n === "Map" || n === "Set") return Array.from(o);
709
- if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen);
710
- }
711
-
712
- function _arrayLikeToArray(arr, len) {
713
- if (len == null || len > arr.length) len = arr.length;
714
-
715
- for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i];
716
-
717
- return arr2;
718
- }
719
-
720
- function _nonIterableSpread() {
721
- throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
722
- }
723
-
724
- function _nonIterableRest() {
725
- throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
726
- }
727
-
728
- var uniqueIdCounter = 0;
729
- var EventRegistry = function () {
730
- function EventRegistry(isSingletonHandler) {
731
- var _this = this;
732
-
733
- _classCallCheck(this, EventRegistry);
734
-
735
- _defineProperty(this, "register", function (callback) {
736
- var id;
737
-
738
- if (_this.isSingletonHandler) {
739
- _this.handler = callback;
740
- return function () {
741
- return _this.handler = undefined;
742
- };
743
- } else {
744
- id = uniqueIdCounter++;
745
-
746
- _this.handlers.push({
747
- callback: callback,
748
- id: id
749
- });
750
-
751
- return function () {
752
- _this.unregister(id);
753
- };
754
- }
755
- });
756
-
757
- this.isSingletonHandler = !!isSingletonHandler;
758
- this.handlers = [];
759
-
760
- this.handler = function () {};
761
- }
762
-
763
- _createClass(EventRegistry, [{
764
- key: "unregister",
765
- value: function unregister(id) {
766
- var foundIdx;
767
-
768
- if (this.isSingletonHandler) {
769
- return;
770
- }
771
-
772
- foundIdx = this.handlers.findIndex(function (handler) {
773
- return handler.id === id;
774
- });
775
-
776
- if (foundIdx !== -1) {
777
- this.handlers.splice(foundIdx, 1);
778
- }
779
- }
780
- }, {
781
- key: "trigger",
782
- value: function trigger(data) {
783
- if (this.isSingletonHandler) {
784
- return this.handler(data);
785
- } else {
786
- this.handlers.forEach(function (handler) {
787
- handler.callback(data);
788
- });
789
- }
790
- }
791
- }]);
792
-
793
- return EventRegistry;
794
- }();
795
-
796
- var globalObj = (typeof global === "undefined" ? "undefined" : _typeof(global)) !== undefined ? global : (typeof self === "undefined" ? "undefined" : _typeof(self)) !== undefined ? self : (typeof window === "undefined" ? "undefined" : _typeof(window)) !== undefined ? window : {};
797
- var pluginSdkClient;
798
- var events = {
799
- 'actions_task': {
800
- save: new EventRegistry(true)
801
- }
802
- };
803
- var pluginTypeHandlers = {
804
- 'actions_task': {
805
- save: function save(data) {
806
- return events['actions_task'].save.trigger(data);
807
- }
808
- }
809
- };
810
- var PluginSdkService = {
811
- getPluginSdkClient: getPluginSdkClient
812
- };
813
-
814
- function getPluginSdkClient(handlers) {
815
- var isAlpha = !globalObj.PluginClient;
816
-
817
- if (pluginSdkClient !== undefined) {
818
- if (isAlpha) {
819
- return pluginSdkClient;
820
- } else {
821
- return new Promise(function (resolve) {
822
- return resolve(pluginSdkClient);
823
- });
824
- }
825
- }
826
-
827
- if (isAlpha) {
828
- return initializeLegacyPluginClient(globalObj.PluginSDKClient);
829
- } else if (!isAlpha && globalObj.PluginClient !== undefined) {
830
- return initializePluginClient(globalObj.PluginClient, handlers);
831
- } else {
832
- throw new Error('No PluginClient or PluginSDKClient found on global object');
833
- }
834
- }
835
-
836
- function initializePluginClient(client, handlerConfig) {
837
- var registerHandler;
838
-
839
- var _getDefaultHandlersFo = getDefaultHandlersForPluginType(handlerConfig),
840
- pluginType = _getDefaultHandlersFo.pluginType,
841
- eventHandlers = _getDefaultHandlersFo.eventHandlers;
842
-
843
- registerHandler = function registerHandler(eventType, callback) {
844
- var availableHandlers;
845
- availableHandlers = Object.keys(eventHandlers);
846
-
847
- if (availableHandlers.includes(eventType)) {
848
- return events[pluginType][eventType].register(callback);
849
- } else {
850
- return function () {};
851
- }
852
- };
853
-
854
- return client.initialize(eventHandlers).then(function (initializedClient) {
855
- if (typeof initializedClient.registerHandler !== 'function') {
856
- initializedClient.registerHandler = registerHandler;
857
- }
858
-
859
- pluginSdkClient = initializedClient;
860
- return pluginSdkClient;
861
- });
862
- }
863
-
864
- function getDefaultHandlersForPluginType(handlerConfig) {
865
- var pluginType, eventHandlers;
866
- pluginType = undefined;
867
- eventHandlers = {};
868
-
869
- if (_typeof(handlerConfig) === 'object') {
870
- eventHandlers = handlerConfig;
871
- } else if (typeof handlerConfig === 'string') {
872
- pluginType = handlerConfig;
873
- eventHandlers = pluginTypeHandlers[handlerConfig] || {};
874
- } else {
875
- eventHandlers = handlerConfig;
876
- }
877
-
878
- return {
879
- pluginType: pluginType,
880
- eventHandlers: eventHandlers
881
- };
882
- }
883
-
884
- function initializeLegacyPluginClient(client) {
885
- console.error('Warning - Initializing outdated version of PluginSDKClient. Please upgrade to PluginClient v1.0.0');
886
- pluginSdkClient = client.initialize();
887
- return pluginSdkClient;
888
- }
889
-
890
- var languageCodeMapping = {
891
- DA: 'da',
892
- DE: 'de',
893
- EN: 'en',
894
- 'EN-GB': 'en-GB',
895
- ES: 'es',
896
- 'ES-ES': 'es-419',
897
- FI: 'fi',
898
- FR: 'fr',
899
- ID: 'id',
900
- IT: 'it',
901
- JA: 'ja',
902
- KO: 'ko',
903
- MS: 'ms',
904
- NL: 'nl',
905
- PB: 'pb',
906
- PT: 'pt',
907
- 'PT-BR': 'pt-BR',
908
- 'RI-GI': 'ri-GI',
909
- RU: 'ru',
910
- SV: 'sv',
911
- TH: 'th',
912
- 'ZH-S': 'zh-Hans',
913
- 'ZH-T': 'zh-Hant'
914
- };
915
- function languageCodeAdapter(languageCode) {
916
- var adaptedCode;
917
- adaptedCode = languageCodeMapping[languageCode];
918
-
919
- if (adaptedCode === undefined) {
920
- throw new Error("No language code mapping found for supplied code: '".concat(languageCode, "'"));
921
- }
922
-
923
- return adaptedCode;
924
- }
925
-
926
- /******************************************************************************
927
- Copyright (c) Microsoft Corporation.
928
-
929
- Permission to use, copy, modify, and/or distribute this software for any
930
- purpose with or without fee is hereby granted.
931
-
932
- THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
933
- REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
934
- AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
935
- INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
936
- LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
937
- OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
938
- PERFORMANCE OF THIS SOFTWARE.
939
- ***************************************************************************** */
940
-
941
- var __assign = function() {
942
- __assign = Object.assign || function __assign(t) {
943
- for (var s, i = 1, n = arguments.length; i < n; i++) {
944
- s = arguments[i];
945
- for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p];
946
- }
947
- return t;
948
- };
949
- return __assign.apply(this, arguments);
950
- };
951
-
952
- function __rest(s, e) {
953
- var t = {};
954
- for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
955
- t[p] = s[p];
956
- if (s != null && typeof Object.getOwnPropertySymbols === "function")
957
- for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
958
- if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
959
- t[p[i]] = s[p[i]];
960
- }
961
- return t;
962
- }
963
-
964
- var Portal = function (_Component) {
965
- _inherits(Portal, _Component);
966
-
967
- var _super = _createSuper(Portal);
968
-
969
- function Portal() {
970
- var _this;
971
-
972
- _classCallCheck(this, Portal);
973
-
974
- for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
975
- args[_key] = arguments[_key];
976
- }
977
-
978
- _this = _super.call.apply(_super, [this].concat(args));
979
-
980
- _defineProperty(_assertThisInitialized(_this), "rootSelector", document.body);
981
-
982
- _defineProperty(_assertThisInitialized(_this), "container", document.createElement('div'));
983
-
984
- return _this;
985
- }
986
-
987
- _createClass(Portal, [{
988
- key: "componentDidMount",
989
- value: function componentDidMount() {
990
- this.rootSelector.appendChild(this.container);
991
- }
992
- }, {
993
- key: "componentWillUnmount",
994
- value: function componentWillUnmount() {
995
- this.rootSelector.removeChild(this.container);
996
- }
997
- }, {
998
- key: "render",
999
- value: function render() {
1000
- return ReactDOM.createPortal(this.props.children, this.container);
1001
- }
1002
- }]);
1003
-
1004
- return Portal;
1005
- }(Component);
1006
-
1007
- var css_248z$i = ".q-popover {\n position: absolute;\n z-index: 1000;\n padding: 4px 0;\n font-size: 14px;\n line-height: 20px;\n color: #32363A;\n fill: #333;\n list-style: none;\n min-width: 160px;\n max-width: 500px;\n min-height: 10px;\n max-height: 99%;\n background: #fff;\n border-radius: 4px;\n box-shadow: 0 5px 5px -3px rgba(0, 0, 0, 0.2), 0 0px 10px 1px rgba(0, 0, 0, 0.14), 0 0px 10px 2px rgba(0, 0, 0, 0.12);\n z-index: 9000; }\n\nbody .q-popover {\n max-height: 50vh;\n overflow-y: scroll;\n max-width: 30vw; }\n";
1008
- styleInject(css_248z$i);
1009
-
1010
- var globalClickRegistry = new EventRegistry();
1011
- var DEFAULT_PLACEMENT = 'bottom-start';
1012
- var DEFAULT_ANCHOR = React.createElement(Button, null, " anchor ");
1013
- var defaultModifiers = [];
1014
- initGlobalListener();
1015
- function Popover(props) {
1016
- var _useState = useState(false),
1017
- _useState2 = _slicedToArray(_useState, 2),
1018
- isOpen = _useState2[0],
1019
- setIsOpen = _useState2[1];
1020
-
1021
- var modifiers = [].concat(defaultModifiers, _toConsumableArray(props.modifiers || []));
1022
-
1023
- var closePopover = function closePopover() {
1024
- setIsOpen(false);
1025
- props.onClose && props.onClose();
1026
- };
1027
-
1028
- var anchorEl = function anchorEl(_ref) {
1029
- var ref = _ref.ref;
1030
- var anchor;
1031
-
1032
- if (typeof props.anchor === 'function') {
1033
- anchor = props.anchor(ref);
1034
- } else {
1035
- anchor = props.anchor;
1036
- anchor = React.createElement("div", {
1037
- ref: ref,
1038
- className: "popover-anchor-container"
1039
- }, props.anchor || DEFAULT_ANCHOR);
1040
- }
1041
-
1042
- return anchor;
1043
- };
1044
-
1045
- useEffect(function () {
1046
- var unregisterFn, ignoreClickSelector;
1047
- ignoreClickSelector = props.ignoreClickSelector;
1048
- unregisterFn = globalClickRegistry.register(function (clickEvent) {
1049
- var ignoreClickEl;
1050
-
1051
- if (ignoreClickSelector) {
1052
- ignoreClickEl = clickEvent.target.closest(ignoreClickSelector);
1053
- }
1054
-
1055
- if (!ignoreClickEl) {
1056
- closePopover();
1057
- }
1058
- });
1059
- return function () {
1060
- unregisterFn();
1061
- };
1062
- }, []);
1063
- useEffect(function () {
1064
- if (!props.show) {
1065
- closePopover();
1066
- } else {
1067
- setIsOpen(props.show);
1068
- }
1069
- }, [props.show]);
1070
- return React.createElement(Manager, null, React.createElement(Reference, null, anchorEl), React.createElement(Portal, null, isOpen && React.createElement(Popper, {
1071
- placement: props.placement || DEFAULT_PLACEMENT,
1072
- modifiers: modifiers
1073
- }, function (_ref2) {
1074
- var ref = _ref2.ref,
1075
- style = _ref2.style,
1076
- placement = _ref2.placement,
1077
- arrowProps = _ref2.arrowProps,
1078
- scheduleUpdate = _ref2.update;
1079
- var children;
1080
- children = [];
1081
-
1082
- if (Array.isArray(props.children)) {
1083
- children = props.children;
1084
- } else if (props.children !== undefined) {
1085
- children = [props.children];
1086
- }
1087
-
1088
- children.forEach(function (child) {
1089
- var optionsRef;
1090
-
1091
- if (child.props.optionsRef) {
1092
- optionsRef = child.props.optionsRef;
1093
- optionsRef.current.scheduleUpdate = scheduleUpdate;
1094
- }
1095
- });
1096
- return React.createElement("div", {
1097
- ref: ref,
1098
- "data-placement": placement,
1099
- style: _objectSpread2({}, style),
1100
- className: "q-popover"
1101
- }, props.children, React.createElement("div", {
1102
- ref: arrowProps.ref,
1103
- style: arrowProps.style
1104
- }));
1105
- })));
1106
- }
1107
-
1108
- function initGlobalListener() {
1109
- window.addEventListener('click', function (evt) {
1110
- var popoverEl;
1111
- popoverEl = evt.target.closest('.q-popover');
1112
-
1113
- if (popoverEl === null) {
1114
- globalClickRegistry.trigger(evt);
1115
- } else {
1116
- evt.stopPropagation();
1117
- evt.stopImmediatePropagation();
1118
- }
1119
- });
1120
- }
1121
-
1122
- var css_248z$h = "div[role=\"menu\"] .piped-text-search-input-container {\n padding: 5px 10px; }\n\n.piped-text-search-input {\n padding: 10px 12px;\n user-select: none;\n box-sizing: border-box;\n overflow-x: hidden;\n text-overflow: ellipsis;\n align-content: center;\n padding: 4px 8px 8px; }\n .piped-text-search-input input.q-plugin-popover-input {\n box-sizing: border-box;\n height: 36px;\n padding: 7px 9px; }\n\n.piped-text-menu-empty-anchor {\n /* the margin-right hack was not in harmony with tao.\n now, the empty-anchor is truly empty */ }\n\n.piped-text-submenu-item-container {\n position: relative; }\n .piped-text-submenu-item-container .piped-text-menu .piped-text-submenu-anchor {\n position: absolute;\n z-index: -1;\n bottom: 0;\n top: 0;\n left: 0;\n right: 0;\n min-width: 100%; }\n\n.piped-text-menu-item, .piped-text-submenu-item {\n padding: 10px 12px;\n user-select: none;\n box-sizing: border-box;\n overflow-x: hidden;\n text-overflow: ellipsis; }\n .piped-text-menu-item:not(.piped-text-header):not(.piped-text-disabled):hover, .piped-text-submenu-item:not(.piped-text-header):not(.piped-text-disabled):hover {\n cursor: pointer;\n background: RGBA(50, 54, 58, 0.08); }\n .piped-text-menu-item.piped-text-header, .piped-text-submenu-item.piped-text-header {\n font-size: 12px;\n line-height: 16px;\n font-weight: 700;\n padding: 12px; }\n .piped-text-menu-item.piped-text-disabled:not(.piped-text-header), .piped-text-submenu-item.piped-text-disabled:not(.piped-text-header) {\n color: RGB(116, 119, 122); }\n\n.piped-text-submenu-item {\n padding-right: 24px; }\n\n.piped-text-information-message {\n padding: 10px 12px;\n user-select: none;\n box-sizing: border-box;\n overflow-x: hidden;\n text-overflow: ellipsis;\n color: #74777A;\n text-align: center;\n white-space: pre-line; }\n\n.piped-text-loading-spinner {\n width: fit-content;\n margin: 0 auto; }\n\n.piped-text-error-container {\n color: #BB0000; }\n .piped-text-error-container .piped-text-error-icon {\n padding: 8px 0; }\n .piped-text-error-container .piped-text-error-icon svg {\n fill: #BB0000;\n display: block;\n margin: 0 auto; }\n .piped-text-error-container .piped-text-error-text {\n text-align: center;\n white-space: pre-line;\n padding: 0 12px 8px; }\n\n.embedded-data-menu {\n padding: 10px 12px;\n user-select: none;\n box-sizing: border-box;\n overflow-x: hidden;\n text-overflow: ellipsis;\n align-content: center;\n padding: 4px 8px 8px; }\n .embedded-data-menu input.q-plugin-popover-input {\n box-sizing: border-box;\n height: 36px;\n padding: 7px 9px; }\n";
1123
- styleInject(css_248z$h);
1124
-
1125
- var EmbeddedDataMenu = React.forwardRef(function EmbeddedDataMeny(props, ref) {
1126
- var _useState = useState(''),
1127
- _useState2 = _slicedToArray(_useState, 2),
1128
- inputValue = _useState2[0],
1129
- setInputValue = _useState2[1];
1130
-
1131
- var _useState3 = useState(false),
1132
- _useState4 = _slicedToArray(_useState3, 2),
1133
- isInputInvalid = _useState4[0],
1134
- setIsInputInvalid = _useState4[1];
1135
-
1136
- var inputRef = useRef();
1137
- var anchor = props.anchor;
1138
-
1139
- var onClose = props.onClose || function () {};
1140
-
1141
- var popoverClassName = 'embedded-data-menu-content';
1142
- var ignoreClickSelector = popoverClassName;
1143
-
1144
- var onSelect = props.onSelect || function () {};
1145
-
1146
- useEffect(function () {
1147
- setTimeout(function () {
1148
- if (_get(inputRef, 'current.focus') !== undefined) {
1149
- inputRef.current.focus();
1150
- }
1151
- });
1152
- }, [props.show]);
1153
-
1154
- var handleInputChange = function handleInputChange($e) {
1155
- var inputValue = ($e.target.value || '').trim();
1156
- var uriEncodedValue = encodeURIComponent(inputValue);
1157
- setInputValue(uriEncodedValue);
1158
-
1159
- if (uriEncodedValue.length > 0 && isInputInvalid) {
1160
- setIsInputInvalid(false);
1161
- }
1162
- };
1163
-
1164
- var handleAddButtonClick = function handleAddButtonClick() {
1165
- var locatorString;
1166
-
1167
- if ((inputValue || '').trim().length < 1) {
1168
- setIsInputInvalid(true);
1169
- return;
1170
- }
1171
-
1172
- locatorString = "${e://Field/".concat(inputValue, "}");
1173
- onSelect(locatorString);
1174
- };
1175
-
1176
- var handleInputKeyDown = function handleInputKeyDown($e) {
1177
- var key = $e.key;
1178
-
1179
- if (key !== 'Enter') {
1180
- return;
1181
- }
1182
-
1183
- handleAddButtonClick();
1184
- };
1185
-
1186
- return React.createElement(Popover, {
1187
- show: props.show,
1188
- anchor: anchor,
1189
- onClose: onClose,
1190
- ignoreClickSelector: ignoreClickSelector,
1191
- placement: props.placement || 'right-start'
1192
- }, React.createElement("div", {
1193
- className: "embedded-data-menu",
1194
- ref: ref
1195
- }, React.createElement("div", null, React.createElement(InputGroup, null, React.createElement(Input, {
1196
- onChange: handleInputChange,
1197
- invalid: isInputInvalid,
1198
- onKeyDown: handleInputKeyDown,
1199
- ref: inputRef,
1200
- className: "q-plugin-popover-input"
1201
- }), React.createElement(Button, {
1202
- kind: "primary",
1203
- onClick: handleAddButtonClick
1204
- }, React.createElement(Icon, {
1205
- type: IconTypes.Add
1206
- }))))));
1207
- });
1208
-
1209
- /**
1210
- * Copied from: https://gitlab-app.eng.qops.net/cfe/ui/-/blob/master/packages/ui-react/src/hooks/useId/useId.js
1211
- * Returns an ID that is stable across renders.
1212
- * @param {string=} defaultExternalId - ID to be used instead of a randomly generated ID. This ID is only considered on mount, so changes to this ID are ignored.
1213
- * @returns {String} If an external ID is passed in, the external ID. Otherwise, a randomly generated ID.
1214
- */
1215
- function useId(defaultExternalId) {
1216
- var currentId = useState(function () {
1217
- return defaultExternalId !== null && defaultExternalId !== void 0 ? defaultExternalId : v4();
1218
- })[0];
1219
- return currentId;
1220
- }
1221
-
1222
- var css_248z$g = "";
1223
- styleInject(css_248z$g);
1224
-
1225
- var css_248z$f = "";
1226
- styleInject(css_248z$f);
1227
-
1228
- // const WrappedPipedTextMenu = PipedTextMenu as PipedTextMenuType;
1229
- var PipedTextSubmenuItem = React.forwardRef(function PipedTextSubmenuItem(props, ref) {
1230
- var submenuAnchorRef = useRef(null);
1231
- var submenuItemId = useId();
1232
- var menuItem = props.menuItem;
1233
- return (React.createElement("div", { "data-testid": "piped-text-submenu", className: "piped-text-submenu-item-container" },
1234
- menuItem.show && (React.createElement(PipedTextMenu, { "aria-labelledby": submenuItemId,
1235
- //@ts-ignore
1236
- items: menuItem.submenu.items, show: menuItem.show, placement: "right-start", onClose: function () {
1237
- menuItem.show = false;
1238
- }, allowCustom: menuItem.submenu.allowCustom, customScheme: menuItem.submenu.customScheme, customInputMessage: menuItem.submenu.customInputMessage, searchPlaceholder: menuItem.submenu.searchPlaceholder, errorText: menuItem.submenu.errorText, onSelected: menuItemClicked, anchor: function (ref) { return (React.createElement("div", { ref: ref, className: "piped-text-submenu-anchor" })); }, anchorRef: submenuAnchorRef })),
1239
- React.createElement("div", {
1240
- // aria-haspopup="menu"
1241
- // id={subMenuItemId}
1242
- className: "piped-text-submenu-item",
1243
- // role="menuitem"
1244
- onMouseEnter: function () { return submenuHovered(menuItem); }, ref: submenuAnchorRef },
1245
- React.createElement("div", { className: "label-text" }, menuItem.label),
1246
- React.createElement("div", { className: "piped-text-icon" },
1247
- React.createElement(Icon, { type: IconTypes.ChevronRight, size: "medium" })))));
1248
- function menuItemClicked(menuItem) {
1249
- props.onMenuItemClick(menuItem);
1250
- }
1251
- function submenuHovered(menuItem) {
1252
- props.onSubmenuHover(menuItem);
1253
- }
1254
- });
1255
-
1256
- var EMBEDDED_DATA_LOCATOR$1 = 'embeddedData';
1257
- var PipedTextMenuItem = React.forwardRef(function PipedTextMenuItem(props, ref) {
1258
- var submenuId = useId();
1259
- return (React.createElement("div", { className: 'piped-text-menu-item-container', ref: ref }, getMenuItemContent(props.menuItem)));
1260
- function getMenuItemContent(menuItem) {
1261
- var innerContent, menuItemEl;
1262
- var menuItemHeaderClass, menuItemDisabledClass, menuItemClassName;
1263
- var isSubmenu = checkSubmenuMenuItemItem$1(menuItem);
1264
- var isDecorated = checkDecoratedMenuItem$1(menuItem);
1265
- var isEmbeddedDataMenuItem = checkEmbeddedDataMenuItem$1(menuItem);
1266
- var isFocusable = checkMenuItemFocusable$1(menuItem);
1267
- var role = isSubmenu
1268
- ? 'submenu'
1269
- : 'menuitemradio';
1270
- if (isSubmenu) {
1271
- innerContent = (React.createElement(PipedTextSubmenuItem, { key: menuItem.key, menuItem: menuItem, onSubmenuHover: handleSubmenuHover, onMenuItemClick: handleMenuItemClick }));
1272
- }
1273
- else if (isDecorated) {
1274
- menuItemHeaderClass = (menuItem.header === true)
1275
- ? 'piped-text-header'
1276
- : '';
1277
- menuItemDisabledClass = (menuItem.disabled === true)
1278
- ? 'piped-text-disabled'
1279
- : '';
1280
- menuItemClassName = "piped-text-menu-item ".concat(menuItemHeaderClass, " ").concat(menuItemDisabledClass);
1281
- innerContent = (React.createElement("div", { className: menuItemClassName }, menuItem.label));
1282
- }
1283
- else if (isEmbeddedDataMenuItem) {
1284
- innerContent = (React.createElement("div", { onClick: function () {
1285
- handleEmbeddedDataItemClick(menuItem);
1286
- }, onMouseEnter: function () { return handleMenuItemHovered(menuItem); } },
1287
- React.createElement(EmbeddedDataMenu
1288
- //@ts-ignore
1289
- , {
1290
- //@ts-ignore
1291
- show: menuItem.show, onSelect: handleEmbeddedDataSelect, anchor: function (ref) { return (React.createElement("div", { ref: ref, className: "embedded-data-menu-anchor" })); } }),
1292
- React.createElement("div", { className: "piped-text-menu-item" }, menuItem.label)));
1293
- }
1294
- else {
1295
- innerContent = (React.createElement("div", { onClick: function () { return handleMenuItemClick(menuItem); }, onMouseEnter: function () { return handleMenuItemHovered(menuItem); } },
1296
- React.createElement("div", { className: "piped-text-menu-item" }, menuItem.label)));
1297
- }
1298
- menuItemEl = (React.createElement("div", { "aria-haspopup": isSubmenu ? 'menu' : undefined, id: isSubmenu ? submenuId : undefined, role: role, className: "piped-text-menu-item-content", tabIndex: isFocusable ? -1 : undefined }, innerContent));
1299
- return menuItemEl;
1300
- }
1301
- function handleEmbeddedDataItemClick(menuItem) {
1302
- props.onEmbeddedDataItemClick(menuItem);
1303
- }
1304
- function handleMenuItemClick(menuItem) {
1305
- props.onMenuItemClicked(menuItem);
1306
- }
1307
- function handleSubmenuHover(menuItem) {
1308
- props.onSubmenuHover(menuItem);
1309
- }
1310
- function handleMenuItemHovered(menuItem) {
1311
- props.onMenuItemHover(menuItem);
1312
- }
1313
- function handleEmbeddedDataSelect(edLocator) {
1314
- var edMenuItem;
1315
- /* Instead of returning the menuItem, we'll construct one that matches the interface.
1316
- There is no mappable "menuItem" here, when ED values are added they can be different
1317
- potentially every time, so we trigger events generically ad hoc
1318
- */
1319
- edMenuItem = {
1320
- value: {
1321
- locator: edLocator,
1322
- },
1323
- };
1324
- props.onMenuItemClicked(edMenuItem);
1325
- }
1326
- });
1327
- function checkEmbeddedDataMenuItem$1(menuItem) {
1328
- return menuItem.value === EMBEDDED_DATA_LOCATOR$1;
1329
- }
1330
- function checkDecoratedMenuItem$1(menuItem) {
1331
- return (menuItem.header === true)
1332
- || (menuItem.disabled === true);
1333
- }
1334
- function checkSubmenuMenuItemItem$1(menuItem) {
1335
- return !!menuItem.hasSubmenu;
1336
- }
1337
- function checkMenuItemFocusable$1(menuItem) {
1338
- var isEmbeddedData, isSubmenu, isDefaultMenuItem;
1339
- isEmbeddedData = checkEmbeddedDataMenuItem$1(menuItem);
1340
- isSubmenu = checkSubmenuMenuItemItem$1(menuItem);
1341
- isDefaultMenuItem = checkDefaultMenuItem$1(menuItem);
1342
- return (isEmbeddedData
1343
- || isSubmenu
1344
- || isDefaultMenuItem);
1345
- }
1346
- function checkDefaultMenuItem$1(menuItem) {
1347
- return !(checkEmbeddedDataMenuItem$1(menuItem)
1348
- || checkDecoratedMenuItem$1(menuItem)
1349
- || checkSubmenuMenuItemItem$1(menuItem));
1350
- }
1351
-
1352
- var css_248z$e = "div[role=\"menu\"] .piped-text-search-input-container {\n padding: 5px 10px; }\n\n.piped-text-search-input {\n padding: 10px 12px;\n user-select: none;\n box-sizing: border-box;\n overflow-x: hidden;\n text-overflow: ellipsis;\n align-content: center;\n padding: 4px 8px 8px; }\n .piped-text-search-input input.q-plugin-popover-input {\n box-sizing: border-box;\n height: 36px;\n padding: 7px 9px; }\n\n.piped-text-menu-empty-anchor {\n /* the margin-right hack was not in harmony with tao.\n now, the empty-anchor is truly empty */ }\n\n.piped-text-submenu-item-container {\n position: relative; }\n .piped-text-submenu-item-container .piped-text-menu .piped-text-submenu-anchor {\n position: absolute;\n z-index: -1;\n bottom: 0;\n top: 0;\n left: 0;\n right: 0;\n min-width: 100%; }\n\n.piped-text-menu-item, .piped-text-submenu-item {\n padding: 10px 12px;\n user-select: none;\n box-sizing: border-box;\n overflow-x: hidden;\n text-overflow: ellipsis; }\n .piped-text-menu-item:not(.piped-text-header):not(.piped-text-disabled):hover, .piped-text-submenu-item:not(.piped-text-header):not(.piped-text-disabled):hover {\n cursor: pointer;\n background: RGBA(50, 54, 58, 0.08); }\n .piped-text-menu-item.piped-text-header, .piped-text-submenu-item.piped-text-header {\n font-size: 12px;\n line-height: 16px;\n font-weight: 700;\n padding: 12px; }\n .piped-text-menu-item.piped-text-disabled:not(.piped-text-header), .piped-text-submenu-item.piped-text-disabled:not(.piped-text-header) {\n color: RGB(116, 119, 122); }\n\n.piped-text-submenu-item {\n padding-right: 24px; }\n\n.piped-text-information-message {\n padding: 10px 12px;\n user-select: none;\n box-sizing: border-box;\n overflow-x: hidden;\n text-overflow: ellipsis;\n color: #74777A;\n text-align: center;\n white-space: pre-line; }\n\n.piped-text-loading-spinner {\n width: fit-content;\n margin: 0 auto; }\n\n.piped-text-error-container {\n color: #BB0000; }\n .piped-text-error-container .piped-text-error-icon {\n padding: 8px 0; }\n .piped-text-error-container .piped-text-error-icon svg {\n fill: #BB0000;\n display: block;\n margin: 0 auto; }\n .piped-text-error-container .piped-text-error-text {\n text-align: center;\n white-space: pre-line;\n padding: 0 12px 8px; }\n";
1353
- styleInject(css_248z$e);
1354
-
1355
- var EMBEDDED_DATA_LOCATOR = 'embeddedData';
1356
- var PipedTextMenu = React.forwardRef(function PipedTextMenu(props, ref) {
1357
- var defaultMenuItems = undefined;
1358
-
1359
- if (typeof props.items !== 'function') {
1360
- defaultMenuItems = _cloneDeep(props.items);
1361
- }
1362
-
1363
- var optionsRef = useRef({});
1364
-
1365
- var _useState = useState(defaultMenuItems),
1366
- _useState2 = _slicedToArray(_useState, 2),
1367
- menuItems = _useState2[0],
1368
- setMenuItems = _useState2[1];
1369
-
1370
- var _useState3 = useState(props.show),
1371
- _useState4 = _slicedToArray(_useState3, 2),
1372
- isMenuOpen = _useState4[0],
1373
- setIsMenuOpen = _useState4[1];
1374
-
1375
- var _useState5 = useState(false),
1376
- _useState6 = _slicedToArray(_useState5, 2),
1377
- isLoadError = _useState6[0],
1378
- setIsLoadError = _useState6[1];
1379
-
1380
- var _useState7 = useState(''),
1381
- _useState8 = _slicedToArray(_useState7, 2),
1382
- searchValue = _useState8[0],
1383
- setSearchValue = _useState8[1];
1384
-
1385
- var _useState9 = useState(undefined),
1386
- _useState10 = _slicedToArray(_useState9, 2);
1387
- _useState10[0];
1388
- var setIsSubmenu = _useState10[1];
1389
-
1390
- var _useState11 = useState([]),
1391
- _useState12 = _slicedToArray(_useState11, 2),
1392
- itemsToRender = _useState12[0],
1393
- setItemsToRender = _useState12[1];
1394
-
1395
- var externalAriaLabelledBy = props['aria-labelledby'];
1396
- var popoverAriaLabelledBy = useId();
1397
-
1398
- var _useState13 = useState([]),
1399
- _useState14 = _slicedToArray(_useState13, 2),
1400
- menuChildren = _useState14[0],
1401
- setMenuChildren = _useState14[1];
1402
-
1403
- var _useState15 = useState(-1),
1404
- _useState16 = _slicedToArray(_useState15, 2),
1405
- higlightedItemIndex = _useState16[0],
1406
- setHighlightedItemIndex = _useState16[1];
1407
-
1408
- var _useState17 = useState([]),
1409
- _useState18 = _slicedToArray(_useState17, 2);
1410
- _useState18[0];
1411
- var setFocusMenuItems = _useState18[1];
1412
-
1413
- var onClose = props.onClose || function () {
1414
- return undefined;
1415
- };
1416
-
1417
- var _useState19 = useState(null),
1418
- _useState20 = _slicedToArray(_useState19, 2),
1419
- popoverEl = _useState20[0],
1420
- setPopoverEl = _useState20[1];
1421
-
1422
- var popoverRefCb = useCallback(function (el) {
1423
- setPopoverEl(el);
1424
- }, []);
1425
-
1426
- var _useState21 = useState(null),
1427
- _useState22 = _slicedToArray(_useState21, 2);
1428
- _useState22[0];
1429
- var setSearchBoxEl = _useState22[1];
1430
-
1431
- var searchBoxRefCb = useCallback(function (el) {
1432
- setSearchBoxEl(el);
1433
- }, []);
1434
- useEffect(function () {
1435
- var nextMenuChildren;
1436
- nextMenuChildren = getPipedTextMenuItems(itemsToRender);
1437
- setMenuChildren(nextMenuChildren);
1438
- }, [itemsToRender]);
1439
- useEffect(function () {
1440
- var nextItemsToRender;
1441
- nextItemsToRender = (menuItems || []).filter(matchesSearch);
1442
- setItemsToRender(nextItemsToRender);
1443
- }, [searchValue, menuItems]);
1444
- useEffect(function () {
1445
- var anchorRefEl = _get(props, 'anchorRef.current');
1446
-
1447
- if (anchorRefEl) {
1448
- var anchorRefElRole = anchorRefEl.getAttribute('role');
1449
- var nextIsSubmenu = anchorRefElRole === 'menuitem';
1450
- setIsSubmenu(nextIsSubmenu);
1451
- }
1452
- }, [popoverEl]);
1453
- useEffect(function () {
1454
- _asyncToGenerator(_regeneratorRuntime().mark(function _callee() {
1455
- var newMenuItems;
1456
- return _regeneratorRuntime().wrap(function _callee$(_context) {
1457
- while (1) {
1458
- switch (_context.prev = _context.next) {
1459
- case 0:
1460
- if (!(typeof props.items === 'function')) {
1461
- _context.next = 13;
1462
- break;
1463
- }
1464
-
1465
- _context.prev = 1;
1466
- _context.next = 4;
1467
- return props.items();
1468
-
1469
- case 4:
1470
- newMenuItems = _context.sent;
1471
- newMenuItems = pipedTextDataAdapter(newMenuItems);
1472
- setMenuItems(newMenuItems);
1473
- _context.next = 12;
1474
- break;
1475
-
1476
- case 9:
1477
- _context.prev = 9;
1478
- _context.t0 = _context["catch"](1);
1479
- setIsLoadError(true);
1480
-
1481
- case 12:
1482
- if (typeof optionsRef.current.scheduleUpdate === 'function') {
1483
- optionsRef.current.scheduleUpdate();
1484
- }
1485
-
1486
- case 13:
1487
- case "end":
1488
- return _context.stop();
1489
- }
1490
- }
1491
- }, _callee, null, [[1, 9]]);
1492
- }))();
1493
- }, [props.items]);
1494
- useEffect(function () {
1495
- if (props.show) {
1496
- setIsMenuOpen(true);
1497
- }
1498
- }, [props.show]);
1499
- useEffect(function () {
1500
- return function () {
1501
- return onClose();
1502
- };
1503
- }, []);
1504
-
1505
- var _onClose = function _onClose() {
1506
- onToggleClick(false);
1507
- onClose();
1508
- };
1509
-
1510
- var reRenderMenus = function reRenderMenus() {
1511
- var nextMenuItems;
1512
- nextMenuItems = _cloneDeep(menuItems);
1513
- setMenuItems(nextMenuItems);
1514
- };
1515
-
1516
- var onToggleClick = function onToggleClick(force) {
1517
- var nextIsMenuOpen;
1518
- nextIsMenuOpen = typeof force === 'boolean' ? force : !isMenuOpen;
1519
- setIsMenuOpen(nextIsMenuOpen);
1520
- };
1521
-
1522
- var submenuHovered = function submenuHovered(menuItem, evt) {
1523
- var nextMenuItems;
1524
- closeSubmenus(menuItems);
1525
-
1526
- if (!menuItem.show) {
1527
- menuItem.show = true;
1528
- }
1529
-
1530
- nextMenuItems = _cloneDeep(menuItems);
1531
- setMenuItems(nextMenuItems);
1532
- };
1533
-
1534
- var menuItemHovered = function menuItemHovered(menuItem, evt) {
1535
- var nextMenuItems;
1536
- closeSubmenus(menuItems);
1537
- nextMenuItems = _cloneDeep(menuItems);
1538
- setMenuItems(nextMenuItems);
1539
- };
1540
-
1541
- var onSearchInputChange = function onSearchInputChange(evt) {
1542
- var searchVal;
1543
- searchVal = evt.target.value;
1544
- setSearchValue(searchVal);
1545
- };
1546
-
1547
- var handleSearchInputClick = function handleSearchInputClick(evt) {
1548
- evt.stopPropagation();
1549
- };
1550
-
1551
- var matchesSearch = function matchesSearch(item) {
1552
- var searchVal = searchValue || '';
1553
- searchVal = searchVal.trim().toLowerCase();
1554
- return JSON.stringify(item).toLowerCase().includes(searchVal);
1555
- };
1556
-
1557
- var menuItemClicked = function menuItemClicked(menuItem) {
1558
- if (!menuItem.disabled) {
1559
- props.onSelected(menuItem);
1560
- }
1561
-
1562
- onClose();
1563
- };
1564
-
1565
- var embeddedDataItemClicked = function embeddedDataItemClicked(menuItem, $e) {
1566
- menuItem.show = true;
1567
- reRenderMenus();
1568
- };
1569
-
1570
- var getPipedTextMenuItems = function getPipedTextMenuItems(menuItems) {
1571
- var pipedTextMenuItems, nextFocusMenuItems;
1572
- pipedTextMenuItems = [];
1573
- nextFocusMenuItems = [];
1574
-
1575
- if (menuItems.length === 0 && props.allowCustom === true && props.customInputMessage) {
1576
- return React.createElement("div", null, React.createElement("div", {
1577
- className: "piped-text-information-message"
1578
- }, props.customInputMessage));
1579
- }
1580
-
1581
- pipedTextMenuItems = menuItems.map(function (menuItem) {
1582
- var isFocusable, menuItemEl;
1583
- var menuItemRef = React.createRef();
1584
- isFocusable = checkMenuItemFocusable(menuItem);
1585
- menuItemEl = React.createElement(PipedTextMenuItem, {
1586
- key: menuItem.key,
1587
- menuItem: menuItem,
1588
- onSubmenuHover: function onSubmenuHover(menuItem) {
1589
- submenuHovered(menuItem);
1590
- },
1591
- onMenuItemClicked: function onMenuItemClicked(menuItem) {
1592
- menuItemClicked(menuItem);
1593
- },
1594
- onMenuItemHover: function onMenuItemHover(menuItem) {
1595
- menuItemHovered();
1596
- },
1597
- onEmbeddedDataItemClick: function onEmbeddedDataItemClick(menuItem) {
1598
- embeddedDataItemClicked(menuItem);
1599
- },
1600
- ref: menuItemRef
1601
- });
1602
-
1603
- if (isFocusable) {
1604
- nextFocusMenuItems.push(menuItemEl);
1605
- }
1606
-
1607
- return menuItemEl;
1608
- });
1609
- setFocusMenuItems(nextFocusMenuItems);
1610
- return pipedTextMenuItems;
1611
- };
1612
-
1613
- var handleSearchSubmit = function handleSearchSubmit(e) {
1614
- e.preventDefault();
1615
-
1616
- if (!(props.allowCustom === true && props.customScheme)) {
1617
- return;
1618
- }
1619
-
1620
- var value = searchValue.trim();
1621
-
1622
- if (value === '') {
1623
- return;
1624
- }
1625
-
1626
- var locator = "${".concat(props.customScheme, "://Field/").concat(encodeURIComponent(value), "}");
1627
- var selected = {
1628
- value: {
1629
- locator: locator
1630
- }
1631
- };
1632
- props.onSelected(selected);
1633
- onClose();
1634
- };
1635
-
1636
- var getLoadError = function getLoadError() {
1637
- return React.createElement("div", {
1638
- className: "piped-text-popover-container"
1639
- }, React.createElement("div", {
1640
- className: "piped-text-error-container"
1641
- }, React.createElement("div", {
1642
- className: "piped-text-error-icon"
1643
- }, React.createElement(ErrorIcon, {
1644
- size: "medium"
1645
- })), props.errorText && React.createElement("div", {
1646
- className: "piped-text-error-text"
1647
- }, props.errorText)));
1648
- };
1649
-
1650
- var getLoadingSpinner = function getLoadingSpinner() {
1651
- return React.createElement("div", {
1652
- className: "piped-text-loading-spinner"
1653
- }, React.createElement(LoadingSpinner, {
1654
- show: true,
1655
- size: "medium"
1656
- }));
1657
- };
1658
-
1659
- var getMenuContent = function getMenuContent() {
1660
- if (isLoadError) {
1661
- return getLoadError();
1662
- } else {
1663
- return React.createElement("div", {
1664
- className: "piped-text-popover-menu"
1665
- }, React.createElement("div", {
1666
- className: "piped-text-search-input"
1667
- }, React.createElement("form", {
1668
- onSubmit: handleSearchSubmit
1669
- }, React.createElement(Input, {
1670
- small: true,
1671
- full: true,
1672
- placeholder: props.searchPlaceholder,
1673
- className: "q-plugin-popover-input",
1674
- value: searchValue,
1675
- onChange: function onChange($e) {
1676
- return onSearchInputChange($e);
1677
- },
1678
- onClick: function onClick($e) {
1679
- return handleSearchInputClick($e);
1680
- },
1681
- ref: searchBoxRefCb
1682
- }))), menuItems === undefined ? getLoadingSpinner() : menuChildren);
1683
- }
1684
- };
1685
-
1686
- return React.createElement("div", {
1687
- className: "piped-text-menu"
1688
- }, React.createElement(Popover, {
1689
- show: isMenuOpen,
1690
- onClose: _onClose,
1691
- placement: props.placement || 'right-start',
1692
- anchor: props.anchor,
1693
- ignoreClickSelector: props.ignoreClickSelector
1694
- }, React.createElement("div", {
1695
- id: popoverAriaLabelledBy,
1696
- "aria-labelledby": externalAriaLabelledBy,
1697
- role: "menu",
1698
- className: "piped-text-popover-container",
1699
- ref: popoverRefCb,
1700
- onFocus: function onFocus($e) {
1701
- return handleFocus($e);
1702
- },
1703
- onKeyDown: function onKeyDown($e) {
1704
- return handleKeyDown($e);
1705
- },
1706
- tabIndex: props.tabIndex !== undefined ? props.tabIndex : -1
1707
- }, getMenuContent()), React.createElement(OptionsPlaceholder, {
1708
- optionsRef: optionsRef
1709
- })));
1710
-
1711
- function handleKeyDown(evt) {
1712
- var nextFocusElIdx;
1713
-
1714
- if (evt.key === 'ArrowDown') {
1715
- if (higlightedItemIndex < menuChildren.length) {
1716
- nextFocusElIdx = higlightedItemIndex + 1;
1717
- menuChildren[nextFocusElIdx];
1718
- setHighlightedItemIndex(nextFocusElIdx);
1719
- }
1720
- } else if (evt.key === 'ArrowUp') ;
1721
- }
1722
-
1723
- function handleFocus(evt) {
1724
-
1725
- evt.stopPropagation();
1726
- }
1727
- });
1728
-
1729
- function OptionsPlaceholder() {
1730
- return React.createElement("span", null);
1731
- }
1732
-
1733
- function closeSubmenus(menuItems) {
1734
- menuItems.forEach(function (item) {
1735
- if (item.show) {
1736
- item.show = false;
1737
- }
1738
- });
1739
- }
1740
-
1741
- function pipedTextDataAdapter(pipedTextData, recursed) {
1742
- var uniqueKey;
1743
-
1744
- if (!recursed) {
1745
- pipedTextData = _cloneDeep(pipedTextData);
1746
- }
1747
-
1748
- uniqueKey = 1;
1749
- pipedTextData.forEach(function (pipedTextItem) {
1750
- pipedTextItem.key = pipedTextItem.key || uniqueKey++;
1751
- pipedTextItem.hasSubmenu = !!_get(pipedTextItem, 'submenu.items.length') || typeof _get(pipedTextItem, 'submenu.items') === 'function';
1752
-
1753
- if (pipedTextItem.hasSubmenu || pipedTextItem.value === EMBEDDED_DATA_LOCATOR) {
1754
- pipedTextItem.show = false;
1755
- }
1756
-
1757
- if (pipedTextItem.hasSubmenu) {
1758
- if (!(typeof pipedTextItem.submenu.items === 'function')) {
1759
- pipedTextDataAdapter(pipedTextItem.submenu.items, true);
1760
- }
1761
- }
1762
- });
1763
- return pipedTextData;
1764
- }
1765
-
1766
- function checkDefaultMenuItem(menuItem) {
1767
- return !(checkEmbeddedDataMenuItem(menuItem) || checkDecoratedMenuItem(menuItem) || checkSubmenuMenuItemItem(menuItem));
1768
- }
1769
-
1770
- function checkEmbeddedDataMenuItem(menuItem) {
1771
- return menuItem.value === EMBEDDED_DATA_LOCATOR;
1772
- }
1773
-
1774
- function checkDecoratedMenuItem(menuItem) {
1775
- return menuItem.header === true || menuItem.disabled === true;
1776
- }
1777
-
1778
- function checkSubmenuMenuItemItem(menuItem) {
1779
- return !!menuItem.hasSubmenu;
1780
- }
1781
-
1782
- function checkMenuItemFocusable(menuItem) {
1783
- var isEmbeddedData, isSubmenu, isDefaultMenuItem;
1784
- isEmbeddedData = checkEmbeddedDataMenuItem(menuItem);
1785
- isSubmenu = checkSubmenuMenuItemItem(menuItem);
1786
- isDefaultMenuItem = checkDefaultMenuItem(menuItem);
1787
- return isEmbeddedData || isSubmenu || isDefaultMenuItem;
1788
- }
1789
-
1790
- var css_248z$d = ".piped-text-dropdown button[type=button].popover-toggle-button {\n min-width: 128px; }\n\n.piped-text-popover-container {\n padding: 0; }\n .piped-text-popover-container > * {\n min-height: 32px; }\n .piped-text-popover-container .piped-text-submenu-item .label-text, .piped-text-popover-container .piped-text-submenu-item > .piped-text-icon {\n display: inline-block;\n vertical-align: middle;\n overflow-wrap: break-word;\n word-wrap: break-word;\n -webkit-hyphens: auto;\n -ms-hyphens: auto;\n -moz-hyphens: auto;\n hyphens: auto; }\n .piped-text-popover-container .piped-text-submenu-item .piped-text-icon {\n display: inline-block;\n box-sizing: content-box;\n position: absolute;\n right: 0;\n max-width: 24px;\n min-width: 24px;\n max-height: 24px; }\n .piped-text-popover-container .piped-text-submenu-item .piped-text-icon > svg {\n position: relative;\n margin-left: -5px;\n margin-top: -3px; }\n";
1791
- styleInject(css_248z$d);
1792
-
1793
- var defaultAnchor = function defaultAnchor(ref) {
1794
- return React.createElement("div", {
1795
- ref: ref,
1796
- className: "piped-text-menu-empty-anchor"
1797
- });
1798
- };
1799
-
1800
- function PipedTextSelect(props) {
1801
- var _useState = useState(props.show),
1802
- _useState2 = _slicedToArray(_useState, 2),
1803
- isMenuOpen = _useState2[0],
1804
- setIsMenuOpen = _useState2[1];
1805
-
1806
- var _useState3 = useState(initializePipedText()),
1807
- _useState4 = _slicedToArray(_useState3, 2),
1808
- pipedTextItems = _useState4[0],
1809
- setPipedTextItems = _useState4[1];
1810
-
1811
- var defaultAnchorRef = useRef(null);
1812
- var externalAnchor = props.anchor;
1813
- var ariaLabelledBy = props['aria-labelledby'];
1814
- useEffect(function () {
1815
- return function () {
1816
- return onClose();
1817
- };
1818
- }, []);
1819
- useEffect(function () {
1820
- var nextIsMenuOpen;
1821
- nextIsMenuOpen = props.show;
1822
- setIsMenuOpen(nextIsMenuOpen);
1823
- }, [props.show]);
1824
- useEffect(function () {
1825
- var formattedPipedText = initializePipedText();
1826
- setPipedTextItems(formattedPipedText);
1827
- }, [props.items]);
1828
-
1829
- var onClose = function onClose() {
1830
- if (props.onClose) {
1831
- props.onClose();
1832
- }
1833
- };
1834
-
1835
- var onSelect = function onSelect(selected) {
1836
- props.onSelect(selected);
1837
- onClose();
1838
- };
1839
-
1840
- var actualAnchor = externalAnchor !== undefined ? React.cloneElement(externalAnchor, {
1841
- ref: externalAnchor.ref
1842
- }) : defaultAnchor(defaultAnchorRef);
1843
- var anchorRef = props.anchorRef || actualAnchor.ref;
1844
- return React.createElement("div", {
1845
- className: "piped-text-dropdown"
1846
- }, isMenuOpen && React.createElement(PipedTextMenu, {
1847
- onClose: onClose,
1848
- show: isMenuOpen,
1849
- onSelected: onSelect,
1850
- items: pipedTextItems,
1851
- anchor: actualAnchor,
1852
- anchorRef: anchorRef,
1853
- ignoreClickSelector: props.ignoreClickSelector,
1854
- "aria-labelledby": ariaLabelledBy
1855
- }));
1856
-
1857
- function initializePipedText() {
1858
- if (props.items) {
1859
- return pipedTextDataAdapter(props.items);
1860
- }
1861
- }
1862
- }
1863
-
1864
- var css_248z$c = ".piped-text-input .piped-text-input-toggle, .piped-text-input .piped-text-select-container {\n display: inline-block; }\n\n.piped-text-input .piped-text-input-toggle {\n display: flex; }\n .piped-text-input .piped-text-input-toggle input {\n flex: 1 1;\n box-sizing: border-box; }\n .piped-text-input .piped-text-input-toggle input:first-child {\n border-right: 0;\n border-top-right-radius: 0;\n border-bottom-right-radius: 0; }\n .piped-text-input .piped-text-input-toggle.multiline-input textarea {\n flex: 1 1;\n box-sizing: border-box; }\n .piped-text-input .piped-text-input-toggle input + button, .piped-text-input .piped-text-input-toggle textarea + button {\n margin-left: 4px; }\n\n.piped-text-input .addon-text-container {\n /*\n These styles are intended to match CFE QDS components,\n notably FormField and InputField.\n See: https://gitlab-app.eng.qops.net/cfe/ui/-/blob/master/packages/ui-react/src/FormField/Caption.less\n */\n margin-top: 6px; }\n .piped-text-input .addon-text-container .helper-text, .piped-text-input .addon-text-container .error-text {\n font-size: 12px; }\n .piped-text-input .addon-text-container .helper-text {\n color: #74777a;\n fill: #74777a; }\n .piped-text-input .addon-text-container .helper-text + .error-text {\n margin-top: 4px; }\n .piped-text-input .addon-text-container .error-text {\n display: flex;\n align-items: center;\n color: #b00;\n fill: #b00; }\n .piped-text-input .addon-text-container .error-text .error-text-icon svg {\n margin-left: -2px;\n margin-right: 3px;\n width: 16px;\n height: 16px; }\n";
1865
- styleInject(css_248z$c);
1866
-
1867
- function PipedTextInput(props) {
1868
- var _a = useState(false), showMenu = _a[0], setShowMenu = _a[1];
1869
- var _b = useState(), cursorPosition = _b[0], setCursorPosition = _b[1];
1870
- var pipedTextButtonId = useId();
1871
- var pipedTextButtonRef = useRef(null);
1872
- /*
1873
- This has to be an Object type ref instead of 'string' or React will lose
1874
- track of state, and the supplied props input value will become stale
1875
- */
1876
- var _c = useState({
1877
- value: props.value || ''
1878
- }), inputRefValue = _c[0], setInputRefValue = _c[1];
1879
- var items = props.items, value = props.value, placeholder = props.placeholder, onChange = props.onChange, onSelect = props.onSelect, onClose = props.onClose, errorText = props.errorText, helperText = props.helperText, _d = props.multiline, multiline = _d === void 0 ? false : _d, restProps = __rest(props, ["items", "value", "placeholder", "onChange", "onSelect", "onClose", "errorText", "helperText", "multiline"]);
1880
- useEffect(function () {
1881
- updateCursorPosition();
1882
- if (onSelect !== undefined && (typeof onSelect) !== 'function') {
1883
- throw new Error('PipedTextInput: onSelect property must be a function');
1884
- }
1885
- if (onChange !== undefined && (typeof onChange) !== 'function') {
1886
- throw new Error('PipedTextInput: onChange property must be a function');
1887
- }
1888
- }, []);
1889
- useEffect(function () {
1890
- var nextInputValue;
1891
- if ((typeof value) === 'string') {
1892
- nextInputValue = value;
1893
- }
1894
- else {
1895
- nextInputValue = '';
1896
- }
1897
- setInputRefValue({
1898
- value: nextInputValue,
1899
- });
1900
- }, [props.value]);
1901
- return (React.createElement("div", { className: "piped-text-input" },
1902
- React.createElement("div", { className: 'piped-text-input-toggle popover-toggle' + (multiline ? ' multiline-input' : '') },
1903
- React.createElement(Input, __assign({ value: inputRefValue.value, onChange: function (evt) {
1904
- onInputChange(evt);
1905
- }, onBlur: onInputBlur, placeholder: placeholder, multiline: multiline }, restProps)),
1906
- React.createElement(IconButton, { id: pipedTextButtonId, "aria-label": "PipedText", "aria-haspopup": "menu", "aria-expanded": showMenu ? true : undefined, role: "button", onClick: toggleMenu, ref: pipedTextButtonRef },
1907
- React.createElement(PipedTextIcon, null)),
1908
- React.createElement("div", { className: "piped-text-select-container" },
1909
- React.createElement(PipedTextSelect, { items: items, onSelect: pipedTextSelected, show: showMenu, onClose: handleClose, ignoreClickSelector: "piped-text-input-toggle", anchorRef: pipedTextButtonRef, "aria-labelledby": pipedTextButtonId }))),
1910
- showAddonText() && (React.createElement("div", { className: "addon-text-container" },
1911
- helperText && (React.createElement("div", { className: "helper-text" }, helperText)),
1912
- errorText && (React.createElement("div", { className: "error-text" },
1913
- React.createElement("div", { className: "error-text-icon" },
1914
- React.createElement(ErrorIcon, null)),
1915
- React.createElement("div", { className: "error-text-content" }, errorText)))))));
1916
- function showAddonText() {
1917
- return ((helperText !== undefined) || (errorText !== undefined));
1918
- }
1919
- function updateCursorPosition() {
1920
- if ((cursorPosition === undefined) && value) {
1921
- var initialCursorPositon = (value.length - 1) || 0;
1922
- setCursorPosition(initialCursorPositon);
1923
- }
1924
- else {
1925
- // default to 0 if no cursorPosition is found or no value is passed
1926
- setCursorPosition(0);
1927
- }
1928
- }
1929
- function handleClose() {
1930
- if (onClose) {
1931
- onClose();
1932
- }
1933
- setShowMenu(false);
1934
- }
1935
- function pipedTextSelected(selected) {
1936
- var nextInputValue, prependString, appendString;
1937
- handleSelect(selected);
1938
- if (_get(selected, 'value.locator')) {
1939
- prependString = inputRefValue.value.substring(0, cursorPosition);
1940
- appendString = inputRefValue.value.substring(cursorPosition);
1941
- nextInputValue = "".concat(prependString).concat(selected.value.locator).concat(appendString);
1942
- setInputRefValue({
1943
- value: nextInputValue,
1944
- });
1945
- handleChange(nextInputValue);
1946
- }
1947
- }
1948
- function toggleMenu() {
1949
- var nextShowMenu;
1950
- nextShowMenu = !showMenu;
1951
- if (!nextShowMenu) {
1952
- handleClose();
1953
- }
1954
- setShowMenu(nextShowMenu);
1955
- }
1956
- function onInputChange(evt) {
1957
- var nextInputValue;
1958
- nextInputValue = evt.target.value;
1959
- setInputRefValue({
1960
- value: nextInputValue,
1961
- });
1962
- handleChange(nextInputValue, evt);
1963
- }
1964
- function onInputBlur(evt) {
1965
- var nextCursorPosition;
1966
- nextCursorPosition = evt.target.selectionStart;
1967
- setCursorPosition(nextCursorPosition);
1968
- }
1969
- function handleChange(value, evt) {
1970
- if (onChange) {
1971
- onChange(value, evt);
1972
- }
1973
- }
1974
- function handleSelect(selected) {
1975
- if (onSelect) {
1976
- onSelect(selected);
1977
- }
1978
- }
1979
- }
1980
-
1981
- var css_248z$b = ".field-row {\n min-width: 475px;\n display: flex;\n align-items: center; }\n .field-row .field-selector, .field-row .field-input, .field-row .delete-row, .field-row .required-indicator {\n display: inline-block; }\n .field-row .field-selector, .field-row .field-input {\n padding: 0 10px; }\n .field-row .custom-field-name, .field-row .field-input, .field-row .delete-row {\n box-sizing: border-box; }\n .field-row .field-selector {\n min-width: 30%; }\n .field-row .field-selector.required-field button:hover {\n cursor: not-allowed; }\n .field-row .field-selector .required-indicator-container {\n padding-left: 12px;\n display: flex;\n color: #32363A; }\n .field-row .field-selector .required-indicator-container .required-indicator-text {\n min-width: 0;\n font-size: 14px; }\n .field-row .field-selector .required-indicator-container .required-indicator-symbol {\n margin-top: -2px; }\n .field-row .field-selector .left-align {\n text-align: left; }\n .field-row .field-selector .custom-field-name {\n padding-left: 16px;\n padding-right: 30px; }\n .field-row .field-selector .custom-field-name input {\n text-align: center;\n display: inline-block;\n width: 100%;\n padding: 0; }\n .field-row .field-input-container {\n display: flex;\n flex: 1 0;\n align-items: center; }\n .field-row .field-input-container .field-input {\n flex: 1;\n min-width: 0;\n margin-right: 4px; }\n .field-row .field-input-container .delete-row {\n max-width: 36px;\n margin-left: 12px;\n vertical-align: middle; }\n .field-row .field-input-container .delete-row .icon-wrapper {\n display: block;\n width: fit-content;\n margin: 0 auto;\n min-width: 41px; }\n .field-row .field-input-container .delete-row .icon-wrapper:hover {\n cursor: pointer; }\n .field-row .full-width {\n width: 100%; }\n";
1982
- styleInject(css_248z$b);
1983
-
1984
- function FieldRow(props) {
1985
- var _useState = useState(props.children),
1986
- _useState2 = _slicedToArray(_useState, 2),
1987
- children = _useState2[0],
1988
- setChildren = _useState2[1];
1989
-
1990
- useEffect(function () {
1991
- var nextChildren;
1992
-
1993
- if (!Array.isArray(children)) {
1994
- nextChildren = [];
1995
- nextChildren.push(children);
1996
- setChildren(nextChildren);
1997
- }
1998
- }, []);
1999
- useEffect(function () {
2000
- var nextChildren;
2001
- nextChildren = props.children.slice();
2002
- setChildren(nextChildren);
2003
- }, [props.children]);
2004
-
2005
- var getRowDelete = function getRowDelete() {
2006
- var handleDelete = function handleDelete() {
2007
- if (typeof props.onRemove === 'function') {
2008
- props.onRemove(props.id);
2009
- }
2010
- };
2011
-
2012
- return React.createElement("div", {
2013
- className: "icon-wrapper",
2014
- onClick: handleDelete
2015
- }, !props.required && React.createElement(IconButton, {
2016
- "aria-label": "RemoveRow",
2017
- size: "medium"
2018
- }, React.createElement(RemoveItemIcon, null)));
2019
- };
2020
-
2021
- var handleFieldSwitch = function handleFieldSwitch(newFieldId) {
2022
- if (typeof props.onFieldSwitch === 'function') {
2023
- props.onFieldSwitch(props.id, newFieldId);
2024
- }
2025
- };
2026
-
2027
- var handleFieldNameChange = function handleFieldNameChange(event) {
2028
- if (typeof props.onFieldNameChange === 'function') {
2029
- props.onFieldNameChange(props.id, event);
2030
- }
2031
- };
2032
-
2033
- var handleFieldValueChange = function handleFieldValueChange(value, event) {
2034
- if (typeof props.onFieldValueChange === 'function') {
2035
- props.onFieldValueChange(props.id, value, event);
2036
- }
2037
- };
2038
-
2039
- var shouldDisableTooltip = function shouldDisableTooltip(tooltipValue) {
2040
- if (typeof tooltipValue === 'string') {
2041
- return tooltipValue.trim().length === 0;
2042
- }
2043
-
2044
- if (typeof tooltipValue === 'function' || tooltipValue === undefined || tooltipValue === null) {
2045
- return true;
2046
- }
2047
-
2048
- return "".concat(tooltipValue).trim().length === 0;
2049
- };
2050
-
2051
- var getFieldSelector = function getFieldSelector() {
2052
- var getInternalContent = function getInternalContent() {
2053
- if (props.isCustom) {
2054
- return React.createElement(Input, {
2055
- full: true,
2056
- value: props.fieldName === undefined ? '' : props.fieldName,
2057
- placeholder: props.customNamePlaceholder === undefined ? '' : props.customNamePlaceholder,
2058
- className: "custom-field-name",
2059
- onChange: handleFieldNameChange
2060
- });
2061
- }
2062
-
2063
- if (props.required || !props.children || Array.isArray(children) && children.length === 0) {
2064
- if (props.subMenu) {
2065
- return React.createElement(SelectMenu, {
2066
- searchable: props.searchable !== undefined && props.searchable !== false,
2067
- defaultLabel: props.fieldName || '',
2068
- label: props.fieldName,
2069
- className: "full-width left-align",
2070
- onChange: handleFieldSwitch
2071
- }, createMenuItems([{
2072
- id: props.id,
2073
- name: props.fieldName,
2074
- subMenu: props.subMenu,
2075
- subMenuLabel: props.subMenuLabel
2076
- }]));
2077
- } else {
2078
- return React.createElement("div", {
2079
- className: "required-indicator-container"
2080
- }, React.createElement("div", {
2081
- className: "required-indicator-text"
2082
- }, props.fieldName), props.required && React.createElement("div", {
2083
- className: "required-indicator-symbol"
2084
- }, "*"));
2085
- }
2086
- }
2087
-
2088
- return React.createElement(SelectMenu, {
2089
- searchable: props.searchable !== undefined && props.searchable !== false,
2090
- defaultLabel: props.fieldName || '',
2091
- label: props.fieldName,
2092
- className: "full-width left-align",
2093
- onChange: handleFieldSwitch
2094
- }, createMenuItems(children));
2095
- };
2096
-
2097
- var tooltipContent = React.createElement("div", null, props.nameTooltip);
2098
- return React.createElement(Tooltip, {
2099
- disabled: !props.isCustom || shouldDisableTooltip(props.nameTooltip),
2100
- placement: "top",
2101
- content: tooltipContent
2102
- }, React.createElement("div", null, getInternalContent()));
2103
- };
2104
-
2105
- var createMenuItems = function createMenuItems(items) {
2106
- return items.map(function (_ref) {
2107
- var id = _ref.id,
2108
- name = _ref.name,
2109
- subMenu = _ref.subMenu,
2110
- subMenuLabel = _ref.subMenuLabel;
2111
- return subMenu !== undefined ? React.createElement(SelectMenu, {
2112
- label: subMenuLabel ? subMenuLabel : name,
2113
- key: id
2114
- }, createMenuItems(subMenu)) : React.createElement(MenuItem, {
2115
- key: id,
2116
- value: id
2117
- }, name);
2118
- });
2119
- };
2120
-
2121
- var getFieldInput = function getFieldInput() {
2122
- var getInternalContent = function getInternalContent() {
2123
- if (props.customInput) {
2124
- return props.customInput;
2125
- } else {
2126
- return React.createElement(PipedTextInput, {
2127
- items: props.pipedTextItems,
2128
- value: props.value === undefined ? '' : props.value,
2129
- onChange: handleFieldValueChange,
2130
- placeholder: props.valuePlaceholder === undefined ? '' : props.valuePlaceholder
2131
- });
2132
- }
2133
- };
2134
-
2135
- var tooltipContent = React.createElement("div", null, props.valueTooltip);
2136
- return React.createElement(Tooltip, {
2137
- disabled: shouldDisableTooltip(props.valueTooltip),
2138
- placement: "top",
2139
- content: tooltipContent
2140
- }, React.createElement("div", null, getInternalContent()));
2141
- };
2142
-
2143
- return React.createElement("div", {
2144
- className: "field-row"
2145
- }, React.createElement("div", {
2146
- className: "field-selector ".concat(props.required && !props.subMenu ? 'required-field' : '')
2147
- }, getFieldSelector()), React.createElement("div", {
2148
- className: "field-input-container"
2149
- }, React.createElement("div", {
2150
- className: "field-input"
2151
- }, getFieldInput()), React.createElement("div", {
2152
- className: "delete-row"
2153
- }, getRowDelete())));
2154
- }
2155
-
2156
- var css_248z$a = "";
2157
- styleInject(css_248z$a);
2158
-
2159
- function FieldItem(props) {
2160
- var label = props.name || undefined;
2161
-
2162
- var handleClick = function handleClick() {
2163
- if (typeof props.onClick === 'function') {
2164
- props.onClick(props.id);
2165
- }
2166
- };
2167
-
2168
- return React.createElement("div", {
2169
- className: "field-item",
2170
- onClick: handleClick
2171
- }, label);
2172
- }
2173
-
2174
- var css_248z$9 = ".task-fields {\n margin-right: 100px; }\n .task-fields .add-field-button .add-field-button-label {\n padding: 0 3px; }\n .task-fields .field-headers {\n margin-bottom: 10px;\n padding-left: 12px; }\n .task-fields .field-headers .field-row {\n color: #6A6D70;\n font-weight: bold; }\n .task-fields .field-headers .field-row .field-selector label, .task-fields .field-headers .field-row .field-input label {\n font-size: 12px; }\n .task-fields .field-headers .field-row .field-selector {\n padding-top: 0;\n padding-right: 24px;\n padding-bottom: 0;\n padding-left: 0; }\n .task-fields .field-headers .field-row .field-input {\n padding-top: 0;\n padding-right: 0;\n padding-bottom: 0;\n padding-left: 12px; }\n .task-fields .field-rows {\n padding-bottom: 12px; }\n .task-fields .field-rows .field-row {\n border-top: 1px solid #E5E5E5; }\n .task-fields .field-rows .field-row .field-selector {\n padding-top: 8px;\n padding-right: 12px;\n padding-bottom: 8px;\n padding-left: 12px; }\n .task-fields .field-rows .field-row .field-input {\n border-left: 1px solid #E5E5E5;\n padding-top: 8px;\n padding-right: 0;\n padding-bottom: 8px;\n padding-left: 12px; }\n\n.q-popover .field-item {\n padding: 5px 32px; }\n .q-popover .field-item:hover {\n cursor: pointer;\n user-select: none;\n background: #007ac0;\n color: #fff;\n fill: #fff; }\n";
2175
- styleInject(css_248z$9);
2176
-
2177
- var uuidv4 = uuid.v4;
2178
- var CUSTOM_TYPE = 'custom';
2179
- function TaskFields(props) {
2180
- var _useState = useState([]),
2181
- _useState2 = _slicedToArray(_useState, 2),
2182
- fieldsInUse = _useState2[0],
2183
- setFieldsInUse = _useState2[1];
2184
-
2185
- var _useState3 = useState([]),
2186
- _useState4 = _slicedToArray(_useState3, 2),
2187
- availableFields = _useState4[0],
2188
- setAvailableFields = _useState4[1];
2189
-
2190
- var _useState5 = useState(),
2191
- _useState6 = _slicedToArray(_useState5, 2),
2192
- allFieldOptions = _useState6[0],
2193
- setAllFieldOptions = _useState6[1];
2194
-
2195
- var onFieldSwitch = function onFieldSwitch(oldId, newId) {
2196
- if (typeof props.onFieldSwitch === 'function') {
2197
- props.onFieldSwitch(oldId, newId);
2198
- }
2199
- };
2200
-
2201
- var onFieldValueChange = function onFieldValueChange(fieldId, value, event) {
2202
- if (typeof props.onFieldInputChange === 'function') {
2203
- props.onFieldInputChange(fieldId, value, event);
2204
- }
2205
- };
2206
-
2207
- var onFieldNameChange = function onFieldNameChange(fieldId, event) {
2208
- var changeFn = _get(props, 'customFieldOptions.onCustomFieldNameChange');
2209
-
2210
- if (typeof changeFn === 'function') {
2211
- changeFn(fieldId, event);
2212
- }
2213
- };
2214
-
2215
- var getFieldRows = function getFieldRows() {
2216
- return fieldsInUse.map(function (field) {
2217
- return React.createElement(FieldRow, {
2218
- customInput: field.children,
2219
- required: field.required,
2220
- fieldName: field.name,
2221
- id: field.id,
2222
- subMenu: field.subMenu,
2223
- subMenuLabel: field.subMenuLabel,
2224
- nameTooltip: field.type === CUSTOM_TYPE ? _get(props, 'customFieldOptions.nameTooltip', '') : field.nameTooltip,
2225
- valueTooltip: field.type === CUSTOM_TYPE ? _get(props, 'customFieldOptions.valueTooltip', '') : field.valueTooltip,
2226
- onFieldNameChange: onFieldNameChange,
2227
- onFieldValueChange: onFieldValueChange,
2228
- onFieldSwitch: onFieldSwitch,
2229
- onRemove: onFieldRemove,
2230
- isCustom: field.type === CUSTOM_TYPE,
2231
- key: field.id,
2232
- value: field.value,
2233
- valuePlaceholder: field.type === CUSTOM_TYPE ? _get(props, 'customFieldOptions.valuePlaceholder', '') : field.valuePlaceholder,
2234
- customNamePlaceholder: _get(props, 'customFieldOptions.namePlaceholder', ''),
2235
- pipedTextItems: props.pipedTextItems,
2236
- searchable: props.searchable
2237
- }, allFieldOptions && getFieldsForFieldRow(availableFields, allFieldOptions, field.id));
2238
- });
2239
- };
2240
-
2241
- var getFieldsForFieldRow = function getFieldsForFieldRow(allAvailableFields, allFields, fieldId) {
2242
- var fieldsToAdd = allAvailableFields.slice();
2243
- allFields.forEach(function (field) {
2244
- if (field.subMenu !== undefined && fieldId === field.id) {
2245
- var foundIndex = fieldsToAdd.findIndex(function (fieldToAdd) {
2246
- return fieldToAdd.id === field.id;
2247
- });
2248
-
2249
- if (foundIndex === -1) {
2250
- fieldsToAdd.push(field);
2251
- }
2252
- }
2253
- });
2254
- return fieldsToAdd;
2255
- };
2256
-
2257
- var onFieldAdd = function onFieldAdd(fieldId) {
2258
- if (typeof props.onFieldAdd === 'function') {
2259
- props.onFieldAdd(fieldId);
2260
- }
2261
- };
2262
-
2263
- var onCustomFieldAdd = function onCustomFieldAdd() {
2264
- var handleFn = _get(props, 'customFieldOptions.onCustomFieldAdd', function () {});
2265
-
2266
- handleFn();
2267
- };
2268
-
2269
- var getAvailableFields = function getAvailableFields() {
2270
- return availableFields.map(function (field) {
2271
- return React.createElement(FieldItem, {
2272
- name: field.name,
2273
- type: field.type,
2274
- required: field.required,
2275
- key: field.id,
2276
- id: field.id,
2277
- subMenu: field.subMenu,
2278
- subMenuLabel: field.subMenuLabel
2279
- });
2280
- });
2281
- };
2282
-
2283
- var onFieldRemove = function onFieldRemove(fieldId) {
2284
- if (typeof props.onFieldRemove === 'function') {
2285
- props.onFieldRemove(fieldId);
2286
- }
2287
- };
2288
-
2289
- var getFieldsInUse = function getFieldsInUse(allFieldOptions) {
2290
- var nextFieldsInUse = [];
2291
- var taskFieldsChildren;
2292
-
2293
- if (allFieldOptions === undefined) {
2294
- return undefined;
2295
- }
2296
-
2297
- if (!Array.isArray(props.children)) {
2298
- taskFieldsChildren = [];
2299
- taskFieldsChildren.push(props.children);
2300
- } else {
2301
- taskFieldsChildren = props.children;
2302
- }
2303
-
2304
- nextFieldsInUse = getRequiredFields(taskFieldsChildren);
2305
- nextFieldsInUse = getFieldsWithValues(nextFieldsInUse);
2306
- nextFieldsInUse = getInlineFields(nextFieldsInUse, taskFieldsChildren);
2307
- return nextFieldsInUse;
2308
-
2309
- function getInlineFields(fieldsInUse, fieldChildren) {
2310
- var nextFieldsInUse = fieldsInUse.slice();
2311
- var values = props.values || [];
2312
- nextFieldsInUse = nextFieldsInUse.map(function (nextFieldInUse) {
2313
- var foundFieldValue, foundNextChild, foundFieldOption;
2314
- foundFieldValue = values.find(function (value) {
2315
- return value.id === nextFieldInUse.id;
2316
- });
2317
- foundFieldOption = fieldChildren.find(function (child) {
2318
- return child.props.id === foundFieldValue.id;
2319
- });
2320
-
2321
- if (foundFieldOption !== undefined && !nextFieldInUse.required) {
2322
- foundNextChild = fieldChildren.find(function (nextChild) {
2323
- return nextChild.props.id === foundFieldValue.id;
2324
- });
2325
- nextFieldInUse = Object.assign({}, nextFieldInUse, {
2326
- name: foundNextChild.props.name,
2327
- id: foundNextChild.props.id,
2328
- children: foundNextChild.props.children,
2329
- nameTooltip: foundNextChild.props.nameTooltip,
2330
- valueTooltip: foundNextChild.props.valueTooltip,
2331
- valuePlaceholder: foundNextChild.props.valuePlaceholder,
2332
- subMenu: foundNextChild.props.subMenu,
2333
- subMenuLabel: foundNextChild.props.subMenuLabel
2334
- });
2335
- }
2336
-
2337
- return nextFieldInUse;
2338
- });
2339
- return nextFieldsInUse;
2340
- }
2341
-
2342
- function getRequiredFields(fieldsToSearch) {
2343
- var requiredFields = [];
2344
- fieldsToSearch.forEach(function (field) {
2345
- if (field.props.required) {
2346
- requiredFields.push({
2347
- required: field.props.required,
2348
- name: field.props.name,
2349
- id: field.props.id,
2350
- children: field.props.children,
2351
- nameTooltip: field.props.nameTooltip,
2352
- valueTooltip: field.props.valueTooltip,
2353
- value: field.props.value || undefined,
2354
- valuePlaceholder: field.props.valuePlaceholder,
2355
- subMenu: field.props.subMenu,
2356
- subMenuLabel: field.props.subMenuLabel
2357
- });
2358
- }
2359
- });
2360
- return requiredFields;
2361
- }
2362
-
2363
- function getFieldsWithValues(fieldsInUse) {
2364
- var nextFieldsInUse = fieldsInUse.slice();
2365
- var fieldValues = props.values || [];
2366
- fieldValues.forEach(function (currentField) {
2367
- var fieldMetadata = allFieldOptions.find(function (field) {
2368
- return field.id === currentField.id;
2369
- });
2370
-
2371
- if (fieldMetadata !== undefined) {
2372
- setFieldValue(nextFieldsInUse, currentField, fieldMetadata);
2373
- } else if (props.customFieldOptions) {
2374
- var customFieldValue = {
2375
- required: false,
2376
- name: currentField.name,
2377
- id: currentField.id,
2378
- value: currentField.value,
2379
- nameTooltip: _get(props, 'customFieldOptions.nameTooltip', ''),
2380
- valueTooltip: _get(props, 'customFieldOptions.valueTooltip', ''),
2381
- namePlaceholder: _get(props, 'customFieldOptions.namePlaceholder', ''),
2382
- type: CUSTOM_TYPE,
2383
- subMenu: currentField.subMenu,
2384
- subMenuLabel: currentField.subMenuLabel
2385
- };
2386
- nextFieldsInUse.push(customFieldValue);
2387
- }
2388
- });
2389
- return nextFieldsInUse;
2390
-
2391
- function setFieldValue(fieldsInUse, fieldValue, fieldMetadata) {
2392
- var field = fieldsInUse.find(function (field) {
2393
- return field.id === fieldValue.id;
2394
- });
2395
-
2396
- if (field !== undefined) {
2397
- field.value = fieldValue.value;
2398
- } else {
2399
- var newField = _cloneDeepWith(fieldMetadata, function (value) {
2400
- if (React.isValidElement(value)) {
2401
- return React.cloneElement(value);
2402
- }
2403
- });
2404
-
2405
- newField.value = fieldValue.value;
2406
- fieldsInUse.push(newField);
2407
- }
2408
- }
2409
- }
2410
- };
2411
-
2412
- var updateAvailableFields = function updateAvailableFields() {
2413
- var nextAllFieldOptions = props.children.map(function (child) {
2414
- var childProps = child.props;
2415
- return {
2416
- required: childProps.required,
2417
- name: childProps.name,
2418
- id: childProps.id,
2419
- children: childProps.children,
2420
- nameTooltip: childProps.nameTooltip,
2421
- valueTooltip: childProps.valueTooltip,
2422
- valuePlaceholder: childProps.valuePlaceholder,
2423
- subMenu: childProps.subMenu,
2424
- subMenuLabel: childProps.subMenuLabel
2425
- };
2426
- });
2427
- var nextFieldsInUse = getFieldsInUse(nextAllFieldOptions);
2428
- var nextAvailableFields = nextAllFieldOptions.filter(function (field) {
2429
- var foundFieldIdx = nextFieldsInUse.findIndex(function (usedField) {
2430
- return field.id === usedField.id;
2431
- });
2432
- return foundFieldIdx === -1;
2433
- });
2434
- setAllFieldOptions(nextAllFieldOptions);
2435
- setFieldsInUse(nextFieldsInUse);
2436
- setAvailableFields(nextAvailableFields);
2437
- };
2438
-
2439
- useEffect(function () {
2440
- updateAvailableFields();
2441
- }, []);
2442
- useEffect(function () {
2443
- updateAvailableFields();
2444
- }, [props.values]);
2445
- return React.createElement("div", {
2446
- className: "task-fields"
2447
- }, React.createElement("div", {
2448
- className: "field-headers"
2449
- }, React.createElement(AddFieldHeaders, {
2450
- itemHeaderText: props.fieldItemsHeaderText,
2451
- inputHeaderText: props.fieldInputsHeaderText
2452
- })), React.createElement("div", {
2453
- className: "field-rows"
2454
- }, getFieldRows()), React.createElement("div", {
2455
- className: "add-field-container"
2456
- }, React.createElement(AddFieldButton, {
2457
- label: props.addFieldLabel,
2458
- onFieldAdded: onFieldAdd,
2459
- disableAddFieldPopover: props.disableAddFieldPopover,
2460
- allowCustom: props.customFieldOptions,
2461
- customLabel: _get(props, 'customFieldOptions.label', ''),
2462
- onCustomFieldAdded: props.customFieldOptions ? onCustomFieldAdd : function () {}
2463
- }, getAvailableFields())));
2464
- }
2465
-
2466
- function AddFieldButton(props) {
2467
- var label = props.label || '';
2468
- var customLabel = props.customLabel || '';
2469
- var disableAddFieldPopover = props.disableAddFieldPopover;
2470
-
2471
- var _useState7 = useState(false),
2472
- _useState8 = _slicedToArray(_useState7, 2),
2473
- popoverShow = _useState8[0],
2474
- setPopoverShow = _useState8[1];
2475
-
2476
- var customId = uuidv4();
2477
- var CUSTOM_OPTION = React.createElement(FieldItem, {
2478
- key: customId,
2479
- onClick: function onClick() {
2480
- props.onCustomFieldAdded();
2481
- setPopoverShow(false);
2482
- },
2483
- id: customId,
2484
- name: customLabel
2485
- });
2486
-
2487
- var onPopoverClose = function onPopoverClose() {
2488
- setPopoverShow(false);
2489
- };
2490
-
2491
- var children = [];
2492
-
2493
- var onPopoverAnchorClick = function onPopoverAnchorClick() {
2494
- if (!disableAddFieldPopover) {
2495
- setPopoverShow(!popoverShow);
2496
- } else {
2497
- props.onFieldAdded(props.children !== 0 ? getFieldIdWhenPopoverIsClicked(props.children[0].props) : '');
2498
- }
2499
- };
2500
-
2501
- var getFieldIdWhenPopoverIsClicked = function getFieldIdWhenPopoverIsClicked(field) {
2502
- if (field.subMenu) {
2503
- return getFieldIdWhenPopoverIsClicked(field.subMenu[0]);
2504
- } else {
2505
- return field.id;
2506
- }
2507
- };
2508
-
2509
- children = props.children.map(function (child) {
2510
- return React.createElement(FieldItem, {
2511
- name: child.props.name,
2512
- key: child.props.id,
2513
- id: child.props.id,
2514
- subMenu: child.props.subMenu,
2515
- onClick: function onClick(fieldId) {
2516
- setPopoverShow(false);
2517
- props.onFieldAdded(fieldId);
2518
- }
2519
- });
2520
- });
2521
-
2522
- if (props.allowCustom) {
2523
- children.push(CUSTOM_OPTION);
2524
- }
2525
-
2526
- return React.createElement("div", {
2527
- className: "add-field-button-container"
2528
- }, React.createElement(Popover, {
2529
- show: popoverShow,
2530
- onClose: onPopoverClose,
2531
- ignoreClickSelector: ".add-field-button",
2532
- anchor: React.createElement(Button, {
2533
- disabled: children.length === 0,
2534
- kind: "secondary",
2535
- className: "add-field-button",
2536
- onClick: onPopoverAnchorClick
2537
- }, React.createElement("span", {
2538
- className: "add-field-button-label"
2539
- }, label))
2540
- }, children));
2541
- }
2542
-
2543
- function AddFieldHeaders(props) {
2544
- var itemHeaderText = props.itemHeaderText,
2545
- inputHeaderText = props.inputHeaderText;
2546
-
2547
- if (itemHeaderText || inputHeaderText) {
2548
- return React.createElement("div", {
2549
- className: "field-row"
2550
- }, React.createElement("div", {
2551
- className: "field-selector"
2552
- }, React.createElement(Label, null, itemHeaderText)), React.createElement("div", {
2553
- className: "field-input"
2554
- }, React.createElement(Label, null, inputHeaderText)));
2555
- } else {
2556
- return null;
2557
- }
2558
- }
2559
-
2560
- var css_248z$8 = ".select-item .item {\n padding: 5px 32px;\n display: inline-flex;\n align-items: center;\n box-sizing: border-box;\n width: 100%; }\n .select-item .item .checked-container, .select-item .item .item-content {\n display: inline-block; }\n .select-item .item .checked-container {\n margin-bottom: -3px;\n transition: opacity cubic-bezier(0.4, 0, 0.2, 1) 0.1s; }\n .select-item .item .checked-container.checked {\n opacity: 1; }\n .select-item .item .checked-container:not(.checked) {\n opacity: 0; }\n .select-item .item:hover {\n cursor: pointer;\n user-select: none;\n background: #007ac0;\n color: #fff;\n fill: #fff; }\n";
2561
- styleInject(css_248z$8);
2562
-
2563
- function SelectItem(props) {
2564
- var checked = props.checked || false;
2565
- var children = props.children || '';
2566
- return React.createElement("div", {
2567
- className: "select-item",
2568
- onClick: function onClick(event) {
2569
- return props.onChange(props.value, event);
2570
- }
2571
- }, React.createElement("div", {
2572
- className: "item"
2573
- }, React.createElement("div", {
2574
- className: "checked-container ".concat(checked ? 'checked' : '')
2575
- }, React.createElement(Icon, {
2576
- type: IconTypes.Check,
2577
- size: "medium"
2578
- })), React.createElement("div", {
2579
- className: "item-content"
2580
- }, children)));
2581
- }
2582
-
2583
- var css_248z$7 = "";
2584
- styleInject(css_248z$7);
2585
-
2586
- function MultiselectDropdown(props) {
2587
- var _useState = useState(false),
2588
- _useState2 = _slicedToArray(_useState, 2),
2589
- isDropdownOpen = _useState2[0],
2590
- setIsDropdownOpen = _useState2[1];
2591
-
2592
- var label = props.label || '';
2593
-
2594
- var onPopoverClose = function onPopoverClose() {
2595
- setIsDropdownOpen(false);
2596
- };
2597
-
2598
- var handleChange = function handleChange(value, event) {
2599
- if (typeof props.onChange === 'function') {
2600
- props.onChange(value, event);
2601
- }
2602
- };
2603
-
2604
- var renderToggleButton = function renderToggleButton() {
2605
- return React.createElement("div", {
2606
- className: "multiselect-dropdown-toggle"
2607
- }, React.createElement(Button, {
2608
- onClick: function onClick() {
2609
- setIsDropdownOpen(!isDropdownOpen);
2610
- }
2611
- }, label));
2612
- };
2613
-
2614
- var children = props.children || [];
2615
-
2616
- if (!Array.isArray(children)) {
2617
- var temp = [];
2618
- temp.push(children);
2619
- children = temp;
2620
- }
2621
-
2622
- return React.createElement("div", {
2623
- className: "multiselect-dropdown"
2624
- }, React.createElement(Popover, {
2625
- show: isDropdownOpen,
2626
- onClose: onPopoverClose,
2627
- ignoreClickSelector: ".multiselect-dropdown-toggle",
2628
- anchor: renderToggleButton()
2629
- }, children.map(function (child) {
2630
- return React.createElement(SelectItem, {
2631
- onChange: handleChange,
2632
- checked: child.props.checked,
2633
- value: child.props.value,
2634
- key: child.props.value
2635
- }, child.props.children);
2636
- })));
2637
- }
2638
-
2639
- var css_248z$6 = ".dynamic-search-input .search-input {\n box-sizing: border-box; }\n\n.dynamic-search-popover-child {\n padding: 5px 32px; }\n .dynamic-search-popover-child:hover {\n cursor: pointer;\n user-select: none;\n background: #007ac0;\n color: #fff;\n fill: #fff; }\n";
2640
- styleInject(css_248z$6);
2641
-
2642
- function DynamicSearchInput(props) {
2643
- var _useState = useState(false),
2644
- _useState2 = _slicedToArray(_useState, 2),
2645
- isDropdownOpen = _useState2[0],
2646
- setIsDropdownOpen = _useState2[1];
2647
-
2648
- var _useState3 = useState([]),
2649
- _useState4 = _slicedToArray(_useState3, 2),
2650
- searchResults = _useState4[0],
2651
- setSearchResults = _useState4[1];
2652
-
2653
- var _useState5 = useState(''),
2654
- _useState6 = _slicedToArray(_useState5, 2),
2655
- inputValue = _useState6[0],
2656
- setInputValue = _useState6[1];
2657
-
2658
- useEffect(function () {
2659
- if (props.search && typeof props.search !== 'function') {
2660
- throw new Error('DynamicSearchInput: Expected function for search property');
2661
- }
2662
-
2663
- if (props.onChange && typeof props.onChange !== 'function') {
2664
- throw new Error("DynamicSearchInput: Expected onChange to be a function. Received type ".concat(_typeof(props.onChange)));
2665
- }
2666
-
2667
- if (!props.search && props.items === undefined) {
2668
- throw new Error('DynamicSearchInput: Expected one of either items or search function but found neither');
2669
- }
2670
-
2671
- if (props.search && props.items !== undefined) {
2672
- throw new Error('DynamicSearchInput: Expected one of either items or search function but found both');
2673
- }
2674
-
2675
- if (props.items !== undefined) {
2676
- if (!Array.isArray(props.items)) {
2677
- throw new Error('DynamicSearchInput: expected items property to be an Array');
2678
- }
2679
-
2680
- props.items.forEach(function (item) {
2681
- if (item.props.label === undefined) {
2682
- throw new Error('DynamicSearchInput: expected items in items property to have "label" property');
2683
- }
2684
- });
2685
- }
2686
- }, []);
2687
-
2688
- var handleChange = function handleChange(value, event) {
2689
- if (typeof props.onChange === 'function') {
2690
- props.onChange(value, event);
2691
- }
2692
- };
2693
-
2694
- var handleSearchItemSelected = function handleSearchItemSelected(value) {
2695
- setInputValue(value);
2696
- handleChange(value);
2697
- setIsDropdownOpen(false);
2698
- };
2699
-
2700
- var onPopoverClose = function onPopoverClose() {
2701
- setIsDropdownOpen(false);
2702
- };
2703
-
2704
- var defaultSearch = function () {
2705
- var _ref = _asyncToGenerator(_regeneratorRuntime().mark(function _callee(value) {
2706
- var results;
2707
- return _regeneratorRuntime().wrap(function _callee$(_context) {
2708
- while (1) {
2709
- switch (_context.prev = _context.next) {
2710
- case 0:
2711
- value = ((value || '') + '').trim().toLowerCase();
2712
-
2713
- if (!(value === '')) {
2714
- _context.next = 3;
2715
- break;
2716
- }
2717
-
2718
- return _context.abrupt("return", []);
2719
-
2720
- case 3:
2721
- results = props.items.filter(function (item) {
2722
- return item.props.label.toLowerCase().includes(value);
2723
- });
2724
- return _context.abrupt("return", results);
2725
-
2726
- case 5:
2727
- case "end":
2728
- return _context.stop();
2729
- }
2730
- }
2731
- }, _callee);
2732
- }));
2733
-
2734
- return function defaultSearch(_x) {
2735
- return _ref.apply(this, arguments);
2736
- };
2737
- }();
2738
-
2739
- var handleInputChange = function () {
2740
- var _ref2 = _asyncToGenerator(_regeneratorRuntime().mark(function _callee2(event) {
2741
- var inputVal, searchFunc, results, resultsType, nextSearchResults;
2742
- return _regeneratorRuntime().wrap(function _callee2$(_context2) {
2743
- while (1) {
2744
- switch (_context2.prev = _context2.next) {
2745
- case 0:
2746
- event.persist();
2747
- inputVal = _get(event, 'target.value', '');
2748
- searchFunc = props.search ? props.search : defaultSearch;
2749
- _context2.next = 5;
2750
- return searchFunc(inputVal);
2751
-
2752
- case 5:
2753
- results = _context2.sent;
2754
-
2755
- if (Array.isArray(results)) {
2756
- _context2.next = 9;
2757
- break;
2758
- }
2759
-
2760
- resultsType = typeof results === 'undefined' && 'undefined' || results === null && 'null' || results.constructor && results.constructor.name || results;
2761
- throw new Error("DynamicSearchInput: expected result from search function to be Array, but was ".concat(resultsType));
2762
-
2763
- case 9:
2764
- nextSearchResults = results.map(function (result) {
2765
- if (_get(result, 'props.label') === undefined) {
2766
- throw new Error('DynamicSearchInput: expected search result array values to have label property but found none');
2767
- }
2768
-
2769
- return React.createElement(SearchItem, {
2770
- key: result.props.id,
2771
- onClick: function onClick() {
2772
- handleSearchItemSelected(result.props.label);
2773
- }
2774
- }, result);
2775
- });
2776
- setInputValue(inputVal);
2777
-
2778
- if (nextSearchResults.length > 0) {
2779
- setIsDropdownOpen(true);
2780
- } else {
2781
- setIsDropdownOpen(false);
2782
- }
2783
-
2784
- setSearchResults(nextSearchResults);
2785
- handleChange(inputVal, event);
2786
-
2787
- case 14:
2788
- case "end":
2789
- return _context2.stop();
2790
- }
2791
- }
2792
- }, _callee2);
2793
- }));
2794
-
2795
- return function handleInputChange(_x2) {
2796
- return _ref2.apply(this, arguments);
2797
- };
2798
- }();
2799
-
2800
- return React.createElement("div", {
2801
- className: "dynamic-search-input"
2802
- }, React.createElement(Popover, {
2803
- show: isDropdownOpen,
2804
- onClose: onPopoverClose,
2805
- anchor: React.createElement(Input, {
2806
- className: "search-input",
2807
- full: true,
2808
- small: true,
2809
- placeholder: props.placeholder,
2810
- value: inputValue,
2811
- onChange: handleInputChange
2812
- })
2813
- }, searchResults));
2814
- }
2815
-
2816
- function SearchItem(props) {
2817
- return React.createElement("div", {
2818
- className: "dynamic-search-popover-child",
2819
- onClick: props.onClick
2820
- }, props.children);
2821
- }
2822
-
2823
- var css_248z$5 = ".capture-event .capture-event-controls {\n display: flex;\n align-items: center;\n gap: 10px;\n margin-bottom: 15px; }\n .capture-event .capture-event-controls .waiting-message {\n display: flex;\n align-items: center; }\n .capture-event .capture-event-controls .waiting-message .waiting-label {\n color: #74777a;\n margin-left: 8px; }\n\n.capture-event .payload-block {\n text-align: left; }\n .capture-event .payload-block .payload-label {\n text-decoration: underline;\n margin-bottom: 3px; }\n";
2824
- styleInject(css_248z$5);
2825
-
2826
- function CaptureEvent(props) {
2827
- var _a = useState(props.payload), payload = _a[0]; _a[1];
2828
- var _b = useState(props.capturing || false), capturing = _b[0], setCapturing = _b[1];
2829
- var _c = useState(props.waitingForEventTranslation), waitingLabel = _c[0], setWaitingLabel = _c[1];
2830
- return (React.createElement("div", { className: "capture-event" },
2831
- React.createElement("div", { className: "capture-event-controls" },
2832
- getCaptureEventButton(),
2833
- capturing && (React.createElement("div", { className: "waiting-message" },
2834
- React.createElement(LoadingSpinner, { show: true, size: 'small' }),
2835
- React.createElement("div", { className: "waiting-label" }, waitingLabel)))),
2836
- payload && (React.createElement("div", { className: "payload-block" },
2837
- React.createElement("div", { className: "payload-label" }, "".concat(props.payloadTranslation, ":")),
2838
- React.createElement("div", { className: "payload" },
2839
- React.createElement("pre", null, payload))))));
2840
- function getCaptureEventButton() {
2841
- if (capturing) {
2842
- return (React.createElement("div", { className: "capture-event-button-container" },
2843
- React.createElement(Button, { kind: "secondary", onClick: cancelCapture }, props.cancelCaptureTranslation)));
2844
- }
2845
- else {
2846
- return (React.createElement("div", { className: "capture-event-button-container" },
2847
- React.createElement(Button, { kind: "primary", onClick: startCapture }, props.captureNextEventTranslation)));
2848
- }
2849
- }
2850
- function startCapture() {
2851
- setCapturing(true);
2852
- props.onStart();
2853
- }
2854
- function cancelCapture() {
2855
- setCapturing(false);
2856
- setWaitingLabel(props.waitingForEventTranslation);
2857
- props.onCancel();
2858
- }
2859
- }
2860
-
2861
- var css_248z$4 = ".copy-text {\n display: flex;\n column-gap: 8px; }\n .copy-text .input-container {\n width: 100%; }\n .copy-text .input-container .input-textbox {\n width: 100%; }\n .copy-text .copy-button-container .selected-button {\n display: flex; }\n .copy-text .copy-button-container .selected-button .selected-button-text {\n display: flex;\n align-self: center; }\n";
2862
- styleInject(css_248z$4);
2863
-
2864
- var COPY_BUTTON_SELECTED_TEXT_TIME = 1.5 * 1000; // seconds * milliseconds
2865
- function CopyText(props) {
2866
- var _a = useState(false), copyButtonSelected = _a[0], setCopyButtonSelected = _a[1];
2867
- return (React.createElement("div", { className: "copy-text" },
2868
- React.createElement("div", { className: "input-container" },
2869
- React.createElement(Input, { className: "input-textbox", defaultValue: props.text, "aria-readonly": true, readOnly: true })),
2870
- React.createElement("div", { className: "copy-button-container" },
2871
- React.createElement(Button, { kind: "secondary", disabled: copyButtonSelected, onClick: copyTextToClipboard }, getCopyButtonContent()))));
2872
- function copyTextToClipboard() {
2873
- try {
2874
- navigator.clipboard.writeText(props.text);
2875
- setCopyButtonSelected(true);
2876
- setTimeout(function () { return setCopyButtonSelected(false); }, COPY_BUTTON_SELECTED_TEXT_TIME);
2877
- }
2878
- catch (err) {
2879
- console.error('Failed to copy text');
2880
- console.error(err);
2881
- }
2882
- }
2883
- function getCopyButtonContent() {
2884
- if (copyButtonSelected) {
2885
- return (React.createElement("div", { className: "selected-button" },
2886
- React.createElement("div", { className: "selected-button-icon" },
2887
- React.createElement(CheckIcon, null)),
2888
- React.createElement("div", { className: "selected-button-text" }, props.copySelectedTranslation)));
2889
- }
2890
- else {
2891
- return (React.createElement("div", { className: "default-button" }, props.copyTranslation));
2892
- }
2893
- }
2894
- }
2895
-
2896
- var css_248z$3 = ".field-mapper {\n padding-bottom: 12px; }\n .field-mapper .field-mapper-row-container .field-mapper-row {\n border-top: 1px solid #E5E5E5; }\n .field-mapper .field-mapper-row-container.field-mapper-header-row {\n margin-bottom: 10px;\n padding-left: 12px; }\n .field-mapper .field-mapper-row-container.field-mapper-header-row .field-mapper-row {\n border: 0; }\n .field-mapper .field-mapper-row-container.field-mapper-header-row .field-mapper-key, .field-mapper .field-mapper-row-container.field-mapper-header-row .field-mapper-value {\n border: 0;\n display: flex;\n align-items: center; }\n .field-mapper .field-mapper-row-container.field-mapper-header-row .field-mapper-key .field-mapper-header-cell, .field-mapper .field-mapper-row-container.field-mapper-header-row .field-mapper-value .field-mapper-header-cell {\n color: #6A6D70;\n font-weight: bold;\n font-size: 12px; }\n .field-mapper .field-mapper-row-container.field-mapper-header-row .field-mapper-key {\n padding-top: 0;\n padding-right: 24px;\n padding-bottom: 0;\n padding-left: 0; }\n .field-mapper .field-mapper-row-container.field-mapper-header-row .field-mapper-value {\n padding-top: 0;\n padding-right: 0;\n padding-bottom: 0;\n padding-left: 12px; }\n .field-mapper .add-field-button-container {\n padding-top: 12px; }\n";
2897
- styleInject(css_248z$3);
2898
-
2899
- function isString(val) {
2900
- return (typeof val) === 'string';
2901
- }
2902
-
2903
- var css_248z$2 = ".field-mapper-row .field-mapper-row-content {\n display: flex; }\n .field-mapper-row .field-mapper-row-content .field-mapper-key-container {\n flex: 4; }\n .field-mapper-row .field-mapper-row-content .field-mapper-value-container {\n flex: 7; }\n .field-mapper-row .field-mapper-row-content .remove-row-container {\n min-height: 100%;\n padding: 8px 12px;\n border-left: 1px solid #E5E5E5; }\n .field-mapper-row .field-mapper-row-content .remove-row-container.hide-remove-button {\n border: 0; }\n .field-mapper-row .field-mapper-row-content .remove-row-container .empty-remove-button {\n min-width: 36px; }\n";
2904
- styleInject(css_248z$2);
2905
-
2906
- var css_248z$1 = ".field-mapper-key {\n display: flex;\n align-items: center;\n padding-top: 8px;\n padding-right: 12px;\n padding-bottom: 8px;\n padding-left: 12px;\n height: 100%; }\n .field-mapper-key .required-field-container {\n display: flex; }\n .field-mapper-key .required-field-container .required-field-text {\n min-width: 0;\n font-size: 14px; }\n .field-mapper-key .required-field-container .required-field-symbol {\n margin-top: -2px; }\n";
2907
- styleInject(css_248z$1);
2908
-
2909
- var FieldMapperKey = React.forwardRef(function FieldMapperKey(props, ref) {
2910
- var _a, _b, _c, _d, _e;
2911
- var availableFields;
2912
- var onFieldKeyChange;
2913
- availableFields = Array.isArray(props.availableFields)
2914
- ? props.availableFields
2915
- : [];
2916
- onFieldKeyChange = (typeof props.onFieldKeyChange === 'function')
2917
- ? props.onFieldKeyChange
2918
- : function () { return undefined; };
2919
- return (React.createElement("div", { className: "field-mapper-key", ref: ref }, (React.Children.count(props.children) > 0)
2920
- ? props.children
2921
- : (React.createElement("div", { className: "field-mapper-key-dropdown" }, fieldMapperKeyDropdownDisabled()
2922
- ? (React.createElement(Button, { disabled: true }, (_a = props.selectedField) === null || _a === void 0 ? void 0 : _a.label))
2923
- : (((_b = props.selectedField) === null || _b === void 0 ? void 0 : _b.required) === true)
2924
- ? (React.createElement("div", { className: "required-field-container" },
2925
- React.createElement("div", { className: "required-field-text" }, (_c = props.selectedField) === null || _c === void 0 ? void 0 : _c.label),
2926
- React.createElement("div", { className: "required-field-symbol" }, "*")))
2927
- : (React.createElement(Dropdown, { onChange: handleFieldKeyChange },
2928
- React.createElement(DropdownButton, { label: (_d = props.selectedField) === null || _d === void 0 ? void 0 : _d.label }),
2929
- React.createElement(DropdownList, null, (_e = props.availableFields) === null || _e === void 0 ? void 0 : _e.map(function (fieldItem) {
2930
- return (React.createElement(DropdownOption, { key: fieldItem.key, label: fieldItem.label, value: fieldItem.value }));
2931
- }))))))));
2932
- function handleFieldKeyChange(value) {
2933
- var foundSelectedFieldKey;
2934
- foundSelectedFieldKey = availableFields.find(function (availableField) {
2935
- return availableField.value === value;
2936
- });
2937
- if (foundSelectedFieldKey === undefined) {
2938
- return;
2939
- }
2940
- onFieldKeyChange(props.selectedField, foundSelectedFieldKey);
2941
- }
2942
- function fieldMapperKeyDropdownDisabled() {
2943
- var hasAvailableFields;
2944
- hasAvailableFields = (availableFields === null || availableFields === void 0 ? void 0 : availableFields.length) > 0;
2945
- return !hasAvailableFields;
2946
- }
2947
- });
2948
-
2949
- var css_248z = ".field-mapper-value {\n border-left: 1px solid #E5E5E5;\n padding-top: 8px;\n padding-right: 12px;\n padding-bottom: 8px;\n padding-left: 12px;\n height: 100%; }\n";
2950
- styleInject(css_248z);
2951
-
2952
- var FieldMapperValue = React.forwardRef(function FieldMapperValue(props, ref) {
2953
- var _a, _b;
2954
- return (React.createElement("div", { className: "field-mapper-value" }, (React.Children.count(props.children) > 0)
2955
- ? props.children
2956
- : (React.createElement("div", { className: "piped-text-input-value-container" },
2957
- React.createElement(PipedTextInput, { items: (_a = props.pipedTextItems) !== null && _a !== void 0 ? _a : [], onChange: (_b = props.onChange) !== null && _b !== void 0 ? _b : (function () { return undefined; }) })))));
2958
- });
2959
-
2960
- var FieldMapperRow = React.forwardRef(function FieldMapperRow(props, ref) {
2961
- return (React.createElement("div", { className: "field-mapper-row", ref: ref },
2962
- React.createElement("div", { className: "field-mapper-row-content" },
2963
- React.Children.map(props.children, function (child) {
2964
- return getWrappedKeyValue(child);
2965
- }),
2966
- React.createElement("div", { className: 'remove-row-container' + ((props.showRemove === false) ? ' hide-remove-button' : '') }, (props.showRemove === false)
2967
- ? (React.createElement("div", { className: "empty-remove-button" }))
2968
- : (React.createElement(IconButton
2969
- /*
2970
- TODO: Require an i18n string to be passed in for a11y labels
2971
- */
2972
- , { "aria-label": "Remove", onClick: function ($e) { return handleRemoveClick(); } },
2973
- React.createElement(RemoveItemIcon, null)))))));
2974
- function handleRemoveClick(evt) {
2975
- var _a;
2976
- (_a = props.onFieldRemove) === null || _a === void 0 ? void 0 : _a.call(props, props.selectedField);
2977
- }
2978
- function getWrappedKeyValue(child) {
2979
- var _a, _b, _c, _d;
2980
- var wrappedEl;
2981
- var fieldMapperKeyProps, fieldMapperValueProps;
2982
- var includeAvailableFields, includeSelectedField;
2983
- var includePipedTextItems, includeOnChange;
2984
- fieldMapperKeyProps = {};
2985
- fieldMapperValueProps = {};
2986
- switch (child.type) {
2987
- case FieldMapperKey:
2988
- includeAvailableFields = (!Array.isArray(child.props.availableFields)
2989
- && (((_a = props.availableFields) === null || _a === void 0 ? void 0 : _a.length) > 0));
2990
- includeSelectedField = (((typeof child.props.selectedField) !== 'object')
2991
- && (props.selectedField !== undefined));
2992
- if (includeAvailableFields) {
2993
- fieldMapperKeyProps.availableFields = (_c = (_b = props.availableFields) === null || _b === void 0 ? void 0 : _b.slice()) !== null && _c !== void 0 ? _c : [];
2994
- }
2995
- if (includeSelectedField) {
2996
- fieldMapperKeyProps.selectedField = Object.assign({}, props.selectedField);
2997
- }
2998
- if (React.isValidElement(child)
2999
- && (includeAvailableFields
3000
- || includeSelectedField)) {
3001
- child = React.cloneElement(child, fieldMapperKeyProps);
3002
- }
3003
- wrappedEl = (React.createElement("div", { className: "field-mapper-key-container" }, child));
3004
- break;
3005
- case FieldMapperValue:
3006
- includePipedTextItems = (!Array.isArray(child.props.pipedTextItems)
3007
- && (((_d = props.pipedTextItems) === null || _d === void 0 ? void 0 : _d.length) > 0));
3008
- includeOnChange = (((typeof child.props.onChange) !== 'function')
3009
- && ((typeof props.onChange) === 'function'));
3010
- if (includePipedTextItems) {
3011
- fieldMapperValueProps.pipedTextItems = props.pipedTextItems;
3012
- }
3013
- if (includeOnChange) {
3014
- fieldMapperValueProps.onChange = function (value) {
3015
- props.onChange(props.selectedField, value);
3016
- };
3017
- }
3018
- if (React.isValidElement(child)
3019
- && includePipedTextItems) {
3020
- child = React.cloneElement(child, fieldMapperValueProps);
3021
- }
3022
- wrappedEl = (React.createElement("div", { className: "field-mapper-value-container" }, child));
3023
- break;
3024
- default:
3025
- wrappedEl = child;
3026
- }
3027
- return wrappedEl;
3028
- }
3029
- });
3030
-
3031
- var MISSING_TRANSLATION_WARNING = '{{MISSING_I18N_STRING}}';
3032
- var FieldMapper = React.forwardRef(function FieldMapper(props, ref) {
3033
- var _a, _b, _c, _d, _e, _f;
3034
- return (React.createElement("div", { className: 'field-mapper ' + ((_a = props.className) !== null && _a !== void 0 ? _a : ''), ref: ref },
3035
- hasHeaderRow() && (React.createElement("div", { className: "field-mapper-row-container field-mapper-header-row" },
3036
- React.createElement(FieldMapperRow, { showRemove: false },
3037
- React.createElement(FieldMapperKey, null,
3038
- React.createElement("div", { className: "field-mapper-header-cell field-mapper-key-header" }, (_b = props.fieldKeysHeaderText) !== null && _b !== void 0 ? _b : '')),
3039
- React.createElement(FieldMapperValue, null,
3040
- React.createElement("div", { className: "field-mapper-header-cell field-mapper-value-header" }, (_c = props.fieldValuesHeaderText) !== null && _c !== void 0 ? _c : ''))))),
3041
- React.createElement("div", { className: "field-mapper-row-container" }, React.Children.map(props.children, function (child) {
3042
- return getWrappedFieldRow(child);
3043
- })),
3044
- React.createElement("div", { className: "add-field-button-container" }, isAddFieldDisabled()
3045
- ? (React.createElement(Button, { disabled: true, kind: "secondary", className: "add-field-button" },
3046
- React.createElement("div", { className: "add-field-icon" },
3047
- React.createElement(AddIcon, null)),
3048
- React.createElement("div", { className: "add-field-button-label" }, (_d = props.addFieldLabel) !== null && _d !== void 0 ? _d : MISSING_TRANSLATION_WARNING)))
3049
- : (React.createElement(Dropdown, null,
3050
- React.createElement(DropdownButton, null,
3051
- React.createElement(Button, { className: "add-field-button", kind: "secondary" },
3052
- React.createElement("div", { className: "add-field-icon" },
3053
- React.createElement(AddIcon, null)),
3054
- React.createElement("div", { className: "add-field-button-label" }, (_e = props.addFieldLabel) !== null && _e !== void 0 ? _e : MISSING_TRANSLATION_WARNING))),
3055
- React.createElement(DropdownList, null, (_f = props.availableFields) === null || _f === void 0 ? void 0 : _f.map(function (fieldItem) {
3056
- return (React.createElement(DropdownOption, { key: fieldItem.key, value: fieldItem.value, label: fieldItem.label, onSelect: function ($e) {
3057
- handleDropdownSelect(fieldItem.value);
3058
- } }));
3059
- })))))));
3060
- function hasHeaderRow() {
3061
- return (isString(props.fieldKeysHeaderText)
3062
- || isString(props.fieldValuesHeaderText));
3063
- }
3064
- function getWrappedFieldRow(child) {
3065
- var _a, _b, _c;
3066
- var wrappedEl;
3067
- var fieldMapperRowProps;
3068
- var includeAvailableFields, includeOnFieldRemove, includePipedTextItems, includeOnFieldValueChange, includeShowRemove;
3069
- fieldMapperRowProps = {};
3070
- switch (child.type) {
3071
- case FieldMapperRow:
3072
- wrappedEl = child;
3073
- break;
3074
- default:
3075
- wrappedEl = (React.createElement(FieldMapperRow, null, child));
3076
- }
3077
- includeAvailableFields = (!Array.isArray(wrappedEl.props.availableFields)
3078
- && (((_a = props.availableFields) === null || _a === void 0 ? void 0 : _a.length) > 0));
3079
- includeOnFieldRemove = (((typeof wrappedEl.props.onFieldRemove) !== 'function')
3080
- && ((typeof props.onFieldRemove) === 'function'));
3081
- includePipedTextItems = (!Array.isArray(wrappedEl.props.pipedTextItems)
3082
- && (((_b = props.pipedTextItems) === null || _b === void 0 ? void 0 : _b.length) > 0));
3083
- includeOnFieldValueChange = (((typeof wrappedEl.props.onChange) !== 'function')
3084
- && (typeof props.onFieldValueChange === 'function'));
3085
- includeShowRemove = (((typeof wrappedEl.props.showRemove !== 'boolean'))
3086
- && ((typeof ((_c = child.props.selectedField) === null || _c === void 0 ? void 0 : _c.required)) === 'boolean'));
3087
- if (includeAvailableFields) {
3088
- fieldMapperRowProps.availableFields = props.availableFields.slice();
3089
- }
3090
- if (includeOnFieldRemove) {
3091
- fieldMapperRowProps.onFieldRemove = function (fieldItem) {
3092
- return props.onFieldRemove(fieldItem);
3093
- };
3094
- }
3095
- if (includePipedTextItems) {
3096
- fieldMapperRowProps.pipedTextItems = props.pipedTextItems;
3097
- }
3098
- if (includeOnFieldValueChange) {
3099
- fieldMapperRowProps.onChange = function (fieldItem, inputValue) {
3100
- return props.onFieldValueChange(fieldItem, inputValue);
3101
- };
3102
- }
3103
- if (includeShowRemove) {
3104
- fieldMapperRowProps.showRemove = !child.props.selectedField.required;
3105
- }
3106
- wrappedEl = React.cloneElement(wrappedEl, fieldMapperRowProps);
3107
- return wrappedEl;
3108
- }
3109
- function handleDropdownSelect(value) {
3110
- var foundFieldMapperItem;
3111
- foundFieldMapperItem = props.availableFields.find(function (availableField) {
3112
- return availableField.value === value;
3113
- });
3114
- if (foundFieldMapperItem) {
3115
- props.onFieldAdd(foundFieldMapperItem);
3116
- }
3117
- }
3118
- function isAddFieldDisabled() {
3119
- var hasAvailableFields;
3120
- hasAvailableFields = ((Array.isArray(props.availableFields))
3121
- && (props.availableFields.length > 0));
3122
- return !hasAvailableFields;
3123
- }
3124
- });
3125
-
3126
- export { CaptureEvent, CopyText, DynamicSearchInput, FieldItem, FieldMapper, FieldMapperKey, FieldMapperRow, FieldMapperValue, MultiselectDropdown, PipedTextInput, PipedTextSelect, PluginSdkService, Popover, SelectItem, TaskFields, languageCodeAdapter };