@qualtrics/plugin-ui-react 1.4.0-alpha.0 → 1.4.0-alpha.2
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/.dockerignore +1 -3
- package/.eslintignore +3 -0
- package/CHANGELOG.md +20 -0
- package/Dockerfile +5 -8
- package/Makefile +9 -17
- package/dist/common/capture-event/capture-event.d.ts +10 -6
- package/dist/common/field-mapper/field-mapper-key/field-mapper-key.d.ts +3 -3
- package/dist/common/field-mapper/field-mapper-row/field-mapper-row.d.ts +3 -2
- package/dist/common/field-mapper/field-mapper.d.ts +1 -1
- package/dist/common/piped-text-select/piped-text-menu/embedded-data-menu/embedded-data-input/embedded-data-input.d.ts +10 -0
- package/dist/common/piped-text-select/piped-text-menu/embedded-data-menu/embedded-data-menu.d.ts +15 -2
- package/dist/common/piped-text-select/piped-text-menu/piped-text-menu-item/piped-text-menu-item.d.ts +10 -7
- package/dist/common/piped-text-select/piped-text-menu/piped-text-menu-item-service.d.ts +7 -0
- package/dist/common/piped-text-select/piped-text-menu/piped-text-menu-keyboard-ctrl.d.ts +27 -0
- package/dist/common/piped-text-select/piped-text-menu/piped-text-menu-list/piped-text-menu-list.d.ts +24 -0
- package/dist/common/piped-text-select/piped-text-menu/piped-text-menu-list/piped-text-menu-load-error/piped-text-menu-load-error.d.ts +7 -0
- package/dist/common/piped-text-select/piped-text-menu/piped-text-menu-list/piped-text-search-input/piped-text-search-input.d.ts +10 -0
- package/dist/common/piped-text-select/piped-text-menu/piped-text-menu.d.ts +26 -4
- package/dist/common/piped-text-select/piped-text-menu/piped-text-submenu-item/piped-text-submenu-item.d.ts +7 -4
- package/dist/common/popover/popover-options.d.ts +3 -0
- package/dist/lib/merge-refs.d.ts +2 -0
- package/dist/main.es.js +1074 -640
- package/dist/main.js +1072 -638
- package/jenkins.groovy +13 -7
- package/jenkinsPipelineUtils/pipelineControls.groovy +8 -0
- package/package.json +2 -1
package/dist/main.es.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
/*! @license @qualtrics/plugin-ui-react 1.4.0-alpha.
|
|
1
|
+
/*! @license @qualtrics/plugin-ui-react 1.4.0-alpha.2
|
|
2
2
|
Qualtrics Software License Agreement
|
|
3
3
|
|
|
4
4
|
1. General.
|
|
@@ -57,26 +57,25 @@ import 'core-js/modules/es.array.for-each.js';
|
|
|
57
57
|
import 'core-js/modules/web.dom-collections.for-each.js';
|
|
58
58
|
import React, { Component, useState, useEffect, useRef, useCallback } from 'react';
|
|
59
59
|
import _get from 'lodash.get';
|
|
60
|
-
import { Button,
|
|
61
|
-
import { ErrorIcon, PipedTextIcon, RemoveItemIcon, CheckIcon, AddIcon } from '@qualtrics/ui-react/icons';
|
|
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
62
|
import 'core-js/modules/es.string.anchor.js';
|
|
63
|
-
import 'core-js/modules/es.array.filter.js';
|
|
64
|
-
import 'core-js/modules/es.string.trim.js';
|
|
65
|
-
import 'core-js/modules/es.array.map.js';
|
|
66
|
-
import 'core-js/modules/es.array.concat.js';
|
|
67
63
|
import _cloneDeep from 'lodash.clonedeep';
|
|
64
|
+
import 'core-js/modules/es.array.concat.js';
|
|
68
65
|
import 'core-js/modules/es.array.is-array.js';
|
|
69
66
|
import { Manager, Reference, Popper } from 'react-popper';
|
|
70
67
|
import ReactDOM from 'react-dom';
|
|
71
|
-
import 'core-js/modules/web.timers.js';
|
|
72
68
|
import uuid, { v4 } from 'uuid';
|
|
69
|
+
import 'core-js/modules/es.array.map.js';
|
|
73
70
|
import 'core-js/modules/es.function.name.js';
|
|
74
71
|
import 'core-js/modules/es.array.slice.js';
|
|
75
72
|
import 'core-js/modules/es.array.iterator.js';
|
|
76
73
|
import 'core-js/modules/web.dom-collections.iterator.js';
|
|
77
74
|
import 'core-js/modules/es.array.find.js';
|
|
78
75
|
import 'core-js/modules/es.object.assign.js';
|
|
76
|
+
import 'core-js/modules/es.array.filter.js';
|
|
79
77
|
import _cloneDeepWith from 'lodash.clonedeepwith';
|
|
78
|
+
import 'core-js/modules/es.string.trim.js';
|
|
80
79
|
import 'core-js/modules/es.regexp.exec.js';
|
|
81
80
|
import 'core-js/modules/es.string.search.js';
|
|
82
81
|
|
|
@@ -107,8 +106,8 @@ function styleInject(css, ref) {
|
|
|
107
106
|
}
|
|
108
107
|
}
|
|
109
108
|
|
|
110
|
-
var css_248z$
|
|
111
|
-
styleInject(css_248z$
|
|
109
|
+
var css_248z$m = ".react-app {\n background-color: RGBA(0, 0, 0, 0.1); }\n";
|
|
110
|
+
styleInject(css_248z$m);
|
|
112
111
|
|
|
113
112
|
function ownKeys(object, enumerableOnly) {
|
|
114
113
|
var keys = Object.keys(object);
|
|
@@ -896,6 +895,7 @@ var languageCodeMapping = {
|
|
|
896
895
|
'ES-ES': 'es-419',
|
|
897
896
|
FI: 'fi',
|
|
898
897
|
FR: 'fr',
|
|
898
|
+
'FR-CA': 'fr-CA',
|
|
899
899
|
ID: 'id',
|
|
900
900
|
IT: 'it',
|
|
901
901
|
JA: 'ja',
|
|
@@ -959,6 +959,54 @@ function __rest(s, e) {
|
|
|
959
959
|
t[p[i]] = s[p[i]];
|
|
960
960
|
}
|
|
961
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));
|
|
962
1010
|
}
|
|
963
1011
|
|
|
964
1012
|
var Portal = function (_Component) {
|
|
@@ -1004,8 +1052,8 @@ var Portal = function (_Component) {
|
|
|
1004
1052
|
return Portal;
|
|
1005
1053
|
}(Component);
|
|
1006
1054
|
|
|
1007
|
-
var css_248z$
|
|
1008
|
-
styleInject(css_248z$
|
|
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);
|
|
1009
1057
|
|
|
1010
1058
|
var globalClickRegistry = new EventRegistry();
|
|
1011
1059
|
var DEFAULT_PLACEMENT = 'bottom-start';
|
|
@@ -1119,92 +1167,8 @@ function initGlobalListener() {
|
|
|
1119
1167
|
});
|
|
1120
1168
|
}
|
|
1121
1169
|
|
|
1122
|
-
var css_248z$
|
|
1123
|
-
styleInject(css_248z$
|
|
1124
|
-
|
|
1125
|
-
var EmbeddedDataMenu = React.forwardRef(function EmbeddedDataMeny(props, ref) {
|
|
1126
|
-
var _useState = useState(''),
|
|
1127
|
-
_useState2 = _slicedToArray(_useState, 2),
|
|
1128
|
-
inputValue = _useState2[0],
|
|
1129
|
-
setInputValue = _useState2[1];
|
|
1130
|
-
|
|
1131
|
-
var _useState3 = useState(false),
|
|
1132
|
-
_useState4 = _slicedToArray(_useState3, 2),
|
|
1133
|
-
isInputInvalid = _useState4[0],
|
|
1134
|
-
setIsInputInvalid = _useState4[1];
|
|
1135
|
-
|
|
1136
|
-
var inputRef = useRef();
|
|
1137
|
-
var anchor = props.anchor;
|
|
1138
|
-
|
|
1139
|
-
var onClose = props.onClose || function () {};
|
|
1140
|
-
|
|
1141
|
-
var popoverClassName = 'embedded-data-menu-content';
|
|
1142
|
-
var ignoreClickSelector = popoverClassName;
|
|
1143
|
-
|
|
1144
|
-
var onSelect = props.onSelect || function () {};
|
|
1145
|
-
|
|
1146
|
-
useEffect(function () {
|
|
1147
|
-
setTimeout(function () {
|
|
1148
|
-
if (_get(inputRef, 'current.focus') !== undefined) {
|
|
1149
|
-
inputRef.current.focus();
|
|
1150
|
-
}
|
|
1151
|
-
});
|
|
1152
|
-
}, [props.show]);
|
|
1153
|
-
|
|
1154
|
-
var handleInputChange = function handleInputChange($e) {
|
|
1155
|
-
var inputValue = ($e.target.value || '').trim();
|
|
1156
|
-
var uriEncodedValue = encodeURIComponent(inputValue);
|
|
1157
|
-
setInputValue(uriEncodedValue);
|
|
1158
|
-
|
|
1159
|
-
if (uriEncodedValue.length > 0 && isInputInvalid) {
|
|
1160
|
-
setIsInputInvalid(false);
|
|
1161
|
-
}
|
|
1162
|
-
};
|
|
1163
|
-
|
|
1164
|
-
var handleAddButtonClick = function handleAddButtonClick() {
|
|
1165
|
-
var locatorString;
|
|
1166
|
-
|
|
1167
|
-
if ((inputValue || '').trim().length < 1) {
|
|
1168
|
-
setIsInputInvalid(true);
|
|
1169
|
-
return;
|
|
1170
|
-
}
|
|
1171
|
-
|
|
1172
|
-
locatorString = "${e://Field/".concat(inputValue, "}");
|
|
1173
|
-
onSelect(locatorString);
|
|
1174
|
-
};
|
|
1175
|
-
|
|
1176
|
-
var handleInputKeyDown = function handleInputKeyDown($e) {
|
|
1177
|
-
var key = $e.key;
|
|
1178
|
-
|
|
1179
|
-
if (key !== 'Enter') {
|
|
1180
|
-
return;
|
|
1181
|
-
}
|
|
1182
|
-
|
|
1183
|
-
handleAddButtonClick();
|
|
1184
|
-
};
|
|
1185
|
-
|
|
1186
|
-
return React.createElement(Popover, {
|
|
1187
|
-
show: props.show,
|
|
1188
|
-
anchor: anchor,
|
|
1189
|
-
onClose: onClose,
|
|
1190
|
-
ignoreClickSelector: ignoreClickSelector,
|
|
1191
|
-
placement: props.placement || 'right-start'
|
|
1192
|
-
}, React.createElement("div", {
|
|
1193
|
-
className: "embedded-data-menu",
|
|
1194
|
-
ref: ref
|
|
1195
|
-
}, React.createElement("div", null, React.createElement(InputGroup, null, React.createElement(Input, {
|
|
1196
|
-
onChange: handleInputChange,
|
|
1197
|
-
invalid: isInputInvalid,
|
|
1198
|
-
onKeyDown: handleInputKeyDown,
|
|
1199
|
-
ref: inputRef,
|
|
1200
|
-
className: "q-plugin-popover-input"
|
|
1201
|
-
}), React.createElement(Button, {
|
|
1202
|
-
kind: "primary",
|
|
1203
|
-
onClick: handleAddButtonClick
|
|
1204
|
-
}, React.createElement(Icon, {
|
|
1205
|
-
type: IconTypes.Add
|
|
1206
|
-
}))))));
|
|
1207
|
-
});
|
|
1170
|
+
var css_248z$k = ".piped-text-menu-list .piped-text-popover-menu > * {\n min-height: 32px; }\n";
|
|
1171
|
+
styleInject(css_248z$k);
|
|
1208
1172
|
|
|
1209
1173
|
/**
|
|
1210
1174
|
* Copied from: https://gitlab-app.eng.qops.net/cfe/ui/-/blob/master/packages/ui-react/src/hooks/useId/useId.js
|
|
@@ -1219,58 +1183,494 @@ function useId(defaultExternalId) {
|
|
|
1219
1183
|
return currentId;
|
|
1220
1184
|
}
|
|
1221
1185
|
|
|
1222
|
-
var css_248z$
|
|
1223
|
-
styleInject(css_248z$
|
|
1186
|
+
var css_248z$j = "";
|
|
1187
|
+
styleInject(css_248z$j);
|
|
1224
1188
|
|
|
1225
|
-
|
|
1226
|
-
|
|
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);
|
|
1227
1228
|
|
|
1228
1229
|
// const WrappedPipedTextMenu = PipedTextMenu as PipedTextMenuType;
|
|
1229
1230
|
var PipedTextSubmenuItem = React.forwardRef(function PipedTextSubmenuItem(props, ref) {
|
|
1230
1231
|
var submenuAnchorRef = useRef(null);
|
|
1231
|
-
var
|
|
1232
|
+
var submenuAnchorId = useId();
|
|
1232
1233
|
var menuItem = props.menuItem;
|
|
1233
|
-
return (React.createElement("div", { "data-testid": "piped-text-submenu", className: "piped-text-submenu-item-container" },
|
|
1234
|
-
menuItem.show && (React.createElement(PipedTextMenu, { "aria-labelledby":
|
|
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,
|
|
1235
1236
|
//@ts-ignore
|
|
1236
1237
|
items: menuItem.submenu.items, show: menuItem.show, placement: "right-start", onClose: function () {
|
|
1237
1238
|
menuItem.show = false;
|
|
1238
|
-
}, allowCustom: menuItem.submenu.allowCustom, customScheme: menuItem.submenu.customScheme, customInputMessage: menuItem.submenu.customInputMessage, searchPlaceholder: menuItem.submenu.searchPlaceholder, errorText: menuItem.submenu.errorText, onSelected: menuItemClicked, anchor: function (ref) { return (React.createElement("div", { ref: ref, className: "piped-text-submenu-anchor" })); }, anchorRef: submenuAnchorRef })),
|
|
1239
|
-
React.createElement("div", {
|
|
1240
|
-
// aria-haspopup="menu"
|
|
1241
|
-
// id={subMenuItemId}
|
|
1242
|
-
className: "piped-text-submenu-item",
|
|
1243
|
-
// role="menuitem"
|
|
1244
|
-
onMouseEnter: function () { return submenuHovered(menuItem); }, ref: submenuAnchorRef },
|
|
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 },
|
|
1245
1241
|
React.createElement("div", { className: "label-text" }, menuItem.label),
|
|
1246
1242
|
React.createElement("div", { className: "piped-text-icon" },
|
|
1247
1243
|
React.createElement(Icon, { type: IconTypes.ChevronRight, size: "medium" })))));
|
|
1248
1244
|
function menuItemClicked(menuItem) {
|
|
1249
1245
|
props.onMenuItemClick(menuItem);
|
|
1250
1246
|
}
|
|
1251
|
-
|
|
1252
|
-
|
|
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;
|
|
1253
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 }))));
|
|
1254
1595
|
});
|
|
1255
1596
|
|
|
1256
|
-
|
|
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';
|
|
1257
1619
|
var PipedTextMenuItem = React.forwardRef(function PipedTextMenuItem(props, ref) {
|
|
1258
|
-
var
|
|
1259
|
-
|
|
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)));
|
|
1260
1667
|
function getMenuItemContent(menuItem) {
|
|
1261
1668
|
var innerContent, menuItemEl;
|
|
1262
1669
|
var menuItemHeaderClass, menuItemDisabledClass, menuItemClassName;
|
|
1263
|
-
|
|
1264
|
-
|
|
1265
|
-
|
|
1266
|
-
|
|
1267
|
-
var role = isSubmenu
|
|
1268
|
-
? 'submenu'
|
|
1269
|
-
: 'menuitemradio';
|
|
1270
|
-
if (isSubmenu) {
|
|
1271
|
-
innerContent = (React.createElement(PipedTextSubmenuItem, { key: menuItem.key, menuItem: menuItem, onSubmenuHover: handleSubmenuHover, onMenuItemClick: handleMenuItemClick }));
|
|
1272
|
-
}
|
|
1273
|
-
else if (isDecorated) {
|
|
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) {
|
|
1274
1674
|
menuItemHeaderClass = (menuItem.header === true)
|
|
1275
1675
|
? 'piped-text-header'
|
|
1276
1676
|
: '';
|
|
@@ -1280,35 +1680,73 @@ var PipedTextMenuItem = React.forwardRef(function PipedTextMenuItem(props, ref)
|
|
|
1280
1680
|
menuItemClassName = "piped-text-menu-item ".concat(menuItemHeaderClass, " ").concat(menuItemDisabledClass);
|
|
1281
1681
|
innerContent = (React.createElement("div", { className: menuItemClassName }, menuItem.label));
|
|
1282
1682
|
}
|
|
1283
|
-
else if (
|
|
1284
|
-
innerContent = (React.createElement("div", {
|
|
1285
|
-
|
|
1286
|
-
|
|
1287
|
-
|
|
1288
|
-
|
|
1289
|
-
|
|
1290
|
-
//@ts-ignore
|
|
1291
|
-
show: menuItem.show, onSelect: handleEmbeddedDataSelect, anchor: function (ref) { return (React.createElement("div", { ref: ref, className: "embedded-data-menu-anchor" })); } }),
|
|
1292
|
-
React.createElement("div", { className: "piped-text-menu-item" }, menuItem.label)));
|
|
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' })))));
|
|
1293
1690
|
}
|
|
1294
1691
|
else {
|
|
1295
|
-
innerContent = (React.createElement("div", {
|
|
1296
|
-
React.createElement("div", { className: "piped-text-menu-item" }, menuItem.label)));
|
|
1692
|
+
innerContent = (React.createElement("div", { className: "piped-text-menu-item", role: 'presentation' }, menuItem.label));
|
|
1297
1693
|
}
|
|
1298
|
-
menuItemEl = (React.createElement("div", {
|
|
1694
|
+
menuItemEl = (React.createElement("div", { className: "piped-text-menu-item-content", role: 'presentation' }, innerContent));
|
|
1299
1695
|
return menuItemEl;
|
|
1300
1696
|
}
|
|
1301
|
-
function
|
|
1302
|
-
|
|
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);
|
|
1303
1741
|
}
|
|
1304
1742
|
function handleMenuItemClick(menuItem) {
|
|
1305
1743
|
props.onMenuItemClicked(menuItem);
|
|
1306
1744
|
}
|
|
1307
1745
|
function handleSubmenuHover(menuItem) {
|
|
1308
|
-
props.onSubmenuHover(menuItem);
|
|
1746
|
+
props.onSubmenuHover(menuItem, localRef);
|
|
1309
1747
|
}
|
|
1310
1748
|
function handleMenuItemHovered(menuItem) {
|
|
1311
|
-
props.onMenuItemHover(menuItem);
|
|
1749
|
+
props.onMenuItemHover(menuItem, localRef);
|
|
1312
1750
|
}
|
|
1313
1751
|
function handleEmbeddedDataSelect(edLocator) {
|
|
1314
1752
|
var edMenuItem;
|
|
@@ -1323,468 +1761,451 @@ var PipedTextMenuItem = React.forwardRef(function PipedTextMenuItem(props, ref)
|
|
|
1323
1761
|
};
|
|
1324
1762
|
props.onMenuItemClicked(edMenuItem);
|
|
1325
1763
|
}
|
|
1326
|
-
});
|
|
1327
|
-
function checkEmbeddedDataMenuItem$1(menuItem) {
|
|
1328
|
-
return menuItem.value === EMBEDDED_DATA_LOCATOR$1;
|
|
1329
|
-
}
|
|
1330
|
-
function checkDecoratedMenuItem$1(menuItem) {
|
|
1331
|
-
return (menuItem.header === true)
|
|
1332
|
-
|| (menuItem.disabled === true);
|
|
1333
|
-
}
|
|
1334
|
-
function checkSubmenuMenuItemItem$1(menuItem) {
|
|
1335
|
-
return !!menuItem.hasSubmenu;
|
|
1336
|
-
}
|
|
1337
|
-
function checkMenuItemFocusable$1(menuItem) {
|
|
1338
|
-
var isEmbeddedData, isSubmenu, isDefaultMenuItem;
|
|
1339
|
-
isEmbeddedData = checkEmbeddedDataMenuItem$1(menuItem);
|
|
1340
|
-
isSubmenu = checkSubmenuMenuItemItem$1(menuItem);
|
|
1341
|
-
isDefaultMenuItem = checkDefaultMenuItem$1(menuItem);
|
|
1342
|
-
return (isEmbeddedData
|
|
1343
|
-
|| isSubmenu
|
|
1344
|
-
|| isDefaultMenuItem);
|
|
1345
|
-
}
|
|
1346
|
-
function checkDefaultMenuItem$1(menuItem) {
|
|
1347
|
-
return !(checkEmbeddedDataMenuItem$1(menuItem)
|
|
1348
|
-
|| checkDecoratedMenuItem$1(menuItem)
|
|
1349
|
-
|| checkSubmenuMenuItemItem$1(menuItem));
|
|
1350
|
-
}
|
|
1351
|
-
|
|
1352
|
-
var css_248z$e = "div[role=\"menu\"] .piped-text-search-input-container {\n padding: 5px 10px; }\n\n.piped-text-search-input {\n padding: 10px 12px;\n user-select: none;\n box-sizing: border-box;\n overflow-x: hidden;\n text-overflow: ellipsis;\n align-content: center;\n padding: 4px 8px 8px; }\n .piped-text-search-input input.q-plugin-popover-input {\n box-sizing: border-box;\n height: 36px;\n padding: 7px 9px; }\n\n.piped-text-menu-empty-anchor {\n /* the margin-right hack was not in harmony with tao.\n now, the empty-anchor is truly empty */ }\n\n.piped-text-submenu-item-container {\n position: relative; }\n .piped-text-submenu-item-container .piped-text-menu .piped-text-submenu-anchor {\n position: absolute;\n z-index: -1;\n bottom: 0;\n top: 0;\n left: 0;\n right: 0;\n min-width: 100%; }\n\n.piped-text-menu-item, .piped-text-submenu-item {\n padding: 10px 12px;\n user-select: none;\n box-sizing: border-box;\n overflow-x: hidden;\n text-overflow: ellipsis; }\n .piped-text-menu-item:not(.piped-text-header):not(.piped-text-disabled):hover, .piped-text-submenu-item:not(.piped-text-header):not(.piped-text-disabled):hover {\n cursor: pointer;\n background: RGBA(50, 54, 58, 0.08); }\n .piped-text-menu-item.piped-text-header, .piped-text-submenu-item.piped-text-header {\n font-size: 12px;\n line-height: 16px;\n font-weight: 700;\n padding: 12px; }\n .piped-text-menu-item.piped-text-disabled:not(.piped-text-header), .piped-text-submenu-item.piped-text-disabled:not(.piped-text-header) {\n color: RGB(116, 119, 122); }\n\n.piped-text-submenu-item {\n padding-right: 24px; }\n\n.piped-text-information-message {\n padding: 10px 12px;\n user-select: none;\n box-sizing: border-box;\n overflow-x: hidden;\n text-overflow: ellipsis;\n color: #74777A;\n text-align: center;\n white-space: pre-line; }\n\n.piped-text-loading-spinner {\n width: fit-content;\n margin: 0 auto; }\n\n.piped-text-error-container {\n color: #BB0000; }\n .piped-text-error-container .piped-text-error-icon {\n padding: 8px 0; }\n .piped-text-error-container .piped-text-error-icon svg {\n fill: #BB0000;\n display: block;\n margin: 0 auto; }\n .piped-text-error-container .piped-text-error-text {\n text-align: center;\n white-space: pre-line;\n padding: 0 12px 8px; }\n";
|
|
1353
|
-
styleInject(css_248z$e);
|
|
1354
|
-
|
|
1355
|
-
var EMBEDDED_DATA_LOCATOR = 'embeddedData';
|
|
1356
|
-
var PipedTextMenu = React.forwardRef(function PipedTextMenu(props, ref) {
|
|
1357
|
-
var defaultMenuItems = undefined;
|
|
1358
|
-
|
|
1359
|
-
if (typeof props.items !== 'function') {
|
|
1360
|
-
defaultMenuItems = _cloneDeep(props.items);
|
|
1361
|
-
}
|
|
1362
|
-
|
|
1363
|
-
var optionsRef = useRef({});
|
|
1364
|
-
|
|
1365
|
-
var _useState = useState(defaultMenuItems),
|
|
1366
|
-
_useState2 = _slicedToArray(_useState, 2),
|
|
1367
|
-
menuItems = _useState2[0],
|
|
1368
|
-
setMenuItems = _useState2[1];
|
|
1369
|
-
|
|
1370
|
-
var _useState3 = useState(props.show),
|
|
1371
|
-
_useState4 = _slicedToArray(_useState3, 2),
|
|
1372
|
-
isMenuOpen = _useState4[0],
|
|
1373
|
-
setIsMenuOpen = _useState4[1];
|
|
1374
|
-
|
|
1375
|
-
var _useState5 = useState(false),
|
|
1376
|
-
_useState6 = _slicedToArray(_useState5, 2),
|
|
1377
|
-
isLoadError = _useState6[0],
|
|
1378
|
-
setIsLoadError = _useState6[1];
|
|
1379
|
-
|
|
1380
|
-
var _useState7 = useState(''),
|
|
1381
|
-
_useState8 = _slicedToArray(_useState7, 2),
|
|
1382
|
-
searchValue = _useState8[0],
|
|
1383
|
-
setSearchValue = _useState8[1];
|
|
1384
|
-
|
|
1385
|
-
var _useState9 = useState(undefined),
|
|
1386
|
-
_useState10 = _slicedToArray(_useState9, 2);
|
|
1387
|
-
_useState10[0];
|
|
1388
|
-
var setIsSubmenu = _useState10[1];
|
|
1389
|
-
|
|
1390
|
-
var _useState11 = useState([]),
|
|
1391
|
-
_useState12 = _slicedToArray(_useState11, 2),
|
|
1392
|
-
itemsToRender = _useState12[0],
|
|
1393
|
-
setItemsToRender = _useState12[1];
|
|
1394
|
-
|
|
1395
|
-
var externalAriaLabelledBy = props['aria-labelledby'];
|
|
1396
|
-
var popoverAriaLabelledBy = useId();
|
|
1397
|
-
|
|
1398
|
-
var _useState13 = useState([]),
|
|
1399
|
-
_useState14 = _slicedToArray(_useState13, 2),
|
|
1400
|
-
menuChildren = _useState14[0],
|
|
1401
|
-
setMenuChildren = _useState14[1];
|
|
1402
|
-
|
|
1403
|
-
var _useState15 = useState(-1),
|
|
1404
|
-
_useState16 = _slicedToArray(_useState15, 2),
|
|
1405
|
-
higlightedItemIndex = _useState16[0],
|
|
1406
|
-
setHighlightedItemIndex = _useState16[1];
|
|
1407
|
-
|
|
1408
|
-
var _useState17 = useState([]),
|
|
1409
|
-
_useState18 = _slicedToArray(_useState17, 2);
|
|
1410
|
-
_useState18[0];
|
|
1411
|
-
var setFocusMenuItems = _useState18[1];
|
|
1412
|
-
|
|
1413
|
-
var onClose = props.onClose || function () {
|
|
1414
|
-
return undefined;
|
|
1415
|
-
};
|
|
1416
|
-
|
|
1417
|
-
var _useState19 = useState(null),
|
|
1418
|
-
_useState20 = _slicedToArray(_useState19, 2),
|
|
1419
|
-
popoverEl = _useState20[0],
|
|
1420
|
-
setPopoverEl = _useState20[1];
|
|
1421
|
-
|
|
1422
|
-
var popoverRefCb = useCallback(function (el) {
|
|
1423
|
-
setPopoverEl(el);
|
|
1424
|
-
}, []);
|
|
1425
|
-
|
|
1426
|
-
var _useState21 = useState(null),
|
|
1427
|
-
_useState22 = _slicedToArray(_useState21, 2);
|
|
1428
|
-
_useState22[0];
|
|
1429
|
-
var setSearchBoxEl = _useState22[1];
|
|
1430
|
-
|
|
1431
|
-
var searchBoxRefCb = useCallback(function (el) {
|
|
1432
|
-
setSearchBoxEl(el);
|
|
1433
|
-
}, []);
|
|
1434
|
-
useEffect(function () {
|
|
1435
|
-
var nextMenuChildren;
|
|
1436
|
-
nextMenuChildren = getPipedTextMenuItems(itemsToRender);
|
|
1437
|
-
setMenuChildren(nextMenuChildren);
|
|
1438
|
-
}, [itemsToRender]);
|
|
1439
|
-
useEffect(function () {
|
|
1440
|
-
var nextItemsToRender;
|
|
1441
|
-
nextItemsToRender = (menuItems || []).filter(matchesSearch);
|
|
1442
|
-
setItemsToRender(nextItemsToRender);
|
|
1443
|
-
}, [searchValue, menuItems]);
|
|
1444
|
-
useEffect(function () {
|
|
1445
|
-
var anchorRefEl = _get(props, 'anchorRef.current');
|
|
1446
|
-
|
|
1447
|
-
if (anchorRefEl) {
|
|
1448
|
-
var anchorRefElRole = anchorRefEl.getAttribute('role');
|
|
1449
|
-
var nextIsSubmenu = anchorRefElRole === 'menuitem';
|
|
1450
|
-
setIsSubmenu(nextIsSubmenu);
|
|
1451
|
-
}
|
|
1452
|
-
}, [popoverEl]);
|
|
1453
|
-
useEffect(function () {
|
|
1454
|
-
_asyncToGenerator(_regeneratorRuntime().mark(function _callee() {
|
|
1455
|
-
var newMenuItems;
|
|
1456
|
-
return _regeneratorRuntime().wrap(function _callee$(_context) {
|
|
1457
|
-
while (1) {
|
|
1458
|
-
switch (_context.prev = _context.next) {
|
|
1459
|
-
case 0:
|
|
1460
|
-
if (!(typeof props.items === 'function')) {
|
|
1461
|
-
_context.next = 13;
|
|
1462
|
-
break;
|
|
1463
|
-
}
|
|
1464
|
-
|
|
1465
|
-
_context.prev = 1;
|
|
1466
|
-
_context.next = 4;
|
|
1467
|
-
return props.items();
|
|
1468
|
-
|
|
1469
|
-
case 4:
|
|
1470
|
-
newMenuItems = _context.sent;
|
|
1471
|
-
newMenuItems = pipedTextDataAdapter(newMenuItems);
|
|
1472
|
-
setMenuItems(newMenuItems);
|
|
1473
|
-
_context.next = 12;
|
|
1474
|
-
break;
|
|
1475
|
-
|
|
1476
|
-
case 9:
|
|
1477
|
-
_context.prev = 9;
|
|
1478
|
-
_context.t0 = _context["catch"](1);
|
|
1479
|
-
setIsLoadError(true);
|
|
1480
|
-
|
|
1481
|
-
case 12:
|
|
1482
|
-
if (typeof optionsRef.current.scheduleUpdate === 'function') {
|
|
1483
|
-
optionsRef.current.scheduleUpdate();
|
|
1484
|
-
}
|
|
1485
|
-
|
|
1486
|
-
case 13:
|
|
1487
|
-
case "end":
|
|
1488
|
-
return _context.stop();
|
|
1489
|
-
}
|
|
1490
|
-
}
|
|
1491
|
-
}, _callee, null, [[1, 9]]);
|
|
1492
|
-
}))();
|
|
1493
|
-
}, [props.items]);
|
|
1494
|
-
useEffect(function () {
|
|
1495
|
-
if (props.show) {
|
|
1496
|
-
setIsMenuOpen(true);
|
|
1497
|
-
}
|
|
1498
|
-
}, [props.show]);
|
|
1499
|
-
useEffect(function () {
|
|
1500
|
-
return function () {
|
|
1501
|
-
return onClose();
|
|
1502
|
-
};
|
|
1503
|
-
}, []);
|
|
1504
|
-
|
|
1505
|
-
var _onClose = function _onClose() {
|
|
1506
|
-
onToggleClick(false);
|
|
1507
|
-
onClose();
|
|
1508
|
-
};
|
|
1509
|
-
|
|
1510
|
-
var reRenderMenus = function reRenderMenus() {
|
|
1511
|
-
var nextMenuItems;
|
|
1512
|
-
nextMenuItems = _cloneDeep(menuItems);
|
|
1513
|
-
setMenuItems(nextMenuItems);
|
|
1514
|
-
};
|
|
1515
|
-
|
|
1516
|
-
var onToggleClick = function onToggleClick(force) {
|
|
1517
|
-
var nextIsMenuOpen;
|
|
1518
|
-
nextIsMenuOpen = typeof force === 'boolean' ? force : !isMenuOpen;
|
|
1519
|
-
setIsMenuOpen(nextIsMenuOpen);
|
|
1520
|
-
};
|
|
1521
|
-
|
|
1522
|
-
var submenuHovered = function submenuHovered(menuItem, evt) {
|
|
1523
|
-
var nextMenuItems;
|
|
1524
|
-
closeSubmenus(menuItems);
|
|
1525
|
-
|
|
1526
|
-
if (!menuItem.show) {
|
|
1527
|
-
menuItem.show = true;
|
|
1528
|
-
}
|
|
1529
|
-
|
|
1530
|
-
nextMenuItems = _cloneDeep(menuItems);
|
|
1531
|
-
setMenuItems(nextMenuItems);
|
|
1532
|
-
};
|
|
1533
|
-
|
|
1534
|
-
var menuItemHovered = function menuItemHovered(menuItem, evt) {
|
|
1535
|
-
var nextMenuItems;
|
|
1536
|
-
closeSubmenus(menuItems);
|
|
1537
|
-
nextMenuItems = _cloneDeep(menuItems);
|
|
1538
|
-
setMenuItems(nextMenuItems);
|
|
1539
|
-
};
|
|
1540
|
-
|
|
1541
|
-
var onSearchInputChange = function onSearchInputChange(evt) {
|
|
1542
|
-
var searchVal;
|
|
1543
|
-
searchVal = evt.target.value;
|
|
1544
|
-
setSearchValue(searchVal);
|
|
1545
|
-
};
|
|
1546
|
-
|
|
1547
|
-
var handleSearchInputClick = function handleSearchInputClick(evt) {
|
|
1548
|
-
evt.stopPropagation();
|
|
1549
|
-
};
|
|
1550
|
-
|
|
1551
|
-
var matchesSearch = function matchesSearch(item) {
|
|
1552
|
-
var searchVal = searchValue || '';
|
|
1553
|
-
searchVal = searchVal.trim().toLowerCase();
|
|
1554
|
-
return JSON.stringify(item).toLowerCase().includes(searchVal);
|
|
1555
|
-
};
|
|
1556
|
-
|
|
1557
|
-
var menuItemClicked = function menuItemClicked(menuItem) {
|
|
1558
|
-
if (!menuItem.disabled) {
|
|
1559
|
-
props.onSelected(menuItem);
|
|
1560
|
-
}
|
|
1561
|
-
|
|
1562
|
-
onClose();
|
|
1563
|
-
};
|
|
1564
|
-
|
|
1565
|
-
var embeddedDataItemClicked = function embeddedDataItemClicked(menuItem, $e) {
|
|
1566
|
-
menuItem.show = true;
|
|
1567
|
-
reRenderMenus();
|
|
1568
|
-
};
|
|
1569
|
-
|
|
1570
|
-
var getPipedTextMenuItems = function getPipedTextMenuItems(menuItems) {
|
|
1571
|
-
var pipedTextMenuItems, nextFocusMenuItems;
|
|
1572
|
-
pipedTextMenuItems = [];
|
|
1573
|
-
nextFocusMenuItems = [];
|
|
1574
|
-
|
|
1575
|
-
if (menuItems.length === 0 && props.allowCustom === true && props.customInputMessage) {
|
|
1576
|
-
return React.createElement("div", null, React.createElement("div", {
|
|
1577
|
-
className: "piped-text-information-message"
|
|
1578
|
-
}, props.customInputMessage));
|
|
1579
|
-
}
|
|
1580
|
-
|
|
1581
|
-
pipedTextMenuItems = menuItems.map(function (menuItem) {
|
|
1582
|
-
var isFocusable, menuItemEl;
|
|
1583
|
-
var menuItemRef = React.createRef();
|
|
1584
|
-
isFocusable = checkMenuItemFocusable(menuItem);
|
|
1585
|
-
menuItemEl = React.createElement(PipedTextMenuItem, {
|
|
1586
|
-
key: menuItem.key,
|
|
1587
|
-
menuItem: menuItem,
|
|
1588
|
-
onSubmenuHover: function onSubmenuHover(menuItem) {
|
|
1589
|
-
submenuHovered(menuItem);
|
|
1590
|
-
},
|
|
1591
|
-
onMenuItemClicked: function onMenuItemClicked(menuItem) {
|
|
1592
|
-
menuItemClicked(menuItem);
|
|
1593
|
-
},
|
|
1594
|
-
onMenuItemHover: function onMenuItemHover(menuItem) {
|
|
1595
|
-
menuItemHovered();
|
|
1596
|
-
},
|
|
1597
|
-
onEmbeddedDataItemClick: function onEmbeddedDataItemClick(menuItem) {
|
|
1598
|
-
embeddedDataItemClicked(menuItem);
|
|
1599
|
-
},
|
|
1600
|
-
ref: menuItemRef
|
|
1601
|
-
});
|
|
1602
|
-
|
|
1603
|
-
if (isFocusable) {
|
|
1604
|
-
nextFocusMenuItems.push(menuItemEl);
|
|
1605
|
-
}
|
|
1606
|
-
|
|
1607
|
-
return menuItemEl;
|
|
1608
|
-
});
|
|
1609
|
-
setFocusMenuItems(nextFocusMenuItems);
|
|
1610
|
-
return pipedTextMenuItems;
|
|
1611
|
-
};
|
|
1612
|
-
|
|
1613
|
-
var handleSearchSubmit = function handleSearchSubmit(e) {
|
|
1614
|
-
e.preventDefault();
|
|
1615
|
-
|
|
1616
|
-
if (!(props.allowCustom === true && props.customScheme)) {
|
|
1617
|
-
return;
|
|
1618
|
-
}
|
|
1619
|
-
|
|
1620
|
-
var value = searchValue.trim();
|
|
1621
|
-
|
|
1622
|
-
if (value === '') {
|
|
1623
|
-
return;
|
|
1624
|
-
}
|
|
1625
|
-
|
|
1626
|
-
var locator = "${".concat(props.customScheme, "://Field/").concat(encodeURIComponent(value), "}");
|
|
1627
|
-
var selected = {
|
|
1628
|
-
value: {
|
|
1629
|
-
locator: locator
|
|
1630
|
-
}
|
|
1631
|
-
};
|
|
1632
|
-
props.onSelected(selected);
|
|
1633
|
-
onClose();
|
|
1634
|
-
};
|
|
1635
|
-
|
|
1636
|
-
var getLoadError = function getLoadError() {
|
|
1637
|
-
return React.createElement("div", {
|
|
1638
|
-
className: "piped-text-popover-container"
|
|
1639
|
-
}, React.createElement("div", {
|
|
1640
|
-
className: "piped-text-error-container"
|
|
1641
|
-
}, React.createElement("div", {
|
|
1642
|
-
className: "piped-text-error-icon"
|
|
1643
|
-
}, React.createElement(ErrorIcon, {
|
|
1644
|
-
size: "medium"
|
|
1645
|
-
})), props.errorText && React.createElement("div", {
|
|
1646
|
-
className: "piped-text-error-text"
|
|
1647
|
-
}, props.errorText)));
|
|
1648
|
-
};
|
|
1649
|
-
|
|
1650
|
-
var getLoadingSpinner = function getLoadingSpinner() {
|
|
1651
|
-
return React.createElement("div", {
|
|
1652
|
-
className: "piped-text-loading-spinner"
|
|
1653
|
-
}, React.createElement(LoadingSpinner, {
|
|
1654
|
-
show: true,
|
|
1655
|
-
size: "medium"
|
|
1656
|
-
}));
|
|
1657
|
-
};
|
|
1658
|
-
|
|
1659
|
-
var getMenuContent = function getMenuContent() {
|
|
1660
|
-
if (isLoadError) {
|
|
1661
|
-
return getLoadError();
|
|
1662
|
-
} else {
|
|
1663
|
-
return React.createElement("div", {
|
|
1664
|
-
className: "piped-text-popover-menu"
|
|
1665
|
-
}, React.createElement("div", {
|
|
1666
|
-
className: "piped-text-search-input"
|
|
1667
|
-
}, React.createElement("form", {
|
|
1668
|
-
onSubmit: handleSearchSubmit
|
|
1669
|
-
}, React.createElement(Input, {
|
|
1670
|
-
small: true,
|
|
1671
|
-
full: true,
|
|
1672
|
-
placeholder: props.searchPlaceholder,
|
|
1673
|
-
className: "q-plugin-popover-input",
|
|
1674
|
-
value: searchValue,
|
|
1675
|
-
onChange: function onChange($e) {
|
|
1676
|
-
return onSearchInputChange($e);
|
|
1677
|
-
},
|
|
1678
|
-
onClick: function onClick($e) {
|
|
1679
|
-
return handleSearchInputClick($e);
|
|
1680
|
-
},
|
|
1681
|
-
ref: searchBoxRefCb
|
|
1682
|
-
}))), menuItems === undefined ? getLoadingSpinner() : menuChildren);
|
|
1683
|
-
}
|
|
1684
|
-
};
|
|
1685
|
-
|
|
1686
|
-
return React.createElement("div", {
|
|
1687
|
-
className: "piped-text-menu"
|
|
1688
|
-
}, React.createElement(Popover, {
|
|
1689
|
-
show: isMenuOpen,
|
|
1690
|
-
onClose: _onClose,
|
|
1691
|
-
placement: props.placement || 'right-start',
|
|
1692
|
-
anchor: props.anchor,
|
|
1693
|
-
ignoreClickSelector: props.ignoreClickSelector
|
|
1694
|
-
}, React.createElement("div", {
|
|
1695
|
-
id: popoverAriaLabelledBy,
|
|
1696
|
-
"aria-labelledby": externalAriaLabelledBy,
|
|
1697
|
-
role: "menu",
|
|
1698
|
-
className: "piped-text-popover-container",
|
|
1699
|
-
ref: popoverRefCb,
|
|
1700
|
-
onFocus: function onFocus($e) {
|
|
1701
|
-
return handleFocus($e);
|
|
1702
|
-
},
|
|
1703
|
-
onKeyDown: function onKeyDown($e) {
|
|
1704
|
-
return handleKeyDown($e);
|
|
1705
|
-
},
|
|
1706
|
-
tabIndex: props.tabIndex !== undefined ? props.tabIndex : -1
|
|
1707
|
-
}, getMenuContent()), React.createElement(OptionsPlaceholder, {
|
|
1708
|
-
optionsRef: optionsRef
|
|
1709
|
-
})));
|
|
1710
|
-
|
|
1711
|
-
function handleKeyDown(evt) {
|
|
1712
|
-
var nextFocusElIdx;
|
|
1713
|
-
|
|
1714
|
-
if (evt.key === 'ArrowDown') {
|
|
1715
|
-
if (higlightedItemIndex < menuChildren.length) {
|
|
1716
|
-
nextFocusElIdx = higlightedItemIndex + 1;
|
|
1717
|
-
menuChildren[nextFocusElIdx];
|
|
1718
|
-
setHighlightedItemIndex(nextFocusElIdx);
|
|
1719
|
-
}
|
|
1720
|
-
} else if (evt.key === 'ArrowUp') ;
|
|
1721
|
-
}
|
|
1722
|
-
|
|
1723
|
-
function handleFocus(evt) {
|
|
1724
|
-
|
|
1725
|
-
evt.stopPropagation();
|
|
1726
|
-
}
|
|
1727
1764
|
});
|
|
1728
1765
|
|
|
1729
|
-
function
|
|
1730
|
-
|
|
1731
|
-
}
|
|
1732
|
-
|
|
1733
|
-
|
|
1734
|
-
|
|
1735
|
-
|
|
1736
|
-
|
|
1737
|
-
|
|
1738
|
-
|
|
1739
|
-
|
|
1740
|
-
|
|
1741
|
-
|
|
1742
|
-
|
|
1743
|
-
|
|
1744
|
-
|
|
1745
|
-
|
|
1746
|
-
|
|
1747
|
-
|
|
1748
|
-
uniqueKey = 1;
|
|
1749
|
-
pipedTextData.forEach(function (pipedTextItem) {
|
|
1750
|
-
pipedTextItem.key = pipedTextItem.key || uniqueKey++;
|
|
1751
|
-
pipedTextItem.hasSubmenu = !!_get(pipedTextItem, 'submenu.items.length') || typeof _get(pipedTextItem, 'submenu.items') === 'function';
|
|
1752
|
-
|
|
1753
|
-
if (pipedTextItem.hasSubmenu || pipedTextItem.value === EMBEDDED_DATA_LOCATOR) {
|
|
1754
|
-
pipedTextItem.show = false;
|
|
1755
|
-
}
|
|
1756
|
-
|
|
1757
|
-
if (pipedTextItem.hasSubmenu) {
|
|
1758
|
-
if (!(typeof pipedTextItem.submenu.items === 'function')) {
|
|
1759
|
-
pipedTextDataAdapter(pipedTextItem.submenu.items, true);
|
|
1760
|
-
}
|
|
1761
|
-
}
|
|
1762
|
-
});
|
|
1763
|
-
return pipedTextData;
|
|
1764
|
-
}
|
|
1765
|
-
|
|
1766
|
-
function checkDefaultMenuItem(menuItem) {
|
|
1767
|
-
return !(checkEmbeddedDataMenuItem(menuItem) || checkDecoratedMenuItem(menuItem) || checkSubmenuMenuItemItem(menuItem));
|
|
1768
|
-
}
|
|
1769
|
-
|
|
1770
|
-
function checkEmbeddedDataMenuItem(menuItem) {
|
|
1771
|
-
return menuItem.value === EMBEDDED_DATA_LOCATOR;
|
|
1772
|
-
}
|
|
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
|
+
});
|
|
1773
1784
|
|
|
1774
|
-
function
|
|
1775
|
-
|
|
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
|
+
});
|
|
1776
2123
|
}
|
|
1777
2124
|
|
|
1778
|
-
|
|
1779
|
-
|
|
1780
|
-
}
|
|
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);
|
|
1781
2127
|
|
|
1782
|
-
|
|
1783
|
-
|
|
1784
|
-
|
|
1785
|
-
|
|
1786
|
-
|
|
1787
|
-
|
|
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;
|
|
1788
2209
|
}
|
|
1789
2210
|
|
|
1790
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";
|
|
@@ -1861,7 +2282,7 @@ function PipedTextSelect(props) {
|
|
|
1861
2282
|
}
|
|
1862
2283
|
}
|
|
1863
2284
|
|
|
1864
|
-
var css_248z$c = ".piped-text-input .piped-text-input-toggle, .piped-text-input .piped-text-select-container {\n display: inline-block; }\n\n.piped-text-input .piped-text-input-toggle {\n display: flex; }\n .piped-text-input .piped-text-input-toggle input {\n flex: 1 1;\n box-sizing: border-box; }\n .piped-text-input .piped-text-input-toggle
|
|
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";
|
|
1865
2286
|
styleInject(css_248z$c);
|
|
1866
2287
|
|
|
1867
2288
|
function PipedTextInput(props) {
|
|
@@ -2171,7 +2592,7 @@ function FieldItem(props) {
|
|
|
2171
2592
|
}, label);
|
|
2172
2593
|
}
|
|
2173
2594
|
|
|
2174
|
-
var css_248z$9 = ".task-fields {\n margin-right: 100px; }\n .task-fields .add-field-button .add-field-button-label {\n padding: 0 3px; }\n .task-fields .field-headers {\n margin-bottom: 10px;\n padding-left: 12px; }\n .task-fields .field-headers .field-row {\n color: #6A6D70;\n font-weight: bold; }\n .task-fields .field-headers .field-row .field-selector label, .task-fields .field-headers .field-row .field-input label {\n font-size: 12px; }\n .task-fields .field-headers .field-row .field-selector {\n padding-top: 0;\n padding-right: 24px;\n padding-bottom: 0;\n padding-left: 0; }\n .task-fields .field-headers .field-row .field-input {\n padding-top: 0;\n padding-right: 0;\n padding-bottom: 0;\n padding-left: 12px; }\n .task-fields .field-rows {\n padding-bottom: 12px; }\n .task-fields .field-rows .field-row {\n border-top: 1px solid #E5E5E5; }\n .task-fields .field-rows .field-row .field-selector {\n padding-top: 8px;\n padding-right: 12px;\n padding-bottom: 8px;\n padding-left: 12px; }\n .task-fields .field-rows .field-row .field-input {\n border-left: 1px solid #E5E5E5;\n padding-top: 8px;\n padding-right: 0;\n padding-bottom: 8px;\n padding-left: 12px; }\n\n.q-popover .field-item {\n padding: 5px 32px; }\n .q-popover .field-item:hover {\n cursor: pointer;\n user-select: none;\n background: #007ac0;\n color: #fff;\n fill: #fff; }\n";
|
|
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";
|
|
2175
2596
|
styleInject(css_248z$9);
|
|
2176
2597
|
|
|
2177
2598
|
var uuidv4 = uuid.v4;
|
|
@@ -2444,6 +2865,9 @@ function TaskFields(props) {
|
|
|
2444
2865
|
}, [props.values]);
|
|
2445
2866
|
return React.createElement("div", {
|
|
2446
2867
|
className: "task-fields"
|
|
2868
|
+
}, React.createElement("div", {
|
|
2869
|
+
className: "field-table",
|
|
2870
|
+
tabIndex: "0"
|
|
2447
2871
|
}, React.createElement("div", {
|
|
2448
2872
|
className: "field-headers"
|
|
2449
2873
|
}, React.createElement(AddFieldHeaders, {
|
|
@@ -2451,7 +2875,7 @@ function TaskFields(props) {
|
|
|
2451
2875
|
inputHeaderText: props.fieldInputsHeaderText
|
|
2452
2876
|
})), React.createElement("div", {
|
|
2453
2877
|
className: "field-rows"
|
|
2454
|
-
}, getFieldRows()), React.createElement("div", {
|
|
2878
|
+
}, getFieldRows())), React.createElement("div", {
|
|
2455
2879
|
className: "add-field-container"
|
|
2456
2880
|
}, React.createElement(AddFieldButton, {
|
|
2457
2881
|
label: props.addFieldLabel,
|
|
@@ -2820,41 +3244,37 @@ function SearchItem(props) {
|
|
|
2820
3244
|
}, props.children);
|
|
2821
3245
|
}
|
|
2822
3246
|
|
|
2823
|
-
var css_248z$5 = ".capture-event .capture-event-controls {\n display: flex;\n align-items: center;\n gap:
|
|
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";
|
|
2824
3248
|
styleInject(css_248z$5);
|
|
2825
3249
|
|
|
2826
3250
|
function CaptureEvent(props) {
|
|
2827
|
-
var _a = useState(props.payload), payload = _a[0]; _a[1];
|
|
2828
|
-
var _b = useState(props.capturing || false), capturing = _b[0], setCapturing = _b[1];
|
|
2829
|
-
var _c = useState(props.waitingForEventTranslation), waitingLabel = _c[0], setWaitingLabel = _c[1];
|
|
2830
3251
|
return (React.createElement("div", { className: "capture-event" },
|
|
2831
3252
|
React.createElement("div", { className: "capture-event-controls" },
|
|
2832
3253
|
getCaptureEventButton(),
|
|
2833
|
-
|
|
2834
|
-
|
|
2835
|
-
|
|
2836
|
-
payload && (React.createElement("div", { className: "payload-block" },
|
|
2837
|
-
React.createElement("div", { className: "payload-label" }, "".concat(props.payloadTranslation, ":")),
|
|
2838
|
-
React.createElement("div", { className: "payload" },
|
|
2839
|
-
React.createElement("pre", null, payload))))));
|
|
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" })))));
|
|
2840
3257
|
function getCaptureEventButton() {
|
|
2841
|
-
if (
|
|
3258
|
+
if (props.status === 'pending') {
|
|
2842
3259
|
return (React.createElement("div", { className: "capture-event-button-container" },
|
|
2843
|
-
React.createElement(Button, { kind: "secondary", onClick:
|
|
3260
|
+
React.createElement(Button, { kind: "secondary", onClick: function () { return props.onCancel(); } }, props.cancelCaptureTranslation)));
|
|
2844
3261
|
}
|
|
2845
3262
|
else {
|
|
2846
3263
|
return (React.createElement("div", { className: "capture-event-button-container" },
|
|
2847
|
-
React.createElement(Button, { kind: "primary", onClick:
|
|
3264
|
+
React.createElement(Button, { kind: "primary", onClick: function () { return props.onStart(); } }, props.startCaptureTranslation)));
|
|
2848
3265
|
}
|
|
2849
3266
|
}
|
|
2850
|
-
function
|
|
2851
|
-
|
|
2852
|
-
|
|
2853
|
-
|
|
2854
|
-
|
|
2855
|
-
|
|
2856
|
-
|
|
2857
|
-
props.
|
|
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));
|
|
2858
3278
|
}
|
|
2859
3279
|
}
|
|
2860
3280
|
|
|
@@ -2913,10 +3333,10 @@ var FieldMapperKey = React.forwardRef(function FieldMapperKey(props, ref) {
|
|
|
2913
3333
|
availableFields = Array.isArray(props.availableFields)
|
|
2914
3334
|
? props.availableFields
|
|
2915
3335
|
: [];
|
|
2916
|
-
onFieldKeyChange = (typeof props.
|
|
2917
|
-
? props.
|
|
3336
|
+
onFieldKeyChange = (typeof props.onChange === 'function')
|
|
3337
|
+
? props.onChange
|
|
2918
3338
|
: function () { return undefined; };
|
|
2919
|
-
return (React.createElement("div", { className: "field-mapper-key", ref: ref }, (React.Children.count(props.children) > 0)
|
|
3339
|
+
return (React.createElement("div", { className: "field-mapper-key" + (props.className ? ' ' + props.className : ''), ref: ref }, (React.Children.count(props.children) > 0)
|
|
2920
3340
|
? props.children
|
|
2921
3341
|
: (React.createElement("div", { className: "field-mapper-key-dropdown" }, fieldMapperKeyDropdownDisabled()
|
|
2922
3342
|
? (React.createElement(Button, { disabled: true }, (_a = props.selectedField) === null || _a === void 0 ? void 0 : _a.label))
|
|
@@ -2951,14 +3371,14 @@ styleInject(css_248z);
|
|
|
2951
3371
|
|
|
2952
3372
|
var FieldMapperValue = React.forwardRef(function FieldMapperValue(props, ref) {
|
|
2953
3373
|
var _a, _b;
|
|
2954
|
-
return (React.createElement("div", { className: "field-mapper-value" }, (React.Children.count(props.children) > 0)
|
|
3374
|
+
return (React.createElement("div", { className: "field-mapper-value" + (props.className ? ' ' + props.className : ''), ref: ref }, (React.Children.count(props.children) > 0)
|
|
2955
3375
|
? props.children
|
|
2956
3376
|
: (React.createElement("div", { className: "piped-text-input-value-container" },
|
|
2957
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; }) })))));
|
|
2958
3378
|
});
|
|
2959
3379
|
|
|
2960
3380
|
var FieldMapperRow = React.forwardRef(function FieldMapperRow(props, ref) {
|
|
2961
|
-
return (React.createElement("div", { className: "field-mapper-row", ref: ref },
|
|
3381
|
+
return (React.createElement("div", { className: "field-mapper-row" + (props.className ? ' ' + props.className : ''), ref: ref },
|
|
2962
3382
|
React.createElement("div", { className: "field-mapper-row-content" },
|
|
2963
3383
|
React.Children.map(props.children, function (child) {
|
|
2964
3384
|
return getWrappedKeyValue(child);
|
|
@@ -2979,8 +3399,8 @@ var FieldMapperRow = React.forwardRef(function FieldMapperRow(props, ref) {
|
|
|
2979
3399
|
var _a, _b, _c, _d;
|
|
2980
3400
|
var wrappedEl;
|
|
2981
3401
|
var fieldMapperKeyProps, fieldMapperValueProps;
|
|
2982
|
-
var includeAvailableFields, includeSelectedField;
|
|
2983
|
-
var includePipedTextItems,
|
|
3402
|
+
var includeAvailableFields, includeSelectedField, includeOnFieldKeyChange;
|
|
3403
|
+
var includePipedTextItems, includeOnFieldValueChange;
|
|
2984
3404
|
fieldMapperKeyProps = {};
|
|
2985
3405
|
fieldMapperValueProps = {};
|
|
2986
3406
|
switch (child.type) {
|
|
@@ -2989,12 +3409,19 @@ var FieldMapperRow = React.forwardRef(function FieldMapperRow(props, ref) {
|
|
|
2989
3409
|
&& (((_a = props.availableFields) === null || _a === void 0 ? void 0 : _a.length) > 0));
|
|
2990
3410
|
includeSelectedField = (((typeof child.props.selectedField) !== 'object')
|
|
2991
3411
|
&& (props.selectedField !== undefined));
|
|
3412
|
+
includeOnFieldKeyChange = (((typeof child.props.onChange) !== 'function')
|
|
3413
|
+
&& ((typeof props.onFieldKeyChange) === 'function'));
|
|
2992
3414
|
if (includeAvailableFields) {
|
|
2993
3415
|
fieldMapperKeyProps.availableFields = (_c = (_b = props.availableFields) === null || _b === void 0 ? void 0 : _b.slice()) !== null && _c !== void 0 ? _c : [];
|
|
2994
3416
|
}
|
|
2995
3417
|
if (includeSelectedField) {
|
|
2996
3418
|
fieldMapperKeyProps.selectedField = Object.assign({}, props.selectedField);
|
|
2997
3419
|
}
|
|
3420
|
+
if (includeOnFieldKeyChange) {
|
|
3421
|
+
fieldMapperKeyProps.onChange = function (prevField, fieldItem) {
|
|
3422
|
+
props.onFieldKeyChange(prevField, fieldItem);
|
|
3423
|
+
};
|
|
3424
|
+
}
|
|
2998
3425
|
if (React.isValidElement(child)
|
|
2999
3426
|
&& (includeAvailableFields
|
|
3000
3427
|
|| includeSelectedField)) {
|
|
@@ -3005,14 +3432,14 @@ var FieldMapperRow = React.forwardRef(function FieldMapperRow(props, ref) {
|
|
|
3005
3432
|
case FieldMapperValue:
|
|
3006
3433
|
includePipedTextItems = (!Array.isArray(child.props.pipedTextItems)
|
|
3007
3434
|
&& (((_d = props.pipedTextItems) === null || _d === void 0 ? void 0 : _d.length) > 0));
|
|
3008
|
-
|
|
3009
|
-
&& ((typeof props.
|
|
3435
|
+
includeOnFieldValueChange = (((typeof child.props.onChange) !== 'function')
|
|
3436
|
+
&& ((typeof props.onFieldValueChange) === 'function'));
|
|
3010
3437
|
if (includePipedTextItems) {
|
|
3011
3438
|
fieldMapperValueProps.pipedTextItems = props.pipedTextItems;
|
|
3012
3439
|
}
|
|
3013
|
-
if (
|
|
3440
|
+
if (includeOnFieldValueChange) {
|
|
3014
3441
|
fieldMapperValueProps.onChange = function (value) {
|
|
3015
|
-
props.
|
|
3442
|
+
props.onFieldValueChange(props.selectedField, value);
|
|
3016
3443
|
};
|
|
3017
3444
|
}
|
|
3018
3445
|
if (React.isValidElement(child)
|
|
@@ -3065,7 +3492,7 @@ var FieldMapper = React.forwardRef(function FieldMapper(props, ref) {
|
|
|
3065
3492
|
var _a, _b, _c;
|
|
3066
3493
|
var wrappedEl;
|
|
3067
3494
|
var fieldMapperRowProps;
|
|
3068
|
-
var includeAvailableFields, includeOnFieldRemove, includePipedTextItems, includeOnFieldValueChange, includeShowRemove;
|
|
3495
|
+
var includeAvailableFields, includeOnFieldRemove, includePipedTextItems, includeOnFieldKeyChange, includeOnFieldValueChange, includeShowRemove;
|
|
3069
3496
|
fieldMapperRowProps = {};
|
|
3070
3497
|
switch (child.type) {
|
|
3071
3498
|
case FieldMapperRow:
|
|
@@ -3080,7 +3507,9 @@ var FieldMapper = React.forwardRef(function FieldMapper(props, ref) {
|
|
|
3080
3507
|
&& ((typeof props.onFieldRemove) === 'function'));
|
|
3081
3508
|
includePipedTextItems = (!Array.isArray(wrappedEl.props.pipedTextItems)
|
|
3082
3509
|
&& (((_b = props.pipedTextItems) === null || _b === void 0 ? void 0 : _b.length) > 0));
|
|
3083
|
-
|
|
3510
|
+
includeOnFieldKeyChange = (((typeof wrappedEl.props.onFieldKeyChange) !== 'function')
|
|
3511
|
+
&& (typeof props.onFieldKeyChange === 'function'));
|
|
3512
|
+
includeOnFieldValueChange = (((typeof wrappedEl.props.onFieldValueChange) !== 'function')
|
|
3084
3513
|
&& (typeof props.onFieldValueChange === 'function'));
|
|
3085
3514
|
includeShowRemove = (((typeof wrappedEl.props.showRemove !== 'boolean'))
|
|
3086
3515
|
&& ((typeof ((_c = child.props.selectedField) === null || _c === void 0 ? void 0 : _c.required)) === 'boolean'));
|
|
@@ -3095,8 +3524,13 @@ var FieldMapper = React.forwardRef(function FieldMapper(props, ref) {
|
|
|
3095
3524
|
if (includePipedTextItems) {
|
|
3096
3525
|
fieldMapperRowProps.pipedTextItems = props.pipedTextItems;
|
|
3097
3526
|
}
|
|
3527
|
+
if (includeOnFieldKeyChange) {
|
|
3528
|
+
fieldMapperRowProps.onFieldKeyChange = function (prevField, fieldItem) {
|
|
3529
|
+
return props.onFieldKeyChange(prevField, fieldItem);
|
|
3530
|
+
};
|
|
3531
|
+
}
|
|
3098
3532
|
if (includeOnFieldValueChange) {
|
|
3099
|
-
fieldMapperRowProps.
|
|
3533
|
+
fieldMapperRowProps.onFieldValueChange = function (fieldItem, inputValue) {
|
|
3100
3534
|
return props.onFieldValueChange(fieldItem, inputValue);
|
|
3101
3535
|
};
|
|
3102
3536
|
}
|