@qualtrics/plugin-ui-react 1.2.4 → 1.3.3-alpha.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +96 -12
- package/dist/common/popover/popover.d.ts +1 -1
- package/dist/main.es.js +237 -94
- package/dist/main.js +366 -222
- package/package.json +7 -6
package/dist/main.es.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
/*! @license @qualtrics/plugin-ui-react 1.
|
|
1
|
+
/*! @license @qualtrics/plugin-ui-react 1.3.3-alpha.1
|
|
2
2
|
Qualtrics Software License Agreement
|
|
3
3
|
|
|
4
4
|
1. General.
|
|
@@ -55,17 +55,17 @@ import 'core-js/modules/es.array.find-index.js';
|
|
|
55
55
|
import 'core-js/modules/es.array.splice.js';
|
|
56
56
|
import 'core-js/modules/es.array.for-each.js';
|
|
57
57
|
import 'core-js/modules/web.dom-collections.for-each.js';
|
|
58
|
-
import React, { Component, useState, useEffect, useRef } from 'react';
|
|
58
|
+
import React, { Component, useState, useEffect, useRef, useCallback } from 'react';
|
|
59
59
|
import _get from 'lodash.get';
|
|
60
60
|
import { Button, InputGroup, Input, Icon, IconTypes, LoadingSpinner, IconButton, Tooltip, SelectMenu, MenuItem, Label } from '@qualtrics/ui-react';
|
|
61
61
|
import { ErrorIcon, PipedTextIcon, RemoveItemIcon } from '@qualtrics/ui-react/icons';
|
|
62
62
|
import 'core-js/modules/es.string.anchor.js';
|
|
63
|
-
import _cloneDeep from 'lodash.clonedeep';
|
|
64
63
|
import 'core-js/modules/es.string.trim.js';
|
|
65
64
|
import 'core-js/modules/es.array.map.js';
|
|
66
65
|
import 'core-js/modules/es.array.concat.js';
|
|
67
66
|
import 'core-js/modules/es.array.filter.js';
|
|
68
67
|
import 'regenerator-runtime/runtime.js';
|
|
68
|
+
import _cloneDeep from 'lodash.clonedeep';
|
|
69
69
|
import 'core-js/modules/es.array.is-array.js';
|
|
70
70
|
import { Manager, Reference, Popper } from 'react-popper';
|
|
71
71
|
import ReactDOM from 'react-dom';
|
|
@@ -76,6 +76,7 @@ import 'core-js/modules/es.array.iterator.js';
|
|
|
76
76
|
import 'core-js/modules/web.dom-collections.iterator.js';
|
|
77
77
|
import 'core-js/modules/es.array.find.js';
|
|
78
78
|
import 'core-js/modules/es.object.assign.js';
|
|
79
|
+
import _cloneDeepWith from 'lodash.clonedeepwith';
|
|
79
80
|
import uuid from 'uuid';
|
|
80
81
|
import 'core-js/modules/es.regexp.exec.js';
|
|
81
82
|
import 'core-js/modules/es.string.search.js';
|
|
@@ -115,14 +116,9 @@ function ownKeys(object, enumerableOnly) {
|
|
|
115
116
|
|
|
116
117
|
if (Object.getOwnPropertySymbols) {
|
|
117
118
|
var symbols = Object.getOwnPropertySymbols(object);
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
return Object.getOwnPropertyDescriptor(object, sym).enumerable;
|
|
122
|
-
});
|
|
123
|
-
}
|
|
124
|
-
|
|
125
|
-
keys.push.apply(keys, symbols);
|
|
119
|
+
enumerableOnly && (symbols = symbols.filter(function (sym) {
|
|
120
|
+
return Object.getOwnPropertyDescriptor(object, sym).enumerable;
|
|
121
|
+
})), keys.push.apply(keys, symbols);
|
|
126
122
|
}
|
|
127
123
|
|
|
128
124
|
return keys;
|
|
@@ -130,19 +126,12 @@ function ownKeys(object, enumerableOnly) {
|
|
|
130
126
|
|
|
131
127
|
function _objectSpread2(target) {
|
|
132
128
|
for (var i = 1; i < arguments.length; i++) {
|
|
133
|
-
var source = arguments[i]
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
} else if (Object.getOwnPropertyDescriptors) {
|
|
140
|
-
Object.defineProperties(target, Object.getOwnPropertyDescriptors(source));
|
|
141
|
-
} else {
|
|
142
|
-
ownKeys(Object(source)).forEach(function (key) {
|
|
143
|
-
Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key));
|
|
144
|
-
});
|
|
145
|
-
}
|
|
129
|
+
var source = null != arguments[i] ? arguments[i] : {};
|
|
130
|
+
i % 2 ? ownKeys(Object(source), !0).forEach(function (key) {
|
|
131
|
+
_defineProperty(target, key, source[key]);
|
|
132
|
+
}) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) {
|
|
133
|
+
Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key));
|
|
134
|
+
});
|
|
146
135
|
}
|
|
147
136
|
|
|
148
137
|
return target;
|
|
@@ -151,17 +140,11 @@ function _objectSpread2(target) {
|
|
|
151
140
|
function _typeof(obj) {
|
|
152
141
|
"@babel/helpers - typeof";
|
|
153
142
|
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
}
|
|
159
|
-
_typeof = function (obj) {
|
|
160
|
-
return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj;
|
|
161
|
-
};
|
|
162
|
-
}
|
|
163
|
-
|
|
164
|
-
return _typeof(obj);
|
|
143
|
+
return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (obj) {
|
|
144
|
+
return typeof obj;
|
|
145
|
+
} : function (obj) {
|
|
146
|
+
return obj && "function" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj;
|
|
147
|
+
}, _typeof(obj);
|
|
165
148
|
}
|
|
166
149
|
|
|
167
150
|
function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) {
|
|
@@ -219,6 +202,9 @@ function _defineProperties(target, props) {
|
|
|
219
202
|
function _createClass(Constructor, protoProps, staticProps) {
|
|
220
203
|
if (protoProps) _defineProperties(Constructor.prototype, protoProps);
|
|
221
204
|
if (staticProps) _defineProperties(Constructor, staticProps);
|
|
205
|
+
Object.defineProperty(Constructor, "prototype", {
|
|
206
|
+
writable: false
|
|
207
|
+
});
|
|
222
208
|
return Constructor;
|
|
223
209
|
}
|
|
224
210
|
|
|
@@ -249,6 +235,9 @@ function _inherits(subClass, superClass) {
|
|
|
249
235
|
configurable: true
|
|
250
236
|
}
|
|
251
237
|
});
|
|
238
|
+
Object.defineProperty(subClass, "prototype", {
|
|
239
|
+
writable: false
|
|
240
|
+
});
|
|
252
241
|
if (superClass) _setPrototypeOf(subClass, superClass);
|
|
253
242
|
}
|
|
254
243
|
|
|
@@ -292,6 +281,8 @@ function _assertThisInitialized(self) {
|
|
|
292
281
|
function _possibleConstructorReturn(self, call) {
|
|
293
282
|
if (call && (typeof call === "object" || typeof call === "function")) {
|
|
294
283
|
return call;
|
|
284
|
+
} else if (call !== void 0) {
|
|
285
|
+
throw new TypeError("Derived constructors may only return object or undefined");
|
|
295
286
|
}
|
|
296
287
|
|
|
297
288
|
return _assertThisInitialized(self);
|
|
@@ -337,7 +328,7 @@ function _iterableToArray(iter) {
|
|
|
337
328
|
}
|
|
338
329
|
|
|
339
330
|
function _iterableToArrayLimit(arr, i) {
|
|
340
|
-
var _i = arr
|
|
331
|
+
var _i = arr == null ? null : typeof Symbol !== "undefined" && arr[Symbol.iterator] || arr["@@iterator"];
|
|
341
332
|
|
|
342
333
|
if (_i == null) return;
|
|
343
334
|
var _arr = [];
|
|
@@ -575,8 +566,8 @@ var languageCodeMapping = {
|
|
|
575
566
|
RU: 'ru',
|
|
576
567
|
SV: 'sv',
|
|
577
568
|
TH: 'th',
|
|
578
|
-
'ZH-S': 'zh-
|
|
579
|
-
'ZH-T': 'zh-
|
|
569
|
+
'ZH-S': 'zh-Hans',
|
|
570
|
+
'ZH-T': 'zh-Hant'
|
|
580
571
|
};
|
|
581
572
|
function languageCodeAdapter(languageCode) {
|
|
582
573
|
var adaptedCode;
|
|
@@ -678,7 +669,7 @@ var DEFAULT_PLACEMENT = 'bottom-start';
|
|
|
678
669
|
var DEFAULT_ANCHOR = React.createElement(Button, null, " anchor ");
|
|
679
670
|
var defaultModifiers = [];
|
|
680
671
|
initGlobalListener();
|
|
681
|
-
function Popover(props
|
|
672
|
+
function Popover(props) {
|
|
682
673
|
var _useState = useState(false),
|
|
683
674
|
_useState2 = _slicedToArray(_useState, 2),
|
|
684
675
|
isOpen = _useState2[0],
|
|
@@ -875,7 +866,7 @@ var css_248z$8 = "div[role=\"menu\"] .piped-text-search-input-container {\n pad
|
|
|
875
866
|
styleInject(css_248z$8);
|
|
876
867
|
|
|
877
868
|
var EMBEDDED_DATA_LOCATOR = 'embeddedData';
|
|
878
|
-
var PipedTextMenu = React.forwardRef(function (props, ref) {
|
|
869
|
+
var PipedTextMenu = React.forwardRef(function PipedTextMenu(props, ref) {
|
|
879
870
|
var defaultMenuItems = undefined;
|
|
880
871
|
|
|
881
872
|
if (typeof props.items !== 'function') {
|
|
@@ -904,8 +895,47 @@ var PipedTextMenu = React.forwardRef(function (props, ref) {
|
|
|
904
895
|
searchValue = _useState8[0],
|
|
905
896
|
setSearchValue = _useState8[1];
|
|
906
897
|
|
|
907
|
-
var
|
|
898
|
+
var _useState9 = useState(undefined),
|
|
899
|
+
_useState10 = _slicedToArray(_useState9, 2),
|
|
900
|
+
isSubmenu = _useState10[0],
|
|
901
|
+
setIsSubmenu = _useState10[1];
|
|
908
902
|
|
|
903
|
+
var onClose = props.onClose || function () {
|
|
904
|
+
return undefined;
|
|
905
|
+
};
|
|
906
|
+
|
|
907
|
+
var _useState11 = useState(null),
|
|
908
|
+
_useState12 = _slicedToArray(_useState11, 2),
|
|
909
|
+
popoverEl = _useState12[0],
|
|
910
|
+
setPopoverEl = _useState12[1];
|
|
911
|
+
|
|
912
|
+
var popoverRefCb = useCallback(function (el) {
|
|
913
|
+
setPopoverEl(el);
|
|
914
|
+
}, []);
|
|
915
|
+
|
|
916
|
+
var _useState13 = useState(null),
|
|
917
|
+
_useState14 = _slicedToArray(_useState13, 2),
|
|
918
|
+
searchBoxEl = _useState14[0],
|
|
919
|
+
setSearchBoxEl = _useState14[1];
|
|
920
|
+
|
|
921
|
+
var searchBoxRefCb = useCallback(function (el) {
|
|
922
|
+
setSearchBoxEl(el);
|
|
923
|
+
}, []);
|
|
924
|
+
useEffect(function () {
|
|
925
|
+
var anchorRefEl = _get(props, 'anchorRef.current');
|
|
926
|
+
|
|
927
|
+
if (anchorRefEl) {
|
|
928
|
+
var anchorRefElRole = anchorRefEl.getAttribute('role');
|
|
929
|
+
var nextIsSubmenu = anchorRefElRole === 'menuitem';
|
|
930
|
+
setIsSubmenu(nextIsSubmenu);
|
|
931
|
+
}
|
|
932
|
+
|
|
933
|
+
if (isSubmenu === true) ; else if (isSubmenu === false) {
|
|
934
|
+
if (popoverEl !== null) {
|
|
935
|
+
popoverEl.focus();
|
|
936
|
+
}
|
|
937
|
+
}
|
|
938
|
+
}, [popoverEl, searchBoxEl, props.anchorRef, isSubmenu]);
|
|
909
939
|
useEffect(function () {
|
|
910
940
|
_asyncToGenerator(regeneratorRuntime.mark(function _callee() {
|
|
911
941
|
var newMenuItems;
|
|
@@ -1000,6 +1030,10 @@ var PipedTextMenu = React.forwardRef(function (props, ref) {
|
|
|
1000
1030
|
setSearchValue(searchVal);
|
|
1001
1031
|
};
|
|
1002
1032
|
|
|
1033
|
+
var handleSearchInputClick = function handleSearchInputClick(evt) {
|
|
1034
|
+
evt.stopPropagation();
|
|
1035
|
+
};
|
|
1036
|
+
|
|
1003
1037
|
var matchesSearch = function matchesSearch(item) {
|
|
1004
1038
|
var searchVal = searchValue || '';
|
|
1005
1039
|
searchVal = searchVal.trim().toLowerCase();
|
|
@@ -1029,11 +1063,12 @@ var PipedTextMenu = React.forwardRef(function (props, ref) {
|
|
|
1029
1063
|
props.onSelected(edMenuItem);
|
|
1030
1064
|
};
|
|
1031
1065
|
|
|
1032
|
-
var
|
|
1066
|
+
var SubmenuItem = function SubmenuItem(props) {
|
|
1067
|
+
var submenuAnchorRef = useRef(null);
|
|
1068
|
+
var menuItem = props.menuItem;
|
|
1033
1069
|
return React.createElement("div", {
|
|
1034
1070
|
"data-testid": "piped-text-submenu",
|
|
1035
|
-
className: "piped-text-submenu-item-container"
|
|
1036
|
-
key: menuItem.key
|
|
1071
|
+
className: "piped-text-submenu-item-container"
|
|
1037
1072
|
}, menuItem.show && React.createElement(PipedTextMenu, {
|
|
1038
1073
|
items: menuItem.submenu.items,
|
|
1039
1074
|
show: menuItem.show,
|
|
@@ -1052,12 +1087,16 @@ var PipedTextMenu = React.forwardRef(function (props, ref) {
|
|
|
1052
1087
|
ref: ref,
|
|
1053
1088
|
className: "piped-text-submenu-anchor"
|
|
1054
1089
|
});
|
|
1055
|
-
}
|
|
1090
|
+
},
|
|
1091
|
+
anchorRef: submenuAnchorRef
|
|
1056
1092
|
}), React.createElement("div", {
|
|
1057
1093
|
className: "piped-text-submenu-item",
|
|
1094
|
+
"aria-haspopup": "menu",
|
|
1095
|
+
role: "menuitem",
|
|
1058
1096
|
onMouseEnter: function onMouseEnter($e) {
|
|
1059
1097
|
return submenuHovered(menuItem);
|
|
1060
|
-
}
|
|
1098
|
+
},
|
|
1099
|
+
ref: submenuAnchorRef
|
|
1061
1100
|
}, React.createElement("div", {
|
|
1062
1101
|
className: "label-text"
|
|
1063
1102
|
}, menuItem.label), React.createElement("div", {
|
|
@@ -1079,7 +1118,10 @@ var PipedTextMenu = React.forwardRef(function (props, ref) {
|
|
|
1079
1118
|
var menuItemHeaderClass, menuItemDisabledClass, menuItemClassName;
|
|
1080
1119
|
|
|
1081
1120
|
if (menuItem.hasSubmenu) {
|
|
1082
|
-
return
|
|
1121
|
+
return React.createElement(SubmenuItem, {
|
|
1122
|
+
key: menuItem.key,
|
|
1123
|
+
menuItem: menuItem
|
|
1124
|
+
});
|
|
1083
1125
|
} else if (menuItem.header === true || menuItem.disabled === true) {
|
|
1084
1126
|
menuItemHeaderClass = menuItem.header === true ? 'piped-text-header' : '';
|
|
1085
1127
|
menuItemDisabledClass = menuItem.disabled === true ? 'piped-text-disabled' : '';
|
|
@@ -1177,7 +1219,7 @@ var PipedTextMenu = React.forwardRef(function (props, ref) {
|
|
|
1177
1219
|
} else {
|
|
1178
1220
|
var itemsToRender = (menuItems || []).filter(matchesSearch);
|
|
1179
1221
|
return React.createElement("div", {
|
|
1180
|
-
className: "piped-text-popover-
|
|
1222
|
+
className: "piped-text-popover-menu"
|
|
1181
1223
|
}, React.createElement("div", {
|
|
1182
1224
|
className: "piped-text-search-input"
|
|
1183
1225
|
}, React.createElement("form", {
|
|
@@ -1190,7 +1232,11 @@ var PipedTextMenu = React.forwardRef(function (props, ref) {
|
|
|
1190
1232
|
value: searchValue,
|
|
1191
1233
|
onChange: function onChange($e) {
|
|
1192
1234
|
return onSearchInputChange($e);
|
|
1193
|
-
}
|
|
1235
|
+
},
|
|
1236
|
+
onClick: function onClick($e) {
|
|
1237
|
+
return handleSearchInputClick($e);
|
|
1238
|
+
},
|
|
1239
|
+
ref: searchBoxRefCb
|
|
1194
1240
|
}))), menuItems === undefined ? getLoadingSpinner() : getPipedTextMenuItems(itemsToRender));
|
|
1195
1241
|
}
|
|
1196
1242
|
};
|
|
@@ -1204,10 +1250,23 @@ var PipedTextMenu = React.forwardRef(function (props, ref) {
|
|
|
1204
1250
|
anchor: props.anchor,
|
|
1205
1251
|
ignoreClickSelector: props.ignoreClickSelector
|
|
1206
1252
|
}, React.createElement("div", {
|
|
1207
|
-
className: "piped-text-popover-container"
|
|
1253
|
+
className: "piped-text-popover-container",
|
|
1254
|
+
ref: popoverRefCb,
|
|
1255
|
+
onFocus: function onFocus($e) {
|
|
1256
|
+
return handleFocus($e);
|
|
1257
|
+
},
|
|
1258
|
+
tabIndex: props.tabIndex !== undefined ? props.tabIndex : -1
|
|
1208
1259
|
}, getMenuContent()), React.createElement(OptionsPlaceholder, {
|
|
1209
1260
|
optionsRef: optionsRef
|
|
1210
1261
|
})));
|
|
1262
|
+
|
|
1263
|
+
function handleFocus(evt) {
|
|
1264
|
+
if (!isSubmenu && searchBoxEl !== null) {
|
|
1265
|
+
searchBoxEl.focus();
|
|
1266
|
+
}
|
|
1267
|
+
|
|
1268
|
+
evt.stopPropagation();
|
|
1269
|
+
}
|
|
1211
1270
|
});
|
|
1212
1271
|
|
|
1213
1272
|
function OptionsPlaceholder() {
|
|
@@ -1268,23 +1327,8 @@ function PipedTextSelect(props) {
|
|
|
1268
1327
|
pipedTextItems = _useState4[0],
|
|
1269
1328
|
setPipedTextItems = _useState4[1];
|
|
1270
1329
|
|
|
1271
|
-
|
|
1272
|
-
|
|
1273
|
-
return pipedTextDataAdapter(props.items);
|
|
1274
|
-
}
|
|
1275
|
-
}
|
|
1276
|
-
|
|
1277
|
-
var onClose = function onClose() {
|
|
1278
|
-
if (props.onClose) {
|
|
1279
|
-
props.onClose();
|
|
1280
|
-
}
|
|
1281
|
-
};
|
|
1282
|
-
|
|
1283
|
-
var onSelect = function onSelect(selected) {
|
|
1284
|
-
props.onSelect(selected);
|
|
1285
|
-
onClose();
|
|
1286
|
-
};
|
|
1287
|
-
|
|
1330
|
+
var defaultAnchorRef = useRef(null);
|
|
1331
|
+
var externalAnchor = props.anchor;
|
|
1288
1332
|
useEffect(function () {
|
|
1289
1333
|
return function () {
|
|
1290
1334
|
return onClose();
|
|
@@ -1299,6 +1343,22 @@ function PipedTextSelect(props) {
|
|
|
1299
1343
|
var formattedPipedText = initializePipedText();
|
|
1300
1344
|
setPipedTextItems(formattedPipedText);
|
|
1301
1345
|
}, [props.items]);
|
|
1346
|
+
|
|
1347
|
+
var onClose = function onClose() {
|
|
1348
|
+
if (props.onClose) {
|
|
1349
|
+
props.onClose();
|
|
1350
|
+
}
|
|
1351
|
+
};
|
|
1352
|
+
|
|
1353
|
+
var onSelect = function onSelect(selected) {
|
|
1354
|
+
props.onSelect(selected);
|
|
1355
|
+
onClose();
|
|
1356
|
+
};
|
|
1357
|
+
|
|
1358
|
+
var actualAnchor = externalAnchor !== undefined ? React.cloneElement(externalAnchor, {
|
|
1359
|
+
ref: externalAnchor.ref
|
|
1360
|
+
}) : defaultAnchor(defaultAnchorRef);
|
|
1361
|
+
var anchorRef = props.anchorRef || actualAnchor.ref;
|
|
1302
1362
|
return React.createElement("div", {
|
|
1303
1363
|
className: "piped-text-dropdown"
|
|
1304
1364
|
}, isMenuOpen && React.createElement(PipedTextMenu, {
|
|
@@ -1306,9 +1366,16 @@ function PipedTextSelect(props) {
|
|
|
1306
1366
|
show: isMenuOpen,
|
|
1307
1367
|
onSelected: onSelect,
|
|
1308
1368
|
items: pipedTextItems,
|
|
1309
|
-
anchor:
|
|
1369
|
+
anchor: actualAnchor,
|
|
1370
|
+
anchorRef: anchorRef,
|
|
1310
1371
|
ignoreClickSelector: props.ignoreClickSelector
|
|
1311
1372
|
}));
|
|
1373
|
+
|
|
1374
|
+
function initializePipedText() {
|
|
1375
|
+
if (props.items) {
|
|
1376
|
+
return pipedTextDataAdapter(props.items);
|
|
1377
|
+
}
|
|
1378
|
+
}
|
|
1312
1379
|
}
|
|
1313
1380
|
|
|
1314
1381
|
var css_248z$6 = ".piped-text-input .piped-text-input-toggle, .piped-text-input .piped-text-select-container {\n display: inline-block; }\n\n.piped-text-input .piped-text-input-toggle {\n display: flex; }\n .piped-text-input .piped-text-input-toggle input {\n flex: 1 1;\n box-sizing: border-box; }\n .piped-text-input .piped-text-input-toggle input:first-child {\n border-right: 0;\n border-top-right-radius: 0;\n border-bottom-right-radius: 0; }\n .piped-text-input .piped-text-input-toggle.multiline-input textarea {\n flex: 1 1;\n box-sizing: border-box; }\n .piped-text-input .piped-text-input-toggle input + button, .piped-text-input .piped-text-input-toggle textarea + button {\n margin-left: 4px; }\n\n.piped-text-input .addon-text-container {\n /*\n These styles are intended to match CFE QDS components,\n notably FormField and InputField.\n See: https://gitlab-app.eng.qops.net/cfe/ui/-/blob/master/packages/ui-react/src/FormField/Caption.less\n */\n margin-top: 6px; }\n .piped-text-input .addon-text-container .helper-text, .piped-text-input .addon-text-container .error-text {\n font-size: 12px; }\n .piped-text-input .addon-text-container .helper-text {\n color: #74777a;\n fill: #74777a; }\n .piped-text-input .addon-text-container .helper-text + .error-text {\n margin-top: 4px; }\n .piped-text-input .addon-text-container .error-text {\n display: flex;\n align-items: center;\n color: #b00;\n fill: #b00; }\n .piped-text-input .addon-text-container .error-text .error-text-icon svg {\n margin-left: -2px;\n margin-right: 3px;\n width: 16px;\n height: 16px; }\n";
|
|
@@ -1317,6 +1384,7 @@ styleInject(css_248z$6);
|
|
|
1317
1384
|
function PipedTextInput(props) {
|
|
1318
1385
|
var _a = useState(false), showMenu = _a[0], setShowMenu = _a[1];
|
|
1319
1386
|
var _b = useState(), cursorPosition = _b[0], setCursorPosition = _b[1];
|
|
1387
|
+
var pipedTextButtonRef = useRef(null);
|
|
1320
1388
|
/*
|
|
1321
1389
|
This has to be an Object type ref instead of 'string' or React will lose
|
|
1322
1390
|
track of state, and the supplied props input value will become stale
|
|
@@ -1351,10 +1419,10 @@ function PipedTextInput(props) {
|
|
|
1351
1419
|
React.createElement(Input, __assign({ value: inputRefValue.value, onChange: function (evt) {
|
|
1352
1420
|
onInputChange(evt);
|
|
1353
1421
|
}, onBlur: onInputBlur, placeholder: placeholder, multiline: multiline }, restProps)),
|
|
1354
|
-
React.createElement(IconButton, { "aria-label": "PipedText",
|
|
1422
|
+
React.createElement(IconButton, { "aria-label": "PipedText", "aria-haspopup": "menu", "aria-expanded": showMenu ? true : undefined, role: "button", onClick: toggleMenu, ref: pipedTextButtonRef },
|
|
1355
1423
|
React.createElement(PipedTextIcon, null)),
|
|
1356
1424
|
React.createElement("div", { className: "piped-text-select-container" },
|
|
1357
|
-
React.createElement(PipedTextSelect, { items: items, onSelect: pipedTextSelected, show: showMenu, onClose: handleClose, ignoreClickSelector: "piped-text-input-toggle" }))),
|
|
1425
|
+
React.createElement(PipedTextSelect, { items: items, onSelect: pipedTextSelected, show: showMenu, onClose: handleClose, ignoreClickSelector: "piped-text-input-toggle", anchorRef: pipedTextButtonRef }))),
|
|
1358
1426
|
showAddonText() && (React.createElement("div", { className: "addon-text-container" },
|
|
1359
1427
|
helperText && (React.createElement("div", { className: "helper-text" }, helperText)),
|
|
1360
1428
|
errorText && (React.createElement("div", { className: "error-text" },
|
|
@@ -1386,7 +1454,7 @@ function PipedTextInput(props) {
|
|
|
1386
1454
|
if (_get(selected, 'value.locator')) {
|
|
1387
1455
|
prependString = inputRefValue.value.substring(0, cursorPosition);
|
|
1388
1456
|
appendString = inputRefValue.value.substring(cursorPosition);
|
|
1389
|
-
nextInputValue = ""
|
|
1457
|
+
nextInputValue = "".concat(prependString).concat(selected.value.locator).concat(appendString);
|
|
1390
1458
|
setInputRefValue({
|
|
1391
1459
|
value: nextInputValue,
|
|
1392
1460
|
});
|
|
@@ -1509,13 +1577,28 @@ function FieldRow(props) {
|
|
|
1509
1577
|
}
|
|
1510
1578
|
|
|
1511
1579
|
if (props.required || !props.children || Array.isArray(children) && children.length === 0) {
|
|
1512
|
-
|
|
1513
|
-
|
|
1514
|
-
|
|
1515
|
-
|
|
1516
|
-
|
|
1517
|
-
|
|
1518
|
-
|
|
1580
|
+
if (props.subMenu) {
|
|
1581
|
+
return React.createElement(SelectMenu, {
|
|
1582
|
+
searchable: props.searchable !== undefined && props.searchable !== false,
|
|
1583
|
+
defaultLabel: props.fieldName || '',
|
|
1584
|
+
label: props.fieldName,
|
|
1585
|
+
className: "full-width left-align",
|
|
1586
|
+
onChange: handleFieldSwitch
|
|
1587
|
+
}, createMenuItems([{
|
|
1588
|
+
id: props.id,
|
|
1589
|
+
name: props.fieldName,
|
|
1590
|
+
subMenu: props.subMenu,
|
|
1591
|
+
subMenuLabel: props.subMenuLabel
|
|
1592
|
+
}]));
|
|
1593
|
+
} else {
|
|
1594
|
+
return React.createElement("div", {
|
|
1595
|
+
className: "required-indicator-container"
|
|
1596
|
+
}, React.createElement("div", {
|
|
1597
|
+
className: "required-indicator-text"
|
|
1598
|
+
}, props.fieldName), props.required && React.createElement("div", {
|
|
1599
|
+
className: "required-indicator-symbol"
|
|
1600
|
+
}, "*"));
|
|
1601
|
+
}
|
|
1519
1602
|
}
|
|
1520
1603
|
|
|
1521
1604
|
return React.createElement(SelectMenu, {
|
|
@@ -1524,12 +1607,7 @@ function FieldRow(props) {
|
|
|
1524
1607
|
label: props.fieldName,
|
|
1525
1608
|
className: "full-width left-align",
|
|
1526
1609
|
onChange: handleFieldSwitch
|
|
1527
|
-
}, children
|
|
1528
|
-
return React.createElement(MenuItem, {
|
|
1529
|
-
value: field.id,
|
|
1530
|
-
key: field.id
|
|
1531
|
-
}, field.name);
|
|
1532
|
-
}));
|
|
1610
|
+
}, createMenuItems(children));
|
|
1533
1611
|
};
|
|
1534
1612
|
|
|
1535
1613
|
var tooltipContent = React.createElement("div", null, props.nameTooltip);
|
|
@@ -1540,6 +1618,22 @@ function FieldRow(props) {
|
|
|
1540
1618
|
}, React.createElement("div", null, getInternalContent()));
|
|
1541
1619
|
};
|
|
1542
1620
|
|
|
1621
|
+
var createMenuItems = function createMenuItems(items) {
|
|
1622
|
+
return items.map(function (_ref) {
|
|
1623
|
+
var id = _ref.id,
|
|
1624
|
+
name = _ref.name,
|
|
1625
|
+
subMenu = _ref.subMenu,
|
|
1626
|
+
subMenuLabel = _ref.subMenuLabel;
|
|
1627
|
+
return subMenu !== undefined ? React.createElement(SelectMenu, {
|
|
1628
|
+
label: subMenuLabel ? subMenuLabel : name,
|
|
1629
|
+
key: id
|
|
1630
|
+
}, createMenuItems(subMenu)) : React.createElement(MenuItem, {
|
|
1631
|
+
key: id,
|
|
1632
|
+
value: id
|
|
1633
|
+
}, name);
|
|
1634
|
+
});
|
|
1635
|
+
};
|
|
1636
|
+
|
|
1543
1637
|
var getFieldInput = function getFieldInput() {
|
|
1544
1638
|
var getInternalContent = function getInternalContent() {
|
|
1545
1639
|
if (props.customInput) {
|
|
@@ -1565,7 +1659,7 @@ function FieldRow(props) {
|
|
|
1565
1659
|
return React.createElement("div", {
|
|
1566
1660
|
className: "field-row"
|
|
1567
1661
|
}, React.createElement("div", {
|
|
1568
|
-
className: "field-selector ".concat(props.required ? 'required-field' : '')
|
|
1662
|
+
className: "field-selector ".concat(props.required && !props.subMenu ? 'required-field' : '')
|
|
1569
1663
|
}, getFieldSelector()), React.createElement("div", {
|
|
1570
1664
|
className: "field-input-container"
|
|
1571
1665
|
}, React.createElement("div", {
|
|
@@ -1641,6 +1735,8 @@ function TaskFields(props) {
|
|
|
1641
1735
|
required: field.required,
|
|
1642
1736
|
fieldName: field.name,
|
|
1643
1737
|
id: field.id,
|
|
1738
|
+
subMenu: field.subMenu,
|
|
1739
|
+
subMenuLabel: field.subMenuLabel,
|
|
1644
1740
|
nameTooltip: field.type === CUSTOM_TYPE ? _get(props, 'customFieldOptions.nameTooltip', '') : field.nameTooltip,
|
|
1645
1741
|
valueTooltip: field.type === CUSTOM_TYPE ? _get(props, 'customFieldOptions.valueTooltip', '') : field.valueTooltip,
|
|
1646
1742
|
onFieldNameChange: onFieldNameChange,
|
|
@@ -1654,8 +1750,24 @@ function TaskFields(props) {
|
|
|
1654
1750
|
customNamePlaceholder: _get(props, 'customFieldOptions.namePlaceholder', ''),
|
|
1655
1751
|
pipedTextItems: props.pipedTextItems,
|
|
1656
1752
|
searchable: props.searchable
|
|
1657
|
-
}, allFieldOptions && availableFields);
|
|
1753
|
+
}, allFieldOptions && getFieldsForFieldRow(availableFields, allFieldOptions, field.id));
|
|
1754
|
+
});
|
|
1755
|
+
};
|
|
1756
|
+
|
|
1757
|
+
var getFieldsForFieldRow = function getFieldsForFieldRow(allAvailableFields, allFields, fieldId) {
|
|
1758
|
+
var fieldsToAdd = allAvailableFields.slice();
|
|
1759
|
+
allFields.forEach(function (field) {
|
|
1760
|
+
if (field.subMenu !== undefined && fieldId === field.id) {
|
|
1761
|
+
var foundIndex = fieldsToAdd.findIndex(function (fieldToAdd) {
|
|
1762
|
+
return fieldToAdd.id === field.id;
|
|
1763
|
+
});
|
|
1764
|
+
|
|
1765
|
+
if (foundIndex === -1) {
|
|
1766
|
+
fieldsToAdd.push(field);
|
|
1767
|
+
}
|
|
1768
|
+
}
|
|
1658
1769
|
});
|
|
1770
|
+
return fieldsToAdd;
|
|
1659
1771
|
};
|
|
1660
1772
|
|
|
1661
1773
|
var onFieldAdd = function onFieldAdd(fieldId) {
|
|
@@ -1677,7 +1789,9 @@ function TaskFields(props) {
|
|
|
1677
1789
|
type: field.type,
|
|
1678
1790
|
required: field.required,
|
|
1679
1791
|
key: field.id,
|
|
1680
|
-
id: field.id
|
|
1792
|
+
id: field.id,
|
|
1793
|
+
subMenu: field.subMenu,
|
|
1794
|
+
subMenuLabel: field.subMenuLabel
|
|
1681
1795
|
});
|
|
1682
1796
|
});
|
|
1683
1797
|
};
|
|
@@ -1730,7 +1844,9 @@ function TaskFields(props) {
|
|
|
1730
1844
|
children: foundNextChild.props.children,
|
|
1731
1845
|
nameTooltip: foundNextChild.props.nameTooltip,
|
|
1732
1846
|
valueTooltip: foundNextChild.props.valueTooltip,
|
|
1733
|
-
valuePlaceholder: foundNextChild.props.valuePlaceholder
|
|
1847
|
+
valuePlaceholder: foundNextChild.props.valuePlaceholder,
|
|
1848
|
+
subMenu: foundNextChild.props.subMenu,
|
|
1849
|
+
subMenuLabel: foundNextChild.props.subMenuLabel
|
|
1734
1850
|
});
|
|
1735
1851
|
}
|
|
1736
1852
|
|
|
@@ -1751,7 +1867,9 @@ function TaskFields(props) {
|
|
|
1751
1867
|
nameTooltip: field.props.nameTooltip,
|
|
1752
1868
|
valueTooltip: field.props.valueTooltip,
|
|
1753
1869
|
value: field.props.value || undefined,
|
|
1754
|
-
valuePlaceholder: field.props.valuePlaceholder
|
|
1870
|
+
valuePlaceholder: field.props.valuePlaceholder,
|
|
1871
|
+
subMenu: field.props.subMenu,
|
|
1872
|
+
subMenuLabel: field.props.subMenuLabel
|
|
1755
1873
|
});
|
|
1756
1874
|
}
|
|
1757
1875
|
});
|
|
@@ -1777,7 +1895,9 @@ function TaskFields(props) {
|
|
|
1777
1895
|
nameTooltip: _get(props, 'customFieldOptions.nameTooltip', ''),
|
|
1778
1896
|
valueTooltip: _get(props, 'customFieldOptions.valueTooltip', ''),
|
|
1779
1897
|
namePlaceholder: _get(props, 'customFieldOptions.namePlaceholder', ''),
|
|
1780
|
-
type: CUSTOM_TYPE
|
|
1898
|
+
type: CUSTOM_TYPE,
|
|
1899
|
+
subMenu: currentField.subMenu,
|
|
1900
|
+
subMenuLabel: currentField.subMenuLabel
|
|
1781
1901
|
};
|
|
1782
1902
|
nextFieldsInUse.push(customFieldValue);
|
|
1783
1903
|
}
|
|
@@ -1792,7 +1912,11 @@ function TaskFields(props) {
|
|
|
1792
1912
|
if (field !== undefined) {
|
|
1793
1913
|
field.value = fieldValue.value;
|
|
1794
1914
|
} else {
|
|
1795
|
-
var newField =
|
|
1915
|
+
var newField = _cloneDeepWith(fieldMetadata, function (value) {
|
|
1916
|
+
if (React.isValidElement(value)) {
|
|
1917
|
+
return React.cloneElement(value);
|
|
1918
|
+
}
|
|
1919
|
+
});
|
|
1796
1920
|
|
|
1797
1921
|
newField.value = fieldValue.value;
|
|
1798
1922
|
fieldsInUse.push(newField);
|
|
@@ -1811,7 +1935,9 @@ function TaskFields(props) {
|
|
|
1811
1935
|
children: childProps.children,
|
|
1812
1936
|
nameTooltip: childProps.nameTooltip,
|
|
1813
1937
|
valueTooltip: childProps.valueTooltip,
|
|
1814
|
-
valuePlaceholder: childProps.valuePlaceholder
|
|
1938
|
+
valuePlaceholder: childProps.valuePlaceholder,
|
|
1939
|
+
subMenu: childProps.subMenu,
|
|
1940
|
+
subMenuLabel: childProps.subMenuLabel
|
|
1815
1941
|
};
|
|
1816
1942
|
});
|
|
1817
1943
|
var nextFieldsInUse = getFieldsInUse(nextAllFieldOptions);
|
|
@@ -1846,6 +1972,7 @@ function TaskFields(props) {
|
|
|
1846
1972
|
}, React.createElement(AddFieldButton, {
|
|
1847
1973
|
label: props.addFieldLabel,
|
|
1848
1974
|
onFieldAdded: onFieldAdd,
|
|
1975
|
+
disableAddFieldPopover: props.disableAddFieldPopover,
|
|
1849
1976
|
allowCustom: props.customFieldOptions,
|
|
1850
1977
|
customLabel: _get(props, 'customFieldOptions.label', ''),
|
|
1851
1978
|
onCustomFieldAdded: props.customFieldOptions ? onCustomFieldAdd : function () {}
|
|
@@ -1855,6 +1982,7 @@ function TaskFields(props) {
|
|
|
1855
1982
|
function AddFieldButton(props) {
|
|
1856
1983
|
var label = props.label || '';
|
|
1857
1984
|
var customLabel = props.customLabel || '';
|
|
1985
|
+
var disableAddFieldPopover = props.disableAddFieldPopover;
|
|
1858
1986
|
|
|
1859
1987
|
var _useState7 = useState(false),
|
|
1860
1988
|
_useState8 = _slicedToArray(_useState7, 2),
|
|
@@ -1876,15 +2004,30 @@ function AddFieldButton(props) {
|
|
|
1876
2004
|
setPopoverShow(false);
|
|
1877
2005
|
};
|
|
1878
2006
|
|
|
2007
|
+
var children = [];
|
|
2008
|
+
|
|
1879
2009
|
var onPopoverAnchorClick = function onPopoverAnchorClick() {
|
|
1880
|
-
|
|
2010
|
+
if (!disableAddFieldPopover) {
|
|
2011
|
+
setPopoverShow(!popoverShow);
|
|
2012
|
+
} else {
|
|
2013
|
+
props.onFieldAdded(props.children !== 0 ? getFieldIdWhenPopoverIsClicked(props.children[0].props) : '');
|
|
2014
|
+
}
|
|
2015
|
+
};
|
|
2016
|
+
|
|
2017
|
+
var getFieldIdWhenPopoverIsClicked = function getFieldIdWhenPopoverIsClicked(field) {
|
|
2018
|
+
if (field.subMenu) {
|
|
2019
|
+
return getFieldIdWhenPopoverIsClicked(field.subMenu[0]);
|
|
2020
|
+
} else {
|
|
2021
|
+
return field.id;
|
|
2022
|
+
}
|
|
1881
2023
|
};
|
|
1882
2024
|
|
|
1883
|
-
|
|
2025
|
+
children = props.children.map(function (child) {
|
|
1884
2026
|
return React.createElement(FieldItem, {
|
|
1885
2027
|
name: child.props.name,
|
|
1886
2028
|
key: child.props.id,
|
|
1887
2029
|
id: child.props.id,
|
|
2030
|
+
subMenu: child.props.subMenu,
|
|
1888
2031
|
onClick: function onClick(fieldId) {
|
|
1889
2032
|
setPopoverShow(false);
|
|
1890
2033
|
props.onFieldAdded(fieldId);
|