@qualtrics/plugin-ui-react 1.4.0-alpha.13 → 1.4.0-alpha.16
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.
- package/dist/common/capture-event/capture-event.test.d.ts +1 -0
- package/dist/common/copy-text/copy-text.test.d.ts +1 -0
- package/dist/common/dynamic-search-input/dynamic-search-input.d.ts +1 -0
- package/dist/common/dynamic-search-input/dynamic-search-input.test.d.ts +1 -0
- package/dist/common/event-registry.d.ts +9 -0
- package/dist/common/language-service.d.ts +1 -0
- package/dist/common/multiselect-dropdown/multiselect-dropdown.d.ts +1 -0
- package/dist/common/multiselect-dropdown/multiselect-dropdown.test.d.ts +1 -0
- package/dist/common/multiselect-dropdown/select-item/select-item.d.ts +1 -0
- package/dist/common/multiselect-dropdown/select-item/select-item.test.d.ts +1 -0
- package/dist/common/piped-text-input/piped-text-input.d.ts +1 -1
- package/dist/common/piped-text-input/piped-text-input.test.d.ts +1 -0
- package/dist/common/piped-text-select/piped-text-select.d.ts +1 -0
- package/dist/common/piped-text-select/piped-text-select.test.d.ts +1 -0
- package/dist/common/plugin-sdk-service.d.ts +5 -0
- package/dist/common/popover/popover.d.ts +1 -0
- package/dist/common/portal.d.ts +10 -0
- package/dist/common/task-fields/field-item/field-item.d.ts +1 -0
- package/dist/common/task-fields/field-item/field-item.test.d.ts +1 -0
- package/dist/common/task-fields/field-row/field-row.d.ts +1 -0
- package/dist/common/task-fields/field-row/field-row.test.d.ts +1 -0
- package/dist/common/task-fields/task-fields.d.ts +1 -0
- package/dist/common/task-fields/task-fields.test.d.ts +1 -0
- package/dist/index.es.js +2 -2
- package/dist/index.js +2 -2
- package/dist/lib/models/field-mapper-item.d.ts +0 -1
- package/dist/main.es.js +3560 -0
- package/dist/main.js +3588 -0
- package/dist/plugin-app/example-data.d.ts +102 -0
- package/dist/plugin-app/plugin-app.d.ts +1 -0
- package/package.json +1 -1
package/dist/main.es.js
ADDED
|
@@ -0,0 +1,3560 @@
|
|
|
1
|
+
/*! @license @qualtrics/plugin-ui-react 1.4.0-alpha.3
|
|
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, Icon, IconTypes, InputGroup, Input, LoadingSpinner, IconButton, Tooltip, SelectMenu, MenuItem, Label, FormField, InputField, Dropdown, DropdownButton, DropdownList, DropdownOption } from '@qualtrics/ui-react';
|
|
61
|
+
import { ErrorIcon, PipedTextIcon, RemoveItemIcon, SuccessIcon, CheckIcon, AddIcon } from '@qualtrics/ui-react/icons';
|
|
62
|
+
import 'core-js/modules/es.string.anchor.js';
|
|
63
|
+
import _cloneDeep from 'lodash.clonedeep';
|
|
64
|
+
import 'core-js/modules/es.array.concat.js';
|
|
65
|
+
import 'core-js/modules/es.array.is-array.js';
|
|
66
|
+
import { Manager, Reference, Popper } from 'react-popper';
|
|
67
|
+
import ReactDOM from 'react-dom';
|
|
68
|
+
import uuid, { v4 } from 'uuid';
|
|
69
|
+
import 'core-js/modules/es.array.map.js';
|
|
70
|
+
import 'core-js/modules/es.function.name.js';
|
|
71
|
+
import 'core-js/modules/es.array.slice.js';
|
|
72
|
+
import 'core-js/modules/es.array.iterator.js';
|
|
73
|
+
import 'core-js/modules/web.dom-collections.iterator.js';
|
|
74
|
+
import 'core-js/modules/es.array.find.js';
|
|
75
|
+
import 'core-js/modules/es.object.assign.js';
|
|
76
|
+
import 'core-js/modules/es.array.filter.js';
|
|
77
|
+
import _cloneDeepWith from 'lodash.clonedeepwith';
|
|
78
|
+
import 'core-js/modules/es.string.trim.js';
|
|
79
|
+
import 'core-js/modules/es.regexp.exec.js';
|
|
80
|
+
import 'core-js/modules/es.string.search.js';
|
|
81
|
+
|
|
82
|
+
function styleInject(css, ref) {
|
|
83
|
+
if ( ref === void 0 ) ref = {};
|
|
84
|
+
var insertAt = ref.insertAt;
|
|
85
|
+
|
|
86
|
+
if (!css || typeof document === 'undefined') { return; }
|
|
87
|
+
|
|
88
|
+
var head = document.head || document.getElementsByTagName('head')[0];
|
|
89
|
+
var style = document.createElement('style');
|
|
90
|
+
style.type = 'text/css';
|
|
91
|
+
|
|
92
|
+
if (insertAt === 'top') {
|
|
93
|
+
if (head.firstChild) {
|
|
94
|
+
head.insertBefore(style, head.firstChild);
|
|
95
|
+
} else {
|
|
96
|
+
head.appendChild(style);
|
|
97
|
+
}
|
|
98
|
+
} else {
|
|
99
|
+
head.appendChild(style);
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
if (style.styleSheet) {
|
|
103
|
+
style.styleSheet.cssText = css;
|
|
104
|
+
} else {
|
|
105
|
+
style.appendChild(document.createTextNode(css));
|
|
106
|
+
}
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
var css_248z$m = ".react-app {\n background-color: RGBA(0, 0, 0, 0.1); }\n";
|
|
110
|
+
styleInject(css_248z$m);
|
|
111
|
+
|
|
112
|
+
function ownKeys(object, enumerableOnly) {
|
|
113
|
+
var keys = Object.keys(object);
|
|
114
|
+
|
|
115
|
+
if (Object.getOwnPropertySymbols) {
|
|
116
|
+
var symbols = Object.getOwnPropertySymbols(object);
|
|
117
|
+
enumerableOnly && (symbols = symbols.filter(function (sym) {
|
|
118
|
+
return Object.getOwnPropertyDescriptor(object, sym).enumerable;
|
|
119
|
+
})), keys.push.apply(keys, symbols);
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
return keys;
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
function _objectSpread2(target) {
|
|
126
|
+
for (var i = 1; i < arguments.length; i++) {
|
|
127
|
+
var source = null != arguments[i] ? arguments[i] : {};
|
|
128
|
+
i % 2 ? ownKeys(Object(source), !0).forEach(function (key) {
|
|
129
|
+
_defineProperty(target, key, source[key]);
|
|
130
|
+
}) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) {
|
|
131
|
+
Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key));
|
|
132
|
+
});
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
return target;
|
|
136
|
+
}
|
|
137
|
+
|
|
138
|
+
function _regeneratorRuntime() {
|
|
139
|
+
/*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/facebook/regenerator/blob/main/LICENSE */
|
|
140
|
+
|
|
141
|
+
_regeneratorRuntime = function () {
|
|
142
|
+
return exports;
|
|
143
|
+
};
|
|
144
|
+
|
|
145
|
+
var exports = {},
|
|
146
|
+
Op = Object.prototype,
|
|
147
|
+
hasOwn = Op.hasOwnProperty,
|
|
148
|
+
$Symbol = "function" == typeof Symbol ? Symbol : {},
|
|
149
|
+
iteratorSymbol = $Symbol.iterator || "@@iterator",
|
|
150
|
+
asyncIteratorSymbol = $Symbol.asyncIterator || "@@asyncIterator",
|
|
151
|
+
toStringTagSymbol = $Symbol.toStringTag || "@@toStringTag";
|
|
152
|
+
|
|
153
|
+
function define(obj, key, value) {
|
|
154
|
+
return Object.defineProperty(obj, key, {
|
|
155
|
+
value: value,
|
|
156
|
+
enumerable: !0,
|
|
157
|
+
configurable: !0,
|
|
158
|
+
writable: !0
|
|
159
|
+
}), obj[key];
|
|
160
|
+
}
|
|
161
|
+
|
|
162
|
+
try {
|
|
163
|
+
define({}, "");
|
|
164
|
+
} catch (err) {
|
|
165
|
+
define = function (obj, key, value) {
|
|
166
|
+
return obj[key] = value;
|
|
167
|
+
};
|
|
168
|
+
}
|
|
169
|
+
|
|
170
|
+
function wrap(innerFn, outerFn, self, tryLocsList) {
|
|
171
|
+
var protoGenerator = outerFn && outerFn.prototype instanceof Generator ? outerFn : Generator,
|
|
172
|
+
generator = Object.create(protoGenerator.prototype),
|
|
173
|
+
context = new Context(tryLocsList || []);
|
|
174
|
+
return generator._invoke = function (innerFn, self, context) {
|
|
175
|
+
var state = "suspendedStart";
|
|
176
|
+
return function (method, arg) {
|
|
177
|
+
if ("executing" === state) throw new Error("Generator is already running");
|
|
178
|
+
|
|
179
|
+
if ("completed" === state) {
|
|
180
|
+
if ("throw" === method) throw arg;
|
|
181
|
+
return doneResult();
|
|
182
|
+
}
|
|
183
|
+
|
|
184
|
+
for (context.method = method, context.arg = arg;;) {
|
|
185
|
+
var delegate = context.delegate;
|
|
186
|
+
|
|
187
|
+
if (delegate) {
|
|
188
|
+
var delegateResult = maybeInvokeDelegate(delegate, context);
|
|
189
|
+
|
|
190
|
+
if (delegateResult) {
|
|
191
|
+
if (delegateResult === ContinueSentinel) continue;
|
|
192
|
+
return delegateResult;
|
|
193
|
+
}
|
|
194
|
+
}
|
|
195
|
+
|
|
196
|
+
if ("next" === context.method) context.sent = context._sent = context.arg;else if ("throw" === context.method) {
|
|
197
|
+
if ("suspendedStart" === state) throw state = "completed", context.arg;
|
|
198
|
+
context.dispatchException(context.arg);
|
|
199
|
+
} else "return" === context.method && context.abrupt("return", context.arg);
|
|
200
|
+
state = "executing";
|
|
201
|
+
var record = tryCatch(innerFn, self, context);
|
|
202
|
+
|
|
203
|
+
if ("normal" === record.type) {
|
|
204
|
+
if (state = context.done ? "completed" : "suspendedYield", record.arg === ContinueSentinel) continue;
|
|
205
|
+
return {
|
|
206
|
+
value: record.arg,
|
|
207
|
+
done: context.done
|
|
208
|
+
};
|
|
209
|
+
}
|
|
210
|
+
|
|
211
|
+
"throw" === record.type && (state = "completed", context.method = "throw", context.arg = record.arg);
|
|
212
|
+
}
|
|
213
|
+
};
|
|
214
|
+
}(innerFn, self, context), generator;
|
|
215
|
+
}
|
|
216
|
+
|
|
217
|
+
function tryCatch(fn, obj, arg) {
|
|
218
|
+
try {
|
|
219
|
+
return {
|
|
220
|
+
type: "normal",
|
|
221
|
+
arg: fn.call(obj, arg)
|
|
222
|
+
};
|
|
223
|
+
} catch (err) {
|
|
224
|
+
return {
|
|
225
|
+
type: "throw",
|
|
226
|
+
arg: err
|
|
227
|
+
};
|
|
228
|
+
}
|
|
229
|
+
}
|
|
230
|
+
|
|
231
|
+
exports.wrap = wrap;
|
|
232
|
+
var ContinueSentinel = {};
|
|
233
|
+
|
|
234
|
+
function Generator() {}
|
|
235
|
+
|
|
236
|
+
function GeneratorFunction() {}
|
|
237
|
+
|
|
238
|
+
function GeneratorFunctionPrototype() {}
|
|
239
|
+
|
|
240
|
+
var IteratorPrototype = {};
|
|
241
|
+
define(IteratorPrototype, iteratorSymbol, function () {
|
|
242
|
+
return this;
|
|
243
|
+
});
|
|
244
|
+
var getProto = Object.getPrototypeOf,
|
|
245
|
+
NativeIteratorPrototype = getProto && getProto(getProto(values([])));
|
|
246
|
+
NativeIteratorPrototype && NativeIteratorPrototype !== Op && hasOwn.call(NativeIteratorPrototype, iteratorSymbol) && (IteratorPrototype = NativeIteratorPrototype);
|
|
247
|
+
var Gp = GeneratorFunctionPrototype.prototype = Generator.prototype = Object.create(IteratorPrototype);
|
|
248
|
+
|
|
249
|
+
function defineIteratorMethods(prototype) {
|
|
250
|
+
["next", "throw", "return"].forEach(function (method) {
|
|
251
|
+
define(prototype, method, function (arg) {
|
|
252
|
+
return this._invoke(method, arg);
|
|
253
|
+
});
|
|
254
|
+
});
|
|
255
|
+
}
|
|
256
|
+
|
|
257
|
+
function AsyncIterator(generator, PromiseImpl) {
|
|
258
|
+
function invoke(method, arg, resolve, reject) {
|
|
259
|
+
var record = tryCatch(generator[method], generator, arg);
|
|
260
|
+
|
|
261
|
+
if ("throw" !== record.type) {
|
|
262
|
+
var result = record.arg,
|
|
263
|
+
value = result.value;
|
|
264
|
+
return value && "object" == typeof value && hasOwn.call(value, "__await") ? PromiseImpl.resolve(value.__await).then(function (value) {
|
|
265
|
+
invoke("next", value, resolve, reject);
|
|
266
|
+
}, function (err) {
|
|
267
|
+
invoke("throw", err, resolve, reject);
|
|
268
|
+
}) : PromiseImpl.resolve(value).then(function (unwrapped) {
|
|
269
|
+
result.value = unwrapped, resolve(result);
|
|
270
|
+
}, function (error) {
|
|
271
|
+
return invoke("throw", error, resolve, reject);
|
|
272
|
+
});
|
|
273
|
+
}
|
|
274
|
+
|
|
275
|
+
reject(record.arg);
|
|
276
|
+
}
|
|
277
|
+
|
|
278
|
+
var previousPromise;
|
|
279
|
+
|
|
280
|
+
this._invoke = function (method, arg) {
|
|
281
|
+
function callInvokeWithMethodAndArg() {
|
|
282
|
+
return new PromiseImpl(function (resolve, reject) {
|
|
283
|
+
invoke(method, arg, resolve, reject);
|
|
284
|
+
});
|
|
285
|
+
}
|
|
286
|
+
|
|
287
|
+
return previousPromise = previousPromise ? previousPromise.then(callInvokeWithMethodAndArg, callInvokeWithMethodAndArg) : callInvokeWithMethodAndArg();
|
|
288
|
+
};
|
|
289
|
+
}
|
|
290
|
+
|
|
291
|
+
function maybeInvokeDelegate(delegate, context) {
|
|
292
|
+
var method = delegate.iterator[context.method];
|
|
293
|
+
|
|
294
|
+
if (undefined === method) {
|
|
295
|
+
if (context.delegate = null, "throw" === context.method) {
|
|
296
|
+
if (delegate.iterator.return && (context.method = "return", context.arg = undefined, maybeInvokeDelegate(delegate, context), "throw" === context.method)) return ContinueSentinel;
|
|
297
|
+
context.method = "throw", context.arg = new TypeError("The iterator does not provide a 'throw' method");
|
|
298
|
+
}
|
|
299
|
+
|
|
300
|
+
return ContinueSentinel;
|
|
301
|
+
}
|
|
302
|
+
|
|
303
|
+
var record = tryCatch(method, delegate.iterator, context.arg);
|
|
304
|
+
if ("throw" === record.type) return context.method = "throw", context.arg = record.arg, context.delegate = null, ContinueSentinel;
|
|
305
|
+
var info = record.arg;
|
|
306
|
+
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);
|
|
307
|
+
}
|
|
308
|
+
|
|
309
|
+
function pushTryEntry(locs) {
|
|
310
|
+
var entry = {
|
|
311
|
+
tryLoc: locs[0]
|
|
312
|
+
};
|
|
313
|
+
1 in locs && (entry.catchLoc = locs[1]), 2 in locs && (entry.finallyLoc = locs[2], entry.afterLoc = locs[3]), this.tryEntries.push(entry);
|
|
314
|
+
}
|
|
315
|
+
|
|
316
|
+
function resetTryEntry(entry) {
|
|
317
|
+
var record = entry.completion || {};
|
|
318
|
+
record.type = "normal", delete record.arg, entry.completion = record;
|
|
319
|
+
}
|
|
320
|
+
|
|
321
|
+
function Context(tryLocsList) {
|
|
322
|
+
this.tryEntries = [{
|
|
323
|
+
tryLoc: "root"
|
|
324
|
+
}], tryLocsList.forEach(pushTryEntry, this), this.reset(!0);
|
|
325
|
+
}
|
|
326
|
+
|
|
327
|
+
function values(iterable) {
|
|
328
|
+
if (iterable) {
|
|
329
|
+
var iteratorMethod = iterable[iteratorSymbol];
|
|
330
|
+
if (iteratorMethod) return iteratorMethod.call(iterable);
|
|
331
|
+
if ("function" == typeof iterable.next) return iterable;
|
|
332
|
+
|
|
333
|
+
if (!isNaN(iterable.length)) {
|
|
334
|
+
var i = -1,
|
|
335
|
+
next = function next() {
|
|
336
|
+
for (; ++i < iterable.length;) if (hasOwn.call(iterable, i)) return next.value = iterable[i], next.done = !1, next;
|
|
337
|
+
|
|
338
|
+
return next.value = undefined, next.done = !0, next;
|
|
339
|
+
};
|
|
340
|
+
|
|
341
|
+
return next.next = next;
|
|
342
|
+
}
|
|
343
|
+
}
|
|
344
|
+
|
|
345
|
+
return {
|
|
346
|
+
next: doneResult
|
|
347
|
+
};
|
|
348
|
+
}
|
|
349
|
+
|
|
350
|
+
function doneResult() {
|
|
351
|
+
return {
|
|
352
|
+
value: undefined,
|
|
353
|
+
done: !0
|
|
354
|
+
};
|
|
355
|
+
}
|
|
356
|
+
|
|
357
|
+
return GeneratorFunction.prototype = GeneratorFunctionPrototype, define(Gp, "constructor", GeneratorFunctionPrototype), define(GeneratorFunctionPrototype, "constructor", GeneratorFunction), GeneratorFunction.displayName = define(GeneratorFunctionPrototype, toStringTagSymbol, "GeneratorFunction"), exports.isGeneratorFunction = function (genFun) {
|
|
358
|
+
var ctor = "function" == typeof genFun && genFun.constructor;
|
|
359
|
+
return !!ctor && (ctor === GeneratorFunction || "GeneratorFunction" === (ctor.displayName || ctor.name));
|
|
360
|
+
}, exports.mark = function (genFun) {
|
|
361
|
+
return Object.setPrototypeOf ? Object.setPrototypeOf(genFun, GeneratorFunctionPrototype) : (genFun.__proto__ = GeneratorFunctionPrototype, define(genFun, toStringTagSymbol, "GeneratorFunction")), genFun.prototype = Object.create(Gp), genFun;
|
|
362
|
+
}, exports.awrap = function (arg) {
|
|
363
|
+
return {
|
|
364
|
+
__await: arg
|
|
365
|
+
};
|
|
366
|
+
}, defineIteratorMethods(AsyncIterator.prototype), define(AsyncIterator.prototype, asyncIteratorSymbol, function () {
|
|
367
|
+
return this;
|
|
368
|
+
}), exports.AsyncIterator = AsyncIterator, exports.async = function (innerFn, outerFn, self, tryLocsList, PromiseImpl) {
|
|
369
|
+
void 0 === PromiseImpl && (PromiseImpl = Promise);
|
|
370
|
+
var iter = new AsyncIterator(wrap(innerFn, outerFn, self, tryLocsList), PromiseImpl);
|
|
371
|
+
return exports.isGeneratorFunction(outerFn) ? iter : iter.next().then(function (result) {
|
|
372
|
+
return result.done ? result.value : iter.next();
|
|
373
|
+
});
|
|
374
|
+
}, defineIteratorMethods(Gp), define(Gp, toStringTagSymbol, "Generator"), define(Gp, iteratorSymbol, function () {
|
|
375
|
+
return this;
|
|
376
|
+
}), define(Gp, "toString", function () {
|
|
377
|
+
return "[object Generator]";
|
|
378
|
+
}), exports.keys = function (object) {
|
|
379
|
+
var keys = [];
|
|
380
|
+
|
|
381
|
+
for (var key in object) keys.push(key);
|
|
382
|
+
|
|
383
|
+
return keys.reverse(), function next() {
|
|
384
|
+
for (; keys.length;) {
|
|
385
|
+
var key = keys.pop();
|
|
386
|
+
if (key in object) return next.value = key, next.done = !1, next;
|
|
387
|
+
}
|
|
388
|
+
|
|
389
|
+
return next.done = !0, next;
|
|
390
|
+
};
|
|
391
|
+
}, exports.values = values, Context.prototype = {
|
|
392
|
+
constructor: Context,
|
|
393
|
+
reset: function (skipTempReset) {
|
|
394
|
+
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);
|
|
395
|
+
},
|
|
396
|
+
stop: function () {
|
|
397
|
+
this.done = !0;
|
|
398
|
+
var rootRecord = this.tryEntries[0].completion;
|
|
399
|
+
if ("throw" === rootRecord.type) throw rootRecord.arg;
|
|
400
|
+
return this.rval;
|
|
401
|
+
},
|
|
402
|
+
dispatchException: function (exception) {
|
|
403
|
+
if (this.done) throw exception;
|
|
404
|
+
var context = this;
|
|
405
|
+
|
|
406
|
+
function handle(loc, caught) {
|
|
407
|
+
return record.type = "throw", record.arg = exception, context.next = loc, caught && (context.method = "next", context.arg = undefined), !!caught;
|
|
408
|
+
}
|
|
409
|
+
|
|
410
|
+
for (var i = this.tryEntries.length - 1; i >= 0; --i) {
|
|
411
|
+
var entry = this.tryEntries[i],
|
|
412
|
+
record = entry.completion;
|
|
413
|
+
if ("root" === entry.tryLoc) return handle("end");
|
|
414
|
+
|
|
415
|
+
if (entry.tryLoc <= this.prev) {
|
|
416
|
+
var hasCatch = hasOwn.call(entry, "catchLoc"),
|
|
417
|
+
hasFinally = hasOwn.call(entry, "finallyLoc");
|
|
418
|
+
|
|
419
|
+
if (hasCatch && hasFinally) {
|
|
420
|
+
if (this.prev < entry.catchLoc) return handle(entry.catchLoc, !0);
|
|
421
|
+
if (this.prev < entry.finallyLoc) return handle(entry.finallyLoc);
|
|
422
|
+
} else if (hasCatch) {
|
|
423
|
+
if (this.prev < entry.catchLoc) return handle(entry.catchLoc, !0);
|
|
424
|
+
} else {
|
|
425
|
+
if (!hasFinally) throw new Error("try statement without catch or finally");
|
|
426
|
+
if (this.prev < entry.finallyLoc) return handle(entry.finallyLoc);
|
|
427
|
+
}
|
|
428
|
+
}
|
|
429
|
+
}
|
|
430
|
+
},
|
|
431
|
+
abrupt: function (type, arg) {
|
|
432
|
+
for (var i = this.tryEntries.length - 1; i >= 0; --i) {
|
|
433
|
+
var entry = this.tryEntries[i];
|
|
434
|
+
|
|
435
|
+
if (entry.tryLoc <= this.prev && hasOwn.call(entry, "finallyLoc") && this.prev < entry.finallyLoc) {
|
|
436
|
+
var finallyEntry = entry;
|
|
437
|
+
break;
|
|
438
|
+
}
|
|
439
|
+
}
|
|
440
|
+
|
|
441
|
+
finallyEntry && ("break" === type || "continue" === type) && finallyEntry.tryLoc <= arg && arg <= finallyEntry.finallyLoc && (finallyEntry = null);
|
|
442
|
+
var record = finallyEntry ? finallyEntry.completion : {};
|
|
443
|
+
return record.type = type, record.arg = arg, finallyEntry ? (this.method = "next", this.next = finallyEntry.finallyLoc, ContinueSentinel) : this.complete(record);
|
|
444
|
+
},
|
|
445
|
+
complete: function (record, afterLoc) {
|
|
446
|
+
if ("throw" === record.type) throw record.arg;
|
|
447
|
+
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;
|
|
448
|
+
},
|
|
449
|
+
finish: function (finallyLoc) {
|
|
450
|
+
for (var i = this.tryEntries.length - 1; i >= 0; --i) {
|
|
451
|
+
var entry = this.tryEntries[i];
|
|
452
|
+
if (entry.finallyLoc === finallyLoc) return this.complete(entry.completion, entry.afterLoc), resetTryEntry(entry), ContinueSentinel;
|
|
453
|
+
}
|
|
454
|
+
},
|
|
455
|
+
catch: function (tryLoc) {
|
|
456
|
+
for (var i = this.tryEntries.length - 1; i >= 0; --i) {
|
|
457
|
+
var entry = this.tryEntries[i];
|
|
458
|
+
|
|
459
|
+
if (entry.tryLoc === tryLoc) {
|
|
460
|
+
var record = entry.completion;
|
|
461
|
+
|
|
462
|
+
if ("throw" === record.type) {
|
|
463
|
+
var thrown = record.arg;
|
|
464
|
+
resetTryEntry(entry);
|
|
465
|
+
}
|
|
466
|
+
|
|
467
|
+
return thrown;
|
|
468
|
+
}
|
|
469
|
+
}
|
|
470
|
+
|
|
471
|
+
throw new Error("illegal catch attempt");
|
|
472
|
+
},
|
|
473
|
+
delegateYield: function (iterable, resultName, nextLoc) {
|
|
474
|
+
return this.delegate = {
|
|
475
|
+
iterator: values(iterable),
|
|
476
|
+
resultName: resultName,
|
|
477
|
+
nextLoc: nextLoc
|
|
478
|
+
}, "next" === this.method && (this.arg = undefined), ContinueSentinel;
|
|
479
|
+
}
|
|
480
|
+
}, exports;
|
|
481
|
+
}
|
|
482
|
+
|
|
483
|
+
function _typeof(obj) {
|
|
484
|
+
"@babel/helpers - typeof";
|
|
485
|
+
|
|
486
|
+
return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (obj) {
|
|
487
|
+
return typeof obj;
|
|
488
|
+
} : function (obj) {
|
|
489
|
+
return obj && "function" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj;
|
|
490
|
+
}, _typeof(obj);
|
|
491
|
+
}
|
|
492
|
+
|
|
493
|
+
function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) {
|
|
494
|
+
try {
|
|
495
|
+
var info = gen[key](arg);
|
|
496
|
+
var value = info.value;
|
|
497
|
+
} catch (error) {
|
|
498
|
+
reject(error);
|
|
499
|
+
return;
|
|
500
|
+
}
|
|
501
|
+
|
|
502
|
+
if (info.done) {
|
|
503
|
+
resolve(value);
|
|
504
|
+
} else {
|
|
505
|
+
Promise.resolve(value).then(_next, _throw);
|
|
506
|
+
}
|
|
507
|
+
}
|
|
508
|
+
|
|
509
|
+
function _asyncToGenerator(fn) {
|
|
510
|
+
return function () {
|
|
511
|
+
var self = this,
|
|
512
|
+
args = arguments;
|
|
513
|
+
return new Promise(function (resolve, reject) {
|
|
514
|
+
var gen = fn.apply(self, args);
|
|
515
|
+
|
|
516
|
+
function _next(value) {
|
|
517
|
+
asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value);
|
|
518
|
+
}
|
|
519
|
+
|
|
520
|
+
function _throw(err) {
|
|
521
|
+
asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err);
|
|
522
|
+
}
|
|
523
|
+
|
|
524
|
+
_next(undefined);
|
|
525
|
+
});
|
|
526
|
+
};
|
|
527
|
+
}
|
|
528
|
+
|
|
529
|
+
function _classCallCheck(instance, Constructor) {
|
|
530
|
+
if (!(instance instanceof Constructor)) {
|
|
531
|
+
throw new TypeError("Cannot call a class as a function");
|
|
532
|
+
}
|
|
533
|
+
}
|
|
534
|
+
|
|
535
|
+
function _defineProperties(target, props) {
|
|
536
|
+
for (var i = 0; i < props.length; i++) {
|
|
537
|
+
var descriptor = props[i];
|
|
538
|
+
descriptor.enumerable = descriptor.enumerable || false;
|
|
539
|
+
descriptor.configurable = true;
|
|
540
|
+
if ("value" in descriptor) descriptor.writable = true;
|
|
541
|
+
Object.defineProperty(target, descriptor.key, descriptor);
|
|
542
|
+
}
|
|
543
|
+
}
|
|
544
|
+
|
|
545
|
+
function _createClass(Constructor, protoProps, staticProps) {
|
|
546
|
+
if (protoProps) _defineProperties(Constructor.prototype, protoProps);
|
|
547
|
+
if (staticProps) _defineProperties(Constructor, staticProps);
|
|
548
|
+
Object.defineProperty(Constructor, "prototype", {
|
|
549
|
+
writable: false
|
|
550
|
+
});
|
|
551
|
+
return Constructor;
|
|
552
|
+
}
|
|
553
|
+
|
|
554
|
+
function _defineProperty(obj, key, value) {
|
|
555
|
+
if (key in obj) {
|
|
556
|
+
Object.defineProperty(obj, key, {
|
|
557
|
+
value: value,
|
|
558
|
+
enumerable: true,
|
|
559
|
+
configurable: true,
|
|
560
|
+
writable: true
|
|
561
|
+
});
|
|
562
|
+
} else {
|
|
563
|
+
obj[key] = value;
|
|
564
|
+
}
|
|
565
|
+
|
|
566
|
+
return obj;
|
|
567
|
+
}
|
|
568
|
+
|
|
569
|
+
function _inherits(subClass, superClass) {
|
|
570
|
+
if (typeof superClass !== "function" && superClass !== null) {
|
|
571
|
+
throw new TypeError("Super expression must either be null or a function");
|
|
572
|
+
}
|
|
573
|
+
|
|
574
|
+
subClass.prototype = Object.create(superClass && superClass.prototype, {
|
|
575
|
+
constructor: {
|
|
576
|
+
value: subClass,
|
|
577
|
+
writable: true,
|
|
578
|
+
configurable: true
|
|
579
|
+
}
|
|
580
|
+
});
|
|
581
|
+
Object.defineProperty(subClass, "prototype", {
|
|
582
|
+
writable: false
|
|
583
|
+
});
|
|
584
|
+
if (superClass) _setPrototypeOf(subClass, superClass);
|
|
585
|
+
}
|
|
586
|
+
|
|
587
|
+
function _getPrototypeOf(o) {
|
|
588
|
+
_getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf.bind() : function _getPrototypeOf(o) {
|
|
589
|
+
return o.__proto__ || Object.getPrototypeOf(o);
|
|
590
|
+
};
|
|
591
|
+
return _getPrototypeOf(o);
|
|
592
|
+
}
|
|
593
|
+
|
|
594
|
+
function _setPrototypeOf(o, p) {
|
|
595
|
+
_setPrototypeOf = Object.setPrototypeOf ? Object.setPrototypeOf.bind() : function _setPrototypeOf(o, p) {
|
|
596
|
+
o.__proto__ = p;
|
|
597
|
+
return o;
|
|
598
|
+
};
|
|
599
|
+
return _setPrototypeOf(o, p);
|
|
600
|
+
}
|
|
601
|
+
|
|
602
|
+
function _isNativeReflectConstruct() {
|
|
603
|
+
if (typeof Reflect === "undefined" || !Reflect.construct) return false;
|
|
604
|
+
if (Reflect.construct.sham) return false;
|
|
605
|
+
if (typeof Proxy === "function") return true;
|
|
606
|
+
|
|
607
|
+
try {
|
|
608
|
+
Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {}));
|
|
609
|
+
return true;
|
|
610
|
+
} catch (e) {
|
|
611
|
+
return false;
|
|
612
|
+
}
|
|
613
|
+
}
|
|
614
|
+
|
|
615
|
+
function _assertThisInitialized(self) {
|
|
616
|
+
if (self === void 0) {
|
|
617
|
+
throw new ReferenceError("this hasn't been initialised - super() hasn't been called");
|
|
618
|
+
}
|
|
619
|
+
|
|
620
|
+
return self;
|
|
621
|
+
}
|
|
622
|
+
|
|
623
|
+
function _possibleConstructorReturn(self, call) {
|
|
624
|
+
if (call && (typeof call === "object" || typeof call === "function")) {
|
|
625
|
+
return call;
|
|
626
|
+
} else if (call !== void 0) {
|
|
627
|
+
throw new TypeError("Derived constructors may only return object or undefined");
|
|
628
|
+
}
|
|
629
|
+
|
|
630
|
+
return _assertThisInitialized(self);
|
|
631
|
+
}
|
|
632
|
+
|
|
633
|
+
function _createSuper(Derived) {
|
|
634
|
+
var hasNativeReflectConstruct = _isNativeReflectConstruct();
|
|
635
|
+
|
|
636
|
+
return function _createSuperInternal() {
|
|
637
|
+
var Super = _getPrototypeOf(Derived),
|
|
638
|
+
result;
|
|
639
|
+
|
|
640
|
+
if (hasNativeReflectConstruct) {
|
|
641
|
+
var NewTarget = _getPrototypeOf(this).constructor;
|
|
642
|
+
|
|
643
|
+
result = Reflect.construct(Super, arguments, NewTarget);
|
|
644
|
+
} else {
|
|
645
|
+
result = Super.apply(this, arguments);
|
|
646
|
+
}
|
|
647
|
+
|
|
648
|
+
return _possibleConstructorReturn(this, result);
|
|
649
|
+
};
|
|
650
|
+
}
|
|
651
|
+
|
|
652
|
+
function _slicedToArray(arr, i) {
|
|
653
|
+
return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest();
|
|
654
|
+
}
|
|
655
|
+
|
|
656
|
+
function _toConsumableArray(arr) {
|
|
657
|
+
return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread();
|
|
658
|
+
}
|
|
659
|
+
|
|
660
|
+
function _arrayWithoutHoles(arr) {
|
|
661
|
+
if (Array.isArray(arr)) return _arrayLikeToArray(arr);
|
|
662
|
+
}
|
|
663
|
+
|
|
664
|
+
function _arrayWithHoles(arr) {
|
|
665
|
+
if (Array.isArray(arr)) return arr;
|
|
666
|
+
}
|
|
667
|
+
|
|
668
|
+
function _iterableToArray(iter) {
|
|
669
|
+
if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter);
|
|
670
|
+
}
|
|
671
|
+
|
|
672
|
+
function _iterableToArrayLimit(arr, i) {
|
|
673
|
+
var _i = arr == null ? null : typeof Symbol !== "undefined" && arr[Symbol.iterator] || arr["@@iterator"];
|
|
674
|
+
|
|
675
|
+
if (_i == null) return;
|
|
676
|
+
var _arr = [];
|
|
677
|
+
var _n = true;
|
|
678
|
+
var _d = false;
|
|
679
|
+
|
|
680
|
+
var _s, _e;
|
|
681
|
+
|
|
682
|
+
try {
|
|
683
|
+
for (_i = _i.call(arr); !(_n = (_s = _i.next()).done); _n = true) {
|
|
684
|
+
_arr.push(_s.value);
|
|
685
|
+
|
|
686
|
+
if (i && _arr.length === i) break;
|
|
687
|
+
}
|
|
688
|
+
} catch (err) {
|
|
689
|
+
_d = true;
|
|
690
|
+
_e = err;
|
|
691
|
+
} finally {
|
|
692
|
+
try {
|
|
693
|
+
if (!_n && _i["return"] != null) _i["return"]();
|
|
694
|
+
} finally {
|
|
695
|
+
if (_d) throw _e;
|
|
696
|
+
}
|
|
697
|
+
}
|
|
698
|
+
|
|
699
|
+
return _arr;
|
|
700
|
+
}
|
|
701
|
+
|
|
702
|
+
function _unsupportedIterableToArray(o, minLen) {
|
|
703
|
+
if (!o) return;
|
|
704
|
+
if (typeof o === "string") return _arrayLikeToArray(o, minLen);
|
|
705
|
+
var n = Object.prototype.toString.call(o).slice(8, -1);
|
|
706
|
+
if (n === "Object" && o.constructor) n = o.constructor.name;
|
|
707
|
+
if (n === "Map" || n === "Set") return Array.from(o);
|
|
708
|
+
if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen);
|
|
709
|
+
}
|
|
710
|
+
|
|
711
|
+
function _arrayLikeToArray(arr, len) {
|
|
712
|
+
if (len == null || len > arr.length) len = arr.length;
|
|
713
|
+
|
|
714
|
+
for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i];
|
|
715
|
+
|
|
716
|
+
return arr2;
|
|
717
|
+
}
|
|
718
|
+
|
|
719
|
+
function _nonIterableSpread() {
|
|
720
|
+
throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
|
|
721
|
+
}
|
|
722
|
+
|
|
723
|
+
function _nonIterableRest() {
|
|
724
|
+
throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
|
|
725
|
+
}
|
|
726
|
+
|
|
727
|
+
var uniqueIdCounter = 0;
|
|
728
|
+
var EventRegistry = function () {
|
|
729
|
+
function EventRegistry(isSingletonHandler) {
|
|
730
|
+
var _this = this;
|
|
731
|
+
|
|
732
|
+
_classCallCheck(this, EventRegistry);
|
|
733
|
+
|
|
734
|
+
_defineProperty(this, "register", function (callback) {
|
|
735
|
+
var id;
|
|
736
|
+
|
|
737
|
+
if (_this.isSingletonHandler) {
|
|
738
|
+
_this.handler = callback;
|
|
739
|
+
return function () {
|
|
740
|
+
return _this.handler = undefined;
|
|
741
|
+
};
|
|
742
|
+
} else {
|
|
743
|
+
id = uniqueIdCounter++;
|
|
744
|
+
|
|
745
|
+
_this.handlers.push({
|
|
746
|
+
callback: callback,
|
|
747
|
+
id: id
|
|
748
|
+
});
|
|
749
|
+
|
|
750
|
+
return function () {
|
|
751
|
+
_this.unregister(id);
|
|
752
|
+
};
|
|
753
|
+
}
|
|
754
|
+
});
|
|
755
|
+
|
|
756
|
+
this.isSingletonHandler = !!isSingletonHandler;
|
|
757
|
+
this.handlers = [];
|
|
758
|
+
|
|
759
|
+
this.handler = function () {};
|
|
760
|
+
}
|
|
761
|
+
|
|
762
|
+
_createClass(EventRegistry, [{
|
|
763
|
+
key: "unregister",
|
|
764
|
+
value: function unregister(id) {
|
|
765
|
+
var foundIdx;
|
|
766
|
+
|
|
767
|
+
if (this.isSingletonHandler) {
|
|
768
|
+
return;
|
|
769
|
+
}
|
|
770
|
+
|
|
771
|
+
foundIdx = this.handlers.findIndex(function (handler) {
|
|
772
|
+
return handler.id === id;
|
|
773
|
+
});
|
|
774
|
+
|
|
775
|
+
if (foundIdx !== -1) {
|
|
776
|
+
this.handlers.splice(foundIdx, 1);
|
|
777
|
+
}
|
|
778
|
+
}
|
|
779
|
+
}, {
|
|
780
|
+
key: "trigger",
|
|
781
|
+
value: function trigger(data) {
|
|
782
|
+
if (this.isSingletonHandler) {
|
|
783
|
+
return this.handler(data);
|
|
784
|
+
} else {
|
|
785
|
+
this.handlers.forEach(function (handler) {
|
|
786
|
+
handler.callback(data);
|
|
787
|
+
});
|
|
788
|
+
}
|
|
789
|
+
}
|
|
790
|
+
}]);
|
|
791
|
+
|
|
792
|
+
return EventRegistry;
|
|
793
|
+
}();
|
|
794
|
+
|
|
795
|
+
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 : {};
|
|
796
|
+
var pluginSdkClient;
|
|
797
|
+
var events = {
|
|
798
|
+
'actions_task': {
|
|
799
|
+
save: new EventRegistry(true)
|
|
800
|
+
}
|
|
801
|
+
};
|
|
802
|
+
var pluginTypeHandlers = {
|
|
803
|
+
'actions_task': {
|
|
804
|
+
save: function save(data) {
|
|
805
|
+
return events['actions_task'].save.trigger(data);
|
|
806
|
+
}
|
|
807
|
+
}
|
|
808
|
+
};
|
|
809
|
+
var PluginSdkService = {
|
|
810
|
+
getPluginSdkClient: getPluginSdkClient
|
|
811
|
+
};
|
|
812
|
+
|
|
813
|
+
function getPluginSdkClient(handlers) {
|
|
814
|
+
var isAlpha = !globalObj.PluginClient;
|
|
815
|
+
|
|
816
|
+
if (pluginSdkClient !== undefined) {
|
|
817
|
+
if (isAlpha) {
|
|
818
|
+
return pluginSdkClient;
|
|
819
|
+
} else {
|
|
820
|
+
return new Promise(function (resolve) {
|
|
821
|
+
return resolve(pluginSdkClient);
|
|
822
|
+
});
|
|
823
|
+
}
|
|
824
|
+
}
|
|
825
|
+
|
|
826
|
+
if (isAlpha) {
|
|
827
|
+
return initializeLegacyPluginClient(globalObj.PluginSDKClient);
|
|
828
|
+
} else if (!isAlpha && globalObj.PluginClient !== undefined) {
|
|
829
|
+
return initializePluginClient(globalObj.PluginClient, handlers);
|
|
830
|
+
} else {
|
|
831
|
+
throw new Error('No PluginClient or PluginSDKClient found on global object');
|
|
832
|
+
}
|
|
833
|
+
}
|
|
834
|
+
|
|
835
|
+
function initializePluginClient(client, handlerConfig) {
|
|
836
|
+
var registerHandler;
|
|
837
|
+
|
|
838
|
+
var _getDefaultHandlersFo = getDefaultHandlersForPluginType(handlerConfig),
|
|
839
|
+
pluginType = _getDefaultHandlersFo.pluginType,
|
|
840
|
+
eventHandlers = _getDefaultHandlersFo.eventHandlers;
|
|
841
|
+
|
|
842
|
+
registerHandler = function registerHandler(eventType, callback) {
|
|
843
|
+
var availableHandlers;
|
|
844
|
+
availableHandlers = Object.keys(eventHandlers);
|
|
845
|
+
|
|
846
|
+
if (availableHandlers.includes(eventType)) {
|
|
847
|
+
return events[pluginType][eventType].register(callback);
|
|
848
|
+
} else {
|
|
849
|
+
return function () {};
|
|
850
|
+
}
|
|
851
|
+
};
|
|
852
|
+
|
|
853
|
+
return client.initialize(eventHandlers).then(function (initializedClient) {
|
|
854
|
+
if (typeof initializedClient.registerHandler !== 'function') {
|
|
855
|
+
initializedClient.registerHandler = registerHandler;
|
|
856
|
+
}
|
|
857
|
+
|
|
858
|
+
pluginSdkClient = initializedClient;
|
|
859
|
+
return pluginSdkClient;
|
|
860
|
+
});
|
|
861
|
+
}
|
|
862
|
+
|
|
863
|
+
function getDefaultHandlersForPluginType(handlerConfig) {
|
|
864
|
+
var pluginType, eventHandlers;
|
|
865
|
+
pluginType = undefined;
|
|
866
|
+
eventHandlers = {};
|
|
867
|
+
|
|
868
|
+
if (_typeof(handlerConfig) === 'object') {
|
|
869
|
+
eventHandlers = handlerConfig;
|
|
870
|
+
} else if (typeof handlerConfig === 'string') {
|
|
871
|
+
pluginType = handlerConfig;
|
|
872
|
+
eventHandlers = pluginTypeHandlers[handlerConfig] || {};
|
|
873
|
+
} else {
|
|
874
|
+
eventHandlers = handlerConfig;
|
|
875
|
+
}
|
|
876
|
+
|
|
877
|
+
return {
|
|
878
|
+
pluginType: pluginType,
|
|
879
|
+
eventHandlers: eventHandlers
|
|
880
|
+
};
|
|
881
|
+
}
|
|
882
|
+
|
|
883
|
+
function initializeLegacyPluginClient(client) {
|
|
884
|
+
console.error('Warning - Initializing outdated version of PluginSDKClient. Please upgrade to PluginClient v1.0.0');
|
|
885
|
+
pluginSdkClient = client.initialize();
|
|
886
|
+
return pluginSdkClient;
|
|
887
|
+
}
|
|
888
|
+
|
|
889
|
+
var languageCodeMapping = {
|
|
890
|
+
DA: 'da',
|
|
891
|
+
DE: 'de',
|
|
892
|
+
EN: 'en',
|
|
893
|
+
'EN-GB': 'en-GB',
|
|
894
|
+
ES: 'es',
|
|
895
|
+
'ES-ES': 'es-419',
|
|
896
|
+
FI: 'fi',
|
|
897
|
+
FR: 'fr',
|
|
898
|
+
'FR-CA': 'fr-CA',
|
|
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
|
+
function __awaiter(thisArg, _arguments, P, generator) {
|
|
965
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
966
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
967
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
968
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
969
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
970
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
971
|
+
});
|
|
972
|
+
}
|
|
973
|
+
|
|
974
|
+
function __generator(thisArg, body) {
|
|
975
|
+
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
|
|
976
|
+
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
|
|
977
|
+
function verb(n) { return function (v) { return step([n, v]); }; }
|
|
978
|
+
function step(op) {
|
|
979
|
+
if (f) throw new TypeError("Generator is already executing.");
|
|
980
|
+
while (_) try {
|
|
981
|
+
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
|
|
982
|
+
if (y = 0, t) op = [op[0] & 2, t.value];
|
|
983
|
+
switch (op[0]) {
|
|
984
|
+
case 0: case 1: t = op; break;
|
|
985
|
+
case 4: _.label++; return { value: op[1], done: false };
|
|
986
|
+
case 5: _.label++; y = op[1]; op = [0]; continue;
|
|
987
|
+
case 7: op = _.ops.pop(); _.trys.pop(); continue;
|
|
988
|
+
default:
|
|
989
|
+
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
|
|
990
|
+
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
|
|
991
|
+
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
|
|
992
|
+
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
|
|
993
|
+
if (t[2]) _.ops.pop();
|
|
994
|
+
_.trys.pop(); continue;
|
|
995
|
+
}
|
|
996
|
+
op = body.call(thisArg, _);
|
|
997
|
+
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
|
|
998
|
+
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
|
999
|
+
}
|
|
1000
|
+
}
|
|
1001
|
+
|
|
1002
|
+
function __spreadArray(to, from, pack) {
|
|
1003
|
+
if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
|
|
1004
|
+
if (ar || !(i in from)) {
|
|
1005
|
+
if (!ar) ar = Array.prototype.slice.call(from, 0, i);
|
|
1006
|
+
ar[i] = from[i];
|
|
1007
|
+
}
|
|
1008
|
+
}
|
|
1009
|
+
return to.concat(ar || Array.prototype.slice.call(from));
|
|
1010
|
+
}
|
|
1011
|
+
|
|
1012
|
+
var Portal = function (_Component) {
|
|
1013
|
+
_inherits(Portal, _Component);
|
|
1014
|
+
|
|
1015
|
+
var _super = _createSuper(Portal);
|
|
1016
|
+
|
|
1017
|
+
function Portal() {
|
|
1018
|
+
var _this;
|
|
1019
|
+
|
|
1020
|
+
_classCallCheck(this, Portal);
|
|
1021
|
+
|
|
1022
|
+
for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
|
|
1023
|
+
args[_key] = arguments[_key];
|
|
1024
|
+
}
|
|
1025
|
+
|
|
1026
|
+
_this = _super.call.apply(_super, [this].concat(args));
|
|
1027
|
+
|
|
1028
|
+
_defineProperty(_assertThisInitialized(_this), "rootSelector", document.body);
|
|
1029
|
+
|
|
1030
|
+
_defineProperty(_assertThisInitialized(_this), "container", document.createElement('div'));
|
|
1031
|
+
|
|
1032
|
+
return _this;
|
|
1033
|
+
}
|
|
1034
|
+
|
|
1035
|
+
_createClass(Portal, [{
|
|
1036
|
+
key: "componentDidMount",
|
|
1037
|
+
value: function componentDidMount() {
|
|
1038
|
+
this.rootSelector.appendChild(this.container);
|
|
1039
|
+
}
|
|
1040
|
+
}, {
|
|
1041
|
+
key: "componentWillUnmount",
|
|
1042
|
+
value: function componentWillUnmount() {
|
|
1043
|
+
this.rootSelector.removeChild(this.container);
|
|
1044
|
+
}
|
|
1045
|
+
}, {
|
|
1046
|
+
key: "render",
|
|
1047
|
+
value: function render() {
|
|
1048
|
+
return ReactDOM.createPortal(this.props.children, this.container);
|
|
1049
|
+
}
|
|
1050
|
+
}]);
|
|
1051
|
+
|
|
1052
|
+
return Portal;
|
|
1053
|
+
}(Component);
|
|
1054
|
+
|
|
1055
|
+
var css_248z$l = ".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";
|
|
1056
|
+
styleInject(css_248z$l);
|
|
1057
|
+
|
|
1058
|
+
var globalClickRegistry = new EventRegistry();
|
|
1059
|
+
var DEFAULT_PLACEMENT = 'bottom-start';
|
|
1060
|
+
var DEFAULT_ANCHOR = React.createElement(Button, null, " anchor ");
|
|
1061
|
+
var defaultModifiers = [];
|
|
1062
|
+
initGlobalListener();
|
|
1063
|
+
function Popover(props) {
|
|
1064
|
+
var _useState = useState(false),
|
|
1065
|
+
_useState2 = _slicedToArray(_useState, 2),
|
|
1066
|
+
isOpen = _useState2[0],
|
|
1067
|
+
setIsOpen = _useState2[1];
|
|
1068
|
+
|
|
1069
|
+
var modifiers = [].concat(defaultModifiers, _toConsumableArray(props.modifiers || []));
|
|
1070
|
+
|
|
1071
|
+
var closePopover = function closePopover() {
|
|
1072
|
+
setIsOpen(false);
|
|
1073
|
+
props.onClose && props.onClose();
|
|
1074
|
+
};
|
|
1075
|
+
|
|
1076
|
+
var anchorEl = function anchorEl(_ref) {
|
|
1077
|
+
var ref = _ref.ref;
|
|
1078
|
+
var anchor;
|
|
1079
|
+
|
|
1080
|
+
if (typeof props.anchor === 'function') {
|
|
1081
|
+
anchor = props.anchor(ref);
|
|
1082
|
+
} else {
|
|
1083
|
+
anchor = props.anchor;
|
|
1084
|
+
anchor = React.createElement("div", {
|
|
1085
|
+
ref: ref,
|
|
1086
|
+
className: "popover-anchor-container"
|
|
1087
|
+
}, props.anchor || DEFAULT_ANCHOR);
|
|
1088
|
+
}
|
|
1089
|
+
|
|
1090
|
+
return anchor;
|
|
1091
|
+
};
|
|
1092
|
+
|
|
1093
|
+
useEffect(function () {
|
|
1094
|
+
var unregisterFn, ignoreClickSelector;
|
|
1095
|
+
ignoreClickSelector = props.ignoreClickSelector;
|
|
1096
|
+
unregisterFn = globalClickRegistry.register(function (clickEvent) {
|
|
1097
|
+
var ignoreClickEl;
|
|
1098
|
+
|
|
1099
|
+
if (ignoreClickSelector) {
|
|
1100
|
+
ignoreClickEl = clickEvent.target.closest(ignoreClickSelector);
|
|
1101
|
+
}
|
|
1102
|
+
|
|
1103
|
+
if (!ignoreClickEl) {
|
|
1104
|
+
closePopover();
|
|
1105
|
+
}
|
|
1106
|
+
});
|
|
1107
|
+
return function () {
|
|
1108
|
+
unregisterFn();
|
|
1109
|
+
};
|
|
1110
|
+
}, []);
|
|
1111
|
+
useEffect(function () {
|
|
1112
|
+
if (!props.show) {
|
|
1113
|
+
closePopover();
|
|
1114
|
+
} else {
|
|
1115
|
+
setIsOpen(props.show);
|
|
1116
|
+
}
|
|
1117
|
+
}, [props.show]);
|
|
1118
|
+
return React.createElement(Manager, null, React.createElement(Reference, null, anchorEl), React.createElement(Portal, null, isOpen && React.createElement(Popper, {
|
|
1119
|
+
placement: props.placement || DEFAULT_PLACEMENT,
|
|
1120
|
+
modifiers: modifiers
|
|
1121
|
+
}, function (_ref2) {
|
|
1122
|
+
var ref = _ref2.ref,
|
|
1123
|
+
style = _ref2.style,
|
|
1124
|
+
placement = _ref2.placement,
|
|
1125
|
+
arrowProps = _ref2.arrowProps,
|
|
1126
|
+
scheduleUpdate = _ref2.update;
|
|
1127
|
+
var children;
|
|
1128
|
+
children = [];
|
|
1129
|
+
|
|
1130
|
+
if (Array.isArray(props.children)) {
|
|
1131
|
+
children = props.children;
|
|
1132
|
+
} else if (props.children !== undefined) {
|
|
1133
|
+
children = [props.children];
|
|
1134
|
+
}
|
|
1135
|
+
|
|
1136
|
+
children.forEach(function (child) {
|
|
1137
|
+
var optionsRef;
|
|
1138
|
+
|
|
1139
|
+
if (child.props.optionsRef) {
|
|
1140
|
+
optionsRef = child.props.optionsRef;
|
|
1141
|
+
optionsRef.current.scheduleUpdate = scheduleUpdate;
|
|
1142
|
+
}
|
|
1143
|
+
});
|
|
1144
|
+
return React.createElement("div", {
|
|
1145
|
+
ref: ref,
|
|
1146
|
+
"data-placement": placement,
|
|
1147
|
+
style: _objectSpread2({}, style),
|
|
1148
|
+
className: "q-popover"
|
|
1149
|
+
}, props.children, React.createElement("div", {
|
|
1150
|
+
ref: arrowProps.ref,
|
|
1151
|
+
style: arrowProps.style
|
|
1152
|
+
}));
|
|
1153
|
+
})));
|
|
1154
|
+
}
|
|
1155
|
+
|
|
1156
|
+
function initGlobalListener() {
|
|
1157
|
+
window.addEventListener('click', function (evt) {
|
|
1158
|
+
var popoverEl;
|
|
1159
|
+
popoverEl = evt.target.closest('.q-popover');
|
|
1160
|
+
|
|
1161
|
+
if (popoverEl === null) {
|
|
1162
|
+
globalClickRegistry.trigger(evt);
|
|
1163
|
+
} else {
|
|
1164
|
+
evt.stopPropagation();
|
|
1165
|
+
evt.stopImmediatePropagation();
|
|
1166
|
+
}
|
|
1167
|
+
});
|
|
1168
|
+
}
|
|
1169
|
+
|
|
1170
|
+
var css_248z$k = ".piped-text-menu-list .piped-text-popover-menu > * {\n min-height: 32px; }\n";
|
|
1171
|
+
styleInject(css_248z$k);
|
|
1172
|
+
|
|
1173
|
+
/**
|
|
1174
|
+
* Copied from: https://gitlab-app.eng.qops.net/cfe/ui/-/blob/master/packages/ui-react/src/hooks/useId/useId.js
|
|
1175
|
+
* Returns an ID that is stable across renders.
|
|
1176
|
+
* @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.
|
|
1177
|
+
* @returns {String} If an external ID is passed in, the external ID. Otherwise, a randomly generated ID.
|
|
1178
|
+
*/
|
|
1179
|
+
function useId(defaultExternalId) {
|
|
1180
|
+
var currentId = useState(function () {
|
|
1181
|
+
return defaultExternalId !== null && defaultExternalId !== void 0 ? defaultExternalId : v4();
|
|
1182
|
+
})[0];
|
|
1183
|
+
return currentId;
|
|
1184
|
+
}
|
|
1185
|
+
|
|
1186
|
+
var css_248z$j = "";
|
|
1187
|
+
styleInject(css_248z$j);
|
|
1188
|
+
|
|
1189
|
+
function PipedTextMenuLoadError(props) {
|
|
1190
|
+
return (React.createElement("div", { className: "piped-text-popover-container" },
|
|
1191
|
+
React.createElement("div", { className: "piped-text-error-container" },
|
|
1192
|
+
React.createElement("div", { className: "piped-text-error-icon" },
|
|
1193
|
+
React.createElement(ErrorIcon, { size: "medium" })),
|
|
1194
|
+
props.errorText && (React.createElement("div", { className: "piped-text-error-text" }, props.errorText)))));
|
|
1195
|
+
}
|
|
1196
|
+
|
|
1197
|
+
var EMBEDDED_DATA_LOCATOR = 'embeddedData';
|
|
1198
|
+
function checkEmbeddedDataMenuItem(menuItem) {
|
|
1199
|
+
return menuItem.value === EMBEDDED_DATA_LOCATOR;
|
|
1200
|
+
}
|
|
1201
|
+
function checkDecoratedMenuItem(menuItem) {
|
|
1202
|
+
return (menuItem.header === true)
|
|
1203
|
+
|| (menuItem.disabled === true);
|
|
1204
|
+
}
|
|
1205
|
+
function checkSubmenuMenuItemItem(menuItem) {
|
|
1206
|
+
return !!menuItem.hasSubmenu;
|
|
1207
|
+
}
|
|
1208
|
+
function checkMenuItemFocusable(menuItem) {
|
|
1209
|
+
var isEmbeddedData, isSubmenu, isDefaultMenuItem;
|
|
1210
|
+
isEmbeddedData = checkEmbeddedDataMenuItem(menuItem);
|
|
1211
|
+
isSubmenu = checkSubmenuMenuItemItem(menuItem);
|
|
1212
|
+
isDefaultMenuItem = checkDefaultMenuItem(menuItem);
|
|
1213
|
+
return (isEmbeddedData
|
|
1214
|
+
|| isSubmenu
|
|
1215
|
+
|| isDefaultMenuItem);
|
|
1216
|
+
}
|
|
1217
|
+
function checkDefaultMenuItem(menuItem) {
|
|
1218
|
+
return !(checkEmbeddedDataMenuItem(menuItem)
|
|
1219
|
+
|| checkDecoratedMenuItem(menuItem)
|
|
1220
|
+
|| checkSubmenuMenuItemItem(menuItem));
|
|
1221
|
+
}
|
|
1222
|
+
|
|
1223
|
+
var css_248z$i = "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-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.piped-text-menu-item-container.highlighted-menu-item {\n background: RGBA(50, 54, 58, 0.08); }\n\n.piped-text-menu-item-container .piped-text-menu-item, .piped-text-menu-item-container .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-container .piped-text-menu-item:not(.piped-text-header):not(.piped-text-disabled):hover, .piped-text-menu-item-container .piped-text-submenu-item:not(.piped-text-header):not(.piped-text-disabled):hover {\n cursor: pointer; }\n .piped-text-menu-item-container .piped-text-menu-item.piped-text-header, .piped-text-menu-item-container .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-container .piped-text-menu-item.piped-text-disabled:not(.piped-text-header), .piped-text-menu-item-container .piped-text-submenu-item.piped-text-disabled:not(.piped-text-header) {\n color: RGB(116, 119, 122); }\n";
|
|
1224
|
+
styleInject(css_248z$i);
|
|
1225
|
+
|
|
1226
|
+
var css_248z$h = "";
|
|
1227
|
+
styleInject(css_248z$h);
|
|
1228
|
+
|
|
1229
|
+
// const WrappedPipedTextMenu = PipedTextMenu as PipedTextMenuType;
|
|
1230
|
+
var PipedTextSubmenuItem = React.forwardRef(function PipedTextSubmenuItem(props, ref) {
|
|
1231
|
+
var submenuAnchorRef = useRef(null);
|
|
1232
|
+
var submenuAnchorId = useId();
|
|
1233
|
+
var menuItem = props.menuItem;
|
|
1234
|
+
return (React.createElement("div", { "data-testid": "piped-text-submenu", className: "piped-text-submenu-item-container", role: 'presentation' },
|
|
1235
|
+
menuItem.show && (React.createElement(PipedTextMenu, { "aria-labelledby": submenuAnchorId,
|
|
1236
|
+
//@ts-ignore
|
|
1237
|
+
items: menuItem.submenu.items, show: menuItem.show, placement: "right-start", onClose: function () {
|
|
1238
|
+
menuItem.show = false;
|
|
1239
|
+
}, 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, keyboardCtrl: props.keyboardCtrl, pipedTextMenuId: props.pipedTextMenuId })),
|
|
1240
|
+
React.createElement("div", { id: submenuAnchorId, className: "piped-text-submenu-item", ref: submenuAnchorRef },
|
|
1241
|
+
React.createElement("div", { className: "label-text" }, menuItem.label),
|
|
1242
|
+
React.createElement("div", { className: "piped-text-icon" },
|
|
1243
|
+
React.createElement(Icon, { type: IconTypes.ChevronRight, size: "medium" })))));
|
|
1244
|
+
function menuItemClicked(menuItem) {
|
|
1245
|
+
props.onMenuItemClick(menuItem);
|
|
1246
|
+
}
|
|
1247
|
+
});
|
|
1248
|
+
|
|
1249
|
+
var css_248z$g = "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-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";
|
|
1250
|
+
styleInject(css_248z$g);
|
|
1251
|
+
|
|
1252
|
+
var css_248z$f = "";
|
|
1253
|
+
styleInject(css_248z$f);
|
|
1254
|
+
|
|
1255
|
+
var TEXT_INPUT_KEYS_TO_ALLOW = [
|
|
1256
|
+
'ArrowDown',
|
|
1257
|
+
'Escape',
|
|
1258
|
+
'Tab',
|
|
1259
|
+
'PageUp',
|
|
1260
|
+
'Home',
|
|
1261
|
+
'PageDown',
|
|
1262
|
+
'End',
|
|
1263
|
+
'Enter',
|
|
1264
|
+
];
|
|
1265
|
+
var PipedTextMenuFocusItem = /** @class */ (function () {
|
|
1266
|
+
function PipedTextMenuFocusItem(currentContainer, menuItems) {
|
|
1267
|
+
this.currentContainer = currentContainer;
|
|
1268
|
+
this.menuItems = menuItems;
|
|
1269
|
+
this.highlightedIdx = -1;
|
|
1270
|
+
}
|
|
1271
|
+
PipedTextMenuFocusItem.prototype.setMenuItems = function (menuItems) {
|
|
1272
|
+
this.menuItems = menuItems;
|
|
1273
|
+
};
|
|
1274
|
+
PipedTextMenuFocusItem.prototype.findMenuItemIdx = function (menuItemRef) {
|
|
1275
|
+
return this.menuItems.findIndex(function (menuItem) {
|
|
1276
|
+
return menuItem.current === menuItemRef.current;
|
|
1277
|
+
});
|
|
1278
|
+
};
|
|
1279
|
+
return PipedTextMenuFocusItem;
|
|
1280
|
+
}());
|
|
1281
|
+
var PipedTextMenuKeyboardCtrl = /** @class */ (function () {
|
|
1282
|
+
function PipedTextMenuKeyboardCtrl() {
|
|
1283
|
+
this.menuFocusItems = [];
|
|
1284
|
+
this.currFocusItemIdx = -1;
|
|
1285
|
+
}
|
|
1286
|
+
PipedTextMenuKeyboardCtrl.prototype.getFocusMenu = function (containerRef) {
|
|
1287
|
+
var foundMenuFocusItemIdx;
|
|
1288
|
+
foundMenuFocusItemIdx = this.menuFocusItems.findIndex(function (focusItem) {
|
|
1289
|
+
return focusItem.currentContainer.current === containerRef.current;
|
|
1290
|
+
});
|
|
1291
|
+
if (foundMenuFocusItemIdx === -1) {
|
|
1292
|
+
return undefined;
|
|
1293
|
+
}
|
|
1294
|
+
return this.menuFocusItems[foundMenuFocusItemIdx];
|
|
1295
|
+
};
|
|
1296
|
+
PipedTextMenuKeyboardCtrl.prototype.getCurrentFocusMenu = function () {
|
|
1297
|
+
return this.menuFocusItems[this.currFocusItemIdx];
|
|
1298
|
+
};
|
|
1299
|
+
PipedTextMenuKeyboardCtrl.prototype.addMenu = function (containerRef, menuItemRefs) {
|
|
1300
|
+
var menuToSet, foundMenuFocusItemIdx;
|
|
1301
|
+
foundMenuFocusItemIdx = this.menuFocusItems.findIndex(function (menuFocusItem) {
|
|
1302
|
+
return menuFocusItem.currentContainer.current === containerRef.current;
|
|
1303
|
+
});
|
|
1304
|
+
if ((this.menuFocusItems.length === 0)
|
|
1305
|
+
|| (foundMenuFocusItemIdx === -1)) {
|
|
1306
|
+
menuToSet = new PipedTextMenuFocusItem(containerRef, menuItemRefs);
|
|
1307
|
+
this.menuFocusItems.push(menuToSet);
|
|
1308
|
+
}
|
|
1309
|
+
else {
|
|
1310
|
+
menuToSet = this.menuFocusItems[foundMenuFocusItemIdx];
|
|
1311
|
+
menuToSet.setMenuItems(menuItemRefs);
|
|
1312
|
+
}
|
|
1313
|
+
};
|
|
1314
|
+
PipedTextMenuKeyboardCtrl.prototype.removeMenu = function (containerRef) {
|
|
1315
|
+
var foundMenuFocusItemIdx;
|
|
1316
|
+
foundMenuFocusItemIdx = this.menuFocusItems.findIndex(function (menuFocusItem) {
|
|
1317
|
+
return menuFocusItem.currentContainer.current === containerRef.current;
|
|
1318
|
+
});
|
|
1319
|
+
if (foundMenuFocusItemIdx === -1) {
|
|
1320
|
+
console.error(this);
|
|
1321
|
+
console.error(containerRef);
|
|
1322
|
+
throw new Error('Could not find a matching PipedTextMenu');
|
|
1323
|
+
}
|
|
1324
|
+
this.menuFocusItems.splice(foundMenuFocusItemIdx, 1);
|
|
1325
|
+
};
|
|
1326
|
+
PipedTextMenuKeyboardCtrl.prototype.handleKeyEvent = function ($e) {
|
|
1327
|
+
var _a, _b, _c, _d, _e, _f, _g;
|
|
1328
|
+
var key;
|
|
1329
|
+
var currFocusMenu, nextFocusMenu, nextFocusElemRef;
|
|
1330
|
+
var highlightedItem;
|
|
1331
|
+
key = $e.key;
|
|
1332
|
+
currFocusMenu = this.getCurrentFocusMenu();
|
|
1333
|
+
if (currFocusMenu === undefined) {
|
|
1334
|
+
// technically an error case...
|
|
1335
|
+
return;
|
|
1336
|
+
}
|
|
1337
|
+
switch (key) {
|
|
1338
|
+
case 'ArrowDown':
|
|
1339
|
+
/*
|
|
1340
|
+
In the current focused submenu, advance to the next available menu item
|
|
1341
|
+
and set it to highlighted, and trigger a focus on the menu item element
|
|
1342
|
+
*/
|
|
1343
|
+
if (currFocusMenu.highlightedIdx < (currFocusMenu.menuItems.length - 1)) {
|
|
1344
|
+
nextFocusElemRef = currFocusMenu.menuItems[currFocusMenu.highlightedIdx + 1];
|
|
1345
|
+
this.setFocusMenuHighlightedIdx(currFocusMenu.currentContainer, nextFocusElemRef);
|
|
1346
|
+
(_a = nextFocusElemRef === null || nextFocusElemRef === void 0 ? void 0 : nextFocusElemRef.current) === null || _a === void 0 ? void 0 : _a.focus();
|
|
1347
|
+
}
|
|
1348
|
+
break;
|
|
1349
|
+
case 'ArrowUp':
|
|
1350
|
+
/*
|
|
1351
|
+
In the current focused submenu, advance to the previous available menu item
|
|
1352
|
+
and set it to highlighted, and trigger a focus on the menu item element
|
|
1353
|
+
*/
|
|
1354
|
+
if (currFocusMenu.highlightedIdx > 0) {
|
|
1355
|
+
nextFocusElemRef = currFocusMenu.menuItems[currFocusMenu.highlightedIdx - 1];
|
|
1356
|
+
this.setFocusMenuHighlightedIdx(currFocusMenu.currentContainer, nextFocusElemRef);
|
|
1357
|
+
(_b = nextFocusElemRef === null || nextFocusElemRef === void 0 ? void 0 : nextFocusElemRef.current) === null || _b === void 0 ? void 0 : _b.focus();
|
|
1358
|
+
}
|
|
1359
|
+
break;
|
|
1360
|
+
case 'ArrowRight':
|
|
1361
|
+
this.focusNextSubmenu();
|
|
1362
|
+
break;
|
|
1363
|
+
case 'ArrowLeft':
|
|
1364
|
+
case 'Escape':
|
|
1365
|
+
/*
|
|
1366
|
+
Set the previous (parent) submenu as the current focused menu.
|
|
1367
|
+
If it has a child menuitem to highlight, focus the highlighted menu item.
|
|
1368
|
+
If no menuitem is highlighted in the target submenu, call focus() on the
|
|
1369
|
+
container element; the container element focus event handler is expected to
|
|
1370
|
+
respond to the event and set it's own highlighted element and index.
|
|
1371
|
+
*/
|
|
1372
|
+
if (this.currFocusItemIdx > 0) {
|
|
1373
|
+
$e.stopPropagation();
|
|
1374
|
+
nextFocusMenu = this.menuFocusItems[this.currFocusItemIdx - 1];
|
|
1375
|
+
if (nextFocusMenu !== undefined) {
|
|
1376
|
+
highlightedItem = nextFocusMenu.menuItems[nextFocusMenu.highlightedIdx];
|
|
1377
|
+
if (highlightedItem === undefined) {
|
|
1378
|
+
(_d = (_c = nextFocusMenu.currentContainer) === null || _c === void 0 ? void 0 : _c.current) === null || _d === void 0 ? void 0 : _d.focus();
|
|
1379
|
+
}
|
|
1380
|
+
else {
|
|
1381
|
+
(_e = highlightedItem === null || highlightedItem === void 0 ? void 0 : highlightedItem.current) === null || _e === void 0 ? void 0 : _e.focus();
|
|
1382
|
+
}
|
|
1383
|
+
}
|
|
1384
|
+
}
|
|
1385
|
+
break;
|
|
1386
|
+
case 'PageUp':
|
|
1387
|
+
case 'Home':
|
|
1388
|
+
/*
|
|
1389
|
+
Focus the first menuitem in the current focus menu
|
|
1390
|
+
*/
|
|
1391
|
+
nextFocusElemRef = currFocusMenu.menuItems[0];
|
|
1392
|
+
if (nextFocusElemRef) {
|
|
1393
|
+
this.setFocusMenuHighlightedIdx(currFocusMenu.currentContainer, nextFocusElemRef);
|
|
1394
|
+
(_f = nextFocusElemRef === null || nextFocusElemRef === void 0 ? void 0 : nextFocusElemRef.current) === null || _f === void 0 ? void 0 : _f.focus();
|
|
1395
|
+
}
|
|
1396
|
+
break;
|
|
1397
|
+
case 'PageDown':
|
|
1398
|
+
case 'End':
|
|
1399
|
+
/*
|
|
1400
|
+
Focus the last menuitem in the current focus menu
|
|
1401
|
+
*/
|
|
1402
|
+
nextFocusElemRef = currFocusMenu.menuItems[currFocusMenu.menuItems.length - 1];
|
|
1403
|
+
if (nextFocusElemRef) {
|
|
1404
|
+
this.setFocusMenuHighlightedIdx(currFocusMenu.currentContainer, nextFocusElemRef);
|
|
1405
|
+
(_g = nextFocusElemRef === null || nextFocusElemRef === void 0 ? void 0 : nextFocusElemRef.current) === null || _g === void 0 ? void 0 : _g.focus();
|
|
1406
|
+
}
|
|
1407
|
+
break;
|
|
1408
|
+
}
|
|
1409
|
+
};
|
|
1410
|
+
PipedTextMenuKeyboardCtrl.prototype.focusNextSubmenu = function () {
|
|
1411
|
+
var _a, _b, _c;
|
|
1412
|
+
var currFocusMenu, nextFocusMenu, highlightedItem;
|
|
1413
|
+
currFocusMenu = this.getCurrentFocusMenu();
|
|
1414
|
+
if (currFocusMenu === undefined) {
|
|
1415
|
+
// technically an error case...
|
|
1416
|
+
return;
|
|
1417
|
+
}
|
|
1418
|
+
nextFocusMenu = this.menuFocusItems[this.currFocusItemIdx + 1];
|
|
1419
|
+
if (nextFocusMenu !== undefined) {
|
|
1420
|
+
highlightedItem = nextFocusMenu.menuItems[nextFocusMenu.highlightedIdx];
|
|
1421
|
+
if (highlightedItem === undefined) {
|
|
1422
|
+
(_b = (_a = nextFocusMenu.currentContainer) === null || _a === void 0 ? void 0 : _a.current) === null || _b === void 0 ? void 0 : _b.focus();
|
|
1423
|
+
}
|
|
1424
|
+
else {
|
|
1425
|
+
(_c = highlightedItem === null || highlightedItem === void 0 ? void 0 : highlightedItem.current) === null || _c === void 0 ? void 0 : _c.focus();
|
|
1426
|
+
}
|
|
1427
|
+
}
|
|
1428
|
+
};
|
|
1429
|
+
PipedTextMenuKeyboardCtrl.prototype.getCurrentFocusMenuRef = function () {
|
|
1430
|
+
var _a;
|
|
1431
|
+
return (_a = this.getCurrentFocusMenu()) === null || _a === void 0 ? void 0 : _a.currentContainer;
|
|
1432
|
+
};
|
|
1433
|
+
PipedTextMenuKeyboardCtrl.prototype.isMenuItemInCurrentFocusMenu = function (menuItemRef) {
|
|
1434
|
+
var currentFocusMenu, foundFocusMenuItemRef;
|
|
1435
|
+
currentFocusMenu = this.getCurrentFocusMenu();
|
|
1436
|
+
foundFocusMenuItemRef = currentFocusMenu.menuItems.find(function (menuItem) {
|
|
1437
|
+
return menuItem.current === menuItemRef.current;
|
|
1438
|
+
});
|
|
1439
|
+
return foundFocusMenuItemRef !== undefined;
|
|
1440
|
+
};
|
|
1441
|
+
PipedTextMenuKeyboardCtrl.prototype.setFocus = function (focusedEl) {
|
|
1442
|
+
var foundMenuFocusItemIdx;
|
|
1443
|
+
foundMenuFocusItemIdx = this.menuFocusItems.findIndex(function (menuFocusItem) {
|
|
1444
|
+
return menuFocusItem.currentContainer.current === focusedEl;
|
|
1445
|
+
});
|
|
1446
|
+
if (foundMenuFocusItemIdx === -1) {
|
|
1447
|
+
console.error(this);
|
|
1448
|
+
console.error(focusedEl);
|
|
1449
|
+
throw new Error('Could not find a matching PipedTextMenu');
|
|
1450
|
+
}
|
|
1451
|
+
this.currFocusItemIdx = foundMenuFocusItemIdx;
|
|
1452
|
+
};
|
|
1453
|
+
PipedTextMenuKeyboardCtrl.prototype.getFocusMenuHighlightedIdx = function (containerRef) {
|
|
1454
|
+
var focusMenu;
|
|
1455
|
+
focusMenu = this.getFocusMenu(containerRef);
|
|
1456
|
+
if (focusMenu === undefined) {
|
|
1457
|
+
return -1;
|
|
1458
|
+
}
|
|
1459
|
+
return focusMenu.highlightedIdx;
|
|
1460
|
+
};
|
|
1461
|
+
PipedTextMenuKeyboardCtrl.prototype.setFocusMenuHighlightedIdx = function (containerRef, highlightedItemRef) {
|
|
1462
|
+
var foundMenuFocusItem, foundHighlightedItemIdx;
|
|
1463
|
+
foundMenuFocusItem = this.getFocusMenu(containerRef);
|
|
1464
|
+
if (foundMenuFocusItem === undefined) {
|
|
1465
|
+
return;
|
|
1466
|
+
}
|
|
1467
|
+
foundHighlightedItemIdx = foundMenuFocusItem.findMenuItemIdx(highlightedItemRef);
|
|
1468
|
+
if (foundHighlightedItemIdx === -1) {
|
|
1469
|
+
return;
|
|
1470
|
+
}
|
|
1471
|
+
foundMenuFocusItem.highlightedIdx = foundHighlightedItemIdx;
|
|
1472
|
+
};
|
|
1473
|
+
return PipedTextMenuKeyboardCtrl;
|
|
1474
|
+
}());
|
|
1475
|
+
|
|
1476
|
+
function EmbeddedDataInput(props) {
|
|
1477
|
+
var _a = useState(''), inputValue = _a[0], setInputValue = _a[1];
|
|
1478
|
+
var _b = useState(false), isInputInvalid = _b[0], setIsInputInvalid = _b[1];
|
|
1479
|
+
var containerRef = useRef();
|
|
1480
|
+
var inputRef = useRef();
|
|
1481
|
+
useEffect(function () {
|
|
1482
|
+
props.keyboardCtrl.addMenu(containerRef, [
|
|
1483
|
+
inputRef,
|
|
1484
|
+
]);
|
|
1485
|
+
}, [
|
|
1486
|
+
containerRef
|
|
1487
|
+
]);
|
|
1488
|
+
useEffect(function () {
|
|
1489
|
+
var $destroy = function () {
|
|
1490
|
+
props.keyboardCtrl.removeMenu(containerRef);
|
|
1491
|
+
};
|
|
1492
|
+
return $destroy;
|
|
1493
|
+
}, []);
|
|
1494
|
+
return (React.createElement("div", { className: 'embedded-data-input', tabIndex: -1, "aria-labelledby": props.ariaLabelledById, ref: containerRef, onFocus: handleContainerFocus, onKeyDown: handleContainerKeyDown },
|
|
1495
|
+
React.createElement(InputGroup, null,
|
|
1496
|
+
React.createElement(Input, { onChange: function ($e) {
|
|
1497
|
+
handleInputChange($e);
|
|
1498
|
+
}, invalid: isInputInvalid, onKeyDown: handleInputKeyDown, className: 'q-plugin-popover-input', ref: inputRef }),
|
|
1499
|
+
React.createElement(Button, { kind: 'primary', onClick: handleAddButtonClick, onKeyDown: handleAddButtonKeyDown, onFocus: function ($e) {
|
|
1500
|
+
$e.stopPropagation();
|
|
1501
|
+
} },
|
|
1502
|
+
React.createElement(Icon, { type: IconTypes.Add })))));
|
|
1503
|
+
function handleContainerFocus($e) {
|
|
1504
|
+
var _a;
|
|
1505
|
+
if ($e.currentTarget === containerRef.current) {
|
|
1506
|
+
props.keyboardCtrl.setFocus(containerRef.current);
|
|
1507
|
+
(_a = inputRef === null || inputRef === void 0 ? void 0 : inputRef.current) === null || _a === void 0 ? void 0 : _a.focus();
|
|
1508
|
+
props.keyboardCtrl.setFocusMenuHighlightedIdx(containerRef, inputRef);
|
|
1509
|
+
$e.stopPropagation();
|
|
1510
|
+
$e.preventDefault();
|
|
1511
|
+
}
|
|
1512
|
+
}
|
|
1513
|
+
function handleContainerKeyDown($e) {
|
|
1514
|
+
switch ($e.key) {
|
|
1515
|
+
case 'ArrowDown':
|
|
1516
|
+
case 'ArrowUp':
|
|
1517
|
+
case 'ArrowRight':
|
|
1518
|
+
case 'ArrowLeft':
|
|
1519
|
+
case 'Escape':
|
|
1520
|
+
props.keyboardCtrl.handleKeyEvent($e);
|
|
1521
|
+
$e.preventDefault(); // prevent scroll
|
|
1522
|
+
break;
|
|
1523
|
+
case 'Enter':
|
|
1524
|
+
handleAddButtonClick();
|
|
1525
|
+
/*
|
|
1526
|
+
We don't want Enter key events to bubble, because when the
|
|
1527
|
+
menu closes after enter the focus will return to the
|
|
1528
|
+
piped-text anchor button, and Enter would reopen the base menu
|
|
1529
|
+
*/
|
|
1530
|
+
$e.stopPropagation();
|
|
1531
|
+
$e.preventDefault();
|
|
1532
|
+
break;
|
|
1533
|
+
case 'PageUp':
|
|
1534
|
+
case 'Home':
|
|
1535
|
+
case 'PageDown':
|
|
1536
|
+
case 'End':
|
|
1537
|
+
$e.stopPropagation();
|
|
1538
|
+
$e.preventDefault();
|
|
1539
|
+
break;
|
|
1540
|
+
}
|
|
1541
|
+
}
|
|
1542
|
+
function handleInputKeyDown($e) {
|
|
1543
|
+
var key = $e.key;
|
|
1544
|
+
if (!TEXT_INPUT_KEYS_TO_ALLOW.includes($e.key)) {
|
|
1545
|
+
$e.stopPropagation();
|
|
1546
|
+
}
|
|
1547
|
+
if (!$e.shiftKey && (key === 'Tab')) {
|
|
1548
|
+
/*
|
|
1549
|
+
User can tab forward to focus add Button element
|
|
1550
|
+
without closing the popover menu
|
|
1551
|
+
*/
|
|
1552
|
+
$e.stopPropagation();
|
|
1553
|
+
}
|
|
1554
|
+
}
|
|
1555
|
+
function handleAddButtonKeyDown($e) {
|
|
1556
|
+
if ($e.shiftKey && ($e.key === 'Tab')) {
|
|
1557
|
+
/*
|
|
1558
|
+
User can shift+tab back to focus Text Input element
|
|
1559
|
+
without closing the popover menu
|
|
1560
|
+
*/
|
|
1561
|
+
$e.stopPropagation();
|
|
1562
|
+
}
|
|
1563
|
+
}
|
|
1564
|
+
function handleAddButtonClick() {
|
|
1565
|
+
var locatorString;
|
|
1566
|
+
// Indicate a validation error if the inputValue is empty.
|
|
1567
|
+
// We do not need to provide an error message, via UX guidelines
|
|
1568
|
+
// input validation errors indicate "Required" implicitly by default.
|
|
1569
|
+
if ((inputValue || '').trim().length < 1) {
|
|
1570
|
+
setIsInputInvalid(true);
|
|
1571
|
+
return;
|
|
1572
|
+
}
|
|
1573
|
+
locatorString = "${e://Field/".concat(inputValue, "}");
|
|
1574
|
+
props.onSelect(locatorString);
|
|
1575
|
+
}
|
|
1576
|
+
function handleInputChange($e) {
|
|
1577
|
+
var nextInputValue = ($e.target.value || '').trim();
|
|
1578
|
+
var uriEncodedValue = encodeURIComponent(nextInputValue);
|
|
1579
|
+
setInputValue(uriEncodedValue);
|
|
1580
|
+
if ((uriEncodedValue.length > 0) && isInputInvalid) {
|
|
1581
|
+
setIsInputInvalid(false);
|
|
1582
|
+
}
|
|
1583
|
+
}
|
|
1584
|
+
}
|
|
1585
|
+
|
|
1586
|
+
var EmbeddedDataMenu = React.forwardRef(function EmbeddedDataMenu(props, ref) {
|
|
1587
|
+
var anchor = props.anchor;
|
|
1588
|
+
var onClose = props.onClose || (function () { return undefined; });
|
|
1589
|
+
var popoverClassName = 'embedded-data-menu-content';
|
|
1590
|
+
var ignoreClickSelector = popoverClassName;
|
|
1591
|
+
var onSelect = props.onSelect || (function () { return undefined; });
|
|
1592
|
+
return (React.createElement(Popover, { show: props.show, anchor: anchor, onClose: onClose, ignoreClickSelector: ignoreClickSelector, placement: props.placement || 'right-start' },
|
|
1593
|
+
React.createElement("div", { className: "embedded-data-menu", ref: ref },
|
|
1594
|
+
React.createElement(EmbeddedDataInput, { onSelect: onSelect, keyboardCtrl: props.keyboardCtrl, ariaLabelledById: props.ariaLabelledById }))));
|
|
1595
|
+
});
|
|
1596
|
+
|
|
1597
|
+
/*
|
|
1598
|
+
Combines refs for using ForwardRef to manage a localRef in the component, while
|
|
1599
|
+
still allowing the passed ref to function
|
|
1600
|
+
|
|
1601
|
+
See following reference implementations:
|
|
1602
|
+
https://gitlab-app.eng.qops.net/cfe/ui/-/blob/master/packages/ui-react/src/utils/mergeRefs/mergeRefs.ts
|
|
1603
|
+
https://github.com/gregberge/react-merge-refs/blob/main/src/index.tsx
|
|
1604
|
+
*/
|
|
1605
|
+
function mergeRefs(refs) {
|
|
1606
|
+
return function (value) {
|
|
1607
|
+
refs.forEach(function (ref) {
|
|
1608
|
+
if ((typeof ref) === 'function') {
|
|
1609
|
+
ref(value);
|
|
1610
|
+
}
|
|
1611
|
+
else if (ref !== null) {
|
|
1612
|
+
ref.current = value;
|
|
1613
|
+
}
|
|
1614
|
+
});
|
|
1615
|
+
};
|
|
1616
|
+
}
|
|
1617
|
+
|
|
1618
|
+
// export const EMBEDDED_DATA_LOCATOR = 'embeddedData';
|
|
1619
|
+
var PipedTextMenuItem = React.forwardRef(function PipedTextMenuItem(props, ref) {
|
|
1620
|
+
var _a = useState(), ariaHaspopup = _a[0], setAriaHaspopup = _a[1];
|
|
1621
|
+
var _b = useState(), tabIndex = _b[0], setTabIndex = _b[1];
|
|
1622
|
+
var _c = useState(), role = _c[0], setRole = _c[1];
|
|
1623
|
+
var _d = useState(), _isSubmenu = _d[0], setIsSubmenu = _d[1];
|
|
1624
|
+
var _e = useState(), _isDecorated = _e[0], setIsDecorated = _e[1];
|
|
1625
|
+
var _f = useState(), _isFocusable = _f[0], setIsFocusable = _f[1];
|
|
1626
|
+
var _g = useState(), _isEmbeddedDataMenu = _g[0], setIsEmbeddedDataMenu = _g[1];
|
|
1627
|
+
var localRef = useRef();
|
|
1628
|
+
var submenuItemId = useId();
|
|
1629
|
+
var pipedTextMenuId = useId();
|
|
1630
|
+
useEffect(function () {
|
|
1631
|
+
var nextIsFocusable, nextIsDecorated, nextIsSubmenu, nextIsEmbeddedDataMenu;
|
|
1632
|
+
var nextTabIndex, nextAriaHaspopup, nextRole;
|
|
1633
|
+
if (props.menuItem === undefined) {
|
|
1634
|
+
return;
|
|
1635
|
+
}
|
|
1636
|
+
nextIsFocusable = checkMenuItemFocusable(props.menuItem);
|
|
1637
|
+
nextIsSubmenu = checkSubmenuMenuItemItem(props.menuItem);
|
|
1638
|
+
nextIsEmbeddedDataMenu = checkEmbeddedDataMenuItem(props.menuItem);
|
|
1639
|
+
nextIsDecorated = checkDecoratedMenuItem(props.menuItem);
|
|
1640
|
+
if (nextIsFocusable) {
|
|
1641
|
+
nextTabIndex = -1;
|
|
1642
|
+
nextRole = 'menuitem';
|
|
1643
|
+
}
|
|
1644
|
+
if (nextIsSubmenu || nextIsEmbeddedDataMenu) {
|
|
1645
|
+
nextAriaHaspopup = 'menu';
|
|
1646
|
+
}
|
|
1647
|
+
setAriaHaspopup(nextAriaHaspopup);
|
|
1648
|
+
setTabIndex(nextTabIndex);
|
|
1649
|
+
setRole(nextRole);
|
|
1650
|
+
setIsSubmenu(nextIsSubmenu);
|
|
1651
|
+
setIsDecorated(nextIsDecorated);
|
|
1652
|
+
setIsFocusable(nextIsFocusable);
|
|
1653
|
+
setIsEmbeddedDataMenu(nextIsEmbeddedDataMenu);
|
|
1654
|
+
}, [
|
|
1655
|
+
props.menuItem,
|
|
1656
|
+
]);
|
|
1657
|
+
return (React.createElement("div", { className: 'piped-text-menu-item-container ' + ((props.isHighlighted)
|
|
1658
|
+
? 'highlighted-menu-item'
|
|
1659
|
+
: ''), ref: mergeRefs([
|
|
1660
|
+
ref,
|
|
1661
|
+
localRef,
|
|
1662
|
+
]), "aria-haspopup": ariaHaspopup, tabIndex: tabIndex, role: role, id: ariaHaspopup ? submenuItemId : undefined, "aria-controls": ariaHaspopup ? pipedTextMenuId : undefined, "aria-expanded": props.menuItem.show, onFocus: function ($e) {
|
|
1663
|
+
handleMenuItemFocused(props.menuItem);
|
|
1664
|
+
}, onKeyDown: function ($e) {
|
|
1665
|
+
handleKeyDown($e);
|
|
1666
|
+
}, onMouseEnter: handleMouseEnter, onClick: handleClick }, getMenuItemContent(props.menuItem)));
|
|
1667
|
+
function getMenuItemContent(menuItem) {
|
|
1668
|
+
var innerContent, menuItemEl;
|
|
1669
|
+
var menuItemHeaderClass, menuItemDisabledClass, menuItemClassName;
|
|
1670
|
+
if (_isSubmenu) {
|
|
1671
|
+
innerContent = (React.createElement(PipedTextSubmenuItem, { key: menuItem.key, menuItem: menuItem, onMenuItemClick: handleMenuItemClick, keyboardCtrl: props.keyboardCtrl, pipedTextMenuId: pipedTextMenuId }));
|
|
1672
|
+
}
|
|
1673
|
+
else if (_isDecorated) {
|
|
1674
|
+
menuItemHeaderClass = (menuItem.header === true)
|
|
1675
|
+
? 'piped-text-header'
|
|
1676
|
+
: '';
|
|
1677
|
+
menuItemDisabledClass = (menuItem.disabled === true)
|
|
1678
|
+
? 'piped-text-disabled'
|
|
1679
|
+
: '';
|
|
1680
|
+
menuItemClassName = "piped-text-menu-item ".concat(menuItemHeaderClass, " ").concat(menuItemDisabledClass);
|
|
1681
|
+
innerContent = (React.createElement("div", { className: menuItemClassName }, menuItem.label));
|
|
1682
|
+
}
|
|
1683
|
+
else if (_isEmbeddedDataMenu) {
|
|
1684
|
+
innerContent = (React.createElement("div", { role: 'presentation' },
|
|
1685
|
+
React.createElement(EmbeddedDataMenu, { show: menuItem.show, onSelect: handleEmbeddedDataSelect, anchor: function (_ref) { return (React.createElement("div", { ref: _ref, className: "embedded-data-menu-anchor", "aria-hidden": 'true' })); }, keyboardCtrl: props.keyboardCtrl, ariaLabelledById: submenuItemId }),
|
|
1686
|
+
React.createElement("div", { className: "piped-text-submenu-item" },
|
|
1687
|
+
React.createElement("div", { className: 'label-text' }, menuItem.label),
|
|
1688
|
+
React.createElement("div", { className: "piped-text-icon" },
|
|
1689
|
+
React.createElement(Icon, { type: IconTypes.ChevronRight, size: 'medium' })))));
|
|
1690
|
+
}
|
|
1691
|
+
else {
|
|
1692
|
+
innerContent = (React.createElement("div", { className: "piped-text-menu-item", role: 'presentation' }, menuItem.label));
|
|
1693
|
+
}
|
|
1694
|
+
menuItemEl = (React.createElement("div", { className: "piped-text-menu-item-content", role: 'presentation' }, innerContent));
|
|
1695
|
+
return menuItemEl;
|
|
1696
|
+
}
|
|
1697
|
+
function handleClick($e) {
|
|
1698
|
+
if (_isSubmenu || _isEmbeddedDataMenu) {
|
|
1699
|
+
handleSubmenuItemClick(props.menuItem);
|
|
1700
|
+
}
|
|
1701
|
+
else if (_isFocusable) {
|
|
1702
|
+
handleMenuItemClick(props.menuItem);
|
|
1703
|
+
}
|
|
1704
|
+
}
|
|
1705
|
+
function handleMouseEnter($e) {
|
|
1706
|
+
if (_isSubmenu || _isEmbeddedDataMenu) {
|
|
1707
|
+
handleSubmenuHover(props.menuItem);
|
|
1708
|
+
}
|
|
1709
|
+
else if (_isFocusable) {
|
|
1710
|
+
handleMenuItemHovered(props.menuItem);
|
|
1711
|
+
}
|
|
1712
|
+
}
|
|
1713
|
+
function handleKeyDown($e) {
|
|
1714
|
+
if (!props.isHighlighted) {
|
|
1715
|
+
return;
|
|
1716
|
+
}
|
|
1717
|
+
if (!props.keyboardCtrl.isMenuItemInCurrentFocusMenu(localRef)) {
|
|
1718
|
+
return;
|
|
1719
|
+
}
|
|
1720
|
+
if (($e.key === ' ')
|
|
1721
|
+
|| ($e.key === 'Enter')) {
|
|
1722
|
+
if (_isSubmenu || _isEmbeddedDataMenu) {
|
|
1723
|
+
props.onSubmenuItemClick(props.menuItem);
|
|
1724
|
+
}
|
|
1725
|
+
else {
|
|
1726
|
+
props.onMenuItemClicked(props.menuItem);
|
|
1727
|
+
}
|
|
1728
|
+
$e.preventDefault(); // prevent scroll
|
|
1729
|
+
}
|
|
1730
|
+
}
|
|
1731
|
+
function handleMenuItemFocused(menuItem) {
|
|
1732
|
+
if (_isSubmenu || _isEmbeddedDataMenu) {
|
|
1733
|
+
props.onSubmenuHover(menuItem, localRef);
|
|
1734
|
+
}
|
|
1735
|
+
else {
|
|
1736
|
+
props.onMenuItemHover(menuItem, localRef);
|
|
1737
|
+
}
|
|
1738
|
+
}
|
|
1739
|
+
function handleSubmenuItemClick(menuItem) {
|
|
1740
|
+
props.onSubmenuItemClick(menuItem);
|
|
1741
|
+
}
|
|
1742
|
+
function handleMenuItemClick(menuItem) {
|
|
1743
|
+
props.onMenuItemClicked(menuItem);
|
|
1744
|
+
}
|
|
1745
|
+
function handleSubmenuHover(menuItem) {
|
|
1746
|
+
props.onSubmenuHover(menuItem, localRef);
|
|
1747
|
+
}
|
|
1748
|
+
function handleMenuItemHovered(menuItem) {
|
|
1749
|
+
props.onMenuItemHover(menuItem, localRef);
|
|
1750
|
+
}
|
|
1751
|
+
function handleEmbeddedDataSelect(edLocator) {
|
|
1752
|
+
var edMenuItem;
|
|
1753
|
+
/* Instead of returning the menuItem, we'll construct one that matches the interface.
|
|
1754
|
+
There is no mappable "menuItem" here, when ED values are added they can be different
|
|
1755
|
+
potentially every time, so we trigger events generically ad hoc
|
|
1756
|
+
*/
|
|
1757
|
+
edMenuItem = {
|
|
1758
|
+
value: {
|
|
1759
|
+
locator: edLocator,
|
|
1760
|
+
},
|
|
1761
|
+
};
|
|
1762
|
+
props.onMenuItemClicked(edMenuItem);
|
|
1763
|
+
}
|
|
1764
|
+
});
|
|
1765
|
+
|
|
1766
|
+
var PipedTextSearchInput = React.forwardRef(function PipedTextSearchInput(props, ref) {
|
|
1767
|
+
var textInputRef = React.useRef();
|
|
1768
|
+
return (React.createElement("div", { className: 'piped-text-search-input', tabIndex: -1, ref: ref, onFocus: handleContainerFocus },
|
|
1769
|
+
React.createElement("form", { onSubmit: props.onSearchSubmit },
|
|
1770
|
+
React.createElement(Input, { small: true, full: true, className: "q-plugin-popover-input", ref: textInputRef, placeholder: props.searchPlaceholder, value: props.value, onChange: props.onInputChange, onClick: props.onInputClick, onKeyDown: handleKeyDown, role: 'searchbox' }))));
|
|
1771
|
+
function handleKeyDown($e) {
|
|
1772
|
+
if (!TEXT_INPUT_KEYS_TO_ALLOW.includes($e.key)) {
|
|
1773
|
+
$e.stopPropagation();
|
|
1774
|
+
}
|
|
1775
|
+
}
|
|
1776
|
+
function handleContainerFocus($e) {
|
|
1777
|
+
var _a;
|
|
1778
|
+
if ($e.target !== textInputRef.current) {
|
|
1779
|
+
(_a = textInputRef.current) === null || _a === void 0 ? void 0 : _a.focus();
|
|
1780
|
+
}
|
|
1781
|
+
props.onFocus($e);
|
|
1782
|
+
}
|
|
1783
|
+
});
|
|
1784
|
+
|
|
1785
|
+
var PipedTextMenuList = React.forwardRef(function PipedTextMenuList(props, ref) {
|
|
1786
|
+
var _this = this;
|
|
1787
|
+
var _a, _b;
|
|
1788
|
+
var _c = useState(false), isLoading = _c[0], setIsLoading = _c[1];
|
|
1789
|
+
var _d = useState(false), isLoadError = _d[0], setIsLoadError = _d[1];
|
|
1790
|
+
var _e = useState(), menuItems = _e[0], setMenuItems = _e[1];
|
|
1791
|
+
var _f = useState(), itemsToRender = _f[0], setItemsToRender = _f[1];
|
|
1792
|
+
var _g = useState(), menuChildren = _g[0], setMenuChildren = _g[1];
|
|
1793
|
+
var _h = useState(), focusMenuItems = _h[0], setFocusMenuItems = _h[1];
|
|
1794
|
+
var _j = useState(''), searchValue = _j[0], setSearchValue = _j[1];
|
|
1795
|
+
var _k = useState(false), autoFocusedOnOpen = _k[0], setAutoFocusedOnOpen = _k[1];
|
|
1796
|
+
var pipedTextMenuId = (_a = props.pipedTextMenuId) !== null && _a !== void 0 ? _a : useId();
|
|
1797
|
+
var externalAriaLabelledBy = props['aria-labelledby'];
|
|
1798
|
+
var localRef = useRef();
|
|
1799
|
+
var searchRef = useRef();
|
|
1800
|
+
/*
|
|
1801
|
+
We need to track whether or not the menu component has rendered, and the
|
|
1802
|
+
localRef is available, so that we can add it to the keyboardCtrl
|
|
1803
|
+
before the menuItems have finished loading
|
|
1804
|
+
*/
|
|
1805
|
+
var _l = useState(false), isLocalRefReady = _l[0], setIsLocalRefReady = _l[1];
|
|
1806
|
+
var localRefReadyCb = useCallback(function (node) {
|
|
1807
|
+
if (node) {
|
|
1808
|
+
setIsLocalRefReady(true);
|
|
1809
|
+
}
|
|
1810
|
+
}, []);
|
|
1811
|
+
var _m = useState(false), isSearchRefReady = _m[0], setIsSearchRefReady = _m[1];
|
|
1812
|
+
var searchRefReadyCb = useCallback(function (node) {
|
|
1813
|
+
if (node) {
|
|
1814
|
+
setIsSearchRefReady(true);
|
|
1815
|
+
}
|
|
1816
|
+
}, []);
|
|
1817
|
+
var isRoot = props.keyboardCtrl === undefined;
|
|
1818
|
+
var _o = useState(isRoot
|
|
1819
|
+
? new PipedTextMenuKeyboardCtrl
|
|
1820
|
+
: props.keyboardCtrl), keyboardCtrl = _o[0]; _o[1];
|
|
1821
|
+
var schedulePopoverUpdate = function () {
|
|
1822
|
+
var _a;
|
|
1823
|
+
if (typeof ((_a = props.popoverOptionsRef) === null || _a === void 0 ? void 0 : _a.current.scheduleUpdate) === 'function') {
|
|
1824
|
+
props.popoverOptionsRef.current.scheduleUpdate();
|
|
1825
|
+
}
|
|
1826
|
+
};
|
|
1827
|
+
useEffect(function () {
|
|
1828
|
+
var $destroy = function () {
|
|
1829
|
+
keyboardCtrl.removeMenu(localRef);
|
|
1830
|
+
};
|
|
1831
|
+
return $destroy;
|
|
1832
|
+
}, []);
|
|
1833
|
+
useEffect(function () {
|
|
1834
|
+
var nextMenuItemRefs, focusMenuItemRefs;
|
|
1835
|
+
if (localRef.current
|
|
1836
|
+
&& searchRef.current
|
|
1837
|
+
&& menuChildren
|
|
1838
|
+
&& !isLoading) {
|
|
1839
|
+
focusMenuItemRefs = React.Children.map(focusMenuItems, function (menuChild) {
|
|
1840
|
+
return menuChild.ref;
|
|
1841
|
+
});
|
|
1842
|
+
nextMenuItemRefs = __spreadArray([
|
|
1843
|
+
searchRef
|
|
1844
|
+
], focusMenuItemRefs, true);
|
|
1845
|
+
keyboardCtrl.addMenu(localRef, nextMenuItemRefs);
|
|
1846
|
+
if (isRoot && (autoFocusedOnOpen === false)) {
|
|
1847
|
+
setTimeout(function () {
|
|
1848
|
+
var _a;
|
|
1849
|
+
/*
|
|
1850
|
+
Hack - see https://github.com/floating-ui/react-popper/issues/395
|
|
1851
|
+
Without this, the page jitters on focus as the page scroll position
|
|
1852
|
+
updates. Using setTimeout, we give Popper one render cycle to
|
|
1853
|
+
set its own position before triggering the autofocus - then the input
|
|
1854
|
+
element will have correct positioning by the time we call .focus()
|
|
1855
|
+
*/
|
|
1856
|
+
(_a = localRef.current) === null || _a === void 0 ? void 0 : _a.focus();
|
|
1857
|
+
}, 0);
|
|
1858
|
+
setAutoFocusedOnOpen(true);
|
|
1859
|
+
}
|
|
1860
|
+
}
|
|
1861
|
+
}, [
|
|
1862
|
+
localRef,
|
|
1863
|
+
menuChildren,
|
|
1864
|
+
keyboardCtrl,
|
|
1865
|
+
isLoading,
|
|
1866
|
+
]);
|
|
1867
|
+
useEffect(function () {
|
|
1868
|
+
var menuItemRefs;
|
|
1869
|
+
if (isLocalRefReady) {
|
|
1870
|
+
menuItemRefs = [];
|
|
1871
|
+
if (isSearchRefReady) {
|
|
1872
|
+
menuItemRefs.push(searchRef);
|
|
1873
|
+
}
|
|
1874
|
+
keyboardCtrl.addMenu(localRef, menuItemRefs);
|
|
1875
|
+
}
|
|
1876
|
+
}, [
|
|
1877
|
+
isLocalRefReady,
|
|
1878
|
+
isSearchRefReady,
|
|
1879
|
+
]);
|
|
1880
|
+
useEffect(function () {
|
|
1881
|
+
if (props.items === undefined) {
|
|
1882
|
+
return;
|
|
1883
|
+
}
|
|
1884
|
+
(function () { return __awaiter(_this, void 0, void 0, function () {
|
|
1885
|
+
var rawMenuItems, nextMenuItems;
|
|
1886
|
+
return __generator(this, function (_a) {
|
|
1887
|
+
switch (_a.label) {
|
|
1888
|
+
case 0:
|
|
1889
|
+
if (!((typeof props.items) === 'function')) return [3 /*break*/, 5];
|
|
1890
|
+
setIsLoading(true);
|
|
1891
|
+
_a.label = 1;
|
|
1892
|
+
case 1:
|
|
1893
|
+
_a.trys.push([1, 3, , 4]);
|
|
1894
|
+
return [4 /*yield*/, props.items()];
|
|
1895
|
+
case 2:
|
|
1896
|
+
rawMenuItems = _a.sent();
|
|
1897
|
+
return [3 /*break*/, 4];
|
|
1898
|
+
case 3:
|
|
1899
|
+
_a.sent();
|
|
1900
|
+
setIsLoadError(true);
|
|
1901
|
+
return [3 /*break*/, 4];
|
|
1902
|
+
case 4:
|
|
1903
|
+
setIsLoading(false);
|
|
1904
|
+
return [3 /*break*/, 6];
|
|
1905
|
+
case 5:
|
|
1906
|
+
rawMenuItems = props.items;
|
|
1907
|
+
_a.label = 6;
|
|
1908
|
+
case 6:
|
|
1909
|
+
try {
|
|
1910
|
+
nextMenuItems = pipedTextDataAdapter(rawMenuItems);
|
|
1911
|
+
setMenuItems(nextMenuItems);
|
|
1912
|
+
}
|
|
1913
|
+
catch (e) {
|
|
1914
|
+
setIsLoadError(true);
|
|
1915
|
+
}
|
|
1916
|
+
return [2 /*return*/];
|
|
1917
|
+
}
|
|
1918
|
+
});
|
|
1919
|
+
}); })();
|
|
1920
|
+
}, [
|
|
1921
|
+
props.items,
|
|
1922
|
+
]);
|
|
1923
|
+
useEffect(function () {
|
|
1924
|
+
var nextItemsToRender;
|
|
1925
|
+
if (menuItems === undefined) {
|
|
1926
|
+
return;
|
|
1927
|
+
}
|
|
1928
|
+
nextItemsToRender = (menuItems || []).filter(matchesSearch);
|
|
1929
|
+
setItemsToRender(nextItemsToRender);
|
|
1930
|
+
}, [
|
|
1931
|
+
searchValue,
|
|
1932
|
+
menuItems,
|
|
1933
|
+
]);
|
|
1934
|
+
useEffect(function () {
|
|
1935
|
+
var nextMenuChildren;
|
|
1936
|
+
if (!Array.isArray(itemsToRender)) {
|
|
1937
|
+
return;
|
|
1938
|
+
}
|
|
1939
|
+
nextMenuChildren = getPipedTextMenuItems(itemsToRender);
|
|
1940
|
+
setMenuChildren(nextMenuChildren);
|
|
1941
|
+
}, [
|
|
1942
|
+
itemsToRender,
|
|
1943
|
+
]);
|
|
1944
|
+
schedulePopoverUpdate();
|
|
1945
|
+
return (React.createElement("div", { className: "piped-text-menu-list ".concat((_b = props.className) !== null && _b !== void 0 ? _b : ''), ref: mergeRefs([
|
|
1946
|
+
ref,
|
|
1947
|
+
localRef,
|
|
1948
|
+
localRefReadyCb,
|
|
1949
|
+
]), id: pipedTextMenuId, "aria-labelledby": externalAriaLabelledBy, role: "menu",
|
|
1950
|
+
// role="listbox"
|
|
1951
|
+
tabIndex: (props.tabIndex === undefined)
|
|
1952
|
+
? -1
|
|
1953
|
+
: props.tabIndex, onKeyDown: function ($e) {
|
|
1954
|
+
handleKeyDown($e);
|
|
1955
|
+
}, onFocus: function ($e) {
|
|
1956
|
+
handleMenuListFocus($e);
|
|
1957
|
+
} },
|
|
1958
|
+
React.createElement("div", { className: "piped-text-popover-menu", role: 'presentation' }, ((isLoadError)
|
|
1959
|
+
? (React.createElement(PipedTextMenuLoadError, { errorText: props.errorText }))
|
|
1960
|
+
: (React.createElement(React.Fragment, null,
|
|
1961
|
+
React.createElement(PipedTextSearchInput, { ref: mergeRefs([
|
|
1962
|
+
searchRef,
|
|
1963
|
+
searchRefReadyCb,
|
|
1964
|
+
]), value: searchValue, onSearchSubmit: handleSearchSubmit, searchPlaceholder: props.searchPlaceholder, onInputChange: function ($e) { return onSearchInputChange($e); }, onInputClick: function ($e) { return handleSearchInputClick($e); }, onFocus: function () {
|
|
1965
|
+
handleSearchFocus();
|
|
1966
|
+
} }),
|
|
1967
|
+
(isLoading)
|
|
1968
|
+
? (React.createElement("div", { className: "piped-text-loading-spinner" },
|
|
1969
|
+
React.createElement(LoadingSpinner, { show: true, size: "medium" })))
|
|
1970
|
+
: menuChildren))))));
|
|
1971
|
+
function handleMenuListFocus($e) {
|
|
1972
|
+
var _a;
|
|
1973
|
+
if ($e.currentTarget === localRef.current) {
|
|
1974
|
+
keyboardCtrl.setFocus(localRef.current);
|
|
1975
|
+
if (keyboardCtrl.getFocusMenuHighlightedIdx(localRef) === -1) {
|
|
1976
|
+
(_a = searchRef.current) === null || _a === void 0 ? void 0 : _a.focus();
|
|
1977
|
+
}
|
|
1978
|
+
$e.stopPropagation();
|
|
1979
|
+
$e.preventDefault();
|
|
1980
|
+
}
|
|
1981
|
+
}
|
|
1982
|
+
function handleKeyDown($e) {
|
|
1983
|
+
var currFocusMenuContainerRef;
|
|
1984
|
+
switch ($e.key) {
|
|
1985
|
+
case 'Tab':
|
|
1986
|
+
onClose();
|
|
1987
|
+
}
|
|
1988
|
+
props === null || props === void 0 ? void 0 : props.menuKeyDown($e);
|
|
1989
|
+
currFocusMenuContainerRef = keyboardCtrl.getCurrentFocusMenuRef();
|
|
1990
|
+
if (localRef.current !== (currFocusMenuContainerRef === null || currFocusMenuContainerRef === void 0 ? void 0 : currFocusMenuContainerRef.current)) {
|
|
1991
|
+
return;
|
|
1992
|
+
}
|
|
1993
|
+
switch ($e.key) {
|
|
1994
|
+
case 'ArrowDown':
|
|
1995
|
+
case 'ArrowUp':
|
|
1996
|
+
case 'ArrowRight':
|
|
1997
|
+
case 'ArrowLeft':
|
|
1998
|
+
case 'Escape':
|
|
1999
|
+
case 'PageUp':
|
|
2000
|
+
case 'Home':
|
|
2001
|
+
case 'PageDown':
|
|
2002
|
+
case 'End':
|
|
2003
|
+
keyboardCtrl.handleKeyEvent($e);
|
|
2004
|
+
$e.preventDefault(); // prevent scroll
|
|
2005
|
+
break;
|
|
2006
|
+
}
|
|
2007
|
+
}
|
|
2008
|
+
function onClose() {
|
|
2009
|
+
var _a;
|
|
2010
|
+
(_a = props.onClose) === null || _a === void 0 ? void 0 : _a.call(props);
|
|
2011
|
+
}
|
|
2012
|
+
function onSearchInputChange(evt) {
|
|
2013
|
+
var nextSearchValue;
|
|
2014
|
+
nextSearchValue = evt.target.value;
|
|
2015
|
+
setSearchValue(nextSearchValue);
|
|
2016
|
+
}
|
|
2017
|
+
function handleSearchInputClick(evt) {
|
|
2018
|
+
evt.stopPropagation();
|
|
2019
|
+
}
|
|
2020
|
+
function matchesSearch(menuItem) {
|
|
2021
|
+
var searchVal;
|
|
2022
|
+
searchVal = searchValue || '';
|
|
2023
|
+
return JSON.stringify(menuItem).toLowerCase().includes(searchVal.toLowerCase());
|
|
2024
|
+
}
|
|
2025
|
+
function handleSearchSubmit(e) {
|
|
2026
|
+
var searchVal, locator, selected;
|
|
2027
|
+
e.preventDefault();
|
|
2028
|
+
if (!(props.allowCustom === true && props.customScheme)) {
|
|
2029
|
+
return;
|
|
2030
|
+
}
|
|
2031
|
+
searchVal = searchValue.trim();
|
|
2032
|
+
if (searchVal === '') {
|
|
2033
|
+
return;
|
|
2034
|
+
}
|
|
2035
|
+
locator = "${".concat(props.customScheme, "://Field/").concat(encodeURIComponent(searchVal), "}");
|
|
2036
|
+
selected = {
|
|
2037
|
+
value: {
|
|
2038
|
+
locator: locator,
|
|
2039
|
+
},
|
|
2040
|
+
};
|
|
2041
|
+
props.onSelected(selected);
|
|
2042
|
+
onClose();
|
|
2043
|
+
}
|
|
2044
|
+
function getPipedTextMenuItems(_menuItems) {
|
|
2045
|
+
var pipedTextMenuItems, nextFocusMenuItems;
|
|
2046
|
+
var focusItemIdx, currHighlightedIdx;
|
|
2047
|
+
pipedTextMenuItems = [];
|
|
2048
|
+
nextFocusMenuItems = [];
|
|
2049
|
+
if (_menuItems.length === 0 && props.allowCustom === true && props.customInputMessage) {
|
|
2050
|
+
return (React.createElement("div", null,
|
|
2051
|
+
React.createElement("div", { className: "piped-text-information-message" }, props.customInputMessage)));
|
|
2052
|
+
}
|
|
2053
|
+
focusItemIdx = 0;
|
|
2054
|
+
currHighlightedIdx = keyboardCtrl.getFocusMenuHighlightedIdx(localRef);
|
|
2055
|
+
pipedTextMenuItems = _menuItems.map(function (menuItem) {
|
|
2056
|
+
var isFocusable, menuItemEl;
|
|
2057
|
+
var isHighlighted;
|
|
2058
|
+
var menuItemRef = React.createRef();
|
|
2059
|
+
isFocusable = checkMenuItemFocusable(menuItem);
|
|
2060
|
+
isHighlighted = (isFocusable) && ((currHighlightedIdx - 1) === focusItemIdx);
|
|
2061
|
+
menuItemEl = (React.createElement(PipedTextMenuItem, { ref: menuItemRef, key: menuItem.key, menuItem: menuItem, onSubmenuHover: submenuHovered, onMenuItemHover: menuSelectItemHovered, onMenuItemClicked: menuItemClicked, onSubmenuItemClick: submenuItemClicked, onEmbeddedDataItemClick: embeddedDataItemClicked, keyboardCtrl: keyboardCtrl, isHighlighted: isHighlighted }));
|
|
2062
|
+
if (isFocusable) {
|
|
2063
|
+
nextFocusMenuItems.push(menuItemEl);
|
|
2064
|
+
focusItemIdx++;
|
|
2065
|
+
}
|
|
2066
|
+
return menuItemEl;
|
|
2067
|
+
});
|
|
2068
|
+
setFocusMenuItems(nextFocusMenuItems);
|
|
2069
|
+
return pipedTextMenuItems;
|
|
2070
|
+
}
|
|
2071
|
+
function submenuHovered(menuItem, menuItemRef) {
|
|
2072
|
+
var nextMenuItems;
|
|
2073
|
+
nextMenuItems = menuItems.slice();
|
|
2074
|
+
handleMenuItemHovered(menuItem, menuItemRef);
|
|
2075
|
+
closeSubmenus(nextMenuItems);
|
|
2076
|
+
setMenuItems(nextMenuItems);
|
|
2077
|
+
if (!menuItem.show) {
|
|
2078
|
+
menuItem.show = true;
|
|
2079
|
+
}
|
|
2080
|
+
}
|
|
2081
|
+
function menuSelectItemHovered(menuItem, menuItemRef) {
|
|
2082
|
+
var nextMenuItems;
|
|
2083
|
+
nextMenuItems = menuItems.slice();
|
|
2084
|
+
handleMenuItemHovered(menuItem, menuItemRef);
|
|
2085
|
+
closeSubmenus(nextMenuItems);
|
|
2086
|
+
setMenuItems(nextMenuItems);
|
|
2087
|
+
}
|
|
2088
|
+
function handleSearchFocus() {
|
|
2089
|
+
var _a;
|
|
2090
|
+
var nextMenuItems;
|
|
2091
|
+
nextMenuItems = (_a = menuItems === null || menuItems === void 0 ? void 0 : menuItems.slice()) !== null && _a !== void 0 ? _a : [];
|
|
2092
|
+
keyboardCtrl.setFocusMenuHighlightedIdx(localRef, searchRef);
|
|
2093
|
+
closeSubmenus(nextMenuItems);
|
|
2094
|
+
setMenuItems(nextMenuItems);
|
|
2095
|
+
}
|
|
2096
|
+
function handleMenuItemHovered(menuItem, menuItemRef) {
|
|
2097
|
+
var _a;
|
|
2098
|
+
keyboardCtrl.setFocusMenuHighlightedIdx(localRef, menuItemRef);
|
|
2099
|
+
(_a = menuItemRef.current) === null || _a === void 0 ? void 0 : _a.focus();
|
|
2100
|
+
}
|
|
2101
|
+
function menuItemClicked(menuItem) {
|
|
2102
|
+
if (!menuItem.disabled) {
|
|
2103
|
+
props.onSelected(menuItem);
|
|
2104
|
+
}
|
|
2105
|
+
}
|
|
2106
|
+
function submenuItemClicked(menuItem) {
|
|
2107
|
+
console.log('PipedTextMenuList submenu click');
|
|
2108
|
+
keyboardCtrl.focusNextSubmenu();
|
|
2109
|
+
}
|
|
2110
|
+
function embeddedDataItemClicked(menuItem) {
|
|
2111
|
+
// let nextMenuItems: PipedTextMenuItemData[];
|
|
2112
|
+
// nextMenuItems = menuItems.slice();
|
|
2113
|
+
// menuItem.show = true;
|
|
2114
|
+
// setMenuItems(nextMenuItems);
|
|
2115
|
+
}
|
|
2116
|
+
});
|
|
2117
|
+
function closeSubmenus(menuItems) {
|
|
2118
|
+
menuItems.forEach(function (item) {
|
|
2119
|
+
if (item.show) {
|
|
2120
|
+
item.show = false;
|
|
2121
|
+
}
|
|
2122
|
+
});
|
|
2123
|
+
}
|
|
2124
|
+
|
|
2125
|
+
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-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";
|
|
2126
|
+
styleInject(css_248z$e);
|
|
2127
|
+
|
|
2128
|
+
/* eslint-disable-next-line prefer-arrow-callback */
|
|
2129
|
+
var PipedTextMenu = React.forwardRef(function PipedTextMenu(props, ref) {
|
|
2130
|
+
var optionsRef = useRef({});
|
|
2131
|
+
var _a = useState(props.show), isMenuOpen = _a[0], setIsMenuOpen = _a[1];
|
|
2132
|
+
var externalAriaLabelledBy = props['aria-labelledby'];
|
|
2133
|
+
var onClose = props.onClose || (function () { return undefined; });
|
|
2134
|
+
/*
|
|
2135
|
+
This ref is left for use cases where the
|
|
2136
|
+
container popover may need to be referenced
|
|
2137
|
+
directly
|
|
2138
|
+
*/
|
|
2139
|
+
var _b = useState(null); _b[0]; var setPopoverEl = _b[1];
|
|
2140
|
+
var popoverRefCb = useCallback(function (el) {
|
|
2141
|
+
setPopoverEl(el);
|
|
2142
|
+
}, []);
|
|
2143
|
+
useEffect(function () {
|
|
2144
|
+
if (props.show) {
|
|
2145
|
+
setIsMenuOpen(true);
|
|
2146
|
+
}
|
|
2147
|
+
}, [props.show]);
|
|
2148
|
+
useEffect(function () {
|
|
2149
|
+
return function () { return onClose(); };
|
|
2150
|
+
}, []);
|
|
2151
|
+
var _onClose = function () {
|
|
2152
|
+
onToggleClick(false);
|
|
2153
|
+
onClose();
|
|
2154
|
+
};
|
|
2155
|
+
var onToggleClick = function (force) {
|
|
2156
|
+
var nextIsMenuOpen;
|
|
2157
|
+
nextIsMenuOpen = ((typeof force) === 'boolean')
|
|
2158
|
+
? force
|
|
2159
|
+
: !isMenuOpen;
|
|
2160
|
+
setIsMenuOpen(nextIsMenuOpen);
|
|
2161
|
+
};
|
|
2162
|
+
return (React.createElement("div", { className: "piped-text-menu" },
|
|
2163
|
+
React.createElement(Popover, { show: isMenuOpen, onClose: _onClose, placement: props.placement || 'right-start', anchor: props.anchor, ignoreClickSelector: props.ignoreClickSelector },
|
|
2164
|
+
React.createElement(PipedTextMenuList, { className: "piped-text-popover-container", items: props.items, errorText: props.errorText, "aria-labelledby": externalAriaLabelledBy, ref: popoverRefCb, allowCustom: props.allowCustom, customInputMessage: props.customInputMessage, customScheme: props.customScheme, searchPlaceholder: props.searchPlaceholder, onSelected: function (menuItem) {
|
|
2165
|
+
props.onSelected(menuItem);
|
|
2166
|
+
closeAndFocusAnchor();
|
|
2167
|
+
}, onClose: function () { return onClose(); }, popoverOptionsRef: optionsRef, keyboardCtrl: props.keyboardCtrl, menuKeyDown: handleMenuKeyDown, pipedTextMenuId: props.pipedTextMenuId }),
|
|
2168
|
+
React.createElement(OptionsPlaceholder, { optionsRef: optionsRef }))));
|
|
2169
|
+
function handleMenuKeyDown($e) {
|
|
2170
|
+
switch ($e.key) {
|
|
2171
|
+
case 'Tab':
|
|
2172
|
+
case 'Escape':
|
|
2173
|
+
closeAndFocusAnchor();
|
|
2174
|
+
break;
|
|
2175
|
+
}
|
|
2176
|
+
}
|
|
2177
|
+
function closeAndFocusAnchor() {
|
|
2178
|
+
var _a, _b;
|
|
2179
|
+
onClose();
|
|
2180
|
+
(_b = (_a = props.anchorRef) === null || _a === void 0 ? void 0 : _a.current) === null || _b === void 0 ? void 0 : _b.focus();
|
|
2181
|
+
}
|
|
2182
|
+
});
|
|
2183
|
+
function OptionsPlaceholder(props) {
|
|
2184
|
+
return (React.createElement("div", null));
|
|
2185
|
+
}
|
|
2186
|
+
/*
|
|
2187
|
+
Takes piped text menu input data and formats it to be compatible
|
|
2188
|
+
with the piped-text-select component(s)
|
|
2189
|
+
*/
|
|
2190
|
+
function pipedTextDataAdapter(pipedTextData, recursed) {
|
|
2191
|
+
var uniqueKey;
|
|
2192
|
+
if (!recursed) {
|
|
2193
|
+
pipedTextData = _cloneDeep(pipedTextData);
|
|
2194
|
+
}
|
|
2195
|
+
uniqueKey = 1;
|
|
2196
|
+
pipedTextData.forEach(function (pipedTextItem) {
|
|
2197
|
+
pipedTextItem.key = pipedTextItem.key || uniqueKey++;
|
|
2198
|
+
pipedTextItem.hasSubmenu = (!!_get(pipedTextItem, 'submenu.items.length') || ((typeof _get(pipedTextItem, 'submenu.items')) === 'function'));
|
|
2199
|
+
if (pipedTextItem.hasSubmenu || pipedTextItem.value === EMBEDDED_DATA_LOCATOR) {
|
|
2200
|
+
pipedTextItem.show = false; // used by menu component to show/hide submenu popover
|
|
2201
|
+
}
|
|
2202
|
+
if (pipedTextItem.hasSubmenu) {
|
|
2203
|
+
if (!(typeof pipedTextItem.submenu.items === 'function')) {
|
|
2204
|
+
pipedTextDataAdapter(pipedTextItem.submenu.items, true);
|
|
2205
|
+
}
|
|
2206
|
+
}
|
|
2207
|
+
});
|
|
2208
|
+
return pipedTextData;
|
|
2209
|
+
}
|
|
2210
|
+
|
|
2211
|
+
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";
|
|
2212
|
+
styleInject(css_248z$d);
|
|
2213
|
+
|
|
2214
|
+
var defaultAnchor = function defaultAnchor(ref) {
|
|
2215
|
+
return React.createElement("div", {
|
|
2216
|
+
ref: ref,
|
|
2217
|
+
className: "piped-text-menu-empty-anchor"
|
|
2218
|
+
});
|
|
2219
|
+
};
|
|
2220
|
+
|
|
2221
|
+
function PipedTextSelect(props) {
|
|
2222
|
+
var _useState = useState(props.show),
|
|
2223
|
+
_useState2 = _slicedToArray(_useState, 2),
|
|
2224
|
+
isMenuOpen = _useState2[0],
|
|
2225
|
+
setIsMenuOpen = _useState2[1];
|
|
2226
|
+
|
|
2227
|
+
var _useState3 = useState(initializePipedText()),
|
|
2228
|
+
_useState4 = _slicedToArray(_useState3, 2),
|
|
2229
|
+
pipedTextItems = _useState4[0],
|
|
2230
|
+
setPipedTextItems = _useState4[1];
|
|
2231
|
+
|
|
2232
|
+
var defaultAnchorRef = useRef(null);
|
|
2233
|
+
var externalAnchor = props.anchor;
|
|
2234
|
+
var ariaLabelledBy = props['aria-labelledby'];
|
|
2235
|
+
useEffect(function () {
|
|
2236
|
+
return function () {
|
|
2237
|
+
return onClose();
|
|
2238
|
+
};
|
|
2239
|
+
}, []);
|
|
2240
|
+
useEffect(function () {
|
|
2241
|
+
var nextIsMenuOpen;
|
|
2242
|
+
nextIsMenuOpen = props.show;
|
|
2243
|
+
setIsMenuOpen(nextIsMenuOpen);
|
|
2244
|
+
}, [props.show]);
|
|
2245
|
+
useEffect(function () {
|
|
2246
|
+
var formattedPipedText = initializePipedText();
|
|
2247
|
+
setPipedTextItems(formattedPipedText);
|
|
2248
|
+
}, [props.items]);
|
|
2249
|
+
|
|
2250
|
+
var onClose = function onClose() {
|
|
2251
|
+
if (props.onClose) {
|
|
2252
|
+
props.onClose();
|
|
2253
|
+
}
|
|
2254
|
+
};
|
|
2255
|
+
|
|
2256
|
+
var onSelect = function onSelect(selected) {
|
|
2257
|
+
props.onSelect(selected);
|
|
2258
|
+
onClose();
|
|
2259
|
+
};
|
|
2260
|
+
|
|
2261
|
+
var actualAnchor = externalAnchor !== undefined ? React.cloneElement(externalAnchor, {
|
|
2262
|
+
ref: externalAnchor.ref
|
|
2263
|
+
}) : defaultAnchor(defaultAnchorRef);
|
|
2264
|
+
var anchorRef = props.anchorRef || actualAnchor.ref;
|
|
2265
|
+
return React.createElement("div", {
|
|
2266
|
+
className: "piped-text-dropdown"
|
|
2267
|
+
}, isMenuOpen && React.createElement(PipedTextMenu, {
|
|
2268
|
+
onClose: onClose,
|
|
2269
|
+
show: isMenuOpen,
|
|
2270
|
+
onSelected: onSelect,
|
|
2271
|
+
items: pipedTextItems,
|
|
2272
|
+
anchor: actualAnchor,
|
|
2273
|
+
anchorRef: anchorRef,
|
|
2274
|
+
ignoreClickSelector: props.ignoreClickSelector,
|
|
2275
|
+
"aria-labelledby": ariaLabelledBy
|
|
2276
|
+
}));
|
|
2277
|
+
|
|
2278
|
+
function initializePipedText() {
|
|
2279
|
+
if (props.items) {
|
|
2280
|
+
return pipedTextDataAdapter(props.items);
|
|
2281
|
+
}
|
|
2282
|
+
}
|
|
2283
|
+
}
|
|
2284
|
+
|
|
2285
|
+
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.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";
|
|
2286
|
+
styleInject(css_248z$c);
|
|
2287
|
+
|
|
2288
|
+
function PipedTextInput(props) {
|
|
2289
|
+
var _a = useState(false), showMenu = _a[0], setShowMenu = _a[1];
|
|
2290
|
+
var _b = useState(), cursorPosition = _b[0], setCursorPosition = _b[1];
|
|
2291
|
+
var pipedTextButtonId = useId();
|
|
2292
|
+
var pipedTextButtonRef = useRef(null);
|
|
2293
|
+
/*
|
|
2294
|
+
This has to be an Object type ref instead of 'string' or React will lose
|
|
2295
|
+
track of state, and the supplied props input value will become stale
|
|
2296
|
+
*/
|
|
2297
|
+
var _c = useState({
|
|
2298
|
+
value: props.value || ''
|
|
2299
|
+
}), inputRefValue = _c[0], setInputRefValue = _c[1];
|
|
2300
|
+
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"]);
|
|
2301
|
+
useEffect(function () {
|
|
2302
|
+
updateCursorPosition();
|
|
2303
|
+
if (onSelect !== undefined && (typeof onSelect) !== 'function') {
|
|
2304
|
+
throw new Error('PipedTextInput: onSelect property must be a function');
|
|
2305
|
+
}
|
|
2306
|
+
if (onChange !== undefined && (typeof onChange) !== 'function') {
|
|
2307
|
+
throw new Error('PipedTextInput: onChange property must be a function');
|
|
2308
|
+
}
|
|
2309
|
+
}, []);
|
|
2310
|
+
useEffect(function () {
|
|
2311
|
+
var nextInputValue;
|
|
2312
|
+
if ((typeof value) === 'string') {
|
|
2313
|
+
nextInputValue = value;
|
|
2314
|
+
}
|
|
2315
|
+
else {
|
|
2316
|
+
nextInputValue = '';
|
|
2317
|
+
}
|
|
2318
|
+
setInputRefValue({
|
|
2319
|
+
value: nextInputValue,
|
|
2320
|
+
});
|
|
2321
|
+
}, [props.value]);
|
|
2322
|
+
return (React.createElement("div", { className: "piped-text-input" },
|
|
2323
|
+
React.createElement("div", { className: 'piped-text-input-toggle popover-toggle' + (multiline ? ' multiline-input' : '') },
|
|
2324
|
+
React.createElement(Input, __assign({ value: inputRefValue.value, onChange: function (evt) {
|
|
2325
|
+
onInputChange(evt);
|
|
2326
|
+
}, onBlur: onInputBlur, placeholder: placeholder, multiline: multiline }, restProps)),
|
|
2327
|
+
React.createElement(IconButton, { id: pipedTextButtonId, "aria-label": "PipedText", "aria-haspopup": "menu", "aria-expanded": showMenu ? true : undefined, role: "button", onClick: toggleMenu, ref: pipedTextButtonRef },
|
|
2328
|
+
React.createElement(PipedTextIcon, null)),
|
|
2329
|
+
React.createElement("div", { className: "piped-text-select-container" },
|
|
2330
|
+
React.createElement(PipedTextSelect, { items: items, onSelect: pipedTextSelected, show: showMenu, onClose: handleClose, ignoreClickSelector: "piped-text-input-toggle", anchorRef: pipedTextButtonRef, "aria-labelledby": pipedTextButtonId }))),
|
|
2331
|
+
showAddonText() && (React.createElement("div", { className: "addon-text-container" },
|
|
2332
|
+
helperText && (React.createElement("div", { className: "helper-text" }, helperText)),
|
|
2333
|
+
errorText && (React.createElement("div", { className: "error-text" },
|
|
2334
|
+
React.createElement("div", { className: "error-text-icon" },
|
|
2335
|
+
React.createElement(ErrorIcon, null)),
|
|
2336
|
+
React.createElement("div", { className: "error-text-content" }, errorText)))))));
|
|
2337
|
+
function showAddonText() {
|
|
2338
|
+
return ((helperText !== undefined) || (errorText !== undefined));
|
|
2339
|
+
}
|
|
2340
|
+
function updateCursorPosition() {
|
|
2341
|
+
if ((cursorPosition === undefined) && value) {
|
|
2342
|
+
var initialCursorPositon = (value.length - 1) || 0;
|
|
2343
|
+
setCursorPosition(initialCursorPositon);
|
|
2344
|
+
}
|
|
2345
|
+
else {
|
|
2346
|
+
// default to 0 if no cursorPosition is found or no value is passed
|
|
2347
|
+
setCursorPosition(0);
|
|
2348
|
+
}
|
|
2349
|
+
}
|
|
2350
|
+
function handleClose() {
|
|
2351
|
+
if (onClose) {
|
|
2352
|
+
onClose();
|
|
2353
|
+
}
|
|
2354
|
+
setShowMenu(false);
|
|
2355
|
+
}
|
|
2356
|
+
function pipedTextSelected(selected) {
|
|
2357
|
+
var nextInputValue, prependString, appendString;
|
|
2358
|
+
handleSelect(selected);
|
|
2359
|
+
if (_get(selected, 'value.locator')) {
|
|
2360
|
+
prependString = inputRefValue.value.substring(0, cursorPosition);
|
|
2361
|
+
appendString = inputRefValue.value.substring(cursorPosition);
|
|
2362
|
+
nextInputValue = "".concat(prependString).concat(selected.value.locator).concat(appendString);
|
|
2363
|
+
setInputRefValue({
|
|
2364
|
+
value: nextInputValue,
|
|
2365
|
+
});
|
|
2366
|
+
handleChange(nextInputValue);
|
|
2367
|
+
}
|
|
2368
|
+
}
|
|
2369
|
+
function toggleMenu() {
|
|
2370
|
+
var nextShowMenu;
|
|
2371
|
+
nextShowMenu = !showMenu;
|
|
2372
|
+
if (!nextShowMenu) {
|
|
2373
|
+
handleClose();
|
|
2374
|
+
}
|
|
2375
|
+
setShowMenu(nextShowMenu);
|
|
2376
|
+
}
|
|
2377
|
+
function onInputChange(evt) {
|
|
2378
|
+
var nextInputValue;
|
|
2379
|
+
nextInputValue = evt.target.value;
|
|
2380
|
+
setInputRefValue({
|
|
2381
|
+
value: nextInputValue,
|
|
2382
|
+
});
|
|
2383
|
+
handleChange(nextInputValue, evt);
|
|
2384
|
+
}
|
|
2385
|
+
function onInputBlur(evt) {
|
|
2386
|
+
var nextCursorPosition;
|
|
2387
|
+
nextCursorPosition = evt.target.selectionStart;
|
|
2388
|
+
setCursorPosition(nextCursorPosition);
|
|
2389
|
+
}
|
|
2390
|
+
function handleChange(value, evt) {
|
|
2391
|
+
if (onChange) {
|
|
2392
|
+
onChange(value, evt);
|
|
2393
|
+
}
|
|
2394
|
+
}
|
|
2395
|
+
function handleSelect(selected) {
|
|
2396
|
+
if (onSelect) {
|
|
2397
|
+
onSelect(selected);
|
|
2398
|
+
}
|
|
2399
|
+
}
|
|
2400
|
+
}
|
|
2401
|
+
|
|
2402
|
+
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";
|
|
2403
|
+
styleInject(css_248z$b);
|
|
2404
|
+
|
|
2405
|
+
function FieldRow(props) {
|
|
2406
|
+
var _useState = useState(props.children),
|
|
2407
|
+
_useState2 = _slicedToArray(_useState, 2),
|
|
2408
|
+
children = _useState2[0],
|
|
2409
|
+
setChildren = _useState2[1];
|
|
2410
|
+
|
|
2411
|
+
useEffect(function () {
|
|
2412
|
+
var nextChildren;
|
|
2413
|
+
|
|
2414
|
+
if (!Array.isArray(children)) {
|
|
2415
|
+
nextChildren = [];
|
|
2416
|
+
nextChildren.push(children);
|
|
2417
|
+
setChildren(nextChildren);
|
|
2418
|
+
}
|
|
2419
|
+
}, []);
|
|
2420
|
+
useEffect(function () {
|
|
2421
|
+
var nextChildren;
|
|
2422
|
+
nextChildren = props.children.slice();
|
|
2423
|
+
setChildren(nextChildren);
|
|
2424
|
+
}, [props.children]);
|
|
2425
|
+
|
|
2426
|
+
var getRowDelete = function getRowDelete() {
|
|
2427
|
+
var handleDelete = function handleDelete() {
|
|
2428
|
+
if (typeof props.onRemove === 'function') {
|
|
2429
|
+
props.onRemove(props.id);
|
|
2430
|
+
}
|
|
2431
|
+
};
|
|
2432
|
+
|
|
2433
|
+
return React.createElement("div", {
|
|
2434
|
+
className: "icon-wrapper",
|
|
2435
|
+
onClick: handleDelete
|
|
2436
|
+
}, !props.required && React.createElement(IconButton, {
|
|
2437
|
+
"aria-label": "RemoveRow",
|
|
2438
|
+
size: "medium"
|
|
2439
|
+
}, React.createElement(RemoveItemIcon, null)));
|
|
2440
|
+
};
|
|
2441
|
+
|
|
2442
|
+
var handleFieldSwitch = function handleFieldSwitch(newFieldId) {
|
|
2443
|
+
if (typeof props.onFieldSwitch === 'function') {
|
|
2444
|
+
props.onFieldSwitch(props.id, newFieldId);
|
|
2445
|
+
}
|
|
2446
|
+
};
|
|
2447
|
+
|
|
2448
|
+
var handleFieldNameChange = function handleFieldNameChange(event) {
|
|
2449
|
+
if (typeof props.onFieldNameChange === 'function') {
|
|
2450
|
+
props.onFieldNameChange(props.id, event);
|
|
2451
|
+
}
|
|
2452
|
+
};
|
|
2453
|
+
|
|
2454
|
+
var handleFieldValueChange = function handleFieldValueChange(value, event) {
|
|
2455
|
+
if (typeof props.onFieldValueChange === 'function') {
|
|
2456
|
+
props.onFieldValueChange(props.id, value, event);
|
|
2457
|
+
}
|
|
2458
|
+
};
|
|
2459
|
+
|
|
2460
|
+
var shouldDisableTooltip = function shouldDisableTooltip(tooltipValue) {
|
|
2461
|
+
if (typeof tooltipValue === 'string') {
|
|
2462
|
+
return tooltipValue.trim().length === 0;
|
|
2463
|
+
}
|
|
2464
|
+
|
|
2465
|
+
if (typeof tooltipValue === 'function' || tooltipValue === undefined || tooltipValue === null) {
|
|
2466
|
+
return true;
|
|
2467
|
+
}
|
|
2468
|
+
|
|
2469
|
+
return "".concat(tooltipValue).trim().length === 0;
|
|
2470
|
+
};
|
|
2471
|
+
|
|
2472
|
+
var getFieldSelector = function getFieldSelector() {
|
|
2473
|
+
var getInternalContent = function getInternalContent() {
|
|
2474
|
+
if (props.isCustom) {
|
|
2475
|
+
return React.createElement(Input, {
|
|
2476
|
+
full: true,
|
|
2477
|
+
value: props.fieldName === undefined ? '' : props.fieldName,
|
|
2478
|
+
placeholder: props.customNamePlaceholder === undefined ? '' : props.customNamePlaceholder,
|
|
2479
|
+
className: "custom-field-name",
|
|
2480
|
+
onChange: handleFieldNameChange
|
|
2481
|
+
});
|
|
2482
|
+
}
|
|
2483
|
+
|
|
2484
|
+
if (props.required || !props.children || Array.isArray(children) && children.length === 0) {
|
|
2485
|
+
if (props.subMenu) {
|
|
2486
|
+
return React.createElement(SelectMenu, {
|
|
2487
|
+
searchable: props.searchable !== undefined && props.searchable !== false,
|
|
2488
|
+
defaultLabel: props.fieldName || '',
|
|
2489
|
+
label: props.fieldName,
|
|
2490
|
+
className: "full-width left-align",
|
|
2491
|
+
onChange: handleFieldSwitch
|
|
2492
|
+
}, createMenuItems([{
|
|
2493
|
+
id: props.id,
|
|
2494
|
+
name: props.fieldName,
|
|
2495
|
+
subMenu: props.subMenu,
|
|
2496
|
+
subMenuLabel: props.subMenuLabel
|
|
2497
|
+
}]));
|
|
2498
|
+
} else {
|
|
2499
|
+
return React.createElement("div", {
|
|
2500
|
+
className: "required-indicator-container"
|
|
2501
|
+
}, React.createElement("div", {
|
|
2502
|
+
className: "required-indicator-text"
|
|
2503
|
+
}, props.fieldName), props.required && React.createElement("div", {
|
|
2504
|
+
className: "required-indicator-symbol"
|
|
2505
|
+
}, "*"));
|
|
2506
|
+
}
|
|
2507
|
+
}
|
|
2508
|
+
|
|
2509
|
+
return React.createElement(SelectMenu, {
|
|
2510
|
+
searchable: props.searchable !== undefined && props.searchable !== false,
|
|
2511
|
+
defaultLabel: props.fieldName || '',
|
|
2512
|
+
label: props.fieldName,
|
|
2513
|
+
className: "full-width left-align",
|
|
2514
|
+
onChange: handleFieldSwitch
|
|
2515
|
+
}, createMenuItems(children));
|
|
2516
|
+
};
|
|
2517
|
+
|
|
2518
|
+
var tooltipContent = React.createElement("div", null, props.nameTooltip);
|
|
2519
|
+
return React.createElement(Tooltip, {
|
|
2520
|
+
disabled: !props.isCustom || shouldDisableTooltip(props.nameTooltip),
|
|
2521
|
+
placement: "top",
|
|
2522
|
+
content: tooltipContent
|
|
2523
|
+
}, React.createElement("div", null, getInternalContent()));
|
|
2524
|
+
};
|
|
2525
|
+
|
|
2526
|
+
var createMenuItems = function createMenuItems(items) {
|
|
2527
|
+
return items.map(function (_ref) {
|
|
2528
|
+
var id = _ref.id,
|
|
2529
|
+
name = _ref.name,
|
|
2530
|
+
subMenu = _ref.subMenu,
|
|
2531
|
+
subMenuLabel = _ref.subMenuLabel;
|
|
2532
|
+
return subMenu !== undefined ? React.createElement(SelectMenu, {
|
|
2533
|
+
label: subMenuLabel ? subMenuLabel : name,
|
|
2534
|
+
key: id
|
|
2535
|
+
}, createMenuItems(subMenu)) : React.createElement(MenuItem, {
|
|
2536
|
+
key: id,
|
|
2537
|
+
value: id
|
|
2538
|
+
}, name);
|
|
2539
|
+
});
|
|
2540
|
+
};
|
|
2541
|
+
|
|
2542
|
+
var getFieldInput = function getFieldInput() {
|
|
2543
|
+
var getInternalContent = function getInternalContent() {
|
|
2544
|
+
if (props.customInput) {
|
|
2545
|
+
return props.customInput;
|
|
2546
|
+
} else {
|
|
2547
|
+
return React.createElement(PipedTextInput, {
|
|
2548
|
+
items: props.pipedTextItems,
|
|
2549
|
+
value: props.value === undefined ? '' : props.value,
|
|
2550
|
+
onChange: handleFieldValueChange,
|
|
2551
|
+
placeholder: props.valuePlaceholder === undefined ? '' : props.valuePlaceholder
|
|
2552
|
+
});
|
|
2553
|
+
}
|
|
2554
|
+
};
|
|
2555
|
+
|
|
2556
|
+
var tooltipContent = React.createElement("div", null, props.valueTooltip);
|
|
2557
|
+
return React.createElement(Tooltip, {
|
|
2558
|
+
disabled: shouldDisableTooltip(props.valueTooltip),
|
|
2559
|
+
placement: "top",
|
|
2560
|
+
content: tooltipContent
|
|
2561
|
+
}, React.createElement("div", null, getInternalContent()));
|
|
2562
|
+
};
|
|
2563
|
+
|
|
2564
|
+
return React.createElement("div", {
|
|
2565
|
+
className: "field-row"
|
|
2566
|
+
}, React.createElement("div", {
|
|
2567
|
+
className: "field-selector ".concat(props.required && !props.subMenu ? 'required-field' : '')
|
|
2568
|
+
}, getFieldSelector()), React.createElement("div", {
|
|
2569
|
+
className: "field-input-container"
|
|
2570
|
+
}, React.createElement("div", {
|
|
2571
|
+
className: "field-input"
|
|
2572
|
+
}, getFieldInput()), React.createElement("div", {
|
|
2573
|
+
className: "delete-row"
|
|
2574
|
+
}, getRowDelete())));
|
|
2575
|
+
}
|
|
2576
|
+
|
|
2577
|
+
var css_248z$a = "";
|
|
2578
|
+
styleInject(css_248z$a);
|
|
2579
|
+
|
|
2580
|
+
function FieldItem(props) {
|
|
2581
|
+
var label = props.name || undefined;
|
|
2582
|
+
|
|
2583
|
+
var handleClick = function handleClick() {
|
|
2584
|
+
if (typeof props.onClick === 'function') {
|
|
2585
|
+
props.onClick(props.id);
|
|
2586
|
+
}
|
|
2587
|
+
};
|
|
2588
|
+
|
|
2589
|
+
return React.createElement("div", {
|
|
2590
|
+
className: "field-item",
|
|
2591
|
+
onClick: handleClick
|
|
2592
|
+
}, label);
|
|
2593
|
+
}
|
|
2594
|
+
|
|
2595
|
+
var css_248z$9 = ".task-fields .add-field-button {\n margin-right: 100px; }\n .task-fields .add-field-button .add-field-button-label {\n padding: 0 3px; }\n\n.task-fields .field-table {\n padding-right: 100px;\n overflow-x: auto; }\n .task-fields .field-table .field-headers {\n margin-bottom: 10px;\n padding-left: 12px; }\n .task-fields .field-table .field-headers .field-row {\n color: #6A6D70;\n font-weight: bold; }\n .task-fields .field-table .field-headers .field-row .field-selector label, .task-fields .field-table .field-headers .field-row .field-input label {\n font-size: 12px; }\n .task-fields .field-table .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-table .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-table .field-rows {\n padding-bottom: 12px; }\n .task-fields .field-table .field-rows .field-row {\n border-top: 1px solid #E5E5E5; }\n .task-fields .field-table .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-table .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";
|
|
2596
|
+
styleInject(css_248z$9);
|
|
2597
|
+
|
|
2598
|
+
var uuidv4 = uuid.v4;
|
|
2599
|
+
var CUSTOM_TYPE = 'custom';
|
|
2600
|
+
function TaskFields(props) {
|
|
2601
|
+
var _useState = useState([]),
|
|
2602
|
+
_useState2 = _slicedToArray(_useState, 2),
|
|
2603
|
+
fieldsInUse = _useState2[0],
|
|
2604
|
+
setFieldsInUse = _useState2[1];
|
|
2605
|
+
|
|
2606
|
+
var _useState3 = useState([]),
|
|
2607
|
+
_useState4 = _slicedToArray(_useState3, 2),
|
|
2608
|
+
availableFields = _useState4[0],
|
|
2609
|
+
setAvailableFields = _useState4[1];
|
|
2610
|
+
|
|
2611
|
+
var _useState5 = useState(),
|
|
2612
|
+
_useState6 = _slicedToArray(_useState5, 2),
|
|
2613
|
+
allFieldOptions = _useState6[0],
|
|
2614
|
+
setAllFieldOptions = _useState6[1];
|
|
2615
|
+
|
|
2616
|
+
var onFieldSwitch = function onFieldSwitch(oldId, newId) {
|
|
2617
|
+
if (typeof props.onFieldSwitch === 'function') {
|
|
2618
|
+
props.onFieldSwitch(oldId, newId);
|
|
2619
|
+
}
|
|
2620
|
+
};
|
|
2621
|
+
|
|
2622
|
+
var onFieldValueChange = function onFieldValueChange(fieldId, value, event) {
|
|
2623
|
+
if (typeof props.onFieldInputChange === 'function') {
|
|
2624
|
+
props.onFieldInputChange(fieldId, value, event);
|
|
2625
|
+
}
|
|
2626
|
+
};
|
|
2627
|
+
|
|
2628
|
+
var onFieldNameChange = function onFieldNameChange(fieldId, event) {
|
|
2629
|
+
var changeFn = _get(props, 'customFieldOptions.onCustomFieldNameChange');
|
|
2630
|
+
|
|
2631
|
+
if (typeof changeFn === 'function') {
|
|
2632
|
+
changeFn(fieldId, event);
|
|
2633
|
+
}
|
|
2634
|
+
};
|
|
2635
|
+
|
|
2636
|
+
var getFieldRows = function getFieldRows() {
|
|
2637
|
+
return fieldsInUse.map(function (field) {
|
|
2638
|
+
return React.createElement(FieldRow, {
|
|
2639
|
+
customInput: field.children,
|
|
2640
|
+
required: field.required,
|
|
2641
|
+
fieldName: field.name,
|
|
2642
|
+
id: field.id,
|
|
2643
|
+
subMenu: field.subMenu,
|
|
2644
|
+
subMenuLabel: field.subMenuLabel,
|
|
2645
|
+
nameTooltip: field.type === CUSTOM_TYPE ? _get(props, 'customFieldOptions.nameTooltip', '') : field.nameTooltip,
|
|
2646
|
+
valueTooltip: field.type === CUSTOM_TYPE ? _get(props, 'customFieldOptions.valueTooltip', '') : field.valueTooltip,
|
|
2647
|
+
onFieldNameChange: onFieldNameChange,
|
|
2648
|
+
onFieldValueChange: onFieldValueChange,
|
|
2649
|
+
onFieldSwitch: onFieldSwitch,
|
|
2650
|
+
onRemove: onFieldRemove,
|
|
2651
|
+
isCustom: field.type === CUSTOM_TYPE,
|
|
2652
|
+
key: field.id,
|
|
2653
|
+
value: field.value,
|
|
2654
|
+
valuePlaceholder: field.type === CUSTOM_TYPE ? _get(props, 'customFieldOptions.valuePlaceholder', '') : field.valuePlaceholder,
|
|
2655
|
+
customNamePlaceholder: _get(props, 'customFieldOptions.namePlaceholder', ''),
|
|
2656
|
+
pipedTextItems: props.pipedTextItems,
|
|
2657
|
+
searchable: props.searchable
|
|
2658
|
+
}, allFieldOptions && getFieldsForFieldRow(availableFields, allFieldOptions, field.id));
|
|
2659
|
+
});
|
|
2660
|
+
};
|
|
2661
|
+
|
|
2662
|
+
var getFieldsForFieldRow = function getFieldsForFieldRow(allAvailableFields, allFields, fieldId) {
|
|
2663
|
+
var fieldsToAdd = allAvailableFields.slice();
|
|
2664
|
+
allFields.forEach(function (field) {
|
|
2665
|
+
if (field.subMenu !== undefined && fieldId === field.id) {
|
|
2666
|
+
var foundIndex = fieldsToAdd.findIndex(function (fieldToAdd) {
|
|
2667
|
+
return fieldToAdd.id === field.id;
|
|
2668
|
+
});
|
|
2669
|
+
|
|
2670
|
+
if (foundIndex === -1) {
|
|
2671
|
+
fieldsToAdd.push(field);
|
|
2672
|
+
}
|
|
2673
|
+
}
|
|
2674
|
+
});
|
|
2675
|
+
return fieldsToAdd;
|
|
2676
|
+
};
|
|
2677
|
+
|
|
2678
|
+
var onFieldAdd = function onFieldAdd(fieldId) {
|
|
2679
|
+
if (typeof props.onFieldAdd === 'function') {
|
|
2680
|
+
props.onFieldAdd(fieldId);
|
|
2681
|
+
}
|
|
2682
|
+
};
|
|
2683
|
+
|
|
2684
|
+
var onCustomFieldAdd = function onCustomFieldAdd() {
|
|
2685
|
+
var handleFn = _get(props, 'customFieldOptions.onCustomFieldAdd', function () {});
|
|
2686
|
+
|
|
2687
|
+
handleFn();
|
|
2688
|
+
};
|
|
2689
|
+
|
|
2690
|
+
var getAvailableFields = function getAvailableFields() {
|
|
2691
|
+
return availableFields.map(function (field) {
|
|
2692
|
+
return React.createElement(FieldItem, {
|
|
2693
|
+
name: field.name,
|
|
2694
|
+
type: field.type,
|
|
2695
|
+
required: field.required,
|
|
2696
|
+
key: field.id,
|
|
2697
|
+
id: field.id,
|
|
2698
|
+
subMenu: field.subMenu,
|
|
2699
|
+
subMenuLabel: field.subMenuLabel
|
|
2700
|
+
});
|
|
2701
|
+
});
|
|
2702
|
+
};
|
|
2703
|
+
|
|
2704
|
+
var onFieldRemove = function onFieldRemove(fieldId) {
|
|
2705
|
+
if (typeof props.onFieldRemove === 'function') {
|
|
2706
|
+
props.onFieldRemove(fieldId);
|
|
2707
|
+
}
|
|
2708
|
+
};
|
|
2709
|
+
|
|
2710
|
+
var getFieldsInUse = function getFieldsInUse(allFieldOptions) {
|
|
2711
|
+
var nextFieldsInUse = [];
|
|
2712
|
+
var taskFieldsChildren;
|
|
2713
|
+
|
|
2714
|
+
if (allFieldOptions === undefined) {
|
|
2715
|
+
return undefined;
|
|
2716
|
+
}
|
|
2717
|
+
|
|
2718
|
+
if (!Array.isArray(props.children)) {
|
|
2719
|
+
taskFieldsChildren = [];
|
|
2720
|
+
taskFieldsChildren.push(props.children);
|
|
2721
|
+
} else {
|
|
2722
|
+
taskFieldsChildren = props.children;
|
|
2723
|
+
}
|
|
2724
|
+
|
|
2725
|
+
nextFieldsInUse = getRequiredFields(taskFieldsChildren);
|
|
2726
|
+
nextFieldsInUse = getFieldsWithValues(nextFieldsInUse);
|
|
2727
|
+
nextFieldsInUse = getInlineFields(nextFieldsInUse, taskFieldsChildren);
|
|
2728
|
+
return nextFieldsInUse;
|
|
2729
|
+
|
|
2730
|
+
function getInlineFields(fieldsInUse, fieldChildren) {
|
|
2731
|
+
var nextFieldsInUse = fieldsInUse.slice();
|
|
2732
|
+
var values = props.values || [];
|
|
2733
|
+
nextFieldsInUse = nextFieldsInUse.map(function (nextFieldInUse) {
|
|
2734
|
+
var foundFieldValue, foundNextChild, foundFieldOption;
|
|
2735
|
+
foundFieldValue = values.find(function (value) {
|
|
2736
|
+
return value.id === nextFieldInUse.id;
|
|
2737
|
+
});
|
|
2738
|
+
foundFieldOption = fieldChildren.find(function (child) {
|
|
2739
|
+
return child.props.id === foundFieldValue.id;
|
|
2740
|
+
});
|
|
2741
|
+
|
|
2742
|
+
if (foundFieldOption !== undefined && !nextFieldInUse.required) {
|
|
2743
|
+
foundNextChild = fieldChildren.find(function (nextChild) {
|
|
2744
|
+
return nextChild.props.id === foundFieldValue.id;
|
|
2745
|
+
});
|
|
2746
|
+
nextFieldInUse = Object.assign({}, nextFieldInUse, {
|
|
2747
|
+
name: foundNextChild.props.name,
|
|
2748
|
+
id: foundNextChild.props.id,
|
|
2749
|
+
children: foundNextChild.props.children,
|
|
2750
|
+
nameTooltip: foundNextChild.props.nameTooltip,
|
|
2751
|
+
valueTooltip: foundNextChild.props.valueTooltip,
|
|
2752
|
+
valuePlaceholder: foundNextChild.props.valuePlaceholder,
|
|
2753
|
+
subMenu: foundNextChild.props.subMenu,
|
|
2754
|
+
subMenuLabel: foundNextChild.props.subMenuLabel
|
|
2755
|
+
});
|
|
2756
|
+
}
|
|
2757
|
+
|
|
2758
|
+
return nextFieldInUse;
|
|
2759
|
+
});
|
|
2760
|
+
return nextFieldsInUse;
|
|
2761
|
+
}
|
|
2762
|
+
|
|
2763
|
+
function getRequiredFields(fieldsToSearch) {
|
|
2764
|
+
var requiredFields = [];
|
|
2765
|
+
fieldsToSearch.forEach(function (field) {
|
|
2766
|
+
if (field.props.required) {
|
|
2767
|
+
requiredFields.push({
|
|
2768
|
+
required: field.props.required,
|
|
2769
|
+
name: field.props.name,
|
|
2770
|
+
id: field.props.id,
|
|
2771
|
+
children: field.props.children,
|
|
2772
|
+
nameTooltip: field.props.nameTooltip,
|
|
2773
|
+
valueTooltip: field.props.valueTooltip,
|
|
2774
|
+
value: field.props.value || undefined,
|
|
2775
|
+
valuePlaceholder: field.props.valuePlaceholder,
|
|
2776
|
+
subMenu: field.props.subMenu,
|
|
2777
|
+
subMenuLabel: field.props.subMenuLabel
|
|
2778
|
+
});
|
|
2779
|
+
}
|
|
2780
|
+
});
|
|
2781
|
+
return requiredFields;
|
|
2782
|
+
}
|
|
2783
|
+
|
|
2784
|
+
function getFieldsWithValues(fieldsInUse) {
|
|
2785
|
+
var nextFieldsInUse = fieldsInUse.slice();
|
|
2786
|
+
var fieldValues = props.values || [];
|
|
2787
|
+
fieldValues.forEach(function (currentField) {
|
|
2788
|
+
var fieldMetadata = allFieldOptions.find(function (field) {
|
|
2789
|
+
return field.id === currentField.id;
|
|
2790
|
+
});
|
|
2791
|
+
|
|
2792
|
+
if (fieldMetadata !== undefined) {
|
|
2793
|
+
setFieldValue(nextFieldsInUse, currentField, fieldMetadata);
|
|
2794
|
+
} else if (props.customFieldOptions) {
|
|
2795
|
+
var customFieldValue = {
|
|
2796
|
+
required: false,
|
|
2797
|
+
name: currentField.name,
|
|
2798
|
+
id: currentField.id,
|
|
2799
|
+
value: currentField.value,
|
|
2800
|
+
nameTooltip: _get(props, 'customFieldOptions.nameTooltip', ''),
|
|
2801
|
+
valueTooltip: _get(props, 'customFieldOptions.valueTooltip', ''),
|
|
2802
|
+
namePlaceholder: _get(props, 'customFieldOptions.namePlaceholder', ''),
|
|
2803
|
+
type: CUSTOM_TYPE,
|
|
2804
|
+
subMenu: currentField.subMenu,
|
|
2805
|
+
subMenuLabel: currentField.subMenuLabel
|
|
2806
|
+
};
|
|
2807
|
+
nextFieldsInUse.push(customFieldValue);
|
|
2808
|
+
}
|
|
2809
|
+
});
|
|
2810
|
+
return nextFieldsInUse;
|
|
2811
|
+
|
|
2812
|
+
function setFieldValue(fieldsInUse, fieldValue, fieldMetadata) {
|
|
2813
|
+
var field = fieldsInUse.find(function (field) {
|
|
2814
|
+
return field.id === fieldValue.id;
|
|
2815
|
+
});
|
|
2816
|
+
|
|
2817
|
+
if (field !== undefined) {
|
|
2818
|
+
field.value = fieldValue.value;
|
|
2819
|
+
} else {
|
|
2820
|
+
var newField = _cloneDeepWith(fieldMetadata, function (value) {
|
|
2821
|
+
if (React.isValidElement(value)) {
|
|
2822
|
+
return React.cloneElement(value);
|
|
2823
|
+
}
|
|
2824
|
+
});
|
|
2825
|
+
|
|
2826
|
+
newField.value = fieldValue.value;
|
|
2827
|
+
fieldsInUse.push(newField);
|
|
2828
|
+
}
|
|
2829
|
+
}
|
|
2830
|
+
}
|
|
2831
|
+
};
|
|
2832
|
+
|
|
2833
|
+
var updateAvailableFields = function updateAvailableFields() {
|
|
2834
|
+
var nextAllFieldOptions = props.children.map(function (child) {
|
|
2835
|
+
var childProps = child.props;
|
|
2836
|
+
return {
|
|
2837
|
+
required: childProps.required,
|
|
2838
|
+
name: childProps.name,
|
|
2839
|
+
id: childProps.id,
|
|
2840
|
+
children: childProps.children,
|
|
2841
|
+
nameTooltip: childProps.nameTooltip,
|
|
2842
|
+
valueTooltip: childProps.valueTooltip,
|
|
2843
|
+
valuePlaceholder: childProps.valuePlaceholder,
|
|
2844
|
+
subMenu: childProps.subMenu,
|
|
2845
|
+
subMenuLabel: childProps.subMenuLabel
|
|
2846
|
+
};
|
|
2847
|
+
});
|
|
2848
|
+
var nextFieldsInUse = getFieldsInUse(nextAllFieldOptions);
|
|
2849
|
+
var nextAvailableFields = nextAllFieldOptions.filter(function (field) {
|
|
2850
|
+
var foundFieldIdx = nextFieldsInUse.findIndex(function (usedField) {
|
|
2851
|
+
return field.id === usedField.id;
|
|
2852
|
+
});
|
|
2853
|
+
return foundFieldIdx === -1;
|
|
2854
|
+
});
|
|
2855
|
+
setAllFieldOptions(nextAllFieldOptions);
|
|
2856
|
+
setFieldsInUse(nextFieldsInUse);
|
|
2857
|
+
setAvailableFields(nextAvailableFields);
|
|
2858
|
+
};
|
|
2859
|
+
|
|
2860
|
+
useEffect(function () {
|
|
2861
|
+
updateAvailableFields();
|
|
2862
|
+
}, []);
|
|
2863
|
+
useEffect(function () {
|
|
2864
|
+
updateAvailableFields();
|
|
2865
|
+
}, [props.values]);
|
|
2866
|
+
return React.createElement("div", {
|
|
2867
|
+
className: "task-fields"
|
|
2868
|
+
}, React.createElement("div", {
|
|
2869
|
+
className: "field-table",
|
|
2870
|
+
tabIndex: "0"
|
|
2871
|
+
}, React.createElement("div", {
|
|
2872
|
+
className: "field-headers"
|
|
2873
|
+
}, React.createElement(AddFieldHeaders, {
|
|
2874
|
+
itemHeaderText: props.fieldItemsHeaderText,
|
|
2875
|
+
inputHeaderText: props.fieldInputsHeaderText
|
|
2876
|
+
})), React.createElement("div", {
|
|
2877
|
+
className: "field-rows"
|
|
2878
|
+
}, getFieldRows())), React.createElement("div", {
|
|
2879
|
+
className: "add-field-container"
|
|
2880
|
+
}, React.createElement(AddFieldButton, {
|
|
2881
|
+
label: props.addFieldLabel,
|
|
2882
|
+
onFieldAdded: onFieldAdd,
|
|
2883
|
+
disableAddFieldPopover: props.disableAddFieldPopover,
|
|
2884
|
+
allowCustom: props.customFieldOptions,
|
|
2885
|
+
customLabel: _get(props, 'customFieldOptions.label', ''),
|
|
2886
|
+
onCustomFieldAdded: props.customFieldOptions ? onCustomFieldAdd : function () {}
|
|
2887
|
+
}, getAvailableFields())));
|
|
2888
|
+
}
|
|
2889
|
+
|
|
2890
|
+
function AddFieldButton(props) {
|
|
2891
|
+
var label = props.label || '';
|
|
2892
|
+
var customLabel = props.customLabel || '';
|
|
2893
|
+
var disableAddFieldPopover = props.disableAddFieldPopover;
|
|
2894
|
+
|
|
2895
|
+
var _useState7 = useState(false),
|
|
2896
|
+
_useState8 = _slicedToArray(_useState7, 2),
|
|
2897
|
+
popoverShow = _useState8[0],
|
|
2898
|
+
setPopoverShow = _useState8[1];
|
|
2899
|
+
|
|
2900
|
+
var customId = uuidv4();
|
|
2901
|
+
var CUSTOM_OPTION = React.createElement(FieldItem, {
|
|
2902
|
+
key: customId,
|
|
2903
|
+
onClick: function onClick() {
|
|
2904
|
+
props.onCustomFieldAdded();
|
|
2905
|
+
setPopoverShow(false);
|
|
2906
|
+
},
|
|
2907
|
+
id: customId,
|
|
2908
|
+
name: customLabel
|
|
2909
|
+
});
|
|
2910
|
+
|
|
2911
|
+
var onPopoverClose = function onPopoverClose() {
|
|
2912
|
+
setPopoverShow(false);
|
|
2913
|
+
};
|
|
2914
|
+
|
|
2915
|
+
var children = [];
|
|
2916
|
+
|
|
2917
|
+
var onPopoverAnchorClick = function onPopoverAnchorClick() {
|
|
2918
|
+
if (!disableAddFieldPopover) {
|
|
2919
|
+
setPopoverShow(!popoverShow);
|
|
2920
|
+
} else {
|
|
2921
|
+
props.onFieldAdded(props.children !== 0 ? getFieldIdWhenPopoverIsClicked(props.children[0].props) : '');
|
|
2922
|
+
}
|
|
2923
|
+
};
|
|
2924
|
+
|
|
2925
|
+
var getFieldIdWhenPopoverIsClicked = function getFieldIdWhenPopoverIsClicked(field) {
|
|
2926
|
+
if (field.subMenu) {
|
|
2927
|
+
return getFieldIdWhenPopoverIsClicked(field.subMenu[0]);
|
|
2928
|
+
} else {
|
|
2929
|
+
return field.id;
|
|
2930
|
+
}
|
|
2931
|
+
};
|
|
2932
|
+
|
|
2933
|
+
children = props.children.map(function (child) {
|
|
2934
|
+
return React.createElement(FieldItem, {
|
|
2935
|
+
name: child.props.name,
|
|
2936
|
+
key: child.props.id,
|
|
2937
|
+
id: child.props.id,
|
|
2938
|
+
subMenu: child.props.subMenu,
|
|
2939
|
+
onClick: function onClick(fieldId) {
|
|
2940
|
+
setPopoverShow(false);
|
|
2941
|
+
props.onFieldAdded(fieldId);
|
|
2942
|
+
}
|
|
2943
|
+
});
|
|
2944
|
+
});
|
|
2945
|
+
|
|
2946
|
+
if (props.allowCustom) {
|
|
2947
|
+
children.push(CUSTOM_OPTION);
|
|
2948
|
+
}
|
|
2949
|
+
|
|
2950
|
+
return React.createElement("div", {
|
|
2951
|
+
className: "add-field-button-container"
|
|
2952
|
+
}, React.createElement(Popover, {
|
|
2953
|
+
show: popoverShow,
|
|
2954
|
+
onClose: onPopoverClose,
|
|
2955
|
+
ignoreClickSelector: ".add-field-button",
|
|
2956
|
+
anchor: React.createElement(Button, {
|
|
2957
|
+
disabled: children.length === 0,
|
|
2958
|
+
kind: "secondary",
|
|
2959
|
+
className: "add-field-button",
|
|
2960
|
+
onClick: onPopoverAnchorClick
|
|
2961
|
+
}, React.createElement("span", {
|
|
2962
|
+
className: "add-field-button-label"
|
|
2963
|
+
}, label))
|
|
2964
|
+
}, children));
|
|
2965
|
+
}
|
|
2966
|
+
|
|
2967
|
+
function AddFieldHeaders(props) {
|
|
2968
|
+
var itemHeaderText = props.itemHeaderText,
|
|
2969
|
+
inputHeaderText = props.inputHeaderText;
|
|
2970
|
+
|
|
2971
|
+
if (itemHeaderText || inputHeaderText) {
|
|
2972
|
+
return React.createElement("div", {
|
|
2973
|
+
className: "field-row"
|
|
2974
|
+
}, React.createElement("div", {
|
|
2975
|
+
className: "field-selector"
|
|
2976
|
+
}, React.createElement(Label, null, itemHeaderText)), React.createElement("div", {
|
|
2977
|
+
className: "field-input"
|
|
2978
|
+
}, React.createElement(Label, null, inputHeaderText)));
|
|
2979
|
+
} else {
|
|
2980
|
+
return null;
|
|
2981
|
+
}
|
|
2982
|
+
}
|
|
2983
|
+
|
|
2984
|
+
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";
|
|
2985
|
+
styleInject(css_248z$8);
|
|
2986
|
+
|
|
2987
|
+
function SelectItem(props) {
|
|
2988
|
+
var checked = props.checked || false;
|
|
2989
|
+
var children = props.children || '';
|
|
2990
|
+
return React.createElement("div", {
|
|
2991
|
+
className: "select-item",
|
|
2992
|
+
onClick: function onClick(event) {
|
|
2993
|
+
return props.onChange(props.value, event);
|
|
2994
|
+
}
|
|
2995
|
+
}, React.createElement("div", {
|
|
2996
|
+
className: "item"
|
|
2997
|
+
}, React.createElement("div", {
|
|
2998
|
+
className: "checked-container ".concat(checked ? 'checked' : '')
|
|
2999
|
+
}, React.createElement(Icon, {
|
|
3000
|
+
type: IconTypes.Check,
|
|
3001
|
+
size: "medium"
|
|
3002
|
+
})), React.createElement("div", {
|
|
3003
|
+
className: "item-content"
|
|
3004
|
+
}, children)));
|
|
3005
|
+
}
|
|
3006
|
+
|
|
3007
|
+
var css_248z$7 = "";
|
|
3008
|
+
styleInject(css_248z$7);
|
|
3009
|
+
|
|
3010
|
+
function MultiselectDropdown(props) {
|
|
3011
|
+
var _useState = useState(false),
|
|
3012
|
+
_useState2 = _slicedToArray(_useState, 2),
|
|
3013
|
+
isDropdownOpen = _useState2[0],
|
|
3014
|
+
setIsDropdownOpen = _useState2[1];
|
|
3015
|
+
|
|
3016
|
+
var label = props.label || '';
|
|
3017
|
+
|
|
3018
|
+
var onPopoverClose = function onPopoverClose() {
|
|
3019
|
+
setIsDropdownOpen(false);
|
|
3020
|
+
};
|
|
3021
|
+
|
|
3022
|
+
var handleChange = function handleChange(value, event) {
|
|
3023
|
+
if (typeof props.onChange === 'function') {
|
|
3024
|
+
props.onChange(value, event);
|
|
3025
|
+
}
|
|
3026
|
+
};
|
|
3027
|
+
|
|
3028
|
+
var renderToggleButton = function renderToggleButton() {
|
|
3029
|
+
return React.createElement("div", {
|
|
3030
|
+
className: "multiselect-dropdown-toggle"
|
|
3031
|
+
}, React.createElement(Button, {
|
|
3032
|
+
onClick: function onClick() {
|
|
3033
|
+
setIsDropdownOpen(!isDropdownOpen);
|
|
3034
|
+
}
|
|
3035
|
+
}, label));
|
|
3036
|
+
};
|
|
3037
|
+
|
|
3038
|
+
var children = props.children || [];
|
|
3039
|
+
|
|
3040
|
+
if (!Array.isArray(children)) {
|
|
3041
|
+
var temp = [];
|
|
3042
|
+
temp.push(children);
|
|
3043
|
+
children = temp;
|
|
3044
|
+
}
|
|
3045
|
+
|
|
3046
|
+
return React.createElement("div", {
|
|
3047
|
+
className: "multiselect-dropdown"
|
|
3048
|
+
}, React.createElement(Popover, {
|
|
3049
|
+
show: isDropdownOpen,
|
|
3050
|
+
onClose: onPopoverClose,
|
|
3051
|
+
ignoreClickSelector: ".multiselect-dropdown-toggle",
|
|
3052
|
+
anchor: renderToggleButton()
|
|
3053
|
+
}, children.map(function (child) {
|
|
3054
|
+
return React.createElement(SelectItem, {
|
|
3055
|
+
onChange: handleChange,
|
|
3056
|
+
checked: child.props.checked,
|
|
3057
|
+
value: child.props.value,
|
|
3058
|
+
key: child.props.value
|
|
3059
|
+
}, child.props.children);
|
|
3060
|
+
})));
|
|
3061
|
+
}
|
|
3062
|
+
|
|
3063
|
+
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";
|
|
3064
|
+
styleInject(css_248z$6);
|
|
3065
|
+
|
|
3066
|
+
function DynamicSearchInput(props) {
|
|
3067
|
+
var _useState = useState(false),
|
|
3068
|
+
_useState2 = _slicedToArray(_useState, 2),
|
|
3069
|
+
isDropdownOpen = _useState2[0],
|
|
3070
|
+
setIsDropdownOpen = _useState2[1];
|
|
3071
|
+
|
|
3072
|
+
var _useState3 = useState([]),
|
|
3073
|
+
_useState4 = _slicedToArray(_useState3, 2),
|
|
3074
|
+
searchResults = _useState4[0],
|
|
3075
|
+
setSearchResults = _useState4[1];
|
|
3076
|
+
|
|
3077
|
+
var _useState5 = useState(''),
|
|
3078
|
+
_useState6 = _slicedToArray(_useState5, 2),
|
|
3079
|
+
inputValue = _useState6[0],
|
|
3080
|
+
setInputValue = _useState6[1];
|
|
3081
|
+
|
|
3082
|
+
useEffect(function () {
|
|
3083
|
+
if (props.search && typeof props.search !== 'function') {
|
|
3084
|
+
throw new Error('DynamicSearchInput: Expected function for search property');
|
|
3085
|
+
}
|
|
3086
|
+
|
|
3087
|
+
if (props.onChange && typeof props.onChange !== 'function') {
|
|
3088
|
+
throw new Error("DynamicSearchInput: Expected onChange to be a function. Received type ".concat(_typeof(props.onChange)));
|
|
3089
|
+
}
|
|
3090
|
+
|
|
3091
|
+
if (!props.search && props.items === undefined) {
|
|
3092
|
+
throw new Error('DynamicSearchInput: Expected one of either items or search function but found neither');
|
|
3093
|
+
}
|
|
3094
|
+
|
|
3095
|
+
if (props.search && props.items !== undefined) {
|
|
3096
|
+
throw new Error('DynamicSearchInput: Expected one of either items or search function but found both');
|
|
3097
|
+
}
|
|
3098
|
+
|
|
3099
|
+
if (props.items !== undefined) {
|
|
3100
|
+
if (!Array.isArray(props.items)) {
|
|
3101
|
+
throw new Error('DynamicSearchInput: expected items property to be an Array');
|
|
3102
|
+
}
|
|
3103
|
+
|
|
3104
|
+
props.items.forEach(function (item) {
|
|
3105
|
+
if (item.props.label === undefined) {
|
|
3106
|
+
throw new Error('DynamicSearchInput: expected items in items property to have "label" property');
|
|
3107
|
+
}
|
|
3108
|
+
});
|
|
3109
|
+
}
|
|
3110
|
+
}, []);
|
|
3111
|
+
|
|
3112
|
+
var handleChange = function handleChange(value, event) {
|
|
3113
|
+
if (typeof props.onChange === 'function') {
|
|
3114
|
+
props.onChange(value, event);
|
|
3115
|
+
}
|
|
3116
|
+
};
|
|
3117
|
+
|
|
3118
|
+
var handleSearchItemSelected = function handleSearchItemSelected(value) {
|
|
3119
|
+
setInputValue(value);
|
|
3120
|
+
handleChange(value);
|
|
3121
|
+
setIsDropdownOpen(false);
|
|
3122
|
+
};
|
|
3123
|
+
|
|
3124
|
+
var onPopoverClose = function onPopoverClose() {
|
|
3125
|
+
setIsDropdownOpen(false);
|
|
3126
|
+
};
|
|
3127
|
+
|
|
3128
|
+
var defaultSearch = function () {
|
|
3129
|
+
var _ref = _asyncToGenerator(_regeneratorRuntime().mark(function _callee(value) {
|
|
3130
|
+
var results;
|
|
3131
|
+
return _regeneratorRuntime().wrap(function _callee$(_context) {
|
|
3132
|
+
while (1) {
|
|
3133
|
+
switch (_context.prev = _context.next) {
|
|
3134
|
+
case 0:
|
|
3135
|
+
value = ((value || '') + '').trim().toLowerCase();
|
|
3136
|
+
|
|
3137
|
+
if (!(value === '')) {
|
|
3138
|
+
_context.next = 3;
|
|
3139
|
+
break;
|
|
3140
|
+
}
|
|
3141
|
+
|
|
3142
|
+
return _context.abrupt("return", []);
|
|
3143
|
+
|
|
3144
|
+
case 3:
|
|
3145
|
+
results = props.items.filter(function (item) {
|
|
3146
|
+
return item.props.label.toLowerCase().includes(value);
|
|
3147
|
+
});
|
|
3148
|
+
return _context.abrupt("return", results);
|
|
3149
|
+
|
|
3150
|
+
case 5:
|
|
3151
|
+
case "end":
|
|
3152
|
+
return _context.stop();
|
|
3153
|
+
}
|
|
3154
|
+
}
|
|
3155
|
+
}, _callee);
|
|
3156
|
+
}));
|
|
3157
|
+
|
|
3158
|
+
return function defaultSearch(_x) {
|
|
3159
|
+
return _ref.apply(this, arguments);
|
|
3160
|
+
};
|
|
3161
|
+
}();
|
|
3162
|
+
|
|
3163
|
+
var handleInputChange = function () {
|
|
3164
|
+
var _ref2 = _asyncToGenerator(_regeneratorRuntime().mark(function _callee2(event) {
|
|
3165
|
+
var inputVal, searchFunc, results, resultsType, nextSearchResults;
|
|
3166
|
+
return _regeneratorRuntime().wrap(function _callee2$(_context2) {
|
|
3167
|
+
while (1) {
|
|
3168
|
+
switch (_context2.prev = _context2.next) {
|
|
3169
|
+
case 0:
|
|
3170
|
+
event.persist();
|
|
3171
|
+
inputVal = _get(event, 'target.value', '');
|
|
3172
|
+
searchFunc = props.search ? props.search : defaultSearch;
|
|
3173
|
+
_context2.next = 5;
|
|
3174
|
+
return searchFunc(inputVal);
|
|
3175
|
+
|
|
3176
|
+
case 5:
|
|
3177
|
+
results = _context2.sent;
|
|
3178
|
+
|
|
3179
|
+
if (Array.isArray(results)) {
|
|
3180
|
+
_context2.next = 9;
|
|
3181
|
+
break;
|
|
3182
|
+
}
|
|
3183
|
+
|
|
3184
|
+
resultsType = typeof results === 'undefined' && 'undefined' || results === null && 'null' || results.constructor && results.constructor.name || results;
|
|
3185
|
+
throw new Error("DynamicSearchInput: expected result from search function to be Array, but was ".concat(resultsType));
|
|
3186
|
+
|
|
3187
|
+
case 9:
|
|
3188
|
+
nextSearchResults = results.map(function (result) {
|
|
3189
|
+
if (_get(result, 'props.label') === undefined) {
|
|
3190
|
+
throw new Error('DynamicSearchInput: expected search result array values to have label property but found none');
|
|
3191
|
+
}
|
|
3192
|
+
|
|
3193
|
+
return React.createElement(SearchItem, {
|
|
3194
|
+
key: result.props.id,
|
|
3195
|
+
onClick: function onClick() {
|
|
3196
|
+
handleSearchItemSelected(result.props.label);
|
|
3197
|
+
}
|
|
3198
|
+
}, result);
|
|
3199
|
+
});
|
|
3200
|
+
setInputValue(inputVal);
|
|
3201
|
+
|
|
3202
|
+
if (nextSearchResults.length > 0) {
|
|
3203
|
+
setIsDropdownOpen(true);
|
|
3204
|
+
} else {
|
|
3205
|
+
setIsDropdownOpen(false);
|
|
3206
|
+
}
|
|
3207
|
+
|
|
3208
|
+
setSearchResults(nextSearchResults);
|
|
3209
|
+
handleChange(inputVal, event);
|
|
3210
|
+
|
|
3211
|
+
case 14:
|
|
3212
|
+
case "end":
|
|
3213
|
+
return _context2.stop();
|
|
3214
|
+
}
|
|
3215
|
+
}
|
|
3216
|
+
}, _callee2);
|
|
3217
|
+
}));
|
|
3218
|
+
|
|
3219
|
+
return function handleInputChange(_x2) {
|
|
3220
|
+
return _ref2.apply(this, arguments);
|
|
3221
|
+
};
|
|
3222
|
+
}();
|
|
3223
|
+
|
|
3224
|
+
return React.createElement("div", {
|
|
3225
|
+
className: "dynamic-search-input"
|
|
3226
|
+
}, React.createElement(Popover, {
|
|
3227
|
+
show: isDropdownOpen,
|
|
3228
|
+
onClose: onPopoverClose,
|
|
3229
|
+
anchor: React.createElement(Input, {
|
|
3230
|
+
className: "search-input",
|
|
3231
|
+
full: true,
|
|
3232
|
+
small: true,
|
|
3233
|
+
placeholder: props.placeholder,
|
|
3234
|
+
value: inputValue,
|
|
3235
|
+
onChange: handleInputChange
|
|
3236
|
+
})
|
|
3237
|
+
}, searchResults));
|
|
3238
|
+
}
|
|
3239
|
+
|
|
3240
|
+
function SearchItem(props) {
|
|
3241
|
+
return React.createElement("div", {
|
|
3242
|
+
className: "dynamic-search-popover-child",
|
|
3243
|
+
onClick: props.onClick
|
|
3244
|
+
}, props.children);
|
|
3245
|
+
}
|
|
3246
|
+
|
|
3247
|
+
var css_248z$5 = ".capture-event .capture-event-controls {\n display: flex;\n align-items: center;\n gap: 8px;\n margin-bottom: 20px; }\n .capture-event .capture-event-controls .status-message {\n font-size: 12px;\n line-height: 16px;\n display: flex;\n align-items: center;\n gap: 4px; }\n .capture-event .capture-event-controls .status-message.pending {\n color: #74777a; }\n .capture-event .capture-event-controls .status-message.success {\n color: #107e3e;\n fill: #107e3e; }\n .capture-event .capture-event-controls .status-message.failure {\n color: #bb0000;\n fill: #bb0000; }\n";
|
|
3248
|
+
styleInject(css_248z$5);
|
|
3249
|
+
|
|
3250
|
+
function CaptureEvent(props) {
|
|
3251
|
+
return (React.createElement("div", { className: "capture-event" },
|
|
3252
|
+
React.createElement("div", { className: "capture-event-controls" },
|
|
3253
|
+
getCaptureEventButton(),
|
|
3254
|
+
getStatusMessage()),
|
|
3255
|
+
props.payload !== undefined && (React.createElement(FormField, { isReadOnly: true },
|
|
3256
|
+
React.createElement(InputField, { "aria-readonly": true, label: props.payloadLabelTranslation, multiline: true, readOnly: true, full: true, value: props.payload, className: "polled-response-output" })))));
|
|
3257
|
+
function getCaptureEventButton() {
|
|
3258
|
+
if (props.status === 'pending') {
|
|
3259
|
+
return (React.createElement("div", { className: "capture-event-button-container" },
|
|
3260
|
+
React.createElement(Button, { kind: "secondary", onClick: function () { return props.onCancel(); } }, props.cancelCaptureTranslation)));
|
|
3261
|
+
}
|
|
3262
|
+
else {
|
|
3263
|
+
return (React.createElement("div", { className: "capture-event-button-container" },
|
|
3264
|
+
React.createElement(Button, { kind: "primary", onClick: function () { return props.onStart(); } }, props.startCaptureTranslation)));
|
|
3265
|
+
}
|
|
3266
|
+
}
|
|
3267
|
+
function getStatusMessage() {
|
|
3268
|
+
var statusMessages = {
|
|
3269
|
+
default: ['', undefined],
|
|
3270
|
+
pending: [props.pendingStatusTranslation, React.createElement(LoadingSpinner, { size: "small", show: true })],
|
|
3271
|
+
success: [props.successStatusTranslation, React.createElement(SuccessIcon, { size: "small" })],
|
|
3272
|
+
failure: [props.failureStatusTranslation, React.createElement(ErrorIcon, { size: "small" })]
|
|
3273
|
+
};
|
|
3274
|
+
var _a = statusMessages[props.status], statusLabel = _a[0], statusIcon = _a[1];
|
|
3275
|
+
return (React.createElement("div", { className: "status-message ".concat(props.status) },
|
|
3276
|
+
statusIcon,
|
|
3277
|
+
statusLabel));
|
|
3278
|
+
}
|
|
3279
|
+
}
|
|
3280
|
+
|
|
3281
|
+
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";
|
|
3282
|
+
styleInject(css_248z$4);
|
|
3283
|
+
|
|
3284
|
+
var COPY_BUTTON_SELECTED_TEXT_TIME = 1.5 * 1000; // seconds * milliseconds
|
|
3285
|
+
function CopyText(props) {
|
|
3286
|
+
var _a = useState(false), copyButtonSelected = _a[0], setCopyButtonSelected = _a[1];
|
|
3287
|
+
return (React.createElement("div", { className: "copy-text" },
|
|
3288
|
+
React.createElement("div", { className: "input-container" },
|
|
3289
|
+
React.createElement(Input, { className: "input-textbox", defaultValue: props.text, "aria-readonly": true, readOnly: true })),
|
|
3290
|
+
React.createElement("div", { className: "copy-button-container" },
|
|
3291
|
+
React.createElement(Button, { kind: "secondary", disabled: copyButtonSelected, onClick: copyTextToClipboard }, getCopyButtonContent()))));
|
|
3292
|
+
function copyTextToClipboard() {
|
|
3293
|
+
try {
|
|
3294
|
+
navigator.clipboard.writeText(props.text);
|
|
3295
|
+
setCopyButtonSelected(true);
|
|
3296
|
+
setTimeout(function () { return setCopyButtonSelected(false); }, COPY_BUTTON_SELECTED_TEXT_TIME);
|
|
3297
|
+
}
|
|
3298
|
+
catch (err) {
|
|
3299
|
+
console.error('Failed to copy text');
|
|
3300
|
+
console.error(err);
|
|
3301
|
+
}
|
|
3302
|
+
}
|
|
3303
|
+
function getCopyButtonContent() {
|
|
3304
|
+
if (copyButtonSelected) {
|
|
3305
|
+
return (React.createElement("div", { className: "selected-button" },
|
|
3306
|
+
React.createElement("div", { className: "selected-button-icon" },
|
|
3307
|
+
React.createElement(CheckIcon, null)),
|
|
3308
|
+
React.createElement("div", { className: "selected-button-text" }, props.copySelectedTranslation)));
|
|
3309
|
+
}
|
|
3310
|
+
else {
|
|
3311
|
+
return (React.createElement("div", { className: "default-button" }, props.copyTranslation));
|
|
3312
|
+
}
|
|
3313
|
+
}
|
|
3314
|
+
}
|
|
3315
|
+
|
|
3316
|
+
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";
|
|
3317
|
+
styleInject(css_248z$3);
|
|
3318
|
+
|
|
3319
|
+
function isString(val) {
|
|
3320
|
+
return (typeof val) === 'string';
|
|
3321
|
+
}
|
|
3322
|
+
|
|
3323
|
+
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";
|
|
3324
|
+
styleInject(css_248z$2);
|
|
3325
|
+
|
|
3326
|
+
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";
|
|
3327
|
+
styleInject(css_248z$1);
|
|
3328
|
+
|
|
3329
|
+
var FieldMapperKey = React.forwardRef(function FieldMapperKey(props, ref) {
|
|
3330
|
+
var _a, _b, _c, _d, _e;
|
|
3331
|
+
var availableFields;
|
|
3332
|
+
var onFieldKeyChange;
|
|
3333
|
+
availableFields = Array.isArray(props.availableFields)
|
|
3334
|
+
? props.availableFields
|
|
3335
|
+
: [];
|
|
3336
|
+
onFieldKeyChange = (typeof props.onChange === 'function')
|
|
3337
|
+
? props.onChange
|
|
3338
|
+
: function () { return undefined; };
|
|
3339
|
+
return (React.createElement("div", { className: "field-mapper-key" + (props.className ? ' ' + props.className : ''), ref: ref }, (React.Children.count(props.children) > 0)
|
|
3340
|
+
? props.children
|
|
3341
|
+
: (React.createElement("div", { className: "field-mapper-key-dropdown" }, fieldMapperKeyDropdownDisabled()
|
|
3342
|
+
? (React.createElement(Button, { disabled: true }, (_a = props.selectedField) === null || _a === void 0 ? void 0 : _a.label))
|
|
3343
|
+
: (((_b = props.selectedField) === null || _b === void 0 ? void 0 : _b.required) === true)
|
|
3344
|
+
? (React.createElement("div", { className: "required-field-container" },
|
|
3345
|
+
React.createElement("div", { className: "required-field-text" }, (_c = props.selectedField) === null || _c === void 0 ? void 0 : _c.label),
|
|
3346
|
+
React.createElement("div", { className: "required-field-symbol" }, "*")))
|
|
3347
|
+
: (React.createElement(Dropdown, { onChange: handleFieldKeyChange },
|
|
3348
|
+
React.createElement(DropdownButton, { label: (_d = props.selectedField) === null || _d === void 0 ? void 0 : _d.label }),
|
|
3349
|
+
React.createElement(DropdownList, null, (_e = props.availableFields) === null || _e === void 0 ? void 0 : _e.map(function (fieldItem) {
|
|
3350
|
+
return (React.createElement(DropdownOption, { key: fieldItem.key, label: fieldItem.label, value: fieldItem.value }));
|
|
3351
|
+
}))))))));
|
|
3352
|
+
function handleFieldKeyChange(value) {
|
|
3353
|
+
var foundSelectedFieldKey;
|
|
3354
|
+
foundSelectedFieldKey = availableFields.find(function (availableField) {
|
|
3355
|
+
return availableField.value === value;
|
|
3356
|
+
});
|
|
3357
|
+
if (foundSelectedFieldKey === undefined) {
|
|
3358
|
+
return;
|
|
3359
|
+
}
|
|
3360
|
+
onFieldKeyChange(props.selectedField, foundSelectedFieldKey);
|
|
3361
|
+
}
|
|
3362
|
+
function fieldMapperKeyDropdownDisabled() {
|
|
3363
|
+
var hasAvailableFields;
|
|
3364
|
+
hasAvailableFields = (availableFields === null || availableFields === void 0 ? void 0 : availableFields.length) > 0;
|
|
3365
|
+
return !hasAvailableFields;
|
|
3366
|
+
}
|
|
3367
|
+
});
|
|
3368
|
+
|
|
3369
|
+
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";
|
|
3370
|
+
styleInject(css_248z);
|
|
3371
|
+
|
|
3372
|
+
var FieldMapperValue = React.forwardRef(function FieldMapperValue(props, ref) {
|
|
3373
|
+
var _a, _b;
|
|
3374
|
+
return (React.createElement("div", { className: "field-mapper-value" + (props.className ? ' ' + props.className : ''), ref: ref }, (React.Children.count(props.children) > 0)
|
|
3375
|
+
? props.children
|
|
3376
|
+
: (React.createElement("div", { className: "piped-text-input-value-container" },
|
|
3377
|
+
React.createElement(PipedTextInput, { items: (_a = props.pipedTextItems) !== null && _a !== void 0 ? _a : [], onChange: (_b = props.onChange) !== null && _b !== void 0 ? _b : (function () { return undefined; }) })))));
|
|
3378
|
+
});
|
|
3379
|
+
|
|
3380
|
+
var FieldMapperRow = React.forwardRef(function FieldMapperRow(props, ref) {
|
|
3381
|
+
return (React.createElement("div", { className: "field-mapper-row" + (props.className ? ' ' + props.className : ''), ref: ref },
|
|
3382
|
+
React.createElement("div", { className: "field-mapper-row-content" },
|
|
3383
|
+
React.Children.map(props.children, function (child) {
|
|
3384
|
+
return getWrappedKeyValue(child);
|
|
3385
|
+
}),
|
|
3386
|
+
React.createElement("div", { className: 'remove-row-container' + ((props.showRemove === false) ? ' hide-remove-button' : '') }, (props.showRemove === false)
|
|
3387
|
+
? (React.createElement("div", { className: "empty-remove-button" }))
|
|
3388
|
+
: (React.createElement(IconButton
|
|
3389
|
+
/*
|
|
3390
|
+
TODO: Require an i18n string to be passed in for a11y labels
|
|
3391
|
+
*/
|
|
3392
|
+
, { "aria-label": "Remove", onClick: function ($e) { return handleRemoveClick(); } },
|
|
3393
|
+
React.createElement(RemoveItemIcon, null)))))));
|
|
3394
|
+
function handleRemoveClick(evt) {
|
|
3395
|
+
var _a;
|
|
3396
|
+
(_a = props.onFieldRemove) === null || _a === void 0 ? void 0 : _a.call(props, props.selectedField);
|
|
3397
|
+
}
|
|
3398
|
+
function getWrappedKeyValue(child) {
|
|
3399
|
+
var _a, _b, _c, _d;
|
|
3400
|
+
var wrappedEl;
|
|
3401
|
+
var fieldMapperKeyProps, fieldMapperValueProps;
|
|
3402
|
+
var includeAvailableFields, includeSelectedField, includeOnFieldKeyChange;
|
|
3403
|
+
var includePipedTextItems, includeOnFieldValueChange;
|
|
3404
|
+
fieldMapperKeyProps = {};
|
|
3405
|
+
fieldMapperValueProps = {};
|
|
3406
|
+
switch (child.type) {
|
|
3407
|
+
case FieldMapperKey:
|
|
3408
|
+
includeAvailableFields = (!Array.isArray(child.props.availableFields)
|
|
3409
|
+
&& (((_a = props.availableFields) === null || _a === void 0 ? void 0 : _a.length) > 0));
|
|
3410
|
+
includeSelectedField = (((typeof child.props.selectedField) !== 'object')
|
|
3411
|
+
&& (props.selectedField !== undefined));
|
|
3412
|
+
includeOnFieldKeyChange = (((typeof child.props.onChange) !== 'function')
|
|
3413
|
+
&& ((typeof props.onFieldKeyChange) === 'function'));
|
|
3414
|
+
if (includeAvailableFields) {
|
|
3415
|
+
fieldMapperKeyProps.availableFields = (_c = (_b = props.availableFields) === null || _b === void 0 ? void 0 : _b.slice()) !== null && _c !== void 0 ? _c : [];
|
|
3416
|
+
}
|
|
3417
|
+
if (includeSelectedField) {
|
|
3418
|
+
fieldMapperKeyProps.selectedField = Object.assign({}, props.selectedField);
|
|
3419
|
+
}
|
|
3420
|
+
if (includeOnFieldKeyChange) {
|
|
3421
|
+
fieldMapperKeyProps.onChange = function (prevField, fieldItem) {
|
|
3422
|
+
props.onFieldKeyChange(prevField, fieldItem);
|
|
3423
|
+
};
|
|
3424
|
+
}
|
|
3425
|
+
if (React.isValidElement(child)
|
|
3426
|
+
&& (includeAvailableFields
|
|
3427
|
+
|| includeSelectedField)) {
|
|
3428
|
+
child = React.cloneElement(child, fieldMapperKeyProps);
|
|
3429
|
+
}
|
|
3430
|
+
wrappedEl = (React.createElement("div", { className: "field-mapper-key-container" }, child));
|
|
3431
|
+
break;
|
|
3432
|
+
case FieldMapperValue:
|
|
3433
|
+
includePipedTextItems = (!Array.isArray(child.props.pipedTextItems)
|
|
3434
|
+
&& (((_d = props.pipedTextItems) === null || _d === void 0 ? void 0 : _d.length) > 0));
|
|
3435
|
+
includeOnFieldValueChange = (((typeof child.props.onChange) !== 'function')
|
|
3436
|
+
&& ((typeof props.onFieldValueChange) === 'function'));
|
|
3437
|
+
if (includePipedTextItems) {
|
|
3438
|
+
fieldMapperValueProps.pipedTextItems = props.pipedTextItems;
|
|
3439
|
+
}
|
|
3440
|
+
if (includeOnFieldValueChange) {
|
|
3441
|
+
fieldMapperValueProps.onChange = function (value) {
|
|
3442
|
+
props.onFieldValueChange(props.selectedField, value);
|
|
3443
|
+
};
|
|
3444
|
+
}
|
|
3445
|
+
if (React.isValidElement(child)
|
|
3446
|
+
&& includePipedTextItems) {
|
|
3447
|
+
child = React.cloneElement(child, fieldMapperValueProps);
|
|
3448
|
+
}
|
|
3449
|
+
wrappedEl = (React.createElement("div", { className: "field-mapper-value-container" }, child));
|
|
3450
|
+
break;
|
|
3451
|
+
default:
|
|
3452
|
+
wrappedEl = child;
|
|
3453
|
+
}
|
|
3454
|
+
return wrappedEl;
|
|
3455
|
+
}
|
|
3456
|
+
});
|
|
3457
|
+
|
|
3458
|
+
var MISSING_TRANSLATION_WARNING = '{{MISSING_I18N_STRING}}';
|
|
3459
|
+
var FieldMapper = React.forwardRef(function FieldMapper(props, ref) {
|
|
3460
|
+
var _a, _b, _c, _d, _e, _f;
|
|
3461
|
+
return (React.createElement("div", { className: 'field-mapper ' + ((_a = props.className) !== null && _a !== void 0 ? _a : ''), ref: ref },
|
|
3462
|
+
hasHeaderRow() && (React.createElement("div", { className: "field-mapper-row-container field-mapper-header-row" },
|
|
3463
|
+
React.createElement(FieldMapperRow, { showRemove: false },
|
|
3464
|
+
React.createElement(FieldMapperKey, null,
|
|
3465
|
+
React.createElement("div", { className: "field-mapper-header-cell field-mapper-key-header" }, (_b = props.fieldKeysHeaderText) !== null && _b !== void 0 ? _b : '')),
|
|
3466
|
+
React.createElement(FieldMapperValue, null,
|
|
3467
|
+
React.createElement("div", { className: "field-mapper-header-cell field-mapper-value-header" }, (_c = props.fieldValuesHeaderText) !== null && _c !== void 0 ? _c : ''))))),
|
|
3468
|
+
React.createElement("div", { className: "field-mapper-row-container" }, React.Children.map(props.children, function (child) {
|
|
3469
|
+
return getWrappedFieldRow(child);
|
|
3470
|
+
})),
|
|
3471
|
+
React.createElement("div", { className: "add-field-button-container" }, isAddFieldDisabled()
|
|
3472
|
+
? (React.createElement(Button, { disabled: true, kind: "secondary", className: "add-field-button" },
|
|
3473
|
+
React.createElement("div", { className: "add-field-icon" },
|
|
3474
|
+
React.createElement(AddIcon, null)),
|
|
3475
|
+
React.createElement("div", { className: "add-field-button-label" }, (_d = props.addFieldLabel) !== null && _d !== void 0 ? _d : MISSING_TRANSLATION_WARNING)))
|
|
3476
|
+
: (React.createElement(Dropdown, null,
|
|
3477
|
+
React.createElement(DropdownButton, null,
|
|
3478
|
+
React.createElement(Button, { className: "add-field-button", kind: "secondary" },
|
|
3479
|
+
React.createElement("div", { className: "add-field-icon" },
|
|
3480
|
+
React.createElement(AddIcon, null)),
|
|
3481
|
+
React.createElement("div", { className: "add-field-button-label" }, (_e = props.addFieldLabel) !== null && _e !== void 0 ? _e : MISSING_TRANSLATION_WARNING))),
|
|
3482
|
+
React.createElement(DropdownList, null, (_f = props.availableFields) === null || _f === void 0 ? void 0 : _f.map(function (fieldItem) {
|
|
3483
|
+
return (React.createElement(DropdownOption, { key: fieldItem.key, value: fieldItem.value, label: fieldItem.label, onSelect: function ($e) {
|
|
3484
|
+
handleDropdownSelect(fieldItem.value);
|
|
3485
|
+
} }));
|
|
3486
|
+
})))))));
|
|
3487
|
+
function hasHeaderRow() {
|
|
3488
|
+
return (isString(props.fieldKeysHeaderText)
|
|
3489
|
+
|| isString(props.fieldValuesHeaderText));
|
|
3490
|
+
}
|
|
3491
|
+
function getWrappedFieldRow(child) {
|
|
3492
|
+
var _a, _b, _c;
|
|
3493
|
+
var wrappedEl;
|
|
3494
|
+
var fieldMapperRowProps;
|
|
3495
|
+
var includeAvailableFields, includeOnFieldRemove, includePipedTextItems, includeOnFieldKeyChange, includeOnFieldValueChange, includeShowRemove;
|
|
3496
|
+
fieldMapperRowProps = {};
|
|
3497
|
+
switch (child.type) {
|
|
3498
|
+
case FieldMapperRow:
|
|
3499
|
+
wrappedEl = child;
|
|
3500
|
+
break;
|
|
3501
|
+
default:
|
|
3502
|
+
wrappedEl = (React.createElement(FieldMapperRow, null, child));
|
|
3503
|
+
}
|
|
3504
|
+
includeAvailableFields = (!Array.isArray(wrappedEl.props.availableFields)
|
|
3505
|
+
&& (((_a = props.availableFields) === null || _a === void 0 ? void 0 : _a.length) > 0));
|
|
3506
|
+
includeOnFieldRemove = (((typeof wrappedEl.props.onFieldRemove) !== 'function')
|
|
3507
|
+
&& ((typeof props.onFieldRemove) === 'function'));
|
|
3508
|
+
includePipedTextItems = (!Array.isArray(wrappedEl.props.pipedTextItems)
|
|
3509
|
+
&& (((_b = props.pipedTextItems) === null || _b === void 0 ? void 0 : _b.length) > 0));
|
|
3510
|
+
includeOnFieldKeyChange = (((typeof wrappedEl.props.onFieldKeyChange) !== 'function')
|
|
3511
|
+
&& (typeof props.onFieldKeyChange === 'function'));
|
|
3512
|
+
includeOnFieldValueChange = (((typeof wrappedEl.props.onFieldValueChange) !== 'function')
|
|
3513
|
+
&& (typeof props.onFieldValueChange === 'function'));
|
|
3514
|
+
includeShowRemove = (((typeof wrappedEl.props.showRemove !== 'boolean'))
|
|
3515
|
+
&& ((typeof ((_c = child.props.selectedField) === null || _c === void 0 ? void 0 : _c.required)) === 'boolean'));
|
|
3516
|
+
if (includeAvailableFields) {
|
|
3517
|
+
fieldMapperRowProps.availableFields = props.availableFields.slice();
|
|
3518
|
+
}
|
|
3519
|
+
if (includeOnFieldRemove) {
|
|
3520
|
+
fieldMapperRowProps.onFieldRemove = function (fieldItem) {
|
|
3521
|
+
return props.onFieldRemove(fieldItem);
|
|
3522
|
+
};
|
|
3523
|
+
}
|
|
3524
|
+
if (includePipedTextItems) {
|
|
3525
|
+
fieldMapperRowProps.pipedTextItems = props.pipedTextItems;
|
|
3526
|
+
}
|
|
3527
|
+
if (includeOnFieldKeyChange) {
|
|
3528
|
+
fieldMapperRowProps.onFieldKeyChange = function (prevField, fieldItem) {
|
|
3529
|
+
return props.onFieldKeyChange(prevField, fieldItem);
|
|
3530
|
+
};
|
|
3531
|
+
}
|
|
3532
|
+
if (includeOnFieldValueChange) {
|
|
3533
|
+
fieldMapperRowProps.onFieldValueChange = function (fieldItem, inputValue) {
|
|
3534
|
+
return props.onFieldValueChange(fieldItem, inputValue);
|
|
3535
|
+
};
|
|
3536
|
+
}
|
|
3537
|
+
if (includeShowRemove) {
|
|
3538
|
+
fieldMapperRowProps.showRemove = !child.props.selectedField.required;
|
|
3539
|
+
}
|
|
3540
|
+
wrappedEl = React.cloneElement(wrappedEl, fieldMapperRowProps);
|
|
3541
|
+
return wrappedEl;
|
|
3542
|
+
}
|
|
3543
|
+
function handleDropdownSelect(value) {
|
|
3544
|
+
var foundFieldMapperItem;
|
|
3545
|
+
foundFieldMapperItem = props.availableFields.find(function (availableField) {
|
|
3546
|
+
return availableField.value === value;
|
|
3547
|
+
});
|
|
3548
|
+
if (foundFieldMapperItem) {
|
|
3549
|
+
props.onFieldAdd(foundFieldMapperItem);
|
|
3550
|
+
}
|
|
3551
|
+
}
|
|
3552
|
+
function isAddFieldDisabled() {
|
|
3553
|
+
var hasAvailableFields;
|
|
3554
|
+
hasAvailableFields = ((Array.isArray(props.availableFields))
|
|
3555
|
+
&& (props.availableFields.length > 0));
|
|
3556
|
+
return !hasAvailableFields;
|
|
3557
|
+
}
|
|
3558
|
+
});
|
|
3559
|
+
|
|
3560
|
+
export { CaptureEvent, CopyText, DynamicSearchInput, FieldItem, FieldMapper, FieldMapperKey, FieldMapperRow, FieldMapperValue, MultiselectDropdown, PipedTextInput, PipedTextSelect, PluginSdkService, Popover, SelectItem, TaskFields, languageCodeAdapter };
|