@splunk/react-ui 5.0.0-beta.4 → 5.0.0-beta.5

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 (74) hide show
  1. package/Button.js +3 -1
  2. package/CHANGELOG.md +4 -1
  3. package/CHANGELOG.v5.mdx +35 -0
  4. package/Card.js +163 -162
  5. package/Chip.js +171 -225
  6. package/Clickable.js +79 -76
  7. package/ComboBox.js +1 -1
  8. package/Date.js +160 -184
  9. package/DualListbox.js +439 -504
  10. package/File.js +449 -324
  11. package/FormRows.js +143 -142
  12. package/JSONTree.js +496 -521
  13. package/Layer.js +162 -97
  14. package/Link.js +20 -13
  15. package/MIGRATION.v5.mdx +47 -0
  16. package/Markdown.js +1 -1
  17. package/Message.js +119 -141
  18. package/MessageBar.js +109 -168
  19. package/Multiselect.js +595 -602
  20. package/Popover.js +194 -190
  21. package/Progress.js +68 -54
  22. package/RadioBar.js +4 -1
  23. package/RadioList.js +67 -65
  24. package/Resize.js +377 -265
  25. package/ResultsMenu.js +573 -661
  26. package/ScrollContainerContext.js +13 -9
  27. package/Search.js +1 -1
  28. package/Select.js +206 -199
  29. package/Slider.js +455 -329
  30. package/StepBar.js +2 -2
  31. package/Switch.js +88 -87
  32. package/TabBar.js +322 -317
  33. package/TabLayout.js +34 -34
  34. package/Table.js +548 -525
  35. package/Text.js +20 -19
  36. package/TextArea.js +278 -152
  37. package/Tooltip.js +173 -177
  38. package/Tree.js +2 -2
  39. package/Typography.js +30 -28
  40. package/WaitSpinner.js +6 -11
  41. package/cypress/support/commands.ts +14 -4
  42. package/cypress/support/index.d.ts +1 -1
  43. package/package.json +5 -5
  44. package/stubs-splunkui.d.ts +0 -4
  45. package/types/src/Card/Card.d.ts +3 -1
  46. package/types/src/Card/Header.d.ts +2 -0
  47. package/types/src/Card/docs/examples/HeadingTitle.d.ts +3 -0
  48. package/types/src/Clickable/Clickable.d.ts +11 -3
  49. package/types/src/Link/Link.d.ts +4 -0
  50. package/types/src/Message/Message.d.ts +1 -1
  51. package/types/src/MessageBar/MessageBar.d.ts +1 -1
  52. package/types/src/Multiselect/Multiselect.d.ts +1 -8
  53. package/types/src/Multiselect/Normal.d.ts +1 -7
  54. package/types/src/Multiselect/docs/examples/Children.d.ts +2 -9
  55. package/types/src/Multiselect/docs/examples/Controlled.d.ts +2 -9
  56. package/types/src/Multiselect/docs/examples/CustomizeSelected.d.ts +2 -9
  57. package/types/src/Multiselect/docs/examples/Disabled.d.ts +2 -9
  58. package/types/src/Multiselect/docs/examples/Error.d.ts +2 -9
  59. package/types/src/Multiselect/docs/examples/Fetching.d.ts +2 -22
  60. package/types/src/Multiselect/docs/examples/Headings.d.ts +2 -1
  61. package/types/src/Multiselect/docs/examples/LoadMoreOnScrollBottom.d.ts +2 -25
  62. package/types/src/Multiselect/docs/examples/NewValues.d.ts +2 -9
  63. package/types/src/Multiselect/docs/examples/TabInput.d.ts +2 -9
  64. package/types/src/ResultsMenu/ResultsMenu.d.ts +23 -34
  65. package/types/src/Select/SelectBase.d.ts +2 -2
  66. package/types/src/TabBar/TabBar.d.ts +8 -5
  67. package/types/src/TabBar/TabBarContext.d.ts +1 -1
  68. package/types/src/TabLayout/TabLayout.d.ts +8 -5
  69. package/types/src/Typography/Typography.d.ts +27 -22
  70. package/types/src/Date/Icon.d.ts +0 -3
  71. package/types/src/TabBar/docs/examples/IconsAbove.d.ts +0 -3
  72. package/types/src/TabBar/docs/examples/VerticalIconsAbove.d.ts +0 -3
  73. /package/types/src/TabBar/docs/examples/{IconsLeft.d.ts → Icons.d.ts} +0 -0
  74. /package/types/src/TabBar/docs/examples/{VerticalIconsLeft.d.ts → VerticalIcons.d.ts} +0 -0
package/Slider.js CHANGED
@@ -8,27 +8,27 @@
8
8
  /******/ /* webpack/runtime/compat get default export */
9
9
  /******/ (() => {
10
10
  /******/ // getDefaultExport function for compatibility with non-harmony modules
11
- /******/ e.n = r => {
12
- /******/ var t = r && r.__esModule ?
13
- /******/ () => r["default"]
14
- /******/ : () => r
11
+ /******/ e.n = t => {
12
+ /******/ var r = t && t.__esModule ?
13
+ /******/ () => t["default"]
14
+ /******/ : () => t
15
15
  /******/;
16
- e.d(t, {
17
- a: t
16
+ e.d(r, {
17
+ a: r
18
18
  });
19
- /******/ return t;
19
+ /******/ return r;
20
20
  /******/ };
21
21
  /******/ })();
22
22
  /******/
23
23
  /******/ /* webpack/runtime/define property getters */
24
24
  /******/ (() => {
25
25
  /******/ // define getter functions for harmony exports
26
- /******/ e.d = (r, t) => {
27
- /******/ for (var a in t) {
28
- /******/ if (e.o(t, a) && !e.o(r, a)) {
29
- /******/ Object.defineProperty(r, a, {
26
+ /******/ e.d = (t, r) => {
27
+ /******/ for (var n in r) {
28
+ /******/ if (e.o(r, n) && !e.o(t, n)) {
29
+ /******/ Object.defineProperty(t, n, {
30
30
  enumerable: true,
31
- get: t[a]
31
+ get: r[n]
32
32
  });
33
33
  /******/ }
34
34
  /******/ }
@@ -37,7 +37,7 @@
37
37
  /******/
38
38
  /******/ /* webpack/runtime/hasOwnProperty shorthand */
39
39
  /******/ (() => {
40
- /******/ e.o = (e, r) => Object.prototype.hasOwnProperty.call(e, r)
40
+ /******/ e.o = (e, t) => Object.prototype.hasOwnProperty.call(e, t)
41
41
  /******/;
42
42
  })();
43
43
  /******/
@@ -56,19 +56,19 @@
56
56
  /******/ };
57
57
  /******/ })();
58
58
  /******/
59
- /************************************************************************/ var r = {};
59
+ /************************************************************************/ var t = {};
60
60
  // ESM COMPAT FLAG
61
- e.r(r);
61
+ e.r(t);
62
62
  // EXPORTS
63
- e.d(r, {
64
- default: () => /* reexport */ G
63
+ e.d(t, {
64
+ default: () => /* reexport */ ne
65
65
  });
66
66
  // CONCATENATED MODULE: external "react"
67
- const t = require("react");
68
- var a = e.n(t);
67
+ const r = require("react");
68
+ var n = e.n(r);
69
69
  // CONCATENATED MODULE: external "prop-types"
70
- const n = require("prop-types");
71
- var i = e.n(n);
70
+ const a = require("prop-types");
71
+ var i = e.n(a);
72
72
  // CONCATENATED MODULE: external "decimal.js-light"
73
73
  const o = require("decimal.js-light");
74
74
  var l = e.n(o);
@@ -76,135 +76,260 @@
76
76
  const u = require("@splunk/ui-utils/keyboard");
77
77
  // CONCATENATED MODULE: external "@splunk/react-ui/EventListener"
78
78
  const s = require("@splunk/react-ui/EventListener");
79
- var d = e.n(s);
79
+ var c = e.n(s);
80
80
  // CONCATENATED MODULE: external "@splunk/react-ui/Popover"
81
- const c = require("@splunk/react-ui/Popover");
82
- var v = e.n(c);
81
+ const d = require("@splunk/react-ui/Popover");
82
+ var f = e.n(d);
83
83
  // CONCATENATED MODULE: external "@splunk/react-ui/useControlled"
84
- const f = require("@splunk/react-ui/useControlled");
85
- var b = e.n(f);
84
+ const v = require("@splunk/react-ui/useControlled");
85
+ var m = e.n(v);
86
86
  // CONCATENATED MODULE: external "styled-components"
87
87
  const p = require("styled-components");
88
- var m = e.n(p);
88
+ var b = e.n(p);
89
89
  // CONCATENATED MODULE: external "@splunk/themes"
90
- const y = require("@splunk/themes");
90
+ const h = require("@splunk/themes");
91
91
  // CONCATENATED MODULE: ./src/Slider/getStepMarksBackground.ts
92
92
  /* this file is being ignored by stylelint via .stylelintignore */
93
93
  /* the radial-gradient returned in the map below needs `css` before backticks
94
94
  * for variable interpolation but is not valid css on its own which throws
95
95
  * a stylelint `Unknown word CssSyntaxError` */
96
96
  /* getStepMarksBackground generates the multiple radial gradient backgrounds for step marks */
97
- function h(e) {
98
- var r = e.stepWidth, t = e.thumbPosition, a = t === void 0 ? 0 : t, n = e.beforeThumbStepColor, i = e.afterThumbStepColor;
99
- /* need to subtract 1 to avoid extra step at the end */ var o = Math.floor(100 / r) - 1;
97
+ function y(e) {
98
+ var t = e.stepWidth, r = e.thumbPosition, n = r === void 0 ? 0 : r, a = e.beforeThumbStepColor, i = e.afterThumbStepColor;
99
+ /* need to subtract 1 to avoid extra step at the end */ var o = Math.floor(100 / t) - 1;
100
100
  var l = new Array(o).fill(false);
101
- return (0, p.css)([ "background:", ";" ], l.map((function(e, t) {
102
- var o = (t + 1) * r;
103
- var u = o <= a ? n : i;
104
- /* css doesn't allow trailing comma */ var s = t < l.length - 1 ? "," : "";
101
+ return (0, p.css)([ "background:", ";" ], l.map((function(e, r) {
102
+ var o = (r + 1) * t;
103
+ var u = o <= n ? a : i;
104
+ /* css doesn't allow trailing comma */ var s = r < l.length - 1 ? "," : "";
105
105
  return (0, p.css)([ "radial-gradient(circle,", " 0%,", " 3px,transparent 3px) calc(", "% - 1.5px) center no-repeat ", "" ], u, u, o, s);
106
106
  })));
107
107
  }
108
- /* harmony default export */ const g = h;
108
+ /* harmony default export */ const g = y;
109
109
  // CONCATENATED MODULE: ./src/Slider/SliderStyles.ts
110
- var x = 8;
110
+ var S = 8;
111
111
  var w = 1;
112
112
  var C = 24;
113
- var S = m().div.withConfig({
113
+ var x = b().div.withConfig({
114
114
  displayName: "SliderStyles__StyledSliderWrapper",
115
115
  componentId: "sc-16ooit4-0"
116
- })([ "", ";grid-template-columns:min-content minmax(200px,100%) min-content;gap:8px;", "" ], y.mixins.reset("grid"), (function(e) {
117
- var r = e.$inline;
118
- return r && (0, p.css)([ "width:300px;" ]);
116
+ })([ "", ";gap:", ";width:100%;", "" ], h.mixins.reset("flex"), h.variables.spacingLarge, (function(e) {
117
+ var t = e.$inline;
118
+ return t && (0, p.css)([ "width:300px;" ]);
119
119
  }));
120
- var k = m().div.withConfig({
120
+ var k = b().div.withConfig({
121
121
  displayName: "SliderStyles__StyledSliderBar",
122
122
  componentId: "sc-16ooit4-1"
123
- })([ "position:relative;left:0;height:", "px;width:100%;border-radius:10px;background-color:", ";border:", "px solid;border-color:", ";", " ", "" ], x, (0,
124
- y.pickVariant)("$state", {
125
- default: y.variables.neutral300,
126
- error: y.variables.neutral300,
127
- disabled: y.variables.neutral200
128
- }), w, (0, y.pickVariant)("$state", {
129
- default: y.variables.interactiveColorBorder,
130
- error: y.variables.interactiveColorBorder,
123
+ })([ "position:relative;left:0;height:", "px;width:100%;border-radius:10px;background-color:", ";border:", "px solid;border-color:", ";", " ", "" ], S, (0,
124
+ h.pickVariant)("$state", {
125
+ default: h.variables.neutral300,
126
+ error: h.variables.neutral300,
127
+ disabled: h.variables.neutral200
128
+ }), w, (0, h.pickVariant)("$state", {
129
+ default: h.variables.interactiveColorBorder,
130
+ error: h.variables.interactiveColorBorder,
131
131
  disabled: "transparent"
132
132
  }), (function(e) {
133
- var r = e.$thumbPosition;
134
- return r && (0, p.css)([ "&::before{position:absolute;border-radius:", ";content:'';height:calc( ", "px + ", "px );top:-", "px;left:-", "px;width:", "%;background-color:", ";}" ], y.variables.borderRadius, x, w * 2, w, w, r, (0,
135
- y.pickVariant)("$state", {
136
- default: y.variables.interactiveColorAccent,
137
- error: y.variables.interactiveColorAccentError,
138
- disabled: y.variables.neutral300
133
+ var t = e.$thumbPosition;
134
+ return t && (0, p.css)([ "&::before{position:absolute;border-radius:", ";content:'';height:calc( ", "px + ", "px );top:-", "px;left:-", "px;width:", "%;background-color:", ";}" ], h.variables.borderRadius, S, w * 2, w, w, t, (0,
135
+ h.pickVariant)("$state", {
136
+ default: h.variables.interactiveColorAccent,
137
+ error: h.variables.interactiveColorAccentError,
138
+ disabled: h.variables.neutral300
139
139
  }));
140
140
  }), (function(e) {
141
- var r = e.$stepWidth, t = e.$thumbPosition;
142
- return r && (0, p.css)([ "&::after{position:absolute;top:0;left:0;width:100%;height:100%;", ";background-size:8px 8px;}" ], g({
143
- beforeThumbStepColor: (0, y.pickVariant)("$state", {
144
- default: y.variables.contentColorAccentWeak,
145
- error: y.variables.contentColorNegativeWeak,
146
- disabled: y.variables.contentColorDisabled
141
+ var t = e.$stepWidth, r = e.$thumbPosition;
142
+ return t && (0, p.css)([ "&::after{position:absolute;top:0;left:0;width:100%;height:100%;", ";background-size:8px 8px;}" ], g({
143
+ beforeThumbStepColor: (0, h.pickVariant)("$state", {
144
+ default: h.variables.contentColorAccentWeak,
145
+ error: h.variables.contentColorNegativeWeak,
146
+ disabled: h.variables.contentColorDisabled
147
147
  }),
148
- afterThumbStepColor: (0, y.pickVariant)("$state", {
149
- default: y.variables.contentColorDefault,
150
- error: y.variables.contentColorDefault,
151
- disabled: y.variables.contentColorDisabled
148
+ afterThumbStepColor: (0, h.pickVariant)("$state", {
149
+ default: h.variables.contentColorDefault,
150
+ error: h.variables.contentColorDefault,
151
+ disabled: h.variables.contentColorDisabled
152
152
  }),
153
- stepWidth: r,
154
- thumbPosition: t
153
+ stepWidth: t,
154
+ thumbPosition: r
155
155
  }));
156
156
  }));
157
- var $ = m().button.withConfig({
157
+ var E = b().button.withConfig({
158
158
  displayName: "SliderStyles__StyledSliderThumb",
159
159
  componentId: "sc-16ooit4-2"
160
160
  })([ "display:block;position:absolute;cursor:pointer;width:", "px;height:", "px;border-radius:50%;background-color:", ";border:2px solid ", ";left:", "%;margin-left:-", "px;", " ", "" ], C, C, (0,
161
- y.pickVariant)("$state", {
162
- default: y.variables.white,
163
- error: y.variables.interactiveColorAccentError,
164
- disabled: y.variables.neutral300
165
- }), (0, y.pickVariant)("$state", {
166
- default: y.variables.borderColorStrong,
167
- error: y.variables.interactiveColorAccentErrorStrong,
168
- disabled: y.variables.neutral300
161
+ h.pickVariant)("$state", {
162
+ default: h.variables.white,
163
+ error: h.variables.interactiveColorAccentError,
164
+ disabled: h.variables.neutral300
165
+ }), (0, h.pickVariant)("$state", {
166
+ default: h.variables.borderColorStrong,
167
+ error: h.variables.interactiveColorAccentErrorStrong,
168
+ disabled: h.variables.neutral300
169
169
  }), (function(e) {
170
- var r = e.$thumbPosition;
171
- return r;
170
+ var t = e.$thumbPosition;
171
+ return t;
172
172
  }), C / 2, (function(e) {
173
- var r = e.$state;
174
- return r !== "disabled" && (0, p.css)([ "&:hover,&:focus,&:active{box-shadow:", ";}" ], y.variables.focusShadow);
173
+ var t = e.$state;
174
+ return t !== "disabled" && (0, p.css)([ "&:hover,&:focus,&:active{box-shadow:", ";}" ], h.variables.focusShadow);
175
175
  }), (function(e) {
176
- var r = e.$state;
177
- return r === "disabled" && (0, p.css)([ "cursor:not-allowed;" ]);
176
+ var t = e.$state;
177
+ return t === "disabled" && (0, p.css)([ "cursor:not-allowed;" ]);
178
178
  }));
179
- var E = m().div.withConfig({
179
+ var $ = b().div.withConfig({
180
180
  displayName: "SliderStyles__StyledPopoverContent",
181
181
  componentId: "sc-16ooit4-3"
182
- })([ "padding:", ";" ], y.variables.spacingMedium);
183
- var O = m().span.withConfig({
182
+ })([ "padding:", ";" ], h.variables.spacingMedium);
183
+ var A = b().span.withConfig({
184
184
  displayName: "SliderStyles__StyledLabel",
185
185
  componentId: "sc-16ooit4-4"
186
186
  })([ "align-self:center;color:", ";" ], (function(e) {
187
- var r = e.$disabled;
188
- return r ? y.variables.contentColorDisabled : y.variables.contentColorActive;
187
+ var t = e.$disabled;
188
+ return t ? h.variables.contentColorDisabled : h.variables.contentColorActive;
189
189
  }));
190
190
  /* using content: '' to control if step marks should be shown
191
191
  * to avoid further issues with variable interpolation given the
192
192
  * complexity of the multiple radial gradient backgrounds. This also
193
- * allows us not to pass in StyledSliderTypes to StyledInput */ var V = (0, p.css)([ "", "{&::after{content:'';}}" ], /* sc-sel */ k);
194
- var P = m().div.withConfig({
193
+ * allows us not to pass in StyledSliderTypes to StyledInput */ var T = (0, p.css)([ "", "{&::after{content:'';}}" ], /* sc-sel */ k);
194
+ var V = b().div.withConfig({
195
195
  displayName: "SliderStyles__StyledInput",
196
196
  componentId: "sc-16ooit4-5"
197
- })([ "display:flex;align-items:center;flex:1 0 0;position:relative;cursor:default;height:", ";max-width:100%;", " &:hover{", "{border-color:", ";}}", "" ], y.variables.inputHeight, (function(e) {
198
- var r = e.$state;
199
- return r === "disabled" && (0, p.css)([ "cursor:not-allowed;" ]);
200
- }), /* sc-sel */ k, (0, y.pickVariant)("$state", {
201
- default: y.variables.interactiveColorBorderHover,
202
- error: y.variables.interactiveColorBorderHover,
197
+ })([ "width:100%;min-width:200px;display:flex;align-items:center;flex:1 0 0;position:relative;cursor:default;height:", ";max-width:100%;", " &:hover{", "{border-color:", ";}}", "" ], h.variables.inputHeight, (function(e) {
198
+ var t = e.$state;
199
+ return t === "disabled" && (0, p.css)([ "cursor:not-allowed;" ]);
200
+ }), /* sc-sel */ k, (0, h.pickVariant)("$state", {
201
+ default: h.variables.interactiveColorBorderHover,
202
+ error: h.variables.interactiveColorBorderHover,
203
203
  disabled: "transparent"
204
- }), (0, y.pickVariant)("$stepAppearance", {
205
- focus: (0, p.css)([ "&:focus-within{", "}" ], V),
206
- always: (0, p.css)([ "", "" ], V)
204
+ }), (0, h.pickVariant)("$stepAppearance", {
205
+ focus: (0, p.css)([ "&:focus-within{", "}" ], T),
206
+ always: (0, p.css)([ "", "" ], T)
207
207
  }));
208
+ // CONCATENATED MODULE: ./src/utils/ssrDocument.ts
209
+ /* eslint-disable @typescript-eslint/no-empty-function */
210
+ var O = {
211
+ body: {
212
+ appendChild: function e() {
213
+ return [];
214
+ }
215
+ },
216
+ addEventListener: function e() {},
217
+ removeEventListener: function e() {},
218
+ activeElement: {
219
+ blur: function e() {},
220
+ nodeName: ""
221
+ },
222
+ querySelector: function e() {
223
+ return null;
224
+ },
225
+ querySelectorAll: function e() {
226
+ return [];
227
+ },
228
+ getElementById: function e() {
229
+ return null;
230
+ },
231
+ createEvent: function e() {
232
+ return {
233
+ initEvent: function e() {}
234
+ };
235
+ },
236
+ createElement: function e() {
237
+ return {
238
+ children: [],
239
+ childNodes: [],
240
+ style: {},
241
+ setAttribute: function e() {},
242
+ getElementsByTagName: function e() {
243
+ return [];
244
+ }
245
+ };
246
+ },
247
+ createElementNS: function e() {
248
+ return {};
249
+ },
250
+ importNode: function e() {
251
+ return null;
252
+ },
253
+ location: {
254
+ hash: "",
255
+ host: "",
256
+ hostname: "",
257
+ href: "",
258
+ origin: "",
259
+ pathname: "",
260
+ protocol: "",
261
+ search: ""
262
+ }
263
+ };
264
+ function P() {
265
+ var e = typeof document !== "undefined" ? document : O;
266
+ return e;
267
+ }
268
+ var B = P();
269
+ /* harmony default export */ const q = /* unused pure expression or super */ null && B;
270
+ // CONCATENATED MODULE: ./src/utils/ssrWindow.ts
271
+ /* eslint-disable @typescript-eslint/no-empty-function */
272
+ var _ = {
273
+ document: O,
274
+ navigator: {
275
+ userAgent: ""
276
+ },
277
+ location: {
278
+ hash: "",
279
+ host: "",
280
+ hostname: "",
281
+ href: "",
282
+ origin: "",
283
+ pathname: "",
284
+ protocol: "",
285
+ search: ""
286
+ },
287
+ history: {
288
+ replaceState: function e() {},
289
+ pushState: function e() {},
290
+ go: function e() {},
291
+ back: function e() {}
292
+ },
293
+ CustomEvent: function e() {
294
+ return this;
295
+ },
296
+ addEventListener: function e() {},
297
+ removeEventListener: function e() {},
298
+ getComputedStyle: function e() {
299
+ return {
300
+ getPropertyValue: function e() {
301
+ return "";
302
+ }
303
+ };
304
+ },
305
+ Image: function e() {},
306
+ Date: function e() {},
307
+ screen: {},
308
+ setTimeout: function e() {},
309
+ clearTimeout: function e() {},
310
+ matchMedia: function e() {
311
+ return {};
312
+ },
313
+ requestAnimationFrame: function e(t) {
314
+ if (typeof setTimeout === "undefined") {
315
+ t();
316
+ return null;
317
+ }
318
+ return setTimeout(t, 0);
319
+ },
320
+ cancelAnimationFrame: function e(t) {
321
+ if (typeof setTimeout === "undefined") {
322
+ return;
323
+ }
324
+ clearTimeout(t);
325
+ }
326
+ };
327
+ function j() {
328
+ var e = typeof window !== "undefined" ? window : _;
329
+ return e;
330
+ }
331
+ var M = j();
332
+ /* harmony default export */ const N = M;
208
333
  // CONCATENATED MODULE: ./src/utils/updateReactRef.ts
209
334
  /**
210
335
  * Updates a React ref. Callback refs and object refs (from `createRef` and `useRef`) are supported.
@@ -212,98 +337,98 @@
212
337
  * @param ref - The React callback or object ref. Can be `null` or `undefined`.
213
338
  * @param current - The new value of the ref.
214
339
  */
215
- function B(e, r) {
340
+ function L(e, t) {
216
341
  if (e) {
217
342
  if (typeof e === "function") {
218
- e(r);
343
+ e(t);
219
344
  } else {
220
345
  // the public signature of this util uses React.Ref<T> to mirror the way React types refs.
221
346
  // the intention here is to signal "we will take care of setting 'current', not you".
222
- e.current = r;
347
+ e.current = t;
223
348
  // eslint-disable-line no-param-reassign
224
349
  }
225
350
  }
226
351
  }
227
352
  // CONCATENATED MODULE: ./src/Slider/Slider.tsx
228
- function _() {
229
- return _ = Object.assign ? Object.assign.bind() : function(e) {
230
- for (var r = 1; r < arguments.length; r++) {
231
- var t = arguments[r];
232
- for (var a in t) {
233
- ({}).hasOwnProperty.call(t, a) && (e[a] = t[a]);
353
+ function I() {
354
+ return I = Object.assign ? Object.assign.bind() : function(e) {
355
+ for (var t = 1; t < arguments.length; t++) {
356
+ var r = arguments[t];
357
+ for (var n in r) {
358
+ ({}).hasOwnProperty.call(r, n) && (e[n] = r[n]);
234
359
  }
235
360
  }
236
361
  return e;
237
- }, _.apply(null, arguments);
362
+ }, I.apply(null, arguments);
238
363
  }
239
- function j(e, r) {
240
- return I(e) || T(e, r) || M(e, r) || A();
364
+ function D(e, t) {
365
+ return z(e) || H(e, t) || W(e, t) || R();
241
366
  }
242
- function A() {
367
+ function R() {
243
368
  throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
244
369
  }
245
- function M(e, r) {
370
+ function W(e, t) {
246
371
  if (e) {
247
- if ("string" == typeof e) return q(e, r);
248
- var t = {}.toString.call(e).slice(8, -1);
249
- return "Object" === t && e.constructor && (t = e.constructor.name), "Map" === t || "Set" === t ? Array.from(e) : "Arguments" === t || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t) ? q(e, r) : void 0;
372
+ if ("string" == typeof e) return F(e, t);
373
+ var r = {}.toString.call(e).slice(8, -1);
374
+ return "Object" === r && e.constructor && (r = e.constructor.name), "Map" === r || "Set" === r ? Array.from(e) : "Arguments" === r || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r) ? F(e, t) : void 0;
250
375
  }
251
376
  }
252
- function q(e, r) {
253
- (null == r || r > e.length) && (r = e.length);
254
- for (var t = 0, a = Array(r); t < r; t++) {
255
- a[t] = e[t];
377
+ function F(e, t) {
378
+ (null == t || t > e.length) && (t = e.length);
379
+ for (var r = 0, n = Array(t); r < t; r++) {
380
+ n[r] = e[r];
256
381
  }
257
- return a;
382
+ return n;
258
383
  }
259
- function T(e, r) {
260
- var t = null == e ? null : "undefined" != typeof Symbol && e[Symbol.iterator] || e["@@iterator"];
261
- if (null != t) {
262
- var a, n, i, o, l = [], u = !0, s = !1;
384
+ function H(e, t) {
385
+ var r = null == e ? null : "undefined" != typeof Symbol && e[Symbol.iterator] || e["@@iterator"];
386
+ if (null != r) {
387
+ var n, a, i, o, l = [], u = !0, s = !1;
263
388
  try {
264
- if (i = (t = t.call(e)).next, 0 === r) {
265
- if (Object(t) !== t) return;
389
+ if (i = (r = r.call(e)).next, 0 === t) {
390
+ if (Object(r) !== r) return;
266
391
  u = !1;
267
- } else for (;!(u = (a = i.call(t)).done) && (l.push(a.value), l.length !== r); u = !0) {
392
+ } else for (;!(u = (n = i.call(r)).done) && (l.push(n.value), l.length !== t); u = !0) {
268
393
  }
269
394
  } catch (e) {
270
- s = !0, n = e;
395
+ s = !0, a = e;
271
396
  } finally {
272
397
  try {
273
- if (!u && null != t["return"] && (o = t["return"](), Object(o) !== o)) return;
398
+ if (!u && null != r["return"] && (o = r["return"](), Object(o) !== o)) return;
274
399
  } finally {
275
- if (s) throw n;
400
+ if (s) throw a;
276
401
  }
277
402
  }
278
403
  return l;
279
404
  }
280
405
  }
281
- function I(e) {
406
+ function z(e) {
282
407
  if (Array.isArray(e)) return e;
283
408
  }
284
- function D(e, r) {
409
+ function K(e, t) {
285
410
  if (null == e) return {};
286
- var t, a, n = N(e, r);
411
+ var r, n, a = U(e, t);
287
412
  if (Object.getOwnPropertySymbols) {
288
413
  var i = Object.getOwnPropertySymbols(e);
289
- for (a = 0; a < i.length; a++) {
290
- t = i[a], r.includes(t) || {}.propertyIsEnumerable.call(e, t) && (n[t] = e[t]);
414
+ for (n = 0; n < i.length; n++) {
415
+ r = i[n], t.includes(r) || {}.propertyIsEnumerable.call(e, r) && (a[r] = e[r]);
291
416
  }
292
417
  }
293
- return n;
418
+ return a;
294
419
  }
295
- function N(e, r) {
420
+ function U(e, t) {
296
421
  if (null == e) return {};
297
- var t = {};
298
- for (var a in e) {
299
- if ({}.hasOwnProperty.call(e, a)) {
300
- if (r.includes(a)) continue;
301
- t[a] = e[a];
422
+ var r = {};
423
+ for (var n in e) {
424
+ if ({}.hasOwnProperty.call(e, n)) {
425
+ if (t.includes(n)) continue;
426
+ r[n] = e[n];
302
427
  }
303
428
  }
304
- return t;
429
+ return r;
305
430
  }
306
- /** @public */ var L = {
431
+ /** @public */ var X = {
307
432
  defaultValue: i().number,
308
433
  describedBy: i().string,
309
434
  disabled: i().bool,
@@ -325,299 +450,300 @@
325
450
  thumbRef: i().oneOfType([ i().func, i().object ]),
326
451
  value: i().number
327
452
  };
328
- var R = function e(r) {
329
- var t = r.max, a = r.min, n = r.value;
330
- if (n > t) {
331
- return t;
453
+ var G = function e(t) {
454
+ var r = t.max, n = t.min, a = t.value;
455
+ if (a > r) {
456
+ return r;
332
457
  }
333
- if (n < a) {
334
- return a;
458
+ if (a < n) {
459
+ return n;
335
460
  }
336
- return n;
461
+ return a;
337
462
  };
338
463
  // If the current value is in between a step, i.e. defaultValue is not at a
339
464
  // step mark, this function handles navigating to the next correct step
340
- var W = function e(r) {
341
- var t = r.direction, a = r.min, n = r.step, i = r.value;
342
- var o = new (l())(i).minus(a).modulo(n).toNumber();
465
+ var J = function e(t) {
466
+ var r = t.direction, n = t.min, a = t.step, i = t.value;
467
+ var o = new (l())(i).minus(n).modulo(a).toNumber();
343
468
  if (o > 0) {
344
- return t === "forward" ? n - o : o;
469
+ return r === "forward" ? a - o : o;
345
470
  }
346
- return n;
471
+ return a;
347
472
  };
348
- var H = function e(r, t) {
349
- if (t === null) {
473
+ var Q = function e(t, r) {
474
+ if (r === null) {
350
475
  return undefined;
351
476
  }
352
- var a = t.getBoundingClientRect();
353
- var n = r.clientX - a.left;
354
- return R({
477
+ var n = r.getBoundingClientRect();
478
+ var a = t.clientX - n.left;
479
+ return G({
355
480
  max: 100,
356
481
  min: 0,
357
- value: n / a.width * 100
482
+ value: a / n.width * 100
358
483
  });
359
484
  };
360
- var F = function e(r) {
361
- var t = r.max, a = r.min, n = r.step, i = r.value;
485
+ var Y = function e(t) {
486
+ var r = t.max, n = t.min, a = t.step, i = t.value;
362
487
  // Handles if the max is in between steps but val is larger than the halfway point between last step mark and max
363
- if (i > t - (t - a) % n / 2) {
364
- return t;
488
+ if (i > r - (r - n) % a / 2) {
489
+ return r;
365
490
  }
366
- return new (l())(i).minus(a).div(n).todp(0).mul(n).add(a).toNumber();
491
+ return new (l())(i).minus(n).div(a).todp(0).mul(a).add(n).toNumber();
367
492
  };
368
- var z = function e(r) {
369
- var t = r.position, a = r.max, n = r.min, i = r.step;
370
- var o = a - n;
371
- var l = t / 100 * o + n;
372
- return F({
373
- max: a,
374
- min: n,
493
+ var Z = function e(t) {
494
+ var r = t.position, n = t.max, a = t.min, i = t.step;
495
+ var o = n - a;
496
+ var l = r / 100 * o + a;
497
+ return Y({
498
+ max: n,
499
+ min: a,
375
500
  step: i,
376
501
  value: l
377
502
  });
378
503
  };
379
- var K = function e(r) {
380
- var t = r.max, a = r.min, n = r.sliderBar, i = r.step;
504
+ var ee = function e(t) {
505
+ var r = t.max, n = t.min, a = t.sliderBar, i = t.step;
381
506
  // don't render stepMarks if they are too small i.e. stepWidth is less than SliderThumb divided by 2
382
507
  // in that case, undefined is returned
383
- if (n === null) {
508
+ if (a === null) {
384
509
  return undefined;
385
510
  }
386
- var o = t - a;
511
+ var o = r - n;
387
512
  var l = Math.round(o / i);
388
- var u = n.getBoundingClientRect();
513
+ var u = a.getBoundingClientRect();
389
514
  var s = i * 100 / o;
390
515
  return u.width / l > C / 2 ? s : undefined;
391
516
  };
392
- var U = function e(r) {
393
- var t = r.max, a = r.min, n = r.value;
394
- if (n === undefined) {
517
+ var te = function e(t) {
518
+ var r = t.max, n = t.min, a = t.value;
519
+ if (a === undefined) {
395
520
  return undefined;
396
521
  }
397
- var i = t - a;
398
- return (n - a) / i * 100;
522
+ var i = r - n;
523
+ return (a - n) / i * 100;
399
524
  };
400
- function X(e) {
401
- var r = e.defaultValue, n = e.describedBy, i = e.disabled, o = e.displayValue, l = e.elementRef, s = e.error, c = e.inline, f = e.labelledBy, p = e.max, m = p === void 0 ? 5 : p, y = e.maxLabel, h = e.min, g = h === void 0 ? 1 : h, x = e.minLabel, w = e.name, C = e.onChange, V = e.required, A = e.step, M = A === void 0 ? 1 : A, q = e.stepMarks, T = q === void 0 ? "focus" : q, I = e.thumbRef, N = e.value, L = D(e, [ "defaultValue", "describedBy", "disabled", "displayValue", "elementRef", "error", "inline", "labelledBy", "max", "maxLabel", "min", "minLabel", "name", "onChange", "required", "step", "stepMarks", "thumbRef", "value" ]);
525
+ function re(e) {
526
+ var t = e.defaultValue, a = e.describedBy, i = e.disabled, o = e.displayValue, l = e.elementRef, s = e.error, d = e.inline, v = e.labelledBy, p = e.max, b = p === void 0 ? 5 : p, h = e.maxLabel, y = e.min, g = y === void 0 ? 1 : y, S = e.minLabel, w = e.name, C = e.onChange, T = e.required, O = e.step, P = O === void 0 ? 1 : O, B = e.stepMarks, q = B === void 0 ? "focus" : B, _ = e.thumbRef, j = e.value, M = K(e, [ "defaultValue", "describedBy", "disabled", "displayValue", "elementRef", "error", "inline", "labelledBy", "max", "maxLabel", "min", "minLabel", "name", "onChange", "required", "step", "stepMarks", "thumbRef", "value" ]);
402
527
  // @docs-props-type SliderPropsBase
403
- var X = b()({
528
+ var R = m()({
404
529
  componentName: "Slider",
405
530
  /* eslint-disable-next-line prefer-rest-params */
406
531
  componentProps: arguments[0]
407
532
  });
408
- var G = (0, t.useState)(false), J = j(G, 2), Q = J[0], Y = J[1];
409
- var Z = (0, t.useState)(false), ee = j(Z, 2), re = ee[0], te = ee[1];
410
- var ae = (0, t.useState)(null), ne = j(ae, 2), ie = ne[0], oe = ne[1];
411
- var le = (0, t.useState)(null), ue = j(le, 2), se = ue[0], de = ue[1];
412
- var ce = (0, t.useMemo)((function() {
413
- return X ? F({
414
- value: (m - g) / 2,
533
+ var W = (0, r.useState)(false), F = D(W, 2), H = F[0], z = F[1];
534
+ var U = (0, r.useState)(false), X = D(U, 2), re = X[0], ne = X[1];
535
+ var ae = (0, r.useState)(null), ie = D(ae, 2), oe = ie[0], le = ie[1];
536
+ var ue = (0, r.useState)(null), se = D(ue, 2), ce = se[0], de = se[1];
537
+ var fe = (0, r.useMemo)((function() {
538
+ return R ? Y({
539
+ value: (b - g) / 2,
415
540
  min: g,
416
- max: m,
417
- step: M
418
- }) : r;
419
- }), [ X, r, m, g, M ]);
420
- var ve = (0, t.useState)(X ? N : ce), fe = j(ve, 2), be = fe[0], pe = fe[1];
421
- var me = (0, t.useCallback)((function(e, r) {
422
- var t = r.newValue;
423
- if (be !== t) {
541
+ max: b,
542
+ step: P
543
+ }) : t;
544
+ }), [ R, t, b, g, P ]);
545
+ var ve = (0, r.useState)(R ? j : fe), me = D(ve, 2), pe = me[0], be = me[1];
546
+ var he = (0, r.useCallback)((function(e, t) {
547
+ var r = t.newValue;
548
+ if (pe !== r) {
424
549
  C === null || C === void 0 ? void 0 : C(e, {
425
- value: t,
550
+ value: r,
426
551
  name: w
427
552
  });
428
- if (!X) {
429
- pe(t);
553
+ if (!R) {
554
+ be(r);
430
555
  }
431
556
  }
432
- }), [ X, w, C, be ]);
557
+ }), [ R, w, C, pe ]);
433
558
  // handlers
434
- var ye = (0, t.useCallback)((function() {
435
- te(false);
559
+ var ye = (0, r.useCallback)((function() {
560
+ ne(false);
436
561
  }), []);
437
- var he = (0, t.useCallback)((function() {
438
- te(true);
562
+ var ge = (0, r.useCallback)((function() {
563
+ ne(true);
439
564
  }), []);
440
- var ge = (0, t.useCallback)((function(e) {
441
- oe(e);
565
+ var Se = (0, r.useCallback)((function(e) {
566
+ le(e);
442
567
  }), []);
443
- var xe = (0, t.useCallback)((function(e) {
568
+ var we = (0, r.useCallback)((function(e) {
444
569
  de(e);
445
- B(I, e);
446
- }), [ I ]);
447
- var we = (0, t.useCallback)((function(e) {
448
- var r = H(e, ie);
449
- if (r !== undefined) {
450
- var t = z({
451
- position: r,
452
- max: m,
570
+ L(_, e);
571
+ }), [ _ ]);
572
+ var Ce = (0, r.useCallback)((function(e) {
573
+ var t = Q(e, oe);
574
+ if (t !== undefined) {
575
+ var r = Z({
576
+ position: t,
577
+ max: b,
453
578
  min: g,
454
- step: M
579
+ step: P
455
580
  });
456
- me(e, {
457
- newValue: t
581
+ he(e, {
582
+ newValue: r
458
583
  });
459
584
  }
460
- }), [ m, g, me, ie, M ]);
461
- var Ce = (0, t.useCallback)((function(e) {
462
- var r = be;
463
- if (r !== undefined) {
464
- var t = (0, u.keycode)(e.nativeEvent);
465
- var a;
466
- var n = W({
585
+ }), [ b, g, he, oe, P ]);
586
+ var xe = (0, r.useCallback)((function(e) {
587
+ var t = pe;
588
+ if (t !== undefined) {
589
+ var r = (0, u.keycode)(e.nativeEvent);
590
+ var n;
591
+ var a = J({
467
592
  direction: "forward",
468
593
  min: g,
469
- step: M,
470
- value: r
594
+ step: P,
595
+ value: t
471
596
  });
472
- var i = W({
597
+ var i = J({
473
598
  direction: "backward",
474
599
  min: g,
475
- step: M,
476
- value: r
600
+ step: P,
601
+ value: t
477
602
  });
478
- if (t === "right") {
479
- a = r + n;
480
- } else if (t === "left") {
481
- a = r - i;
482
- } else if (t === "up") {
603
+ if (r === "right") {
604
+ n = t + a;
605
+ } else if (r === "left") {
606
+ n = t - i;
607
+ } else if (r === "up") {
483
608
  e.preventDefault();
484
- a = r + n;
485
- } else if (t === "down") {
609
+ n = t + a;
610
+ } else if (r === "down") {
486
611
  e.preventDefault();
487
- a = r - i;
612
+ n = t - i;
488
613
  } else {
489
614
  return;
490
615
  }
491
- r = R({
492
- max: m,
616
+ t = G({
617
+ max: b,
493
618
  min: g,
494
- value: a
619
+ value: n
495
620
  });
496
- r = F({
497
- max: m,
621
+ t = Y({
622
+ max: b,
498
623
  min: g,
499
- step: M,
500
- value: r
624
+ step: P,
625
+ value: t
501
626
  });
502
- me(e, {
503
- newValue: r
627
+ he(e, {
628
+ newValue: t
504
629
  });
505
630
  }
506
- }), [ m, g, me, M, be ]);
507
- var Se = (0, t.useCallback)((function(e) {
631
+ }), [ b, g, he, P, pe ]);
632
+ var ke = (0, r.useCallback)((function(e) {
508
633
  e.preventDefault();
509
- se === null || se === void 0 ? void 0 : se.focus();
510
- Y(true);
511
- te(true);
512
- }), [ se ]);
513
- var ke = (0, t.useCallback)((function() {
514
- te(true);
634
+ ce === null || ce === void 0 ? void 0 : ce.focus();
635
+ z(true);
636
+ ne(true);
637
+ }), [ ce ]);
638
+ var Ee = (0, r.useCallback)((function() {
639
+ ne(true);
515
640
  }), []);
516
- var $e = (0, t.useCallback)((function() {
517
- if (!Q) {
518
- te(false);
641
+ var $e = (0, r.useCallback)((function() {
642
+ if (!H) {
643
+ ne(false);
519
644
  }
520
- }), [ Q ]);
521
- var Ee = (0, t.useCallback)((function(e) {
522
- if (Q) {
523
- var r = H(e, ie);
524
- if (r !== undefined) {
525
- var t = z({
526
- position: r,
645
+ }), [ H ]);
646
+ var Ae = (0, r.useCallback)((function(e) {
647
+ if (H) {
648
+ var t = Q(e, oe);
649
+ if (t !== undefined) {
650
+ var r = Z({
651
+ position: t,
527
652
  min: g,
528
- max: m,
529
- step: M
653
+ max: b,
654
+ step: P
530
655
  });
531
- me(e, {
532
- newValue: t
656
+ he(e, {
657
+ newValue: r
533
658
  });
534
659
  }
535
660
  }
536
- }), [ Q, m, g, me, ie, M ]);
537
- var Oe = (0, t.useCallback)((function() {
538
- Y(false);
539
- te(false);
661
+ }), [ H, b, g, he, oe, P ]);
662
+ var Te = (0, r.useCallback)((function() {
663
+ z(false);
664
+ ne(false);
540
665
  }), []);
541
- (0, t.useEffect)((function() {
666
+ (0, r.useEffect)((function() {
542
667
  if (false) {}
543
- }), [ m, g ]);
544
- (0, t.useEffect)((function() {
668
+ }), [ b, g ]);
669
+ (0, r.useEffect)((function() {
545
670
  // keep valueState in sync with value prop when controlled
546
- if (X) {
547
- pe(N);
671
+ if (R) {
672
+ be(j);
548
673
  }
549
- }), [ X, N ]);
674
+ }), [ R, j ]);
550
675
  var Ve = i && "disabled" || s && "error" || "default";
551
- var Pe = U({
552
- value: be,
676
+ var Oe = te({
677
+ value: pe,
553
678
  min: g,
554
- max: m
679
+ max: b
555
680
  });
556
- var Be = M ? K({
557
- max: m,
681
+ var Pe = P ? ee({
682
+ max: b,
558
683
  min: g,
559
- sliderBar: ie,
560
- step: M
684
+ sliderBar: oe,
685
+ step: P
561
686
  }) : undefined;
562
687
  /* eslint-disable jsx-a11y/no-static-element-interactions */
563
- return a().createElement(S, _({
688
+ return n().createElement(x, I({
564
689
  "data-test": "slider",
565
- "data-test-value": be,
690
+ "data-test-disabled": i ? "disabled" : undefined,
691
+ "data-test-value": pe,
566
692
  ref: l,
567
- $inline: c
568
- }, L), Q && a().createElement(a().Fragment, null, a().createElement(d(), {
569
- target: window,
693
+ $inline: d
694
+ }, M), H && n().createElement(n().Fragment, null, n().createElement(c(), {
695
+ target: N,
570
696
  eventType: "mouseup",
571
- listener: Oe
572
- }), a().createElement(d(), {
573
- target: window,
697
+ listener: Te
698
+ }), n().createElement(c(), {
699
+ target: N,
574
700
  eventType: "mousemove",
575
- listener: Ee
576
- })), x !== null && a().createElement(O, {
701
+ listener: Ae
702
+ })), S !== null && n().createElement(A, {
577
703
  "data-test": "min-label",
578
704
  $disabled: i
579
- }, x || g), a().createElement(P, {
580
- onClick: i ? undefined : we,
705
+ }, S || g), n().createElement(V, {
706
+ onClick: i ? undefined : Ce,
581
707
  $state: Ve,
582
- $stepAppearance: T
583
- }, a().createElement(k, {
584
- "aria-required": V,
708
+ $stepAppearance: q
709
+ }, n().createElement(k, {
710
+ "aria-required": T,
585
711
  "data-test": "bar",
586
- ref: ge,
587
- $thumbPosition: Pe,
588
- $stepWidth: Be,
712
+ ref: Se,
713
+ $thumbPosition: Oe,
714
+ $stepWidth: Pe,
589
715
  $state: Ve
590
- }), a().createElement($, {
591
- "aria-describedby": n,
592
- "aria-labelledby": f,
716
+ }), n().createElement(E, {
717
+ "aria-describedby": a,
718
+ "aria-labelledby": v,
593
719
  "aria-invalid": s,
594
- "aria-valuemax": m,
720
+ "aria-valuemax": b,
595
721
  "aria-valuemin": g,
596
- "aria-valuenow": be,
722
+ "aria-valuenow": pe,
597
723
  "data-test": "thumb",
598
724
  onBlur: ye,
599
- onMouseEnter: ke,
725
+ onMouseEnter: Ee,
600
726
  onMouseLeave: $e,
601
- onKeyDown: i ? undefined : Ce,
602
- onMouseDown: i ? undefined : Se,
603
- onFocus: he,
604
- ref: xe,
727
+ onKeyDown: i ? undefined : xe,
728
+ onMouseDown: i ? undefined : ke,
729
+ onFocus: ge,
730
+ ref: we,
605
731
  role: "slider",
606
732
  disabled: i,
607
- $thumbPosition: Pe,
733
+ $thumbPosition: Oe,
608
734
  $state: Ve
609
- }), a().createElement(v(), {
735
+ }), n().createElement(f(), {
610
736
  open: re,
611
- anchor: se,
737
+ anchor: ce,
612
738
  appearance: "inverted",
613
739
  align: "center"
614
- }, a().createElement(E, null, o || be))), y !== null && a().createElement(O, {
740
+ }, n().createElement($, null, o || pe))), h !== null && n().createElement(A, {
615
741
  "data-test": "max-label",
616
742
  $disabled: i
617
- }, y || m));
743
+ }, h || b));
618
744
  }
619
- X.propTypes = L;
620
- /* harmony default export */ const G = X;
745
+ re.propTypes = X;
746
+ /* harmony default export */ const ne = re;
621
747
  // CONCATENATED MODULE: ./src/Slider/index.ts
622
- module.exports = r;
748
+ module.exports = t;
623
749
  /******/})();