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