@splunk/react-ui 4.23.0 → 4.25.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/Breadcrumbs.js +99 -124
- package/Button.js +8 -7
- package/ButtonSimple.js +40 -39
- package/CHANGELOG.md +22 -0
- package/Code.js +193 -100
- package/Color.js +18 -15
- package/ComboBox.js +49 -37
- package/JSONTree.js +210 -177
- package/Menu.js +643 -472
- package/Modal.js +265 -226
- package/Multiselect.js +634 -620
- package/RadioList.js +12 -11
- package/ResultsMenu.js +863 -148
- package/Search.js +3 -1
- package/Select.js +427 -416
- package/TabBar.js +2 -2
- package/Table.js +2 -2
- package/Tree.js +617 -0
- package/cypress/README.md +11 -0
- package/cypress/support/commands.ts +1 -0
- package/cypress/support/component.ts +0 -1
- package/cypress/tsconfig.cypress.json +14 -0
- package/package.json +12 -12
- package/types/src/Breadcrumbs/Breadcrumbs.d.ts +7 -1
- package/types/src/Breadcrumbs/Item.d.ts +8 -2
- package/types/src/Button/Button.d.ts +4 -2
- package/types/src/Button/docs/examples/Block.d.ts +2 -2
- package/types/src/Button/docs/examples/Dimmed.d.ts +2 -0
- package/types/src/Button/docs/examples/Disabled.d.ts +2 -2
- package/types/src/Button/docs/examples/Icons.d.ts +2 -2
- package/types/src/Button/docs/examples/Menus.d.ts +2 -2
- package/types/src/Button/docs/examples/To.d.ts +2 -2
- package/types/src/Button/docs/examples/Truncated.d.ts +2 -2
- package/types/src/Button/docs/examples/prisma/Basic.d.ts +2 -2
- package/types/src/Button/docs/examples/prisma/Block.d.ts +2 -2
- package/types/src/Button/docs/examples/prisma/Dimmed.d.ts +2 -0
- package/types/src/Button/docs/examples/prisma/Disabled.d.ts +2 -2
- package/types/src/Button/docs/examples/prisma/Menus.d.ts +2 -2
- package/types/src/Button/docs/examples/prisma/To.d.ts +2 -2
- package/types/src/Button/docs/examples/prisma/Truncated.d.ts +2 -2
- package/types/src/ButtonSimple/ButtonSimple.d.ts +4 -2
- package/types/src/Color/Color.d.ts +5 -3
- package/types/src/ComboBox/ComboBox.d.ts +6 -0
- package/types/src/JSONTree/JSONTree.d.ts +3 -2
- package/types/src/Menu/Menu.d.ts +14 -1
- package/types/src/Modal/Header.d.ts +0 -2
- package/types/src/Modal/Modal.d.ts +7 -0
- package/types/src/Modal/ModalContext.d.ts +1 -0
- package/types/src/Multiselect/Compact.d.ts +6 -0
- package/types/src/Multiselect/Multiselect.d.ts +7 -0
- package/types/src/RadioList/RadioList.d.ts +27 -27
- package/types/src/RadioList/RadioListContext.d.ts +5 -4
- package/types/src/ResultsMenu/ResultsMenu.d.ts +53 -1
- package/types/src/ResultsMenu/VirtualizedResultsMenu/VirtualizedItem.d.ts +9 -0
- package/types/src/ResultsMenu/VirtualizedResultsMenu/VirtualizedResultsMenu.d.ts +33 -0
- package/types/src/ResultsMenu/VirtualizedResultsMenu/groupChildren.d.ts +16 -0
- package/types/src/ResultsMenu/VirtualizedResultsMenu/index.d.ts +3 -0
- package/types/src/ResultsMenu/VirtualizedResultsMenu/injectVirtualizedItem.d.ts +21 -0
- package/types/src/ResultsMenu/index.d.ts +2 -1
- package/types/src/Select/Select.d.ts +2 -0
- package/types/src/Select/SelectBase.d.ts +6 -0
- package/types/src/Tree/Tree.d.ts +24 -0
- package/types/src/Tree/TreeContext.d.ts +13 -0
- package/types/src/Tree/TreeItem.d.ts +31 -0
- package/types/src/Tree/index.d.ts +3 -0
- package/types/src/Tree/treeUtils.d.ts +29 -0
- package/types/unit-test-setup-testing-library.d.ts +1 -0
- package/types/src/Modal/docs/examples/prisma/TypicalUsage.d.ts +0 -2
package/TabBar.js
CHANGED
|
@@ -110,7 +110,7 @@
|
|
|
110
110
|
var m = c()(y()).withConfig({
|
|
111
111
|
displayName: "TabStyles__StyledClickable",
|
|
112
112
|
componentId: "sc-1ry8mzj-0"
|
|
113
|
-
})([ "flex:0 1 auto;display:block;position:relative;line-height:", ";text-align:center;white-space:nowrap;color:", ";&::after{display:block;content:attr(title);font-weight:", ";height:0;color:transparent;overflow:hidden;visibility:hidden;}", ";&[aria-selected='true']{cursor:default;", "}&[aria-selected='false']{box-shadow:none;font-weight:", ";&:hover:not([disabled]){", "}}&:focus{box-shadow:", ";", "}" ], (0,
|
|
113
|
+
})([ "flex:0 1 auto;display:block;position:relative;line-height:", ";text-align:center;white-space:nowrap;color:", ";&::after{display:block;content:attr(data-title);font-weight:", ";height:0;color:transparent;overflow:hidden;visibility:hidden;}", ";&[aria-selected='true']{cursor:default;", "}&[aria-selected='false']{box-shadow:none;font-weight:", ";&:hover:not([disabled]){", "}}&:focus{box-shadow:", ";", "}" ], (0,
|
|
114
114
|
s.pick)({
|
|
115
115
|
enterprise: "24px",
|
|
116
116
|
prisma: "20px"
|
|
@@ -549,7 +549,7 @@
|
|
|
549
549
|
onMouseLeave: this.handleTooltipClose,
|
|
550
550
|
role: "tab",
|
|
551
551
|
tabIndex: r ? undefined : -1,
|
|
552
|
-
title: W,
|
|
552
|
+
"data-title": W,
|
|
553
553
|
to: f
|
|
554
554
|
}), n().createElement(k, {
|
|
555
555
|
"data-test": "label",
|
package/Table.js
CHANGED
|
@@ -816,8 +816,8 @@
|
|
|
816
816
|
}
|
|
817
817
|
}), (0, P.pickVariant)("$appearance", {
|
|
818
818
|
rowLink: {
|
|
819
|
-
enterprise: (0, j.css)([ "color:", ";*:hover >
|
|
820
|
-
prisma: (0, j.css)([ "color:", ";*:hover >
|
|
819
|
+
enterprise: (0, j.css)([ "color:", ";*:hover > &&{cursor:pointer;}" ], P.variables.linkColor),
|
|
820
|
+
prisma: (0, j.css)([ "color:", ";*:hover > &&{cursor:pointer;}" ], P.variables.contentColorDefault)
|
|
821
821
|
},
|
|
822
822
|
link: {
|
|
823
823
|
enterprise: (0, j.css)([ "color:", ";&:hover{cursor:pointer;color:{dark:variables.accentColorL20,light:variables.linkColor,};box-shadow:", ";}&:focus{color:{dark:variables.accentColorL20,light:variables.focusColor,};box-shadow:", ";}" ], P.variables.linkColor, P.variables.focusShadowInset, P.variables.focusShadowInset)
|
package/Tree.js
ADDED
|
@@ -0,0 +1,617 @@
|
|
|
1
|
+
/******/ (() => {
|
|
2
|
+
// webpackBootstrap
|
|
3
|
+
/******/ "use strict";
|
|
4
|
+
/******/ // The require scope
|
|
5
|
+
/******/ var e = {};
|
|
6
|
+
/******/
|
|
7
|
+
/************************************************************************/
|
|
8
|
+
/******/ /* webpack/runtime/compat get default export */
|
|
9
|
+
/******/ (() => {
|
|
10
|
+
/******/ // getDefaultExport function for compatibility with non-harmony modules
|
|
11
|
+
/******/ e.n = r => {
|
|
12
|
+
/******/ var t = r && r.__esModule ?
|
|
13
|
+
/******/ () => r["default"]
|
|
14
|
+
/******/ : () => r
|
|
15
|
+
/******/;
|
|
16
|
+
e.d(t, {
|
|
17
|
+
a: t
|
|
18
|
+
});
|
|
19
|
+
/******/ return t;
|
|
20
|
+
/******/ };
|
|
21
|
+
/******/ })();
|
|
22
|
+
/******/
|
|
23
|
+
/******/ /* webpack/runtime/define property getters */
|
|
24
|
+
/******/ (() => {
|
|
25
|
+
/******/ // define getter functions for harmony exports
|
|
26
|
+
/******/ e.d = (r, t) => {
|
|
27
|
+
/******/ for (var n in t) {
|
|
28
|
+
/******/ if (e.o(t, n) && !e.o(r, n)) {
|
|
29
|
+
/******/ Object.defineProperty(r, n, {
|
|
30
|
+
enumerable: true,
|
|
31
|
+
get: t[n]
|
|
32
|
+
});
|
|
33
|
+
/******/ }
|
|
34
|
+
/******/ }
|
|
35
|
+
/******/ };
|
|
36
|
+
/******/ })();
|
|
37
|
+
/******/
|
|
38
|
+
/******/ /* webpack/runtime/hasOwnProperty shorthand */
|
|
39
|
+
/******/ (() => {
|
|
40
|
+
/******/ e.o = (e, r) => Object.prototype.hasOwnProperty.call(e, r)
|
|
41
|
+
/******/;
|
|
42
|
+
})();
|
|
43
|
+
/******/
|
|
44
|
+
/******/ /* webpack/runtime/make namespace object */
|
|
45
|
+
/******/ (() => {
|
|
46
|
+
/******/ // define __esModule on exports
|
|
47
|
+
/******/ e.r = e => {
|
|
48
|
+
/******/ if (typeof Symbol !== "undefined" && Symbol.toStringTag) {
|
|
49
|
+
/******/ Object.defineProperty(e, Symbol.toStringTag, {
|
|
50
|
+
value: "Module"
|
|
51
|
+
});
|
|
52
|
+
/******/ }
|
|
53
|
+
/******/ Object.defineProperty(e, "__esModule", {
|
|
54
|
+
value: true
|
|
55
|
+
});
|
|
56
|
+
/******/ };
|
|
57
|
+
/******/ })();
|
|
58
|
+
/******/
|
|
59
|
+
/************************************************************************/ var r = {};
|
|
60
|
+
// ESM COMPAT FLAG
|
|
61
|
+
e.r(r);
|
|
62
|
+
// EXPORTS
|
|
63
|
+
e.d(r, {
|
|
64
|
+
TreeItem: () => /* reexport */ k,
|
|
65
|
+
default: () => /* reexport */ re
|
|
66
|
+
});
|
|
67
|
+
// CONCATENATED MODULE: external "react"
|
|
68
|
+
const t = require("react");
|
|
69
|
+
var n = e.n(t);
|
|
70
|
+
// CONCATENATED MODULE: external "prop-types"
|
|
71
|
+
const o = require("prop-types");
|
|
72
|
+
var a = e.n(o);
|
|
73
|
+
// CONCATENATED MODULE: external "@splunk/ui-utils/keyboard"
|
|
74
|
+
const i = require("@splunk/ui-utils/keyboard");
|
|
75
|
+
// CONCATENATED MODULE: ./src/Tree/TreeContext.tsx
|
|
76
|
+
var u = (0, t.createContext)({
|
|
77
|
+
defaultIndent: true
|
|
78
|
+
});
|
|
79
|
+
/* harmony default export */ const l = u;
|
|
80
|
+
// CONCATENATED MODULE: external "styled-components"
|
|
81
|
+
const f = require("styled-components");
|
|
82
|
+
var c = e.n(f);
|
|
83
|
+
// CONCATENATED MODULE: external "@splunk/themes"
|
|
84
|
+
const d = require("@splunk/themes");
|
|
85
|
+
// CONCATENATED MODULE: ./src/Tree/TreeItemStyles.ts
|
|
86
|
+
var v = c().span.withConfig({
|
|
87
|
+
displayName: "TreeItemStyles__StyledTreeItemContent",
|
|
88
|
+
componentId: "ie7zrw-0"
|
|
89
|
+
})([ "font-family:inherit;" ]);
|
|
90
|
+
var s = c().span.withConfig({
|
|
91
|
+
displayName: "TreeItemStyles__StyledTreeItemNode",
|
|
92
|
+
componentId: "ie7zrw-1"
|
|
93
|
+
})([ "&:focus{box-shadow:", ";outline:0;&:active{box-shadow:none;}}" ], d.variables.focusShadow);
|
|
94
|
+
// CONCATENATED MODULE: ./src/Tree/TreeStyles.ts
|
|
95
|
+
var p = c().ul.withConfig({
|
|
96
|
+
displayName: "TreeStyles__StyledUnorderedList",
|
|
97
|
+
componentId: "sc-13pokwt-0"
|
|
98
|
+
})([ "", ";font-family:inherit;list-style:none;", ";" ], d.mixins.reset("ul"), (function(e) {
|
|
99
|
+
var r = e.$defaultIndent;
|
|
100
|
+
return r && (0, f.css)([ "padding-left:", ";" ], d.variables.spacingXXXLarge);
|
|
101
|
+
}));
|
|
102
|
+
// CONCATENATED MODULE: ./src/Tree/TreeItem.tsx
|
|
103
|
+
function y() {
|
|
104
|
+
y = Object.assign || function(e) {
|
|
105
|
+
for (var r = 1; r < arguments.length; r++) {
|
|
106
|
+
var t = arguments[r];
|
|
107
|
+
for (var n in t) {
|
|
108
|
+
if (Object.prototype.hasOwnProperty.call(t, n)) {
|
|
109
|
+
e[n] = t[n];
|
|
110
|
+
}
|
|
111
|
+
}
|
|
112
|
+
}
|
|
113
|
+
return e;
|
|
114
|
+
};
|
|
115
|
+
return y.apply(this, arguments);
|
|
116
|
+
}
|
|
117
|
+
function b(e, r) {
|
|
118
|
+
return w(e) || I(e, r) || h(e, r) || m();
|
|
119
|
+
}
|
|
120
|
+
function m() {
|
|
121
|
+
throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
|
|
122
|
+
}
|
|
123
|
+
function h(e, r) {
|
|
124
|
+
if (!e) return;
|
|
125
|
+
if (typeof e === "string") return g(e, r);
|
|
126
|
+
var t = Object.prototype.toString.call(e).slice(8, -1);
|
|
127
|
+
if (t === "Object" && e.constructor) t = e.constructor.name;
|
|
128
|
+
if (t === "Map" || t === "Set") return Array.from(e);
|
|
129
|
+
if (t === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t)) return g(e, r);
|
|
130
|
+
}
|
|
131
|
+
function g(e, r) {
|
|
132
|
+
if (r == null || r > e.length) r = e.length;
|
|
133
|
+
for (var t = 0, n = new Array(r); t < r; t++) {
|
|
134
|
+
n[t] = e[t];
|
|
135
|
+
}
|
|
136
|
+
return n;
|
|
137
|
+
}
|
|
138
|
+
function I(e, r) {
|
|
139
|
+
if (typeof Symbol === "undefined" || !(Symbol.iterator in Object(e))) return;
|
|
140
|
+
var t = [];
|
|
141
|
+
var n = true;
|
|
142
|
+
var o = false;
|
|
143
|
+
var a = undefined;
|
|
144
|
+
try {
|
|
145
|
+
for (var i = e[Symbol.iterator](), u; !(n = (u = i.next()).done); n = true) {
|
|
146
|
+
t.push(u.value);
|
|
147
|
+
if (r && t.length === r) break;
|
|
148
|
+
}
|
|
149
|
+
} catch (e) {
|
|
150
|
+
o = true;
|
|
151
|
+
a = e;
|
|
152
|
+
} finally {
|
|
153
|
+
try {
|
|
154
|
+
if (!n && i["return"] != null) i["return"]();
|
|
155
|
+
} finally {
|
|
156
|
+
if (o) throw a;
|
|
157
|
+
}
|
|
158
|
+
}
|
|
159
|
+
return t;
|
|
160
|
+
}
|
|
161
|
+
function w(e) {
|
|
162
|
+
if (Array.isArray(e)) return e;
|
|
163
|
+
}
|
|
164
|
+
function O(e, r) {
|
|
165
|
+
if (e == null) return {};
|
|
166
|
+
var t = S(e, r);
|
|
167
|
+
var n, o;
|
|
168
|
+
if (Object.getOwnPropertySymbols) {
|
|
169
|
+
var a = Object.getOwnPropertySymbols(e);
|
|
170
|
+
for (o = 0; o < a.length; o++) {
|
|
171
|
+
n = a[o];
|
|
172
|
+
if (r.indexOf(n) >= 0) continue;
|
|
173
|
+
if (!Object.prototype.propertyIsEnumerable.call(e, n)) continue;
|
|
174
|
+
t[n] = e[n];
|
|
175
|
+
}
|
|
176
|
+
}
|
|
177
|
+
return t;
|
|
178
|
+
}
|
|
179
|
+
function S(e, r) {
|
|
180
|
+
if (e == null) return {};
|
|
181
|
+
var t = {};
|
|
182
|
+
var n = Object.keys(e);
|
|
183
|
+
var o, a;
|
|
184
|
+
for (a = 0; a < n.length; a++) {
|
|
185
|
+
o = n[a];
|
|
186
|
+
if (r.indexOf(o) >= 0) continue;
|
|
187
|
+
t[o] = e[o];
|
|
188
|
+
}
|
|
189
|
+
return t;
|
|
190
|
+
}
|
|
191
|
+
var j = {
|
|
192
|
+
id: a().string,
|
|
193
|
+
children: a().node,
|
|
194
|
+
content: a().node,
|
|
195
|
+
labelledBy: a().string,
|
|
196
|
+
onFocus: a().func,
|
|
197
|
+
open: a().bool
|
|
198
|
+
};
|
|
199
|
+
function A(e) {
|
|
200
|
+
var r = e.id, o = e.children, a = e.content, i = e.labelledBy, u = e.onFocus, f = O(e, [ "id", "children", "content", "labelledBy", "onFocus" ]);
|
|
201
|
+
var c = (0, t.useContext)(l), d = c.defaultIndent, m = d === void 0 ? true : d, h = c.onItemKeyDown, g = c.removeNode, I = c.setNode, w = c.itemPaths, S = c.focusedItemId;
|
|
202
|
+
var j = (0, t.useState)(true), A = b(j, 2), k = A[0], P = A[1];
|
|
203
|
+
var E = (0, t.useRef)(null);
|
|
204
|
+
var x = t.Children.toArray(o).filter(t.isValidElement);
|
|
205
|
+
x.forEach((function(e, t) {
|
|
206
|
+
if (e.props.id) {
|
|
207
|
+
if (k && I) {
|
|
208
|
+
I("".concat(e.props.id), "".concat(w === null || w === void 0 ? void 0 : w.get("".concat(r)), "-").concat(t));
|
|
209
|
+
} else if (g) {
|
|
210
|
+
g(e.props.id);
|
|
211
|
+
}
|
|
212
|
+
}
|
|
213
|
+
}));
|
|
214
|
+
var T = function e(r) {
|
|
215
|
+
P(r);
|
|
216
|
+
};
|
|
217
|
+
var C = function e() {
|
|
218
|
+
P(!k);
|
|
219
|
+
};
|
|
220
|
+
var _ = function e(r) {
|
|
221
|
+
var t;
|
|
222
|
+
r.stopPropagation();
|
|
223
|
+
E === null || E === void 0 ? void 0 : (t = E.current) === null || t === void 0 ? void 0 : t.focus();
|
|
224
|
+
u === null || u === void 0 ? void 0 : u(r);
|
|
225
|
+
};
|
|
226
|
+
if (S === r) {
|
|
227
|
+
var D;
|
|
228
|
+
E === null || E === void 0 ? void 0 : (D = E.current) === null || D === void 0 ? void 0 : D.focus();
|
|
229
|
+
}
|
|
230
|
+
// make first tree item tabbable
|
|
231
|
+
var N = -1;
|
|
232
|
+
if ((w === null || w === void 0 ? void 0 : w.get("".concat(r))) === "0") {
|
|
233
|
+
N = 0;
|
|
234
|
+
}
|
|
235
|
+
var $ = function e(r) {
|
|
236
|
+
r.stopPropagation();
|
|
237
|
+
};
|
|
238
|
+
var M = function e(t) {
|
|
239
|
+
t.stopPropagation();
|
|
240
|
+
h === null || h === void 0 ? void 0 : h(t, r, k, x, T);
|
|
241
|
+
};
|
|
242
|
+
|
|
243
|
+
return n().createElement("li", y({}, f, {
|
|
244
|
+
onFocus: _,
|
|
245
|
+
onKeyDown: M,
|
|
246
|
+
role: "treeitem",
|
|
247
|
+
"aria-labelledby": i,
|
|
248
|
+
"aria-expanded": x.length ? k : undefined
|
|
249
|
+
}), n().createElement(s, {
|
|
250
|
+
ref: E,
|
|
251
|
+
tabIndex: N,
|
|
252
|
+
onFocus: $,
|
|
253
|
+
onClick: C
|
|
254
|
+
}, n().createElement(v, null, a)), k && n().createElement(p, {
|
|
255
|
+
role: "group",
|
|
256
|
+
$defaultIndent: m
|
|
257
|
+
}, o));
|
|
258
|
+
}
|
|
259
|
+
A.propTypes = j;
|
|
260
|
+
/* harmony default export */ const k = A;
|
|
261
|
+
// CONCATENATED MODULE: ./src/Tree/treeUtils.ts
|
|
262
|
+
function P(e, r) {
|
|
263
|
+
return _(e) || C(e, r) || x(e, r) || E();
|
|
264
|
+
}
|
|
265
|
+
function E() {
|
|
266
|
+
throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
|
|
267
|
+
}
|
|
268
|
+
function x(e, r) {
|
|
269
|
+
if (!e) return;
|
|
270
|
+
if (typeof e === "string") return T(e, r);
|
|
271
|
+
var t = Object.prototype.toString.call(e).slice(8, -1);
|
|
272
|
+
if (t === "Object" && e.constructor) t = e.constructor.name;
|
|
273
|
+
if (t === "Map" || t === "Set") return Array.from(e);
|
|
274
|
+
if (t === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t)) return T(e, r);
|
|
275
|
+
}
|
|
276
|
+
function T(e, r) {
|
|
277
|
+
if (r == null || r > e.length) r = e.length;
|
|
278
|
+
for (var t = 0, n = new Array(r); t < r; t++) {
|
|
279
|
+
n[t] = e[t];
|
|
280
|
+
}
|
|
281
|
+
return n;
|
|
282
|
+
}
|
|
283
|
+
function C(e, r) {
|
|
284
|
+
if (typeof Symbol === "undefined" || !(Symbol.iterator in Object(e))) return;
|
|
285
|
+
var t = [];
|
|
286
|
+
var n = true;
|
|
287
|
+
var o = false;
|
|
288
|
+
var a = undefined;
|
|
289
|
+
try {
|
|
290
|
+
for (var i = e[Symbol.iterator](), u; !(n = (u = i.next()).done); n = true) {
|
|
291
|
+
t.push(u.value);
|
|
292
|
+
if (r && t.length === r) break;
|
|
293
|
+
}
|
|
294
|
+
} catch (e) {
|
|
295
|
+
o = true;
|
|
296
|
+
a = e;
|
|
297
|
+
} finally {
|
|
298
|
+
try {
|
|
299
|
+
if (!n && i["return"] != null) i["return"]();
|
|
300
|
+
} finally {
|
|
301
|
+
if (o) throw a;
|
|
302
|
+
}
|
|
303
|
+
}
|
|
304
|
+
return t;
|
|
305
|
+
}
|
|
306
|
+
function _(e) {
|
|
307
|
+
if (Array.isArray(e)) return e;
|
|
308
|
+
}
|
|
309
|
+
/**
|
|
310
|
+
* A helper function to get first key in Map that matches given value
|
|
311
|
+
*/ function D(e, r) {
|
|
312
|
+
var t;
|
|
313
|
+
var n = Array.from(e.entries());
|
|
314
|
+
return (t = n.find((function(e) {
|
|
315
|
+
var t = P(e, 2), n = t[1];
|
|
316
|
+
return n === r;
|
|
317
|
+
}))) === null || t === void 0 ? void 0 : t[0];
|
|
318
|
+
}
|
|
319
|
+
/**
|
|
320
|
+
* A helper function to get parent path of current item path
|
|
321
|
+
*/ function N(e) {
|
|
322
|
+
// remove last index number of the current item path string to get parent
|
|
323
|
+
return e.split("-").slice(0, -1).join("-");
|
|
324
|
+
}
|
|
325
|
+
/**
|
|
326
|
+
* A helper function to get next path of current item path in same level
|
|
327
|
+
*/ function $(e, r) {
|
|
328
|
+
return e === null || e === void 0 ? void 0 : e.replace(/([^-]*)$/, "".concat(r + 1));
|
|
329
|
+
}
|
|
330
|
+
/**
|
|
331
|
+
* A helper function to get the last index number of an item path string
|
|
332
|
+
*/ function M(e) {
|
|
333
|
+
var r = e.split("-").pop();
|
|
334
|
+
if (!r) {
|
|
335
|
+
return 0;
|
|
336
|
+
}
|
|
337
|
+
return parseInt(r, 10) || 0;
|
|
338
|
+
}
|
|
339
|
+
function q(e, r) {
|
|
340
|
+
var t = e.get(r);
|
|
341
|
+
if (!t) {
|
|
342
|
+
return r;
|
|
343
|
+
}
|
|
344
|
+
var n = N(t);
|
|
345
|
+
return D(e, n) || r;
|
|
346
|
+
}
|
|
347
|
+
/**
|
|
348
|
+
* A helper function for getNextTreeItem
|
|
349
|
+
*/ function F(e, r) {
|
|
350
|
+
var t = N(r);
|
|
351
|
+
if (!t) {
|
|
352
|
+
return D(e, r);
|
|
353
|
+
}
|
|
354
|
+
// get next node in the parent level
|
|
355
|
+
var n = M(t);
|
|
356
|
+
var o = $(t, n);
|
|
357
|
+
var a = D(e, o);
|
|
358
|
+
if (a) {
|
|
359
|
+
return a;
|
|
360
|
+
}
|
|
361
|
+
// continue getting parents until find next node or reach root
|
|
362
|
+
return F(e, o);
|
|
363
|
+
}
|
|
364
|
+
function U(e, r) {
|
|
365
|
+
var t = e.get(r);
|
|
366
|
+
if (!t) {
|
|
367
|
+
return r;
|
|
368
|
+
}
|
|
369
|
+
// case where next tree item is the first visible child
|
|
370
|
+
var n = D(e, "".concat(t, "-0"));
|
|
371
|
+
if (n) {
|
|
372
|
+
return n;
|
|
373
|
+
}
|
|
374
|
+
// case where next tree item is the next node in the same level
|
|
375
|
+
var o = M(t);
|
|
376
|
+
var a = $(t, o);
|
|
377
|
+
var i = D(e, a);
|
|
378
|
+
if (i) {
|
|
379
|
+
return i;
|
|
380
|
+
}
|
|
381
|
+
// case where next tree item is a higher level or does not exist
|
|
382
|
+
return F(e, t) || r;
|
|
383
|
+
}
|
|
384
|
+
/**
|
|
385
|
+
* A helper function for getPrevTreeItem
|
|
386
|
+
*/ function B(e, r) {
|
|
387
|
+
var t = D(e, "".concat(r, "-0"));
|
|
388
|
+
if (!t) {
|
|
389
|
+
return D(e, r);
|
|
390
|
+
}
|
|
391
|
+
var n = D(e, r);
|
|
392
|
+
var o = "".concat(r, "-0");
|
|
393
|
+
// get the last child in current node, and continue to find its children recursively
|
|
394
|
+
while (n) {
|
|
395
|
+
var a = M(o);
|
|
396
|
+
var i = $(o, a);
|
|
397
|
+
n = D(e, i);
|
|
398
|
+
if (n) {
|
|
399
|
+
o = i;
|
|
400
|
+
}
|
|
401
|
+
}
|
|
402
|
+
return B(e, o);
|
|
403
|
+
}
|
|
404
|
+
function K(e, r) {
|
|
405
|
+
var t = e.get(r);
|
|
406
|
+
if (!t) {
|
|
407
|
+
return r;
|
|
408
|
+
}
|
|
409
|
+
var n = M(t);
|
|
410
|
+
// case where current is first child of parent or root item
|
|
411
|
+
if (n === 0) {
|
|
412
|
+
return q(e, r);
|
|
413
|
+
}
|
|
414
|
+
// case where previous tree item is or is a child of previous node in same level
|
|
415
|
+
var o = t.replace(/[^-]+$/, "".concat(n - 1));
|
|
416
|
+
return B(e, o) || r;
|
|
417
|
+
}
|
|
418
|
+
function X(e) {
|
|
419
|
+
return D(e, "0");
|
|
420
|
+
}
|
|
421
|
+
function z(e) {
|
|
422
|
+
var r = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : "0";
|
|
423
|
+
var t = D(e, r);
|
|
424
|
+
var n = r;
|
|
425
|
+
// find last child in current node
|
|
426
|
+
while (t) {
|
|
427
|
+
var o = M(n);
|
|
428
|
+
t = D(e, $(n, o));
|
|
429
|
+
if (t) {
|
|
430
|
+
n = $(n, o);
|
|
431
|
+
}
|
|
432
|
+
}
|
|
433
|
+
// check if last child has children
|
|
434
|
+
var a = D(e, "".concat(n, "-0"));
|
|
435
|
+
if (!a) {
|
|
436
|
+
return D(e, n);
|
|
437
|
+
}
|
|
438
|
+
// continue to find its last child recursively
|
|
439
|
+
n = "".concat(n, "-0");
|
|
440
|
+
return z(e, n);
|
|
441
|
+
}
|
|
442
|
+
// CONCATENATED MODULE: ./src/Tree/Tree.tsx
|
|
443
|
+
function L() {
|
|
444
|
+
L = Object.assign || function(e) {
|
|
445
|
+
for (var r = 1; r < arguments.length; r++) {
|
|
446
|
+
var t = arguments[r];
|
|
447
|
+
for (var n in t) {
|
|
448
|
+
if (Object.prototype.hasOwnProperty.call(t, n)) {
|
|
449
|
+
e[n] = t[n];
|
|
450
|
+
}
|
|
451
|
+
}
|
|
452
|
+
}
|
|
453
|
+
return e;
|
|
454
|
+
};
|
|
455
|
+
return L.apply(this, arguments);
|
|
456
|
+
}
|
|
457
|
+
function V(e, r) {
|
|
458
|
+
return Q(e) || J(e, r) || G(e, r) || R();
|
|
459
|
+
}
|
|
460
|
+
function R() {
|
|
461
|
+
throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
|
|
462
|
+
}
|
|
463
|
+
function G(e, r) {
|
|
464
|
+
if (!e) return;
|
|
465
|
+
if (typeof e === "string") return H(e, r);
|
|
466
|
+
var t = Object.prototype.toString.call(e).slice(8, -1);
|
|
467
|
+
if (t === "Object" && e.constructor) t = e.constructor.name;
|
|
468
|
+
if (t === "Map" || t === "Set") return Array.from(e);
|
|
469
|
+
if (t === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t)) return H(e, r);
|
|
470
|
+
}
|
|
471
|
+
function H(e, r) {
|
|
472
|
+
if (r == null || r > e.length) r = e.length;
|
|
473
|
+
for (var t = 0, n = new Array(r); t < r; t++) {
|
|
474
|
+
n[t] = e[t];
|
|
475
|
+
}
|
|
476
|
+
return n;
|
|
477
|
+
}
|
|
478
|
+
function J(e, r) {
|
|
479
|
+
if (typeof Symbol === "undefined" || !(Symbol.iterator in Object(e))) return;
|
|
480
|
+
var t = [];
|
|
481
|
+
var n = true;
|
|
482
|
+
var o = false;
|
|
483
|
+
var a = undefined;
|
|
484
|
+
try {
|
|
485
|
+
for (var i = e[Symbol.iterator](), u; !(n = (u = i.next()).done); n = true) {
|
|
486
|
+
t.push(u.value);
|
|
487
|
+
if (r && t.length === r) break;
|
|
488
|
+
}
|
|
489
|
+
} catch (e) {
|
|
490
|
+
o = true;
|
|
491
|
+
a = e;
|
|
492
|
+
} finally {
|
|
493
|
+
try {
|
|
494
|
+
if (!n && i["return"] != null) i["return"]();
|
|
495
|
+
} finally {
|
|
496
|
+
if (o) throw a;
|
|
497
|
+
}
|
|
498
|
+
}
|
|
499
|
+
return t;
|
|
500
|
+
}
|
|
501
|
+
function Q(e) {
|
|
502
|
+
if (Array.isArray(e)) return e;
|
|
503
|
+
}
|
|
504
|
+
function W(e, r) {
|
|
505
|
+
if (e == null) return {};
|
|
506
|
+
var t = Y(e, r);
|
|
507
|
+
var n, o;
|
|
508
|
+
if (Object.getOwnPropertySymbols) {
|
|
509
|
+
var a = Object.getOwnPropertySymbols(e);
|
|
510
|
+
for (o = 0; o < a.length; o++) {
|
|
511
|
+
n = a[o];
|
|
512
|
+
if (r.indexOf(n) >= 0) continue;
|
|
513
|
+
if (!Object.prototype.propertyIsEnumerable.call(e, n)) continue;
|
|
514
|
+
t[n] = e[n];
|
|
515
|
+
}
|
|
516
|
+
}
|
|
517
|
+
return t;
|
|
518
|
+
}
|
|
519
|
+
function Y(e, r) {
|
|
520
|
+
if (e == null) return {};
|
|
521
|
+
var t = {};
|
|
522
|
+
var n = Object.keys(e);
|
|
523
|
+
var o, a;
|
|
524
|
+
for (a = 0; a < n.length; a++) {
|
|
525
|
+
o = n[a];
|
|
526
|
+
if (r.indexOf(o) >= 0) continue;
|
|
527
|
+
t[o] = e[o];
|
|
528
|
+
}
|
|
529
|
+
return t;
|
|
530
|
+
}
|
|
531
|
+
var Z = {
|
|
532
|
+
children: a().node,
|
|
533
|
+
defaultIndent: a().bool
|
|
534
|
+
};
|
|
535
|
+
function ee(e) {
|
|
536
|
+
var r = e.children, o = e.defaultIndent, a = o === void 0 ? true : o, u = W(e, [ "children", "defaultIndent" ]);
|
|
537
|
+
var f = (0, t.useState)(), c = V(f, 2), d = c[0], v = c[1];
|
|
538
|
+
var s = new Map;
|
|
539
|
+
var y = function e(r, t, n, o, a) {
|
|
540
|
+
var u = (0, i.keycode)(r.nativeEvent);
|
|
541
|
+
r.stopPropagation();
|
|
542
|
+
switch (u) {
|
|
543
|
+
case "up":
|
|
544
|
+
r.preventDefault();
|
|
545
|
+
v(K(s, t));
|
|
546
|
+
break;
|
|
547
|
+
|
|
548
|
+
case "down":
|
|
549
|
+
r.preventDefault();
|
|
550
|
+
v(U(s, t));
|
|
551
|
+
break;
|
|
552
|
+
|
|
553
|
+
case "left":
|
|
554
|
+
r.preventDefault();
|
|
555
|
+
if (n && (o === null || o === void 0 ? void 0 : o.length)) {
|
|
556
|
+
a(false);
|
|
557
|
+
} else {
|
|
558
|
+
v(q(s, t));
|
|
559
|
+
}
|
|
560
|
+
break;
|
|
561
|
+
|
|
562
|
+
case "right":
|
|
563
|
+
r.preventDefault();
|
|
564
|
+
if (n && (o === null || o === void 0 ? void 0 : o.length)) {
|
|
565
|
+
v(U(s, t));
|
|
566
|
+
} else {
|
|
567
|
+
a(true);
|
|
568
|
+
}
|
|
569
|
+
break;
|
|
570
|
+
|
|
571
|
+
case "home":
|
|
572
|
+
r.preventDefault();
|
|
573
|
+
v(X(s));
|
|
574
|
+
break;
|
|
575
|
+
|
|
576
|
+
case "end":
|
|
577
|
+
r.preventDefault();
|
|
578
|
+
v(z(s));
|
|
579
|
+
break;
|
|
580
|
+
|
|
581
|
+
default:
|
|
582
|
+
// do nothing
|
|
583
|
+
}
|
|
584
|
+
};
|
|
585
|
+
var b = function e(r) {
|
|
586
|
+
s["delete"](r);
|
|
587
|
+
};
|
|
588
|
+
var m = function e(r, t) {
|
|
589
|
+
s.set(r, t);
|
|
590
|
+
};
|
|
591
|
+
var h = t.Children.toArray(r).filter(t.isValidElement);
|
|
592
|
+
h.forEach((function(e, r) {
|
|
593
|
+
if (e.props.id && m) {
|
|
594
|
+
m("".concat(e.props.id), "".concat(r));
|
|
595
|
+
}
|
|
596
|
+
}));
|
|
597
|
+
|
|
598
|
+
return n().createElement(l.Provider, {
|
|
599
|
+
value: {
|
|
600
|
+
defaultIndent: a,
|
|
601
|
+
onItemKeyDown: y,
|
|
602
|
+
removeNode: b,
|
|
603
|
+
setNode: m,
|
|
604
|
+
itemPaths: s,
|
|
605
|
+
focusedItemId: d
|
|
606
|
+
}
|
|
607
|
+
}, n().createElement(p, L({
|
|
608
|
+
role: "tree",
|
|
609
|
+
$defaultIndent: a
|
|
610
|
+
}, u), r));
|
|
611
|
+
}
|
|
612
|
+
ee.propTypes = Z;
|
|
613
|
+
ee.TreeItem = k;
|
|
614
|
+
/* harmony default export */ const re = ee;
|
|
615
|
+
// CONCATENATED MODULE: ./src/Tree/index.ts
|
|
616
|
+
module.exports = r;
|
|
617
|
+
/******/})();
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
#TS Configuration
|
|
2
|
+
|
|
3
|
+
Cypress' expect type clashes with Jest's: see https://docs.cypress.io/guides/tooling/typescript-support#Clashing-types-with-Jest.
|
|
4
|
+
To get around this we use separate tsconfigs to check src files from Cypress tests (.spec.tsx) files, following [cypress' example](https://github.com/cypress-io/cypress-and-jest-typescript-example)
|
|
5
|
+
|
|
6
|
+
There are some notable specifics in the cypress config that need to be maintained:
|
|
7
|
+
* Cypress tests only need to be compiled but do not have public types, so this config sets `"noEmit": true,`
|
|
8
|
+
* When types are specified they must be relative paths to the tsconfig, hence the `../node_modules`.
|
|
9
|
+
* The inheritance method when using `extends` means that `include` and `exclude` entries need to be explicitly listed or repeated. This affects:
|
|
10
|
+
* Common types, jest and cypress types.
|
|
11
|
+
* `include` must be repeated in `cypress.tsconfig` so that `.spec` files are not excluded
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
// Cypress tests (.spec.tsx files) need a separate config to avoid clashing types with jest, see README for more details
|
|
2
|
+
{
|
|
3
|
+
"extends": "../tsconfig.json",
|
|
4
|
+
"compilerOptions": {
|
|
5
|
+
"noEmit": true,
|
|
6
|
+
"types": [
|
|
7
|
+
"../../../node_modules/@testing-library/cypress",
|
|
8
|
+
"../../../node_modules/cypress",
|
|
9
|
+
"../../../node_modules/cypress-real-events"
|
|
10
|
+
]
|
|
11
|
+
},
|
|
12
|
+
"include": ["../stubs-*.d.ts", "../src/**/tests/*.spec.tsx", "../src/**/tests/*.spec.ts"],
|
|
13
|
+
"exclude": ["../src/docs/*"]
|
|
14
|
+
}
|