@itcase/ui 1.0.10 → 1.0.13

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 (41) hide show
  1. package/dist/components/Avatar.js +4 -2
  2. package/dist/components/Chips.js +2 -0
  3. package/dist/components/Choice.js +118 -0
  4. package/dist/components/DatePicker.js +10201 -0
  5. package/dist/components/Empty.js +95 -0
  6. package/dist/components/FormField.js +1 -1
  7. package/dist/components/Grid.js +8 -14
  8. package/dist/components/Input.js +2 -0
  9. package/dist/components/Label.js +0 -5
  10. package/dist/components/Logo.js +4 -4
  11. package/dist/components/Modal.js +3 -3
  12. package/dist/components/RangeSlider.js +7 -1978
  13. package/dist/components/Scrollbar.js +5 -3826
  14. package/dist/components/Search.js +4 -5
  15. package/dist/components/Segmented.js +5 -1
  16. package/dist/components/Select.js +348 -270
  17. package/dist/components/Swiper.js +4208 -188
  18. package/dist/components/Switch.js +3 -2
  19. package/dist/components/Tab.js +0 -1
  20. package/dist/components/Textarea.js +5 -1
  21. package/dist/components/Tile.js +0 -3
  22. package/dist/css/components/Choice/Choice.css +73 -0
  23. package/dist/css/components/DatePicker/DatePicker.css +924 -0
  24. package/dist/css/components/Empty/Empty.css +13 -0
  25. package/dist/css/components/Input/Input.css +12 -4
  26. package/dist/css/components/Segmented/Segmented.css +16 -0
  27. package/dist/css/components/Select/Select.css +11 -4
  28. package/dist/css/components/Select/css/__menu/select__menu.css +7 -3
  29. package/dist/css/components/Swiper/Swiper.css +128 -83
  30. package/dist/css/styles/fill/fill.css +4 -4
  31. package/dist/css/styles/fill/fill_active.css +5 -5
  32. package/dist/defineProperty-f9e5e1f3.js +166 -0
  33. package/dist/hooks/styleAttributes.js +5 -1
  34. package/package.json +30 -27
  35. package/dist/components/Emoji.js +0 -124
  36. package/dist/components/Profile.js +0 -105
  37. package/dist/css/components/Emoji/Emoji.css +0 -104
  38. package/dist/css/components/Emoji/css/__icon/emoji__icon-shape.css +0 -12
  39. package/dist/css/components/Emoji/css/__icon/emoji__icon.css +0 -5
  40. package/dist/css/components/Profile/Profile.css +0 -19
  41. package/dist/objectWithoutProperties-ea190611.js +0 -188
@@ -8,7 +8,7 @@ var shape = require('../constants/componentProps/shape.js');
8
8
  var width = require('../constants/componentProps/width.js');
9
9
  var useStyles = require('../useStyles-e4accb53.js');
10
10
  var useDeviceTargetClass = require('../hooks/useDeviceTargetClass.js');
11
- var objectWithoutProperties = require('../objectWithoutProperties-ea190611.js');
11
+ var Slider = require('rc-slider');
12
12
  require('lodash/camelCase');
13
13
  require('lodash/maxBy');
14
14
  require('lodash/upperFirst');
@@ -20,1981 +20,10 @@ require('lodash/castArray');
20
20
 
21
21
  function _interopDefault (e) { return e && e.__esModule ? e : { default: e }; }
22
22
 
23
- function _interopNamespace(e) {
24
- if (e && e.__esModule) return e;
25
- var n = Object.create(null);
26
- if (e) {
27
- Object.keys(e).forEach(function (k) {
28
- if (k !== 'default') {
29
- var d = Object.getOwnPropertyDescriptor(e, k);
30
- Object.defineProperty(n, k, d.get ? d : {
31
- enumerable: true,
32
- get: function () { return e[k]; }
33
- });
34
- }
35
- });
36
- }
37
- n.default = e;
38
- return Object.freeze(n);
39
- }
40
-
41
- var React__namespace = /*#__PURE__*/_interopNamespace(React);
23
+ var React__default = /*#__PURE__*/_interopDefault(React);
42
24
  var PropTypes__default = /*#__PURE__*/_interopDefault(PropTypes);
43
25
  var clsx__default = /*#__PURE__*/_interopDefault(clsx);
44
-
45
- function getDefaultExportFromCjs (x) {
46
- return x && x.__esModule && Object.prototype.hasOwnProperty.call(x, 'default') ? x['default'] : x;
47
- }
48
-
49
- var classnames = {exports: {}};
50
-
51
- /*!
52
- Copyright (c) 2018 Jed Watson.
53
- Licensed under the MIT License (MIT), see
54
- http://jedwatson.github.io/classnames
55
- */
56
-
57
- (function (module) {
58
- /* global define */
59
-
60
- (function () {
61
-
62
- var hasOwn = {}.hasOwnProperty;
63
-
64
- function classNames() {
65
- var classes = [];
66
-
67
- for (var i = 0; i < arguments.length; i++) {
68
- var arg = arguments[i];
69
- if (!arg) continue;
70
-
71
- var argType = typeof arg;
72
-
73
- if (argType === 'string' || argType === 'number') {
74
- classes.push(arg);
75
- } else if (Array.isArray(arg)) {
76
- if (arg.length) {
77
- var inner = classNames.apply(null, arg);
78
- if (inner) {
79
- classes.push(inner);
80
- }
81
- }
82
- } else if (argType === 'object') {
83
- if (arg.toString !== Object.prototype.toString && !arg.toString.toString().includes('[native code]')) {
84
- classes.push(arg.toString());
85
- continue;
86
- }
87
-
88
- for (var key in arg) {
89
- if (hasOwn.call(arg, key) && arg[key]) {
90
- classes.push(key);
91
- }
92
- }
93
- }
94
- }
95
-
96
- return classes.join(' ');
97
- }
98
-
99
- if (module.exports) {
100
- classNames.default = classNames;
101
- module.exports = classNames;
102
- } else {
103
- window.classNames = classNames;
104
- }
105
- }());
106
- } (classnames));
107
-
108
- var classnamesExports = classnames.exports;
109
- var classNames = /*@__PURE__*/getDefaultExportFromCjs(classnamesExports);
110
-
111
- /* eslint-disable no-console */
112
- var warned = {};
113
- var preWarningFns = [];
114
-
115
- /**
116
- * Pre warning enable you to parse content before console.error.
117
- * Modify to null will prevent warning.
118
- */
119
- var preMessage = function preMessage(fn) {
120
- preWarningFns.push(fn);
121
- };
122
- function warning(valid, message) {
123
- // Support uglify
124
- if (process.env.NODE_ENV !== 'production' && !valid && console !== undefined) {
125
- var finalMessage = preWarningFns.reduce(function (msg, preMessageFn) {
126
- return preMessageFn(msg !== null && msg !== void 0 ? msg : '', 'warning');
127
- }, message);
128
- if (finalMessage) {
129
- console.error("Warning: ".concat(finalMessage));
130
- }
131
- }
132
- }
133
- function note(valid, message) {
134
- // Support uglify
135
- if (process.env.NODE_ENV !== 'production' && !valid && console !== undefined) {
136
- var finalMessage = preWarningFns.reduce(function (msg, preMessageFn) {
137
- return preMessageFn(msg !== null && msg !== void 0 ? msg : '', 'note');
138
- }, message);
139
- if (finalMessage) {
140
- console.warn("Note: ".concat(finalMessage));
141
- }
142
- }
143
- }
144
- function resetWarned() {
145
- warned = {};
146
- }
147
- function call(method, valid, message) {
148
- if (!valid && !warned[message]) {
149
- method(false, message);
150
- warned[message] = true;
151
- }
152
- }
153
- function warningOnce(valid, message) {
154
- call(warning, valid, message);
155
- }
156
- function noteOnce(valid, message) {
157
- call(note, valid, message);
158
- }
159
- warningOnce.preMessage = preMessage;
160
- warningOnce.resetWarned = resetWarned;
161
- warningOnce.noteOnce = noteOnce;
162
- /* eslint-enable */
163
-
164
- /**
165
- * Deeply compares two object literals.
166
- * @param obj1 object 1
167
- * @param obj2 object 2
168
- * @param shallow shallow compare
169
- * @returns
170
- */
171
- function isEqual(obj1, obj2) {
172
- var shallow = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : false;
173
- // https://github.com/mapbox/mapbox-gl-js/pull/5979/files#diff-fde7145050c47cc3a306856efd5f9c3016e86e859de9afbd02c879be5067e58f
174
- var refSet = new Set();
175
- function deepEqual(a, b) {
176
- var level = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 1;
177
- var circular = refSet.has(a);
178
- warningOnce(!circular, 'Warning: There may be circular references');
179
- if (circular) {
180
- return false;
181
- }
182
- if (a === b) {
183
- return true;
184
- }
185
- if (shallow && level > 1) {
186
- return false;
187
- }
188
- refSet.add(a);
189
- var newLevel = level + 1;
190
- if (Array.isArray(a)) {
191
- if (!Array.isArray(b) || a.length !== b.length) {
192
- return false;
193
- }
194
- for (var i = 0; i < a.length; i++) {
195
- if (!deepEqual(a[i], b[i], newLevel)) {
196
- return false;
197
- }
198
- }
199
- return true;
200
- }
201
- if (a && b && objectWithoutProperties._typeof(a) === 'object' && objectWithoutProperties._typeof(b) === 'object') {
202
- var keys = Object.keys(a);
203
- if (keys.length !== Object.keys(b).length) {
204
- return false;
205
- }
206
- return keys.every(function (key) {
207
- return deepEqual(a[key], b[key], newLevel);
208
- });
209
- }
210
- // other
211
- return false;
212
- }
213
- return deepEqual(obj1, obj2);
214
- }
215
-
216
- function useEvent(callback) {
217
- var fnRef = React__namespace.useRef();
218
- fnRef.current = callback;
219
- var memoFn = React__namespace.useCallback(function () {
220
- var _fnRef$current;
221
- for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
222
- args[_key] = arguments[_key];
223
- }
224
- return (_fnRef$current = fnRef.current) === null || _fnRef$current === void 0 ? void 0 : _fnRef$current.call.apply(_fnRef$current, [fnRef].concat(args));
225
- }, []);
226
- return memoFn;
227
- }
228
-
229
- function canUseDom() {
230
- return !!(typeof window !== 'undefined' && window.document && window.document.createElement);
231
- }
232
-
233
- /**
234
- * Wrap `React.useLayoutEffect` which will not throw warning message in test env
235
- */
236
- var useInternalLayoutEffect = process.env.NODE_ENV !== 'test' && canUseDom() ? React__namespace.useLayoutEffect : React__namespace.useEffect;
237
- var useLayoutEffect = function useLayoutEffect(callback, deps) {
238
- var firstMountRef = React__namespace.useRef(true);
239
- useInternalLayoutEffect(function () {
240
- return callback(firstMountRef.current);
241
- }, deps);
242
-
243
- // We tell react that first mount has passed
244
- useInternalLayoutEffect(function () {
245
- firstMountRef.current = false;
246
- return function () {
247
- firstMountRef.current = true;
248
- };
249
- }, []);
250
- };
251
- var useLayoutUpdateEffect = function useLayoutUpdateEffect(callback, deps) {
252
- useLayoutEffect(function (firstMount) {
253
- if (!firstMount) {
254
- return callback();
255
- }
256
- }, deps);
257
- };
258
-
259
- /**
260
- * Same as React.useState but `setState` accept `ignoreDestroy` param to not to setState after destroyed.
261
- * We do not make this auto is to avoid real memory leak.
262
- * Developer should confirm it's safe to ignore themselves.
263
- */
264
- function useSafeState(defaultValue) {
265
- var destroyRef = React__namespace.useRef(false);
266
- var _React$useState = React__namespace.useState(defaultValue),
267
- _React$useState2 = objectWithoutProperties._slicedToArray(_React$useState, 2),
268
- value = _React$useState2[0],
269
- setValue = _React$useState2[1];
270
- React__namespace.useEffect(function () {
271
- destroyRef.current = false;
272
- return function () {
273
- destroyRef.current = true;
274
- };
275
- }, []);
276
- function safeSetState(updater, ignoreDestroy) {
277
- if (ignoreDestroy && destroyRef.current) {
278
- return;
279
- }
280
- setValue(updater);
281
- }
282
- return [value, safeSetState];
283
- }
284
-
285
- /** We only think `undefined` is empty */
286
- function hasValue(value) {
287
- return value !== undefined;
288
- }
289
-
290
- /**
291
- * Similar to `useState` but will use props value if provided.
292
- * Note that internal use rc-util `useState` hook.
293
- */
294
- function useMergedState(defaultStateValue, option) {
295
- var _ref = option || {},
296
- defaultValue = _ref.defaultValue,
297
- value = _ref.value,
298
- onChange = _ref.onChange,
299
- postState = _ref.postState;
300
-
301
- // ======================= Init =======================
302
- var _useState = useSafeState(function () {
303
- if (hasValue(value)) {
304
- return value;
305
- } else if (hasValue(defaultValue)) {
306
- return typeof defaultValue === 'function' ? defaultValue() : defaultValue;
307
- } else {
308
- return typeof defaultStateValue === 'function' ? defaultStateValue() : defaultStateValue;
309
- }
310
- }),
311
- _useState2 = objectWithoutProperties._slicedToArray(_useState, 2),
312
- innerValue = _useState2[0],
313
- setInnerValue = _useState2[1];
314
- var mergedValue = value !== undefined ? value : innerValue;
315
- var postMergedValue = postState ? postState(mergedValue) : mergedValue;
316
-
317
- // ====================== Change ======================
318
- var onChangeFn = useEvent(onChange);
319
- var _useState3 = useSafeState([mergedValue]),
320
- _useState4 = objectWithoutProperties._slicedToArray(_useState3, 2),
321
- prevValue = _useState4[0],
322
- setPrevValue = _useState4[1];
323
- useLayoutUpdateEffect(function () {
324
- var prev = prevValue[0];
325
- if (innerValue !== prev) {
326
- onChangeFn(innerValue, prev);
327
- }
328
- }, [prevValue]);
329
-
330
- // Sync value back to `undefined` when it from control to un-control
331
- useLayoutUpdateEffect(function () {
332
- if (!hasValue(value)) {
333
- setInnerValue(value);
334
- }
335
- }, [value]);
336
-
337
- // ====================== Update ======================
338
- var triggerChange = useEvent(function (updater, ignoreDestroy) {
339
- setInnerValue(updater, ignoreDestroy);
340
- setPrevValue([mergedValue], ignoreDestroy);
341
- });
342
- return [postMergedValue, triggerChange];
343
- }
344
-
345
- /**
346
- * @ignore
347
- * some key-codes definition and utils from closure-library
348
- * @author yiminghe@gmail.com
349
- */
350
-
351
- var KeyCode = {
352
- /**
353
- * MAC_ENTER
354
- */
355
- MAC_ENTER: 3,
356
- /**
357
- * BACKSPACE
358
- */
359
- BACKSPACE: 8,
360
- /**
361
- * TAB
362
- */
363
- TAB: 9,
364
- /**
365
- * NUMLOCK on FF/Safari Mac
366
- */
367
- NUM_CENTER: 12,
368
- // NUMLOCK on FF/Safari Mac
369
- /**
370
- * ENTER
371
- */
372
- ENTER: 13,
373
- /**
374
- * SHIFT
375
- */
376
- SHIFT: 16,
377
- /**
378
- * CTRL
379
- */
380
- CTRL: 17,
381
- /**
382
- * ALT
383
- */
384
- ALT: 18,
385
- /**
386
- * PAUSE
387
- */
388
- PAUSE: 19,
389
- /**
390
- * CAPS_LOCK
391
- */
392
- CAPS_LOCK: 20,
393
- /**
394
- * ESC
395
- */
396
- ESC: 27,
397
- /**
398
- * SPACE
399
- */
400
- SPACE: 32,
401
- /**
402
- * PAGE_UP
403
- */
404
- PAGE_UP: 33,
405
- // also NUM_NORTH_EAST
406
- /**
407
- * PAGE_DOWN
408
- */
409
- PAGE_DOWN: 34,
410
- // also NUM_SOUTH_EAST
411
- /**
412
- * END
413
- */
414
- END: 35,
415
- // also NUM_SOUTH_WEST
416
- /**
417
- * HOME
418
- */
419
- HOME: 36,
420
- // also NUM_NORTH_WEST
421
- /**
422
- * LEFT
423
- */
424
- LEFT: 37,
425
- // also NUM_WEST
426
- /**
427
- * UP
428
- */
429
- UP: 38,
430
- // also NUM_NORTH
431
- /**
432
- * RIGHT
433
- */
434
- RIGHT: 39,
435
- // also NUM_EAST
436
- /**
437
- * DOWN
438
- */
439
- DOWN: 40,
440
- // also NUM_SOUTH
441
- /**
442
- * PRINT_SCREEN
443
- */
444
- PRINT_SCREEN: 44,
445
- /**
446
- * INSERT
447
- */
448
- INSERT: 45,
449
- // also NUM_INSERT
450
- /**
451
- * DELETE
452
- */
453
- DELETE: 46,
454
- // also NUM_DELETE
455
- /**
456
- * ZERO
457
- */
458
- ZERO: 48,
459
- /**
460
- * ONE
461
- */
462
- ONE: 49,
463
- /**
464
- * TWO
465
- */
466
- TWO: 50,
467
- /**
468
- * THREE
469
- */
470
- THREE: 51,
471
- /**
472
- * FOUR
473
- */
474
- FOUR: 52,
475
- /**
476
- * FIVE
477
- */
478
- FIVE: 53,
479
- /**
480
- * SIX
481
- */
482
- SIX: 54,
483
- /**
484
- * SEVEN
485
- */
486
- SEVEN: 55,
487
- /**
488
- * EIGHT
489
- */
490
- EIGHT: 56,
491
- /**
492
- * NINE
493
- */
494
- NINE: 57,
495
- /**
496
- * QUESTION_MARK
497
- */
498
- QUESTION_MARK: 63,
499
- // needs localization
500
- /**
501
- * A
502
- */
503
- A: 65,
504
- /**
505
- * B
506
- */
507
- B: 66,
508
- /**
509
- * C
510
- */
511
- C: 67,
512
- /**
513
- * D
514
- */
515
- D: 68,
516
- /**
517
- * E
518
- */
519
- E: 69,
520
- /**
521
- * F
522
- */
523
- F: 70,
524
- /**
525
- * G
526
- */
527
- G: 71,
528
- /**
529
- * H
530
- */
531
- H: 72,
532
- /**
533
- * I
534
- */
535
- I: 73,
536
- /**
537
- * J
538
- */
539
- J: 74,
540
- /**
541
- * K
542
- */
543
- K: 75,
544
- /**
545
- * L
546
- */
547
- L: 76,
548
- /**
549
- * M
550
- */
551
- M: 77,
552
- /**
553
- * N
554
- */
555
- N: 78,
556
- /**
557
- * O
558
- */
559
- O: 79,
560
- /**
561
- * P
562
- */
563
- P: 80,
564
- /**
565
- * Q
566
- */
567
- Q: 81,
568
- /**
569
- * R
570
- */
571
- R: 82,
572
- /**
573
- * S
574
- */
575
- S: 83,
576
- /**
577
- * T
578
- */
579
- T: 84,
580
- /**
581
- * U
582
- */
583
- U: 85,
584
- /**
585
- * V
586
- */
587
- V: 86,
588
- /**
589
- * W
590
- */
591
- W: 87,
592
- /**
593
- * X
594
- */
595
- X: 88,
596
- /**
597
- * Y
598
- */
599
- Y: 89,
600
- /**
601
- * Z
602
- */
603
- Z: 90,
604
- /**
605
- * META
606
- */
607
- META: 91,
608
- // WIN_KEY_LEFT
609
- /**
610
- * WIN_KEY_RIGHT
611
- */
612
- WIN_KEY_RIGHT: 92,
613
- /**
614
- * CONTEXT_MENU
615
- */
616
- CONTEXT_MENU: 93,
617
- /**
618
- * NUM_ZERO
619
- */
620
- NUM_ZERO: 96,
621
- /**
622
- * NUM_ONE
623
- */
624
- NUM_ONE: 97,
625
- /**
626
- * NUM_TWO
627
- */
628
- NUM_TWO: 98,
629
- /**
630
- * NUM_THREE
631
- */
632
- NUM_THREE: 99,
633
- /**
634
- * NUM_FOUR
635
- */
636
- NUM_FOUR: 100,
637
- /**
638
- * NUM_FIVE
639
- */
640
- NUM_FIVE: 101,
641
- /**
642
- * NUM_SIX
643
- */
644
- NUM_SIX: 102,
645
- /**
646
- * NUM_SEVEN
647
- */
648
- NUM_SEVEN: 103,
649
- /**
650
- * NUM_EIGHT
651
- */
652
- NUM_EIGHT: 104,
653
- /**
654
- * NUM_NINE
655
- */
656
- NUM_NINE: 105,
657
- /**
658
- * NUM_MULTIPLY
659
- */
660
- NUM_MULTIPLY: 106,
661
- /**
662
- * NUM_PLUS
663
- */
664
- NUM_PLUS: 107,
665
- /**
666
- * NUM_MINUS
667
- */
668
- NUM_MINUS: 109,
669
- /**
670
- * NUM_PERIOD
671
- */
672
- NUM_PERIOD: 110,
673
- /**
674
- * NUM_DIVISION
675
- */
676
- NUM_DIVISION: 111,
677
- /**
678
- * F1
679
- */
680
- F1: 112,
681
- /**
682
- * F2
683
- */
684
- F2: 113,
685
- /**
686
- * F3
687
- */
688
- F3: 114,
689
- /**
690
- * F4
691
- */
692
- F4: 115,
693
- /**
694
- * F5
695
- */
696
- F5: 116,
697
- /**
698
- * F6
699
- */
700
- F6: 117,
701
- /**
702
- * F7
703
- */
704
- F7: 118,
705
- /**
706
- * F8
707
- */
708
- F8: 119,
709
- /**
710
- * F9
711
- */
712
- F9: 120,
713
- /**
714
- * F10
715
- */
716
- F10: 121,
717
- /**
718
- * F11
719
- */
720
- F11: 122,
721
- /**
722
- * F12
723
- */
724
- F12: 123,
725
- /**
726
- * NUMLOCK
727
- */
728
- NUMLOCK: 144,
729
- /**
730
- * SEMICOLON
731
- */
732
- SEMICOLON: 186,
733
- // needs localization
734
- /**
735
- * DASH
736
- */
737
- DASH: 189,
738
- // needs localization
739
- /**
740
- * EQUALS
741
- */
742
- EQUALS: 187,
743
- // needs localization
744
- /**
745
- * COMMA
746
- */
747
- COMMA: 188,
748
- // needs localization
749
- /**
750
- * PERIOD
751
- */
752
- PERIOD: 190,
753
- // needs localization
754
- /**
755
- * SLASH
756
- */
757
- SLASH: 191,
758
- // needs localization
759
- /**
760
- * APOSTROPHE
761
- */
762
- APOSTROPHE: 192,
763
- // needs localization
764
- /**
765
- * SINGLE_QUOTE
766
- */
767
- SINGLE_QUOTE: 222,
768
- // needs localization
769
- /**
770
- * OPEN_SQUARE_BRACKET
771
- */
772
- OPEN_SQUARE_BRACKET: 219,
773
- // needs localization
774
- /**
775
- * BACKSLASH
776
- */
777
- BACKSLASH: 220,
778
- // needs localization
779
- /**
780
- * CLOSE_SQUARE_BRACKET
781
- */
782
- CLOSE_SQUARE_BRACKET: 221,
783
- // needs localization
784
- /**
785
- * WIN_KEY
786
- */
787
- WIN_KEY: 224,
788
- /**
789
- * MAC_FF_META
790
- */
791
- MAC_FF_META: 224,
792
- // Firefox (Gecko) fires this for the meta key instead of 91
793
- /**
794
- * WIN_IME
795
- */
796
- WIN_IME: 229,
797
- // ======================== Function ========================
798
- /**
799
- * whether text and modified key is entered at the same time.
800
- */
801
- isTextModifyingKeyEvent: function isTextModifyingKeyEvent(e) {
802
- var keyCode = e.keyCode;
803
- if (e.altKey && !e.ctrlKey || e.metaKey ||
804
- // Function keys don't generate text
805
- keyCode >= KeyCode.F1 && keyCode <= KeyCode.F12) {
806
- return false;
807
- }
808
-
809
- // The following keys are quite harmless, even in combination with
810
- // CTRL, ALT or SHIFT.
811
- switch (keyCode) {
812
- case KeyCode.ALT:
813
- case KeyCode.CAPS_LOCK:
814
- case KeyCode.CONTEXT_MENU:
815
- case KeyCode.CTRL:
816
- case KeyCode.DOWN:
817
- case KeyCode.END:
818
- case KeyCode.ESC:
819
- case KeyCode.HOME:
820
- case KeyCode.INSERT:
821
- case KeyCode.LEFT:
822
- case KeyCode.MAC_FF_META:
823
- case KeyCode.META:
824
- case KeyCode.NUMLOCK:
825
- case KeyCode.NUM_CENTER:
826
- case KeyCode.PAGE_DOWN:
827
- case KeyCode.PAGE_UP:
828
- case KeyCode.PAUSE:
829
- case KeyCode.PRINT_SCREEN:
830
- case KeyCode.RIGHT:
831
- case KeyCode.SHIFT:
832
- case KeyCode.UP:
833
- case KeyCode.WIN_KEY:
834
- case KeyCode.WIN_KEY_RIGHT:
835
- return false;
836
- default:
837
- return true;
838
- }
839
- },
840
- /**
841
- * whether character is entered.
842
- */
843
- isCharacterKey: function isCharacterKey(keyCode) {
844
- if (keyCode >= KeyCode.ZERO && keyCode <= KeyCode.NINE) {
845
- return true;
846
- }
847
- if (keyCode >= KeyCode.NUM_ZERO && keyCode <= KeyCode.NUM_MULTIPLY) {
848
- return true;
849
- }
850
- if (keyCode >= KeyCode.A && keyCode <= KeyCode.Z) {
851
- return true;
852
- }
853
-
854
- // Safari sends zero key code for non-latin characters.
855
- if (window.navigator.userAgent.indexOf('WebKit') !== -1 && keyCode === 0) {
856
- return true;
857
- }
858
- switch (keyCode) {
859
- case KeyCode.SPACE:
860
- case KeyCode.QUESTION_MARK:
861
- case KeyCode.NUM_PLUS:
862
- case KeyCode.NUM_MINUS:
863
- case KeyCode.NUM_PERIOD:
864
- case KeyCode.NUM_DIVISION:
865
- case KeyCode.SEMICOLON:
866
- case KeyCode.DASH:
867
- case KeyCode.EQUALS:
868
- case KeyCode.COMMA:
869
- case KeyCode.PERIOD:
870
- case KeyCode.SLASH:
871
- case KeyCode.APOSTROPHE:
872
- case KeyCode.SINGLE_QUOTE:
873
- case KeyCode.OPEN_SQUARE_BRACKET:
874
- case KeyCode.BACKSLASH:
875
- case KeyCode.CLOSE_SQUARE_BRACKET:
876
- return true;
877
- default:
878
- return false;
879
- }
880
- }
881
- };
882
-
883
- var SliderContext = /*#__PURE__*/React__namespace.createContext({
884
- min: 0,
885
- max: 0,
886
- direction: 'ltr',
887
- step: 1,
888
- includedStart: 0,
889
- includedEnd: 0,
890
- tabIndex: 0,
891
- keyboard: true
892
- });
893
-
894
- function getOffset(value, min, max) {
895
- return (value - min) / (max - min);
896
- }
897
- function getDirectionStyle(direction, value, min, max) {
898
- var offset = getOffset(value, min, max);
899
- var positionStyle = {};
900
- switch (direction) {
901
- case 'rtl':
902
- positionStyle.right = "".concat(offset * 100, "%");
903
- positionStyle.transform = 'translateX(50%)';
904
- break;
905
- case 'btt':
906
- positionStyle.bottom = "".concat(offset * 100, "%");
907
- positionStyle.transform = 'translateY(50%)';
908
- break;
909
- case 'ttb':
910
- positionStyle.top = "".concat(offset * 100, "%");
911
- positionStyle.transform = 'translateY(-50%)';
912
- break;
913
- default:
914
- positionStyle.left = "".concat(offset * 100, "%");
915
- positionStyle.transform = 'translateX(-50%)';
916
- break;
917
- }
918
- return positionStyle;
919
- }
920
- /** Return index value if is list or return value directly */
921
- function getIndex(value, index) {
922
- return Array.isArray(value) ? value[index] : value;
923
- }
924
-
925
- var _excluded$1 = ["prefixCls", "value", "valueIndex", "onStartMove", "style", "render", "dragging", "onOffsetChange"];
926
- var Handle = /*#__PURE__*/React__namespace.forwardRef(function (props, ref) {
927
- var _classNames, _getIndex;
928
- var prefixCls = props.prefixCls,
929
- value = props.value,
930
- valueIndex = props.valueIndex,
931
- onStartMove = props.onStartMove,
932
- style = props.style,
933
- render = props.render,
934
- dragging = props.dragging,
935
- onOffsetChange = props.onOffsetChange,
936
- restProps = objectWithoutProperties._objectWithoutProperties(props, _excluded$1);
937
- var _React$useContext = React__namespace.useContext(SliderContext),
938
- min = _React$useContext.min,
939
- max = _React$useContext.max,
940
- direction = _React$useContext.direction,
941
- disabled = _React$useContext.disabled,
942
- keyboard = _React$useContext.keyboard,
943
- range = _React$useContext.range,
944
- tabIndex = _React$useContext.tabIndex,
945
- ariaLabelForHandle = _React$useContext.ariaLabelForHandle,
946
- ariaLabelledByForHandle = _React$useContext.ariaLabelledByForHandle,
947
- ariaValueTextFormatterForHandle = _React$useContext.ariaValueTextFormatterForHandle;
948
- var handlePrefixCls = "".concat(prefixCls, "-handle");
949
- // ============================ Events ============================
950
- var onInternalStartMove = function onInternalStartMove(e) {
951
- if (!disabled) {
952
- onStartMove(e, valueIndex);
953
- }
954
- };
955
- // =========================== Keyboard ===========================
956
- var onKeyDown = function onKeyDown(e) {
957
- if (!disabled && keyboard) {
958
- var offset = null;
959
- // Change the value
960
- switch (e.which || e.keyCode) {
961
- case KeyCode.LEFT:
962
- offset = direction === 'ltr' || direction === 'btt' ? -1 : 1;
963
- break;
964
- case KeyCode.RIGHT:
965
- offset = direction === 'ltr' || direction === 'btt' ? 1 : -1;
966
- break;
967
- // Up is plus
968
- case KeyCode.UP:
969
- offset = direction !== 'ttb' ? 1 : -1;
970
- break;
971
- // Down is minus
972
- case KeyCode.DOWN:
973
- offset = direction !== 'ttb' ? -1 : 1;
974
- break;
975
- case KeyCode.HOME:
976
- offset = 'min';
977
- break;
978
- case KeyCode.END:
979
- offset = 'max';
980
- break;
981
- case KeyCode.PAGE_UP:
982
- offset = 2;
983
- break;
984
- case KeyCode.PAGE_DOWN:
985
- offset = -2;
986
- break;
987
- }
988
- if (offset !== null) {
989
- e.preventDefault();
990
- onOffsetChange(offset, valueIndex);
991
- }
992
- }
993
- };
994
- // ============================ Offset ============================
995
- var positionStyle = getDirectionStyle(direction, value, min, max);
996
- // ============================ Render ============================
997
- var handleNode = /*#__PURE__*/React__namespace.createElement("div", objectWithoutProperties._extends({
998
- ref: ref,
999
- className: classNames(handlePrefixCls, (_classNames = {}, objectWithoutProperties._defineProperty(_classNames, "".concat(handlePrefixCls, "-").concat(valueIndex + 1), range), objectWithoutProperties._defineProperty(_classNames, "".concat(handlePrefixCls, "-dragging"), dragging), _classNames)),
1000
- style: objectWithoutProperties._objectSpread2(objectWithoutProperties._objectSpread2({}, positionStyle), style),
1001
- onMouseDown: onInternalStartMove,
1002
- onTouchStart: onInternalStartMove,
1003
- onKeyDown: onKeyDown,
1004
- tabIndex: disabled ? null : getIndex(tabIndex, valueIndex),
1005
- role: "slider",
1006
- "aria-valuemin": min,
1007
- "aria-valuemax": max,
1008
- "aria-valuenow": value,
1009
- "aria-disabled": disabled,
1010
- "aria-label": getIndex(ariaLabelForHandle, valueIndex),
1011
- "aria-labelledby": getIndex(ariaLabelledByForHandle, valueIndex),
1012
- "aria-valuetext": (_getIndex = getIndex(ariaValueTextFormatterForHandle, valueIndex)) === null || _getIndex === void 0 ? void 0 : _getIndex(value),
1013
- "aria-orientation": direction === 'ltr' || direction === 'rtl' ? 'horizontal' : 'vertical'
1014
- }, restProps));
1015
- // Customize
1016
- if (render) {
1017
- handleNode = render(handleNode, {
1018
- index: valueIndex,
1019
- prefixCls: prefixCls,
1020
- value: value,
1021
- dragging: dragging
1022
- });
1023
- }
1024
- return handleNode;
1025
- });
1026
- if (process.env.NODE_ENV !== 'production') {
1027
- Handle.displayName = 'Handle';
1028
- }
1029
-
1030
- var _excluded = ["prefixCls", "style", "onStartMove", "onOffsetChange", "values", "handleRender", "draggingIndex"];
1031
- var Handles = /*#__PURE__*/React__namespace.forwardRef(function (props, ref) {
1032
- var prefixCls = props.prefixCls,
1033
- style = props.style,
1034
- onStartMove = props.onStartMove,
1035
- onOffsetChange = props.onOffsetChange,
1036
- values = props.values,
1037
- handleRender = props.handleRender,
1038
- draggingIndex = props.draggingIndex,
1039
- restProps = objectWithoutProperties._objectWithoutProperties(props, _excluded);
1040
- var handlesRef = React__namespace.useRef({});
1041
- React__namespace.useImperativeHandle(ref, function () {
1042
- return {
1043
- focus: function focus(index) {
1044
- var _handlesRef$current$i;
1045
- (_handlesRef$current$i = handlesRef.current[index]) === null || _handlesRef$current$i === void 0 ? void 0 : _handlesRef$current$i.focus();
1046
- }
1047
- };
1048
- });
1049
- return /*#__PURE__*/React__namespace.createElement(React__namespace.Fragment, null, values.map(function (value, index) {
1050
- return /*#__PURE__*/React__namespace.createElement(Handle, objectWithoutProperties._extends({
1051
- ref: function ref(node) {
1052
- if (!node) {
1053
- delete handlesRef.current[index];
1054
- } else {
1055
- handlesRef.current[index] = node;
1056
- }
1057
- },
1058
- dragging: draggingIndex === index,
1059
- prefixCls: prefixCls,
1060
- style: getIndex(style, index),
1061
- key: index,
1062
- value: value,
1063
- valueIndex: index,
1064
- onStartMove: onStartMove,
1065
- onOffsetChange: onOffsetChange,
1066
- render: handleRender
1067
- }, restProps));
1068
- }));
1069
- });
1070
- if (process.env.NODE_ENV !== 'production') {
1071
- Handles.displayName = 'Handles';
1072
- }
1073
-
1074
- function getPosition(e) {
1075
- var obj = 'touches' in e ? e.touches[0] : e;
1076
- return {
1077
- pageX: obj.pageX,
1078
- pageY: obj.pageY
1079
- };
1080
- }
1081
- function useDrag(containerRef, direction, rawValues, min, max, formatValue, triggerChange, finishChange, offsetValues) {
1082
- var _React$useState = React__namespace.useState(null),
1083
- _React$useState2 = objectWithoutProperties._slicedToArray(_React$useState, 2),
1084
- draggingValue = _React$useState2[0],
1085
- setDraggingValue = _React$useState2[1];
1086
- var _React$useState3 = React__namespace.useState(-1),
1087
- _React$useState4 = objectWithoutProperties._slicedToArray(_React$useState3, 2),
1088
- draggingIndex = _React$useState4[0],
1089
- setDraggingIndex = _React$useState4[1];
1090
- var _React$useState5 = React__namespace.useState(rawValues),
1091
- _React$useState6 = objectWithoutProperties._slicedToArray(_React$useState5, 2),
1092
- cacheValues = _React$useState6[0],
1093
- setCacheValues = _React$useState6[1];
1094
- var _React$useState7 = React__namespace.useState(rawValues),
1095
- _React$useState8 = objectWithoutProperties._slicedToArray(_React$useState7, 2),
1096
- originValues = _React$useState8[0],
1097
- setOriginValues = _React$useState8[1];
1098
- var mouseMoveEventRef = React__namespace.useRef(null);
1099
- var mouseUpEventRef = React__namespace.useRef(null);
1100
- React__namespace.useEffect(function () {
1101
- if (draggingIndex === -1) {
1102
- setCacheValues(rawValues);
1103
- }
1104
- }, [rawValues, draggingIndex]);
1105
- // Clean up event
1106
- React__namespace.useEffect(function () {
1107
- return function () {
1108
- document.removeEventListener('mousemove', mouseMoveEventRef.current);
1109
- document.removeEventListener('mouseup', mouseUpEventRef.current);
1110
- document.removeEventListener('touchmove', mouseMoveEventRef.current);
1111
- document.removeEventListener('touchend', mouseUpEventRef.current);
1112
- };
1113
- }, []);
1114
- var flushValues = function flushValues(nextValues, nextValue) {
1115
- // Perf: Only update state when value changed
1116
- if (cacheValues.some(function (val, i) {
1117
- return val !== nextValues[i];
1118
- })) {
1119
- if (nextValue !== undefined) {
1120
- setDraggingValue(nextValue);
1121
- }
1122
- setCacheValues(nextValues);
1123
- triggerChange(nextValues);
1124
- }
1125
- };
1126
- var updateCacheValue = function updateCacheValue(valueIndex, offsetPercent) {
1127
- // Basic point offset
1128
- if (valueIndex === -1) {
1129
- // >>>> Dragging on the track
1130
- var startValue = originValues[0];
1131
- var endValue = originValues[originValues.length - 1];
1132
- var maxStartOffset = min - startValue;
1133
- var maxEndOffset = max - endValue;
1134
- // Get valid offset
1135
- var offset = offsetPercent * (max - min);
1136
- offset = Math.max(offset, maxStartOffset);
1137
- offset = Math.min(offset, maxEndOffset);
1138
- // Use first value to revert back of valid offset (like steps marks)
1139
- var formatStartValue = formatValue(startValue + offset);
1140
- offset = formatStartValue - startValue;
1141
- var cloneCacheValues = originValues.map(function (val) {
1142
- return val + offset;
1143
- });
1144
- flushValues(cloneCacheValues);
1145
- } else {
1146
- // >>>> Dragging on the handle
1147
- var offsetDist = (max - min) * offsetPercent;
1148
- // Always start with the valueIndex origin value
1149
- var cloneValues = objectWithoutProperties._toConsumableArray(cacheValues);
1150
- cloneValues[valueIndex] = originValues[valueIndex];
1151
- var next = offsetValues(cloneValues, offsetDist, valueIndex, 'dist');
1152
- flushValues(next.values, next.value);
1153
- }
1154
- };
1155
- // Resolve closure
1156
- var updateCacheValueRef = React__namespace.useRef(updateCacheValue);
1157
- updateCacheValueRef.current = updateCacheValue;
1158
- var onStartMove = function onStartMove(e, valueIndex) {
1159
- e.stopPropagation();
1160
- var originValue = rawValues[valueIndex];
1161
- setDraggingIndex(valueIndex);
1162
- setDraggingValue(originValue);
1163
- setOriginValues(rawValues);
1164
- var _getPosition = getPosition(e),
1165
- startX = _getPosition.pageX,
1166
- startY = _getPosition.pageY;
1167
- // Moving
1168
- var onMouseMove = function onMouseMove(event) {
1169
- event.preventDefault();
1170
- var _getPosition2 = getPosition(event),
1171
- moveX = _getPosition2.pageX,
1172
- moveY = _getPosition2.pageY;
1173
- var offsetX = moveX - startX;
1174
- var offsetY = moveY - startY;
1175
- var _containerRef$current = containerRef.current.getBoundingClientRect(),
1176
- width = _containerRef$current.width,
1177
- height = _containerRef$current.height;
1178
- var offSetPercent;
1179
- switch (direction) {
1180
- case 'btt':
1181
- offSetPercent = -offsetY / height;
1182
- break;
1183
- case 'ttb':
1184
- offSetPercent = offsetY / height;
1185
- break;
1186
- case 'rtl':
1187
- offSetPercent = -offsetX / width;
1188
- break;
1189
- default:
1190
- offSetPercent = offsetX / width;
1191
- }
1192
- updateCacheValueRef.current(valueIndex, offSetPercent);
1193
- };
1194
- // End
1195
- var onMouseUp = function onMouseUp(event) {
1196
- event.preventDefault();
1197
- document.removeEventListener('mouseup', onMouseUp);
1198
- document.removeEventListener('mousemove', onMouseMove);
1199
- document.removeEventListener('touchend', onMouseUp);
1200
- document.removeEventListener('touchmove', onMouseMove);
1201
- mouseMoveEventRef.current = null;
1202
- mouseUpEventRef.current = null;
1203
- setDraggingIndex(-1);
1204
- finishChange();
1205
- };
1206
- document.addEventListener('mouseup', onMouseUp);
1207
- document.addEventListener('mousemove', onMouseMove);
1208
- document.addEventListener('touchend', onMouseUp);
1209
- document.addEventListener('touchmove', onMouseMove);
1210
- mouseMoveEventRef.current = onMouseMove;
1211
- mouseUpEventRef.current = onMouseUp;
1212
- };
1213
- // Only return cache value when it mapping with rawValues
1214
- var returnValues = React__namespace.useMemo(function () {
1215
- var sourceValues = objectWithoutProperties._toConsumableArray(rawValues).sort(function (a, b) {
1216
- return a - b;
1217
- });
1218
- var targetValues = objectWithoutProperties._toConsumableArray(cacheValues).sort(function (a, b) {
1219
- return a - b;
1220
- });
1221
- return sourceValues.every(function (val, index) {
1222
- return val === targetValues[index];
1223
- }) ? cacheValues : rawValues;
1224
- }, [rawValues, cacheValues]);
1225
- return [draggingIndex, draggingValue, returnValues, onStartMove];
1226
- }
1227
-
1228
- function Track(props) {
1229
- var _classNames;
1230
- var prefixCls = props.prefixCls,
1231
- style = props.style,
1232
- start = props.start,
1233
- end = props.end,
1234
- index = props.index,
1235
- onStartMove = props.onStartMove;
1236
- var _React$useContext = React__namespace.useContext(SliderContext),
1237
- direction = _React$useContext.direction,
1238
- min = _React$useContext.min,
1239
- max = _React$useContext.max,
1240
- disabled = _React$useContext.disabled,
1241
- range = _React$useContext.range;
1242
- var trackPrefixCls = "".concat(prefixCls, "-track");
1243
- var offsetStart = getOffset(start, min, max);
1244
- var offsetEnd = getOffset(end, min, max);
1245
- // ============================ Events ============================
1246
- var onInternalStartMove = function onInternalStartMove(e) {
1247
- if (!disabled && onStartMove) {
1248
- onStartMove(e, -1);
1249
- }
1250
- };
1251
- // ============================ Render ============================
1252
- var positionStyle = {};
1253
- switch (direction) {
1254
- case 'rtl':
1255
- positionStyle.right = "".concat(offsetStart * 100, "%");
1256
- positionStyle.width = "".concat(offsetEnd * 100 - offsetStart * 100, "%");
1257
- break;
1258
- case 'btt':
1259
- positionStyle.bottom = "".concat(offsetStart * 100, "%");
1260
- positionStyle.height = "".concat(offsetEnd * 100 - offsetStart * 100, "%");
1261
- break;
1262
- case 'ttb':
1263
- positionStyle.top = "".concat(offsetStart * 100, "%");
1264
- positionStyle.height = "".concat(offsetEnd * 100 - offsetStart * 100, "%");
1265
- break;
1266
- default:
1267
- positionStyle.left = "".concat(offsetStart * 100, "%");
1268
- positionStyle.width = "".concat(offsetEnd * 100 - offsetStart * 100, "%");
1269
- }
1270
- return /*#__PURE__*/React__namespace.createElement("div", {
1271
- className: classNames(trackPrefixCls, (_classNames = {}, objectWithoutProperties._defineProperty(_classNames, "".concat(trackPrefixCls, "-").concat(index + 1), range), objectWithoutProperties._defineProperty(_classNames, "".concat(prefixCls, "-track-draggable"), onStartMove), _classNames)),
1272
- style: objectWithoutProperties._objectSpread2(objectWithoutProperties._objectSpread2({}, positionStyle), style),
1273
- onMouseDown: onInternalStartMove,
1274
- onTouchStart: onInternalStartMove
1275
- });
1276
- }
1277
-
1278
- function Tracks(props) {
1279
- var prefixCls = props.prefixCls,
1280
- style = props.style,
1281
- values = props.values,
1282
- startPoint = props.startPoint,
1283
- onStartMove = props.onStartMove;
1284
- var _React$useContext = React__namespace.useContext(SliderContext),
1285
- included = _React$useContext.included,
1286
- range = _React$useContext.range,
1287
- min = _React$useContext.min;
1288
- var trackList = React__namespace.useMemo(function () {
1289
- if (!range) {
1290
- // null value do not have track
1291
- if (values.length === 0) {
1292
- return [];
1293
- }
1294
- var startValue = startPoint !== null && startPoint !== void 0 ? startPoint : min;
1295
- var endValue = values[0];
1296
- return [{
1297
- start: Math.min(startValue, endValue),
1298
- end: Math.max(startValue, endValue)
1299
- }];
1300
- }
1301
- // Multiple
1302
- var list = [];
1303
- for (var i = 0; i < values.length - 1; i += 1) {
1304
- list.push({
1305
- start: values[i],
1306
- end: values[i + 1]
1307
- });
1308
- }
1309
- return list;
1310
- }, [values, range, startPoint, min]);
1311
- return included ? trackList.map(function (_ref, index) {
1312
- var start = _ref.start,
1313
- end = _ref.end;
1314
- return /*#__PURE__*/React__namespace.createElement(Track, {
1315
- index: index,
1316
- prefixCls: prefixCls,
1317
- style: getIndex(style, index),
1318
- start: start,
1319
- end: end,
1320
- key: index,
1321
- onStartMove: onStartMove
1322
- });
1323
- }) : null;
1324
- }
1325
-
1326
- function Mark(props) {
1327
- var prefixCls = props.prefixCls,
1328
- style = props.style,
1329
- children = props.children,
1330
- value = props.value,
1331
- _onClick = props.onClick;
1332
- var _React$useContext = React__namespace.useContext(SliderContext),
1333
- min = _React$useContext.min,
1334
- max = _React$useContext.max,
1335
- direction = _React$useContext.direction,
1336
- includedStart = _React$useContext.includedStart,
1337
- includedEnd = _React$useContext.includedEnd,
1338
- included = _React$useContext.included;
1339
- var textCls = "".concat(prefixCls, "-text");
1340
- // ============================ Offset ============================
1341
- var positionStyle = getDirectionStyle(direction, value, min, max);
1342
- return /*#__PURE__*/React__namespace.createElement("span", {
1343
- className: classNames(textCls, objectWithoutProperties._defineProperty({}, "".concat(textCls, "-active"), included && includedStart <= value && value <= includedEnd)),
1344
- style: objectWithoutProperties._objectSpread2(objectWithoutProperties._objectSpread2({}, positionStyle), style),
1345
- onMouseDown: function onMouseDown(e) {
1346
- e.stopPropagation();
1347
- },
1348
- onClick: function onClick() {
1349
- _onClick(value);
1350
- }
1351
- }, children);
1352
- }
1353
-
1354
- function Marks(props) {
1355
- var prefixCls = props.prefixCls,
1356
- marks = props.marks,
1357
- onClick = props.onClick;
1358
- var markPrefixCls = "".concat(prefixCls, "-mark");
1359
- // Not render mark if empty
1360
- if (!marks.length) {
1361
- return null;
1362
- }
1363
- return /*#__PURE__*/React__namespace.createElement("div", {
1364
- className: markPrefixCls
1365
- }, marks.map(function (_ref) {
1366
- var value = _ref.value,
1367
- style = _ref.style,
1368
- label = _ref.label;
1369
- return /*#__PURE__*/React__namespace.createElement(Mark, {
1370
- key: value,
1371
- prefixCls: markPrefixCls,
1372
- style: style,
1373
- value: value,
1374
- onClick: onClick
1375
- }, label);
1376
- }));
1377
- }
1378
-
1379
- function Dot(props) {
1380
- var prefixCls = props.prefixCls,
1381
- value = props.value,
1382
- style = props.style,
1383
- activeStyle = props.activeStyle;
1384
- var _React$useContext = React__namespace.useContext(SliderContext),
1385
- min = _React$useContext.min,
1386
- max = _React$useContext.max,
1387
- direction = _React$useContext.direction,
1388
- included = _React$useContext.included,
1389
- includedStart = _React$useContext.includedStart,
1390
- includedEnd = _React$useContext.includedEnd;
1391
- var dotClassName = "".concat(prefixCls, "-dot");
1392
- var active = included && includedStart <= value && value <= includedEnd;
1393
- // ============================ Offset ============================
1394
- var mergedStyle = objectWithoutProperties._objectSpread2(objectWithoutProperties._objectSpread2({}, getDirectionStyle(direction, value, min, max)), typeof style === 'function' ? style(value) : style);
1395
- if (active) {
1396
- mergedStyle = objectWithoutProperties._objectSpread2(objectWithoutProperties._objectSpread2({}, mergedStyle), typeof activeStyle === 'function' ? activeStyle(value) : activeStyle);
1397
- }
1398
- return /*#__PURE__*/React__namespace.createElement("span", {
1399
- className: classNames(dotClassName, objectWithoutProperties._defineProperty({}, "".concat(dotClassName, "-active"), active)),
1400
- style: mergedStyle
1401
- });
1402
- }
1403
-
1404
- function Steps(props) {
1405
- var prefixCls = props.prefixCls,
1406
- marks = props.marks,
1407
- dots = props.dots,
1408
- style = props.style,
1409
- activeStyle = props.activeStyle;
1410
- var _React$useContext = React__namespace.useContext(SliderContext),
1411
- min = _React$useContext.min,
1412
- max = _React$useContext.max,
1413
- step = _React$useContext.step;
1414
- var stepDots = React__namespace.useMemo(function () {
1415
- var dotSet = new Set();
1416
- // Add marks
1417
- marks.forEach(function (mark) {
1418
- dotSet.add(mark.value);
1419
- });
1420
- // Fill dots
1421
- if (dots && step !== null) {
1422
- var current = min;
1423
- while (current <= max) {
1424
- dotSet.add(current);
1425
- current += step;
1426
- }
1427
- }
1428
- return Array.from(dotSet);
1429
- }, [min, max, step, dots, marks]);
1430
- return /*#__PURE__*/React__namespace.createElement("div", {
1431
- className: "".concat(prefixCls, "-step")
1432
- }, stepDots.map(function (dotValue) {
1433
- return /*#__PURE__*/React__namespace.createElement(Dot, {
1434
- prefixCls: prefixCls,
1435
- key: dotValue,
1436
- value: dotValue,
1437
- style: style,
1438
- activeStyle: activeStyle
1439
- });
1440
- }));
1441
- }
1442
-
1443
- function useOffset(min, max, step, markList, allowCross, pushable) {
1444
- var formatRangeValue = React__namespace.useCallback(function (val) {
1445
- var formatNextValue = isFinite(val) ? val : min;
1446
- formatNextValue = Math.min(max, val);
1447
- formatNextValue = Math.max(min, formatNextValue);
1448
- return formatNextValue;
1449
- }, [min, max]);
1450
- var formatStepValue = React__namespace.useCallback(function (val) {
1451
- if (step !== null) {
1452
- var stepValue = min + Math.round((formatRangeValue(val) - min) / step) * step;
1453
- // Cut number in case to be like 0.30000000000000004
1454
- var getDecimal = function getDecimal(num) {
1455
- return (String(num).split('.')[1] || '').length;
1456
- };
1457
- var maxDecimal = Math.max(getDecimal(step), getDecimal(max), getDecimal(min));
1458
- var fixedValue = Number(stepValue.toFixed(maxDecimal));
1459
- return min <= fixedValue && fixedValue <= max ? fixedValue : null;
1460
- }
1461
- return null;
1462
- }, [step, min, max, formatRangeValue]);
1463
- var formatValue = React__namespace.useCallback(function (val) {
1464
- var formatNextValue = formatRangeValue(val);
1465
- // List align values
1466
- var alignValues = markList.map(function (mark) {
1467
- return mark.value;
1468
- });
1469
- if (step !== null) {
1470
- alignValues.push(formatStepValue(val));
1471
- }
1472
- // min & max
1473
- alignValues.push(min, max);
1474
- // Align with marks
1475
- var closeValue = alignValues[0];
1476
- var closeDist = max - min;
1477
- alignValues.forEach(function (alignValue) {
1478
- var dist = Math.abs(formatNextValue - alignValue);
1479
- if (dist <= closeDist) {
1480
- closeValue = alignValue;
1481
- closeDist = dist;
1482
- }
1483
- });
1484
- return closeValue;
1485
- }, [min, max, markList, step, formatRangeValue, formatStepValue]);
1486
- // ========================== Offset ==========================
1487
- // Single Value
1488
- var offsetValue = function offsetValue(values, offset, valueIndex) {
1489
- var mode = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : 'unit';
1490
- if (typeof offset === 'number') {
1491
- var nextValue;
1492
- var originValue = values[valueIndex];
1493
- // Only used for `dist` mode
1494
- var targetDistValue = originValue + offset;
1495
- // Compare next step value & mark value which is best match
1496
- var potentialValues = [];
1497
- markList.forEach(function (mark) {
1498
- potentialValues.push(mark.value);
1499
- });
1500
- // Min & Max
1501
- potentialValues.push(min, max);
1502
- // In case origin value is align with mark but not with step
1503
- potentialValues.push(formatStepValue(originValue));
1504
- // Put offset step value also
1505
- var sign = offset > 0 ? 1 : -1;
1506
- if (mode === 'unit') {
1507
- potentialValues.push(formatStepValue(originValue + sign * step));
1508
- } else {
1509
- potentialValues.push(formatStepValue(targetDistValue));
1510
- }
1511
- // Find close one
1512
- potentialValues = potentialValues.filter(function (val) {
1513
- return val !== null;
1514
- })
1515
- // Remove reverse value
1516
- .filter(function (val) {
1517
- return offset < 0 ? val <= originValue : val >= originValue;
1518
- });
1519
- if (mode === 'unit') {
1520
- // `unit` mode can not contain itself
1521
- potentialValues = potentialValues.filter(function (val) {
1522
- return val !== originValue;
1523
- });
1524
- }
1525
- var compareValue = mode === 'unit' ? originValue : targetDistValue;
1526
- nextValue = potentialValues[0];
1527
- var valueDist = Math.abs(nextValue - compareValue);
1528
- potentialValues.forEach(function (potentialValue) {
1529
- var dist = Math.abs(potentialValue - compareValue);
1530
- if (dist < valueDist) {
1531
- nextValue = potentialValue;
1532
- valueDist = dist;
1533
- }
1534
- });
1535
- // Out of range will back to range
1536
- if (nextValue === undefined) {
1537
- return offset < 0 ? min : max;
1538
- }
1539
- // `dist` mode
1540
- if (mode === 'dist') {
1541
- return nextValue;
1542
- }
1543
- // `unit` mode may need another round
1544
- if (Math.abs(offset) > 1) {
1545
- var cloneValues = objectWithoutProperties._toConsumableArray(values);
1546
- cloneValues[valueIndex] = nextValue;
1547
- return offsetValue(cloneValues, offset - sign, valueIndex, mode);
1548
- }
1549
- return nextValue;
1550
- } else if (offset === 'min') {
1551
- return min;
1552
- } else if (offset === 'max') {
1553
- return max;
1554
- }
1555
- };
1556
- /** Same as `offsetValue` but return `changed` mark to tell value changed */
1557
- var offsetChangedValue = function offsetChangedValue(values, offset, valueIndex) {
1558
- var mode = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : 'unit';
1559
- var originValue = values[valueIndex];
1560
- var nextValue = offsetValue(values, offset, valueIndex, mode);
1561
- return {
1562
- value: nextValue,
1563
- changed: nextValue !== originValue
1564
- };
1565
- };
1566
- var needPush = function needPush(dist) {
1567
- return pushable === null && dist === 0 || typeof pushable === 'number' && dist < pushable;
1568
- };
1569
- // Values
1570
- var offsetValues = function offsetValues(values, offset, valueIndex) {
1571
- var mode = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : 'unit';
1572
- var nextValues = values.map(formatValue);
1573
- var originValue = nextValues[valueIndex];
1574
- var nextValue = offsetValue(nextValues, offset, valueIndex, mode);
1575
- nextValues[valueIndex] = nextValue;
1576
- if (allowCross === false) {
1577
- // >>>>> Allow Cross
1578
- var pushNum = pushable || 0;
1579
- // ============ AllowCross ===============
1580
- if (valueIndex > 0 && nextValues[valueIndex - 1] !== originValue) {
1581
- nextValues[valueIndex] = Math.max(nextValues[valueIndex], nextValues[valueIndex - 1] + pushNum);
1582
- }
1583
- if (valueIndex < nextValues.length - 1 && nextValues[valueIndex + 1] !== originValue) {
1584
- nextValues[valueIndex] = Math.min(nextValues[valueIndex], nextValues[valueIndex + 1] - pushNum);
1585
- }
1586
- } else if (typeof pushable === 'number' || pushable === null) {
1587
- // >>>>> Pushable
1588
- // =============== Push ==================
1589
- // >>>>>> Basic push
1590
- // End values
1591
- for (var i = valueIndex + 1; i < nextValues.length; i += 1) {
1592
- var changed = true;
1593
- while (needPush(nextValues[i] - nextValues[i - 1]) && changed) {
1594
- var _offsetChangedValue = offsetChangedValue(nextValues, 1, i);
1595
- nextValues[i] = _offsetChangedValue.value;
1596
- changed = _offsetChangedValue.changed;
1597
- }
1598
- }
1599
- // Start values
1600
- for (var _i = valueIndex; _i > 0; _i -= 1) {
1601
- var _changed = true;
1602
- while (needPush(nextValues[_i] - nextValues[_i - 1]) && _changed) {
1603
- var _offsetChangedValue2 = offsetChangedValue(nextValues, -1, _i - 1);
1604
- nextValues[_i - 1] = _offsetChangedValue2.value;
1605
- _changed = _offsetChangedValue2.changed;
1606
- }
1607
- }
1608
- // >>>>> Revert back to safe push range
1609
- // End to Start
1610
- for (var _i2 = nextValues.length - 1; _i2 > 0; _i2 -= 1) {
1611
- var _changed2 = true;
1612
- while (needPush(nextValues[_i2] - nextValues[_i2 - 1]) && _changed2) {
1613
- var _offsetChangedValue3 = offsetChangedValue(nextValues, -1, _i2 - 1);
1614
- nextValues[_i2 - 1] = _offsetChangedValue3.value;
1615
- _changed2 = _offsetChangedValue3.changed;
1616
- }
1617
- }
1618
- // Start to End
1619
- for (var _i3 = 0; _i3 < nextValues.length - 1; _i3 += 1) {
1620
- var _changed3 = true;
1621
- while (needPush(nextValues[_i3 + 1] - nextValues[_i3]) && _changed3) {
1622
- var _offsetChangedValue4 = offsetChangedValue(nextValues, 1, _i3 + 1);
1623
- nextValues[_i3 + 1] = _offsetChangedValue4.value;
1624
- _changed3 = _offsetChangedValue4.changed;
1625
- }
1626
- }
1627
- }
1628
- return {
1629
- value: nextValues[valueIndex],
1630
- values: nextValues
1631
- };
1632
- };
1633
- return [formatValue, offsetValues];
1634
- }
1635
-
1636
- var Slider = /*#__PURE__*/React__namespace.forwardRef(function (props, ref) {
1637
- var _classNames;
1638
- var _props$prefixCls = props.prefixCls,
1639
- prefixCls = _props$prefixCls === void 0 ? 'rc-slider' : _props$prefixCls,
1640
- className = props.className,
1641
- style = props.style,
1642
- _props$disabled = props.disabled,
1643
- disabled = _props$disabled === void 0 ? false : _props$disabled,
1644
- _props$keyboard = props.keyboard,
1645
- keyboard = _props$keyboard === void 0 ? true : _props$keyboard,
1646
- autoFocus = props.autoFocus,
1647
- onFocus = props.onFocus,
1648
- onBlur = props.onBlur,
1649
- _props$min = props.min,
1650
- min = _props$min === void 0 ? 0 : _props$min,
1651
- _props$max = props.max,
1652
- max = _props$max === void 0 ? 100 : _props$max,
1653
- _props$step = props.step,
1654
- step = _props$step === void 0 ? 1 : _props$step,
1655
- value = props.value,
1656
- defaultValue = props.defaultValue,
1657
- range = props.range,
1658
- count = props.count,
1659
- onChange = props.onChange,
1660
- onBeforeChange = props.onBeforeChange,
1661
- onAfterChange = props.onAfterChange,
1662
- _props$allowCross = props.allowCross,
1663
- allowCross = _props$allowCross === void 0 ? true : _props$allowCross,
1664
- _props$pushable = props.pushable,
1665
- pushable = _props$pushable === void 0 ? false : _props$pushable,
1666
- draggableTrack = props.draggableTrack,
1667
- reverse = props.reverse,
1668
- vertical = props.vertical,
1669
- _props$included = props.included,
1670
- included = _props$included === void 0 ? true : _props$included,
1671
- startPoint = props.startPoint,
1672
- trackStyle = props.trackStyle,
1673
- handleStyle = props.handleStyle,
1674
- railStyle = props.railStyle,
1675
- dotStyle = props.dotStyle,
1676
- activeDotStyle = props.activeDotStyle,
1677
- marks = props.marks,
1678
- dots = props.dots,
1679
- handleRender = props.handleRender,
1680
- _props$tabIndex = props.tabIndex,
1681
- tabIndex = _props$tabIndex === void 0 ? 0 : _props$tabIndex,
1682
- ariaLabelForHandle = props.ariaLabelForHandle,
1683
- ariaLabelledByForHandle = props.ariaLabelledByForHandle,
1684
- ariaValueTextFormatterForHandle = props.ariaValueTextFormatterForHandle;
1685
- var handlesRef = React__namespace.useRef();
1686
- var containerRef = React__namespace.useRef();
1687
- var direction = React__namespace.useMemo(function () {
1688
- if (vertical) {
1689
- return reverse ? 'ttb' : 'btt';
1690
- }
1691
- return reverse ? 'rtl' : 'ltr';
1692
- }, [reverse, vertical]);
1693
- // ============================ Range =============================
1694
- var mergedMin = React__namespace.useMemo(function () {
1695
- return isFinite(min) ? min : 0;
1696
- }, [min]);
1697
- var mergedMax = React__namespace.useMemo(function () {
1698
- return isFinite(max) ? max : 100;
1699
- }, [max]);
1700
- // ============================= Step =============================
1701
- var mergedStep = React__namespace.useMemo(function () {
1702
- return step !== null && step <= 0 ? 1 : step;
1703
- }, [step]);
1704
- // ============================= Push =============================
1705
- var mergedPush = React__namespace.useMemo(function () {
1706
- if (typeof pushable === 'boolean') {
1707
- return pushable ? mergedStep : false;
1708
- }
1709
- return pushable >= 0 ? pushable : false;
1710
- }, [pushable, mergedStep]);
1711
- // ============================ Marks =============================
1712
- var markList = React__namespace.useMemo(function () {
1713
- var keys = Object.keys(marks || {});
1714
- return keys.map(function (key) {
1715
- var mark = marks[key];
1716
- var markObj = {
1717
- value: Number(key)
1718
- };
1719
- if (mark && objectWithoutProperties._typeof(mark) === 'object' && ! /*#__PURE__*/React__namespace.isValidElement(mark) && ('label' in mark || 'style' in mark)) {
1720
- markObj.style = mark.style;
1721
- markObj.label = mark.label;
1722
- } else {
1723
- markObj.label = mark;
1724
- }
1725
- return markObj;
1726
- }).filter(function (_ref) {
1727
- var label = _ref.label;
1728
- return label || typeof label === 'number';
1729
- }).sort(function (a, b) {
1730
- return a.value - b.value;
1731
- });
1732
- }, [marks]);
1733
- // ============================ Format ============================
1734
- var _useOffset = useOffset(mergedMin, mergedMax, mergedStep, markList, allowCross, mergedPush),
1735
- _useOffset2 = objectWithoutProperties._slicedToArray(_useOffset, 2),
1736
- formatValue = _useOffset2[0],
1737
- offsetValues = _useOffset2[1];
1738
- // ============================ Values ============================
1739
- var _useMergedState = useMergedState(defaultValue, {
1740
- value: value
1741
- }),
1742
- _useMergedState2 = objectWithoutProperties._slicedToArray(_useMergedState, 2),
1743
- mergedValue = _useMergedState2[0],
1744
- setValue = _useMergedState2[1];
1745
- var rawValues = React__namespace.useMemo(function () {
1746
- var valueList = mergedValue === null || mergedValue === undefined ? [] : Array.isArray(mergedValue) ? mergedValue : [mergedValue];
1747
- var _valueList = objectWithoutProperties._slicedToArray(valueList, 1),
1748
- _valueList$ = _valueList[0],
1749
- val0 = _valueList$ === void 0 ? mergedMin : _valueList$;
1750
- var returnValues = mergedValue === null ? [] : [val0];
1751
- // Format as range
1752
- if (range) {
1753
- returnValues = objectWithoutProperties._toConsumableArray(valueList);
1754
- // When count provided or value is `undefined`, we fill values
1755
- if (count || mergedValue === undefined) {
1756
- var pointCount = count >= 0 ? count + 1 : 2;
1757
- returnValues = returnValues.slice(0, pointCount);
1758
- // Fill with count
1759
- while (returnValues.length < pointCount) {
1760
- var _returnValues;
1761
- returnValues.push((_returnValues = returnValues[returnValues.length - 1]) !== null && _returnValues !== void 0 ? _returnValues : mergedMin);
1762
- }
1763
- }
1764
- returnValues.sort(function (a, b) {
1765
- return a - b;
1766
- });
1767
- }
1768
- // Align in range
1769
- returnValues.forEach(function (val, index) {
1770
- returnValues[index] = formatValue(val);
1771
- });
1772
- return returnValues;
1773
- }, [mergedValue, range, mergedMin, count, formatValue]);
1774
- // =========================== onChange ===========================
1775
- var rawValuesRef = React__namespace.useRef(rawValues);
1776
- rawValuesRef.current = rawValues;
1777
- var getTriggerValue = function getTriggerValue(triggerValues) {
1778
- return range ? triggerValues : triggerValues[0];
1779
- };
1780
- var triggerChange = function triggerChange(nextValues) {
1781
- // Order first
1782
- var cloneNextValues = objectWithoutProperties._toConsumableArray(nextValues).sort(function (a, b) {
1783
- return a - b;
1784
- });
1785
- // Trigger event if needed
1786
- if (onChange && !isEqual(cloneNextValues, rawValuesRef.current, true)) {
1787
- onChange(getTriggerValue(cloneNextValues));
1788
- }
1789
- // We set this later since it will re-render component immediately
1790
- setValue(cloneNextValues);
1791
- };
1792
- var changeToCloseValue = function changeToCloseValue(newValue) {
1793
- if (!disabled) {
1794
- var valueIndex = 0;
1795
- var valueDist = mergedMax - mergedMin;
1796
- rawValues.forEach(function (val, index) {
1797
- var dist = Math.abs(newValue - val);
1798
- if (dist <= valueDist) {
1799
- valueDist = dist;
1800
- valueIndex = index;
1801
- }
1802
- });
1803
- // Create new values
1804
- var cloneNextValues = objectWithoutProperties._toConsumableArray(rawValues);
1805
- cloneNextValues[valueIndex] = newValue;
1806
- // Fill value to match default 2
1807
- if (range && !rawValues.length && count === undefined) {
1808
- cloneNextValues.push(newValue);
1809
- }
1810
- onBeforeChange === null || onBeforeChange === void 0 ? void 0 : onBeforeChange(getTriggerValue(cloneNextValues));
1811
- triggerChange(cloneNextValues);
1812
- onAfterChange === null || onAfterChange === void 0 ? void 0 : onAfterChange(getTriggerValue(cloneNextValues));
1813
- }
1814
- };
1815
- // ============================ Click =============================
1816
- var onSliderMouseDown = function onSliderMouseDown(e) {
1817
- e.preventDefault();
1818
- var _containerRef$current = containerRef.current.getBoundingClientRect(),
1819
- width = _containerRef$current.width,
1820
- height = _containerRef$current.height,
1821
- left = _containerRef$current.left,
1822
- top = _containerRef$current.top,
1823
- bottom = _containerRef$current.bottom,
1824
- right = _containerRef$current.right;
1825
- var clientX = e.clientX,
1826
- clientY = e.clientY;
1827
- var percent;
1828
- switch (direction) {
1829
- case 'btt':
1830
- percent = (bottom - clientY) / height;
1831
- break;
1832
- case 'ttb':
1833
- percent = (clientY - top) / height;
1834
- break;
1835
- case 'rtl':
1836
- percent = (right - clientX) / width;
1837
- break;
1838
- default:
1839
- percent = (clientX - left) / width;
1840
- }
1841
- var nextValue = mergedMin + percent * (mergedMax - mergedMin);
1842
- changeToCloseValue(formatValue(nextValue));
1843
- };
1844
- // =========================== Keyboard ===========================
1845
- var _React$useState = React__namespace.useState(null),
1846
- _React$useState2 = objectWithoutProperties._slicedToArray(_React$useState, 2),
1847
- keyboardValue = _React$useState2[0],
1848
- setKeyboardValue = _React$useState2[1];
1849
- var onHandleOffsetChange = function onHandleOffsetChange(offset, valueIndex) {
1850
- if (!disabled) {
1851
- var next = offsetValues(rawValues, offset, valueIndex);
1852
- onBeforeChange === null || onBeforeChange === void 0 ? void 0 : onBeforeChange(getTriggerValue(rawValues));
1853
- triggerChange(next.values);
1854
- onAfterChange === null || onAfterChange === void 0 ? void 0 : onAfterChange(getTriggerValue(next.values));
1855
- setKeyboardValue(next.value);
1856
- }
1857
- };
1858
- React__namespace.useEffect(function () {
1859
- if (keyboardValue !== null) {
1860
- var valueIndex = rawValues.indexOf(keyboardValue);
1861
- if (valueIndex >= 0) {
1862
- handlesRef.current.focus(valueIndex);
1863
- }
1864
- }
1865
- setKeyboardValue(null);
1866
- }, [keyboardValue]);
1867
- // ============================= Drag =============================
1868
- var mergedDraggableTrack = React__namespace.useMemo(function () {
1869
- if (draggableTrack && mergedStep === null) {
1870
- if (process.env.NODE_ENV !== 'production') {
1871
- warningOnce(false, '`draggableTrack` is not supported when `step` is `null`.');
1872
- }
1873
- return false;
1874
- }
1875
- return draggableTrack;
1876
- }, [draggableTrack, mergedStep]);
1877
- var finishChange = function finishChange() {
1878
- onAfterChange === null || onAfterChange === void 0 ? void 0 : onAfterChange(getTriggerValue(rawValuesRef.current));
1879
- };
1880
- var _useDrag = useDrag(containerRef, direction, rawValues, mergedMin, mergedMax, formatValue, triggerChange, finishChange, offsetValues),
1881
- _useDrag2 = objectWithoutProperties._slicedToArray(_useDrag, 4),
1882
- draggingIndex = _useDrag2[0],
1883
- draggingValue = _useDrag2[1],
1884
- cacheValues = _useDrag2[2],
1885
- onStartDrag = _useDrag2[3];
1886
- var onStartMove = function onStartMove(e, valueIndex) {
1887
- onStartDrag(e, valueIndex);
1888
- onBeforeChange === null || onBeforeChange === void 0 ? void 0 : onBeforeChange(getTriggerValue(rawValuesRef.current));
1889
- };
1890
- // Auto focus for updated handle
1891
- var dragging = draggingIndex !== -1;
1892
- React__namespace.useEffect(function () {
1893
- if (!dragging) {
1894
- var valueIndex = rawValues.lastIndexOf(draggingValue);
1895
- handlesRef.current.focus(valueIndex);
1896
- }
1897
- }, [dragging]);
1898
- // =========================== Included ===========================
1899
- var sortedCacheValues = React__namespace.useMemo(function () {
1900
- return objectWithoutProperties._toConsumableArray(cacheValues).sort(function (a, b) {
1901
- return a - b;
1902
- });
1903
- }, [cacheValues]);
1904
- // Provide a range values with included [min, max]
1905
- // Used for Track, Mark & Dot
1906
- var _React$useMemo = React__namespace.useMemo(function () {
1907
- if (!range) {
1908
- return [mergedMin, sortedCacheValues[0]];
1909
- }
1910
- return [sortedCacheValues[0], sortedCacheValues[sortedCacheValues.length - 1]];
1911
- }, [sortedCacheValues, range, mergedMin]),
1912
- _React$useMemo2 = objectWithoutProperties._slicedToArray(_React$useMemo, 2),
1913
- includedStart = _React$useMemo2[0],
1914
- includedEnd = _React$useMemo2[1];
1915
- // ============================= Refs =============================
1916
- React__namespace.useImperativeHandle(ref, function () {
1917
- return {
1918
- focus: function focus() {
1919
- handlesRef.current.focus(0);
1920
- },
1921
- blur: function blur() {
1922
- var _document = document,
1923
- activeElement = _document.activeElement;
1924
- if (containerRef.current.contains(activeElement)) {
1925
- activeElement === null || activeElement === void 0 ? void 0 : activeElement.blur();
1926
- }
1927
- }
1928
- };
1929
- });
1930
- // ========================== Auto Focus ==========================
1931
- React__namespace.useEffect(function () {
1932
- if (autoFocus) {
1933
- handlesRef.current.focus(0);
1934
- }
1935
- }, []);
1936
- // =========================== Context ============================
1937
- var context = React__namespace.useMemo(function () {
1938
- return {
1939
- min: mergedMin,
1940
- max: mergedMax,
1941
- direction: direction,
1942
- disabled: disabled,
1943
- keyboard: keyboard,
1944
- step: mergedStep,
1945
- included: included,
1946
- includedStart: includedStart,
1947
- includedEnd: includedEnd,
1948
- range: range,
1949
- tabIndex: tabIndex,
1950
- ariaLabelForHandle: ariaLabelForHandle,
1951
- ariaLabelledByForHandle: ariaLabelledByForHandle,
1952
- ariaValueTextFormatterForHandle: ariaValueTextFormatterForHandle
1953
- };
1954
- }, [mergedMin, mergedMax, direction, disabled, keyboard, mergedStep, included, includedStart, includedEnd, range, tabIndex, ariaLabelForHandle, ariaLabelledByForHandle, ariaValueTextFormatterForHandle]);
1955
- // ============================ Render ============================
1956
- return /*#__PURE__*/React__namespace.createElement(SliderContext.Provider, {
1957
- value: context
1958
- }, /*#__PURE__*/React__namespace.createElement("div", {
1959
- ref: containerRef,
1960
- className: classNames(prefixCls, className, (_classNames = {}, objectWithoutProperties._defineProperty(_classNames, "".concat(prefixCls, "-disabled"), disabled), objectWithoutProperties._defineProperty(_classNames, "".concat(prefixCls, "-vertical"), vertical), objectWithoutProperties._defineProperty(_classNames, "".concat(prefixCls, "-horizontal"), !vertical), objectWithoutProperties._defineProperty(_classNames, "".concat(prefixCls, "-with-marks"), markList.length), _classNames)),
1961
- style: style,
1962
- onMouseDown: onSliderMouseDown
1963
- }, /*#__PURE__*/React__namespace.createElement("div", {
1964
- className: "".concat(prefixCls, "-rail"),
1965
- style: railStyle
1966
- }), /*#__PURE__*/React__namespace.createElement(Tracks, {
1967
- prefixCls: prefixCls,
1968
- style: trackStyle,
1969
- values: sortedCacheValues,
1970
- startPoint: startPoint,
1971
- onStartMove: mergedDraggableTrack ? onStartMove : null
1972
- }), /*#__PURE__*/React__namespace.createElement(Steps, {
1973
- prefixCls: prefixCls,
1974
- marks: markList,
1975
- dots: dots,
1976
- style: dotStyle,
1977
- activeStyle: activeDotStyle
1978
- }), /*#__PURE__*/React__namespace.createElement(Handles, {
1979
- ref: handlesRef,
1980
- prefixCls: prefixCls,
1981
- style: handleStyle,
1982
- values: cacheValues,
1983
- draggingIndex: draggingIndex,
1984
- onStartMove: onStartMove,
1985
- onOffsetChange: onHandleOffsetChange,
1986
- onFocus: onFocus,
1987
- onBlur: onBlur,
1988
- handleRender: handleRender
1989
- }), /*#__PURE__*/React__namespace.createElement(Marks, {
1990
- prefixCls: prefixCls,
1991
- marks: markList,
1992
- onClick: changeToCloseValue
1993
- })));
1994
- });
1995
- if (process.env.NODE_ENV !== 'production') {
1996
- Slider.displayName = 'Slider';
1997
- }
26
+ var Slider__default = /*#__PURE__*/_interopDefault(Slider);
1998
27
 
1999
28
  function RangeSlider(props) {
2000
29
  var after = props.after,
@@ -2048,12 +77,12 @@ function RangeSlider(props) {
2048
77
  });
2049
78
  var _useStyles = useStyles.useStyles(props),
2050
79
  rangeSliderStyles = _useStyles.styles;
2051
- return /*#__PURE__*/React__namespace.default.createElement("div", {
80
+ return /*#__PURE__*/React__default.default.createElement("div", {
2052
81
  className: clsx__default.default(className, 'range-slider', set && "range-slider_set_" + set, fillClass, trackFillClass, railFillClass, handleFillClass, handleFillHoverClass, handleDraggingFillClass, handleDraggingFillHoverClass, shapeClass, widthClass),
2053
82
  style: rangeSliderStyles
2054
- }, before && /*#__PURE__*/React__namespace.default.createElement("div", {
83
+ }, before && /*#__PURE__*/React__default.default.createElement("div", {
2055
84
  className: "range-slider__before"
2056
- }, before), /*#__PURE__*/React__namespace.default.createElement(Slider, {
85
+ }, before), /*#__PURE__*/React__default.default.createElement(Slider__default.default, {
2057
86
  className: "range-slider__wrapper",
2058
87
  disabled: disabled,
2059
88
  min: min,
@@ -2063,7 +92,7 @@ function RangeSlider(props) {
2063
92
  vertical: vertical,
2064
93
  value: value,
2065
94
  onChange: onChangeSlider
2066
- }), children, after && /*#__PURE__*/React__namespace.default.createElement("div", {
95
+ }), children, after && /*#__PURE__*/React__default.default.createElement("div", {
2067
96
  className: "range-slider__after"
2068
97
  }, after));
2069
98
  }