@splunk/react-ui 5.0.0-beta.5 → 5.0.0-rc.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.
Files changed (52) hide show
  1. package/ButtonSimple.js +92 -168
  2. package/{CHANGELOG.v5.mdx → CHANGELOG.v5.md} +43 -0
  3. package/Calendar.js +148 -151
  4. package/Card.js +139 -139
  5. package/Code.js +197 -167
  6. package/CollapsiblePanel.js +172 -164
  7. package/Color.js +584 -506
  8. package/ComboBox.js +51 -51
  9. package/ControlGroup.js +132 -127
  10. package/Date.js +137 -150
  11. package/Dropdown.js +97 -96
  12. package/DualListbox.js +468 -469
  13. package/FetchOptions.d.ts +2 -2
  14. package/FormRows.js +158 -157
  15. package/JSONTree.js +354 -360
  16. package/{MIGRATION.mdx → MIGRATION.md} +13 -43
  17. package/{MIGRATION.v5.mdx → MIGRATION.v5.md} +67 -1
  18. package/Markdown.js +3 -4
  19. package/Menu.js +194 -195
  20. package/Modal.js +18 -18
  21. package/ModalLayer.js +171 -217
  22. package/Multiselect.js +785 -778
  23. package/Number.js +103 -102
  24. package/Popover.js +48 -46
  25. package/RadioBar.js +144 -146
  26. package/Resize.js +149 -151
  27. package/ResultsMenu.js +112 -114
  28. package/Search.js +49 -49
  29. package/Select.js +455 -457
  30. package/Slider.js +328 -331
  31. package/Switch.js +251 -178
  32. package/TabBar.js +277 -280
  33. package/Table.js +1212 -1178
  34. package/Text.js +45 -46
  35. package/Tooltip.js +192 -189
  36. package/Tree.js +177 -188
  37. package/package.json +10 -9
  38. package/types/src/Code/Code.d.ts +1 -1
  39. package/types/src/Color/Color.d.ts +2 -2
  40. package/types/src/ControlGroup/ControlGroup.d.ts +1 -2
  41. package/types/src/Dropdown/Dropdown.d.ts +5 -2
  42. package/types/src/Layer/Layer.d.ts +2 -1
  43. package/types/src/Layer/index.d.ts +1 -0
  44. package/types/src/ModalLayer/ModalLayer.d.ts +16 -21
  45. package/types/src/Number/Number.d.ts +1 -1
  46. package/types/src/Popover/Popover.d.ts +5 -2
  47. package/types/src/Table/HeadCell.d.ts +6 -1
  48. package/types/src/Table/HeadInner.d.ts +3 -1
  49. package/types/src/Tooltip/Tooltip.d.ts +7 -7
  50. package/types/src/fixtures/useFetchOptions.d.ts +33 -0
  51. package/useRovingFocus.js +20 -23
  52. package/types/src/fixtures/FetchOptions.d.ts +0 -76
package/Dropdown.js CHANGED
@@ -69,16 +69,14 @@
69
69
  // CONCATENATED MODULE: external "prop-types"
70
70
  const t = require("prop-types");
71
71
  var a = e.n(t);
72
- // CONCATENATED MODULE: external "@splunk/ui-utils/id"
73
- const l = require("@splunk/ui-utils/id");
74
- // CONCATENATED MODULE: external "@splunk/ui-utils/keyboard"
75
- const i = require("@splunk/ui-utils/keyboard");
76
72
  // CONCATENATED MODULE: external "@splunk/react-ui/Popover"
77
- const u = require("@splunk/react-ui/Popover");
78
- var c = e.n(u);
73
+ const l = require("@splunk/react-ui/Popover");
74
+ var i = e.n(l);
79
75
  // CONCATENATED MODULE: external "@splunk/react-ui/useControlled"
80
- const s = require("@splunk/react-ui/useControlled");
81
- var f = e.n(s);
76
+ const u = require("@splunk/react-ui/useControlled");
77
+ var c = e.n(u);
78
+ // CONCATENATED MODULE: external "@splunk/ui-utils/id"
79
+ const s = require("@splunk/ui-utils/id");
82
80
  // CONCATENATED MODULE: ./src/utils/updateReactRef.ts
83
81
  /**
84
82
  * Updates a React ref. Callback refs and object refs (from `createRef` and `useRef`) are supported.
@@ -86,7 +84,7 @@
86
84
  * @param ref - The React callback or object ref. Can be `null` or `undefined`.
87
85
  * @param current - The new value of the ref.
88
86
  */
89
- function d(e, o) {
87
+ function f(e, o) {
90
88
  if (e) {
91
89
  if (typeof e === "function") {
92
90
  e(o);
@@ -99,27 +97,27 @@
99
97
  }
100
98
  }
101
99
  // CONCATENATED MODULE: ./src/Dropdown/Dropdown.tsx
102
- function p(e, o) {
103
- return m(e) || b(e, o) || y(e, o) || v();
100
+ function d(e, o) {
101
+ return b(e) || g(e, o) || v(e, o) || p();
104
102
  }
105
- function v() {
103
+ function p() {
106
104
  throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
107
105
  }
108
- function y(e, o) {
106
+ function v(e, o) {
109
107
  if (e) {
110
- if ("string" == typeof e) return g(e, o);
108
+ if ("string" == typeof e) return y(e, o);
111
109
  var n = {}.toString.call(e).slice(8, -1);
112
- return "Object" === n && e.constructor && (n = e.constructor.name), "Map" === n || "Set" === n ? Array.from(e) : "Arguments" === n || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n) ? g(e, o) : void 0;
110
+ return "Object" === n && e.constructor && (n = e.constructor.name), "Map" === n || "Set" === n ? Array.from(e) : "Arguments" === n || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n) ? y(e, o) : void 0;
113
111
  }
114
112
  }
115
- function g(e, o) {
113
+ function y(e, o) {
116
114
  (null == o || o > e.length) && (o = e.length);
117
115
  for (var n = 0, r = Array(o); n < o; n++) {
118
116
  r[n] = e[n];
119
117
  }
120
118
  return r;
121
119
  }
122
- function b(e, o) {
120
+ function g(e, o) {
123
121
  var n = null == e ? null : "undefined" != typeof Symbol && e[Symbol.iterator] || e["@@iterator"];
124
122
  if (null != n) {
125
123
  var r, t, a, l, i = [], u = !0, c = !1;
@@ -141,7 +139,7 @@
141
139
  return i;
142
140
  }
143
141
  }
144
- function m(e) {
142
+ function b(e) {
145
143
  if (Array.isArray(e)) return e;
146
144
  }
147
145
  /** @public */
@@ -150,16 +148,18 @@
150
148
  /** @public */
151
149
  /** @public */
152
150
  /** @public */
153
- /** @public */ var k = [ "clickAway", "contentClick", "escapeKey", "offScreen", "tabKey", "toggleClick" ];
154
- var C = [ "contentClick", "escapeKey", "tabKey", "toggleClick" ];
151
+ /** @public */
152
+ /** @public */ var m = [ "toggleClick", "toggleKeydown" ];
153
+ var C = [ "clickAway", "contentClick", "escapeKey", "offScreen", "tabKey", "toggleClick" ];
154
+ var k = [ "contentClick", "escapeKey", "tabKey", "toggleClick" ];
155
155
  var h = {
156
156
  align: a().oneOf([ "center", "edge", "end" ]),
157
157
  canCoverAnchor: a().bool,
158
158
  children: a().oneOfType([ a().node, a().func ]),
159
- closeReasons: a().arrayOf(a().oneOf(k)),
159
+ closeReasons: a().arrayOf(a().oneOf(C)),
160
160
  defaultPlacement: a().oneOf([ "above", "below", "left", "right", "vertical", "horizontal" ]),
161
161
  elementRef: a().oneOfType([ a().func, a().object ]),
162
- focusToggleReasons: a().arrayOf(a().oneOf(k)),
162
+ focusToggleReasons: a().arrayOf(a().oneOf(C)),
163
163
  inputId: a().string,
164
164
  onRequestClose: a().func,
165
165
  onRequestOpen: a().func,
@@ -171,12 +171,12 @@
171
171
  toggle: a().element.isRequired
172
172
  };
173
173
  function O(e) {
174
- var o = e["aria-labelledby"], t = e.align, a = t === void 0 ? "center" : t, u = e.canCoverAnchor, s = u === void 0 ? true : u, v = e.children, y = e.closeReasons, g = y === void 0 ? k : y, b = e.defaultPlacement, m = b === void 0 ? "below" : b, h = e.elementRef, O = e.focusToggleReasons, w = O === void 0 ? C : O, S = e.inputId, R = e.open, A = e.openWithArrowKeys, q = e.onRequestClose, I = e.onRequestOpen, P = e.repositionMode, j = P === void 0 ? "flip" : P, K = e.retainFocus, M = K === void 0 ? false : K, D = e.takeFocus, T = D === void 0 ? true : D, E = e.toggle;
174
+ var o = e["aria-labelledby"], t = e.align, a = t === void 0 ? "center" : t, l = e.canCoverAnchor, u = l === void 0 ? true : l, p = e.children, v = e.closeReasons, y = v === void 0 ? C : v, g = e.defaultPlacement, b = g === void 0 ? "below" : g, m = e.elementRef, h = e.focusToggleReasons, O = h === void 0 ? k : h, w = e.inputId, R = e.open, S = e.openWithArrowKeys, A = e.onRequestClose, q = e.onRequestOpen, I = e.repositionMode, P = I === void 0 ? "flip" : I, K = e.retainFocus, j = K === void 0 ? false : K, D = e.takeFocus, M = D === void 0 ? true : D, T = e.toggle;
175
175
  // @docs-props-type DropdownPropsBase
176
- var F = (0, n.useState)(null), N = p(F, 2), _ = N[0], x = N[1];
177
- var W = (0, n.useState)(false), z = p(W, 2), U = z[0], V = z[1];
178
- var $ = (0, n.useRef)(null);
179
- var B = f()({
176
+ var F = (0, n.useState)(null), E = d(F, 2), N = E[0], _ = E[1];
177
+ var x = (0, n.useState)(false), W = d(x, 2), U = W[0], z = W[1];
178
+ var V = (0, n.useRef)(null);
179
+ var $ = c()({
180
180
  componentName: "Dropdown",
181
181
  /* eslint-disable-next-line prefer-rest-params */
182
182
  componentProps: arguments[0],
@@ -184,125 +184,126 @@
184
184
  defaultValuePropName: "defaultOpen",
185
185
  valuePropName: "open"
186
186
  });
187
- var G = B ? R : U;
188
- var H = (0, n.useState)((function() {
187
+ var B = $ ? R : U;
188
+ var G = (0, n.useState)((function() {
189
189
  return {
190
- popoverId: (0, l.createDOMID)("popover"),
191
- toggleId: (0, l.createDOMID)("toggle")
190
+ popoverId: (0, s.createDOMID)("popover"),
191
+ toggleId: (0, s.createDOMID)("toggle")
192
192
  };
193
- })), J = p(H, 1), L = J[0], Q = L.popoverId, X = L.toggleId;
194
- var Y = S || E.props.id || X;
195
- var Z = (0, n.useCallback)((function(e) {
196
- $.current = e;
197
- x(e);
193
+ })), H = d(G, 1), J = H[0], L = J.popoverId, Q = J.toggleId;
194
+ var X = w || T.props.id || Q;
195
+ var Y = (0, n.useCallback)((function(e) {
196
+ V.current = e;
197
+ _(e);
198
198
  // TS: ref does not exist on React.ReactElement - technically, this is undocumented API
199
- d(E.ref, e);
200
- }), [ E ]);
201
- var ee = (0, n.useCallback)((function(e) {
199
+ f(T.ref, e);
200
+ }), [ T ]);
201
+ var Z = (0, n.useCallback)((function(e) {
202
202
  var o, n;
203
- (o = (n = E.props).onKeyDown) === null || o === void 0 ? void 0 : o.call(n, e);
204
- if (!A) {
203
+ (o = (n = T.props).onKeyDown) === null || o === void 0 ? void 0 : o.call(n, e);
204
+ if (!S) {
205
205
  return;
206
206
  }
207
- var r = (0, i.keycode)(e.nativeEvent);
208
- if (r === "up" || r === "down") {
207
+ var r = e.key;
208
+ if (r === "ArrowUp" || r === "ArrowDown") {
209
209
  e.preventDefault();
210
- I === null || I === void 0 ? void 0 : I(e, {
210
+ q === null || q === void 0 ? void 0 : q(e, {
211
211
  reason: "toggleKeydown"
212
212
  });
213
- if (!B) {
214
- V(true);
213
+ if (!$) {
214
+ z(true);
215
215
  }
216
216
  }
217
- }), [ B, A, I, E ]);
218
- var oe = (0, n.useCallback)((function(e) {
217
+ }), [ $, S, q, T ]);
218
+ var ee = (0, n.useCallback)((function(e) {
219
219
  var o = e.event, n = e.reason;
220
220
  if (o && n === "clickAway") {
221
221
  var r = o.target;
222
222
  while (r) {
223
223
  // Ignore clicks on toggle.
224
- if (r.id === Y) {
224
+ if (r.id === X) {
225
225
  return;
226
226
  }
227
227
  r = r.parentNode;
228
228
  }
229
229
  }
230
- if (G && g.includes(n)) {
231
- if (w.includes(n)) {
230
+ if (B && y.includes(n)) {
231
+ if (O.includes(n)) {
232
232
  var t;
233
- (t = $.current) === null || t === void 0 ? void 0 : t.focus();
233
+ (t = V.current) === null || t === void 0 ? void 0 : t.focus();
234
234
  }
235
- if (!B) {
236
- V(false);
235
+ if (!$) {
236
+ z(false);
237
237
  }
238
- q === null || q === void 0 ? void 0 : q(e);
238
+ A === null || A === void 0 ? void 0 : A(e);
239
239
  }
240
- }), [ g, w, B, G, q, Y ]);
241
- var ne = (0, n.useCallback)((function(e) {
242
- oe({
240
+ }), [ y, O, $, B, A, X ]);
241
+ var oe = (0, n.useCallback)((function(e) {
242
+ ee({
243
243
  reason: "contentClick",
244
244
  event: e
245
245
  });
246
- }), [ oe ]);
247
- var re = (0, n.useCallback)((function(e) {
246
+ }), [ ee ]);
247
+ var ne = (0, n.useCallback)((function(e) {
248
248
  var o, n;
249
- (o = (n = E.props).onClick) === null || o === void 0 ? void 0 : o.call(n, e);
250
- if (G) {
251
- oe({
249
+ (o = (n = T.props).onClick) === null || o === void 0 ? void 0 : o.call(n, e);
250
+ if (B) {
251
+ ee({
252
252
  reason: "toggleClick",
253
253
  event: e
254
254
  });
255
255
  } else {
256
- I === null || I === void 0 ? void 0 : I(e, {
256
+ q === null || q === void 0 ? void 0 : q(e, {
257
257
  reason: "toggleClick"
258
258
  });
259
- if (!B) {
260
- V(true);
259
+ if (!$) {
260
+ z(true);
261
261
  }
262
262
  }
263
- }), [ oe, B, G, I, E ]);
264
- var te = (0, n.cloneElement)(E, {
265
- onClick: re,
266
- onKeyDown: ee,
267
- ref: Z,
268
- "aria-controls": G ? Q : undefined,
269
- "aria-haspopup": E.props["aria-haspopup"] || true,
270
- "aria-expanded": G,
271
- "data-test": E.props["data-test"] || "dropdown",
272
- "data-test-popover-id": Q,
273
- id: Y
263
+ }), [ ee, $, B, q, T ]);
264
+ var re = (0, n.cloneElement)(T, {
265
+ onClick: ne,
266
+ onKeyDown: Z,
267
+ ref: Y,
268
+ "aria-controls": B ? L : undefined,
269
+ "aria-haspopup": T.props["aria-haspopup"] || true,
270
+ "aria-expanded": B,
271
+ "data-test": T.props["data-test"] || "dropdown",
272
+ "data-test-popover-id": L,
273
+ id: X
274
274
  });
275
275
 
276
- return r().createElement(r().Fragment, null, te, r().createElement(c(), {
276
+ return r().createElement(r().Fragment, null, re, r().createElement(i(), {
277
277
  align: a,
278
- open: !!_ && G,
279
- autoCloseWhenOffScreen: g.includes("offScreen"),
280
- anchor: _,
281
- canCoverAnchor: s,
282
- elementRef: h,
283
- retainFocus: M,
284
- defaultPlacement: m,
285
- onRequestClose: oe,
286
- repositionMode: j,
287
- id: Q,
288
- "aria-labelledby": "".concat(o !== null && o !== void 0 ? o : "", " ").concat(Y).trim(),
289
- takeFocus: T
290
- }, typeof v === "function" ?
278
+ open: !!N && B,
279
+ autoCloseWhenOffScreen: y.includes("offScreen"),
280
+ anchor: N,
281
+ canCoverAnchor: u,
282
+ elementRef: m,
283
+ retainFocus: j,
284
+ defaultPlacement: b,
285
+ onRequestClose: ee,
286
+ repositionMode: P,
287
+ id: L,
288
+ "aria-labelledby": "".concat(o !== null && o !== void 0 ? o : "", " ").concat(X).trim(),
289
+ takeFocus: M
290
+ }, typeof p === "function" ?
291
291
  // eslint-disable-next-line jsx-a11y/click-events-have-key-events, jsx-a11y/no-static-element-interactions
292
292
  function() {
293
293
 
294
294
  return r().createElement("div", {
295
- onClick: ne
296
- }, v.apply(void 0, arguments));
295
+ onClick: oe
296
+ }, p.apply(void 0, arguments));
297
297
  } :
298
298
 
299
299
  // eslint-disable-next-line jsx-a11y/click-events-have-key-events, jsx-a11y/no-static-element-interactions
300
300
  r().createElement("div", {
301
- onClick: ne
302
- }, v)));
301
+ onClick: oe
302
+ }, p)));
303
303
  }
304
304
  O.propTypes = h;
305
- O.possibleCloseReasons = k;
305
+ O.possibleOpenReasons = m;
306
+ O.possibleCloseReasons = C;
306
307
  /* harmony default export */ const w = O;
307
308
  // CONCATENATED MODULE: ./src/Dropdown/index.ts
308
309
  module.exports = o;