@lumx/react 3.0.2-alpha-react-utils.2 → 3.0.2-alpha-react-utils.3
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/_internal/{6340c129.js → ClickAwayProvider.js} +107 -2
- package/_internal/ClickAwayProvider.js.map +1 -0
- package/_internal/{eca6d4dc.d.ts → types.d.ts} +1 -1
- package/index.d.ts +2627 -56
- package/index.js +12438 -56
- package/index.js.map +1 -1
- package/package.json +4 -4
- package/utils/index.d.ts +1 -1
- package/utils/index.js +1 -1
- package/_internal/0062d1bc.js +0 -220
- package/_internal/0062d1bc.js.map +0 -1
- package/_internal/03e8323d.d.ts +0 -118
- package/_internal/0402f9bc.d.ts +0 -183
- package/_internal/0b370acc.js +0 -796
- package/_internal/0b370acc.js.map +0 -1
- package/_internal/0d154d73.d.ts +0 -67
- package/_internal/113e3b40.d.ts +0 -31
- package/_internal/12ab39e4.js +0 -58
- package/_internal/12ab39e4.js.map +0 -1
- package/_internal/13e759f3.js +0 -343
- package/_internal/13e759f3.js.map +0 -1
- package/_internal/158b46d5.js +0 -151
- package/_internal/158b46d5.js.map +0 -1
- package/_internal/17b74e16.d.ts +0 -31
- package/_internal/1b1530a4.d.ts +0 -43
- package/_internal/20976405.js +0 -87
- package/_internal/20976405.js.map +0 -1
- package/_internal/20b0e9a5.d.ts +0 -77
- package/_internal/26cd9c63.js +0 -118
- package/_internal/26cd9c63.js.map +0 -1
- package/_internal/27f21164.js +0 -79
- package/_internal/27f21164.js.map +0 -1
- package/_internal/288dfd0f.js +0 -13
- package/_internal/288dfd0f.js.map +0 -1
- package/_internal/28aaf23a.d.ts +0 -41
- package/_internal/2c829c0b.d.ts +0 -57
- package/_internal/2cc0aec5.js +0 -86
- package/_internal/2cc0aec5.js.map +0 -1
- package/_internal/2d0a5b28.js +0 -23
- package/_internal/2d0a5b28.js.map +0 -1
- package/_internal/2d4b5a5e.d.ts +0 -92
- package/_internal/2d770113.d.ts +0 -38
- package/_internal/2fe97f00.js +0 -291
- package/_internal/2fe97f00.js.map +0 -1
- package/_internal/31c16fa0.d.ts +0 -37
- package/_internal/329a01d3.js +0 -25
- package/_internal/329a01d3.js.map +0 -1
- package/_internal/3326e990.js +0 -168
- package/_internal/3326e990.js.map +0 -1
- package/_internal/377b2f44.js +0 -70
- package/_internal/377b2f44.js.map +0 -1
- package/_internal/3b8d2a6e.js +0 -124
- package/_internal/3b8d2a6e.js.map +0 -1
- package/_internal/3bd3186e.d.ts +0 -57
- package/_internal/48e40868.js +0 -101
- package/_internal/48e40868.js.map +0 -1
- package/_internal/490ec1da.js +0 -322
- package/_internal/490ec1da.js.map +0 -1
- package/_internal/49127d69.d.ts +0 -52
- package/_internal/4dcd87cb.js +0 -78
- package/_internal/4dcd87cb.js.map +0 -1
- package/_internal/4f44d848.js +0 -157
- package/_internal/4f44d848.js.map +0 -1
- package/_internal/4fc64a2e.js +0 -27
- package/_internal/4fc64a2e.js.map +0 -1
- package/_internal/53a831be.js +0 -108
- package/_internal/53a831be.js.map +0 -1
- package/_internal/55271fa1.d.ts +0 -34
- package/_internal/55d30377.d.ts +0 -22
- package/_internal/56385b04.js +0 -116
- package/_internal/56385b04.js.map +0 -1
- package/_internal/599e250a.d.ts +0 -88
- package/_internal/5a054691.d.ts +0 -33
- package/_internal/5a127b58.js +0 -82
- package/_internal/5a127b58.js.map +0 -1
- package/_internal/5a1c0db4.js +0 -156
- package/_internal/5a1c0db4.js.map +0 -1
- package/_internal/5babcc39.js +0 -147
- package/_internal/5babcc39.js.map +0 -1
- package/_internal/5c1bf4d4.d.ts +0 -81
- package/_internal/5d8ed4ee.js +0 -113
- package/_internal/5d8ed4ee.js.map +0 -1
- package/_internal/616f2912.js +0 -301
- package/_internal/616f2912.js.map +0 -1
- package/_internal/61f915de.d.ts +0 -49
- package/_internal/620081fa.js +0 -122
- package/_internal/620081fa.js.map +0 -1
- package/_internal/6340c129.js.map +0 -1
- package/_internal/6581c863.d.ts +0 -34
- package/_internal/66de4d45.d.ts +0 -32
- package/_internal/6735c5c8.d.ts +0 -62
- package/_internal/69dd1472.js +0 -112
- package/_internal/69dd1472.js.map +0 -1
- package/_internal/6a0e1c77.js +0 -327
- package/_internal/6a0e1c77.js.map +0 -1
- package/_internal/701c20b0.d.ts +0 -24
- package/_internal/7391188a.js +0 -81
- package/_internal/7391188a.js.map +0 -1
- package/_internal/74cb6c26.js +0 -136
- package/_internal/74cb6c26.js.map +0 -1
- package/_internal/761031bf.js +0 -314
- package/_internal/761031bf.js.map +0 -1
- package/_internal/76fed69d.js +0 -50
- package/_internal/76fed69d.js.map +0 -1
- package/_internal/78ef8e34.js +0 -40
- package/_internal/78ef8e34.js.map +0 -1
- package/_internal/7b906e16.d.ts +0 -17
- package/_internal/7be11ddc.d.ts +0 -35
- package/_internal/7d39705e.d.ts +0 -20
- package/_internal/7e03266f.js +0 -47
- package/_internal/7e03266f.js.map +0 -1
- package/_internal/7e8d0ac5.js +0 -84
- package/_internal/7e8d0ac5.js.map +0 -1
- package/_internal/7ffa45f6.js +0 -48
- package/_internal/7ffa45f6.js.map +0 -1
- package/_internal/84c1ec44.js +0 -257
- package/_internal/84c1ec44.js.map +0 -1
- package/_internal/8518279f.js +0 -96
- package/_internal/8518279f.js.map +0 -1
- package/_internal/853713cd.js +0 -25
- package/_internal/853713cd.js.map +0 -1
- package/_internal/86566d75.d.ts +0 -27
- package/_internal/86d22dde.d.ts +0 -57
- package/_internal/8e755ded.d.ts +0 -101
- package/_internal/901471f5.d.ts +0 -37
- package/_internal/935ce959.d.ts +0 -49
- package/_internal/97089888.d.ts +0 -16
- package/_internal/97cc728c.d.ts +0 -26
- package/_internal/9ab3c637.js +0 -2474
- package/_internal/9ab3c637.js.map +0 -1
- package/_internal/9ca3f59c.js +0 -60
- package/_internal/9ca3f59c.js.map +0 -1
- package/_internal/9e95ea38.d.ts +0 -43
- package/_internal/a0108f92.js +0 -84
- package/_internal/a0108f92.js.map +0 -1
- package/_internal/a493a193.d.ts +0 -65
- package/_internal/a521723d.js +0 -120
- package/_internal/a521723d.js.map +0 -1
- package/_internal/a6fad025.d.ts +0 -107
- package/_internal/a8fa525f.js +0 -124
- package/_internal/a8fa525f.js.map +0 -1
- package/_internal/aca2ecf5.js +0 -141
- package/_internal/aca2ecf5.js.map +0 -1
- package/_internal/aef2ef1c.js +0 -53
- package/_internal/aef2ef1c.js.map +0 -1
- package/_internal/af048b0c.js +0 -89
- package/_internal/af048b0c.js.map +0 -1
- package/_internal/af2cd0cd.d.ts +0 -17
- package/_internal/afec6b62.js +0 -864
- package/_internal/afec6b62.js.map +0 -1
- package/_internal/b0eb3a30.js +0 -72
- package/_internal/b0eb3a30.js.map +0 -1
- package/_internal/b89517ea.js +0 -275
- package/_internal/b89517ea.js.map +0 -1
- package/_internal/bafa6fcc.js +0 -116
- package/_internal/bafa6fcc.js.map +0 -1
- package/_internal/bbbeb49e.js +0 -47
- package/_internal/bbbeb49e.js.map +0 -1
- package/_internal/c11f6162.d.ts +0 -52
- package/_internal/c723dab4.js +0 -133
- package/_internal/c723dab4.js.map +0 -1
- package/_internal/c87cc857.d.ts +0 -42
- package/_internal/c97f8d04.js +0 -424
- package/_internal/c97f8d04.js.map +0 -1
- package/_internal/cbb373ea.d.ts +0 -6
- package/_internal/cbef23b6.d.ts +0 -104
- package/_internal/cdf77f06.d.ts +0 -88
- package/_internal/d350f2ff.js +0 -105
- package/_internal/d350f2ff.js.map +0 -1
- package/_internal/d71a8cf7.js +0 -54
- package/_internal/d71a8cf7.js.map +0 -1
- package/_internal/d9337952.js +0 -96
- package/_internal/d9337952.js.map +0 -1
- package/_internal/def14e1a.d.ts +0 -24
- package/_internal/e0cd29c7.d.ts +0 -35
- package/_internal/e354228f.js +0 -145
- package/_internal/e354228f.js.map +0 -1
- package/_internal/e3922a05.d.ts +0 -22
- package/_internal/e3cb6177.d.ts +0 -75
- package/_internal/e810c841.d.ts +0 -182
- package/_internal/ea700b01.d.ts +0 -43
- package/_internal/eed07003.js +0 -122
- package/_internal/eed07003.js.map +0 -1
- package/_internal/f1c9b334.d.ts +0 -22
- package/_internal/f3c3a674.js +0 -281
- package/_internal/f3c3a674.js.map +0 -1
- package/_internal/f571cdcd.js +0 -132
- package/_internal/f571cdcd.js.map +0 -1
- package/_internal/f5bdff7e.js +0 -282
- package/_internal/f5bdff7e.js.map +0 -1
- package/_internal/f851fc00.d.ts +0 -34
- package/_internal/f859b007.d.ts +0 -49
- package/_internal/fb384b79.d.ts +0 -38
- package/_internal/fc4c034b.js +0 -63
- package/_internal/fc4c034b.js.map +0 -1
- package/_internal/fc608bd9.js +0 -16
- package/_internal/fc608bd9.js.map +0 -1
- package/_internal/fd1f4d68.d.ts +0 -36
- package/_internal/fd867c9d.js +0 -346
- package/_internal/fd867c9d.js.map +0 -1
- package/_internal/ff8081e5.js +0 -57
- package/_internal/ff8081e5.js.map +0 -1
- package/_internal/ffd1bfe3.js +0 -123
- package/_internal/ffd1bfe3.js.map +0 -1
- package/components/alert-dialog.d.ts +0 -6
- package/components/alert-dialog.js +0 -2
- package/components/alert-dialog.js.map +0 -1
- package/components/autocomplete.d.ts +0 -8
- package/components/autocomplete.js +0 -2
- package/components/autocomplete.js.map +0 -1
- package/components/avatar.d.ts +0 -4
- package/components/avatar.js +0 -2
- package/components/avatar.js.map +0 -1
- package/components/badge.d.ts +0 -3
- package/components/badge.js +0 -2
- package/components/badge.js.map +0 -1
- package/components/button.d.ts +0 -8
- package/components/button.js +0 -4
- package/components/button.js.map +0 -1
- package/components/checkbox.d.ts +0 -3
- package/components/checkbox.js +0 -2
- package/components/checkbox.js.map +0 -1
- package/components/chip.d.ts +0 -3
- package/components/chip.js +0 -3
- package/components/chip.js.map +0 -1
- package/components/comment-block.d.ts +0 -5
- package/components/comment-block.js +0 -2
- package/components/comment-block.js.map +0 -1
- package/components/date-picker.d.ts +0 -7
- package/components/date-picker.js +0 -2
- package/components/date-picker.js.map +0 -1
- package/components/dialog.d.ts +0 -3
- package/components/dialog.js +0 -2
- package/components/dialog.js.map +0 -1
- package/components/divider.d.ts +0 -3
- package/components/divider.js +0 -2
- package/components/divider.js.map +0 -1
- package/components/drag-handle.d.ts +0 -3
- package/components/drag-handle.js +0 -2
- package/components/drag-handle.js.map +0 -1
- package/components/dropdown.d.ts +0 -4
- package/components/dropdown.js +0 -2
- package/components/dropdown.js.map +0 -1
- package/components/expansion-panel.d.ts +0 -7
- package/components/expansion-panel.js +0 -2
- package/components/expansion-panel.js.map +0 -1
- package/components/flag.d.ts +0 -3
- package/components/flag.js +0 -2
- package/components/flag.js.map +0 -1
- package/components/flex-box.d.ts +0 -3
- package/components/flex-box.js +0 -2
- package/components/flex-box.js.map +0 -1
- package/components/generic-block.d.ts +0 -4
- package/components/generic-block.js +0 -2
- package/components/generic-block.js.map +0 -1
- package/components/grid.d.ts +0 -3
- package/components/grid.js +0 -2
- package/components/grid.js.map +0 -1
- package/components/heading.d.ts +0 -4
- package/components/heading.js +0 -2
- package/components/heading.js.map +0 -1
- package/components/icon.d.ts +0 -3
- package/components/icon.js +0 -2
- package/components/icon.js.map +0 -1
- package/components/image-block.d.ts +0 -4
- package/components/image-block.js +0 -2
- package/components/image-block.js.map +0 -1
- package/components/input-helper.d.ts +0 -3
- package/components/input-helper.js +0 -2
- package/components/input-helper.js.map +0 -1
- package/components/input-label.d.ts +0 -3
- package/components/input-label.js +0 -2
- package/components/input-label.js.map +0 -1
- package/components/lightbox.d.ts +0 -7
- package/components/lightbox.js +0 -2
- package/components/lightbox.js.map +0 -1
- package/components/link-preview.d.ts +0 -5
- package/components/link-preview.js +0 -2
- package/components/link-preview.js.map +0 -1
- package/components/link.d.ts +0 -3
- package/components/link.js +0 -2
- package/components/link.js.map +0 -1
- package/components/list.d.ts +0 -3
- package/components/list.js +0 -3
- package/components/list.js.map +0 -1
- package/components/message.d.ts +0 -3
- package/components/message.js +0 -2
- package/components/message.js.map +0 -1
- package/components/mosaic.d.ts +0 -4
- package/components/mosaic.js +0 -2
- package/components/mosaic.js.map +0 -1
- package/components/notification.d.ts +0 -3
- package/components/notification.js +0 -2
- package/components/notification.js.map +0 -1
- package/components/popover.d.ts +0 -3
- package/components/popover.js +0 -2
- package/components/popover.js.map +0 -1
- package/components/post-block.d.ts +0 -4
- package/components/post-block.js +0 -2
- package/components/post-block.js.map +0 -1
- package/components/progress-tracker.d.ts +0 -3
- package/components/progress-tracker.js +0 -2
- package/components/progress-tracker.js.map +0 -1
- package/components/progress.d.ts +0 -3
- package/components/progress.js +0 -2
- package/components/progress.js.map +0 -1
- package/components/radio-button.d.ts +0 -3
- package/components/radio-button.js +0 -2
- package/components/radio-button.js.map +0 -1
- package/components/select.d.ts +0 -7
- package/components/select.js +0 -2
- package/components/select.js.map +0 -1
- package/components/side-navigation.d.ts +0 -7
- package/components/side-navigation.js +0 -2
- package/components/side-navigation.js.map +0 -1
- package/components/skeleton.d.ts +0 -3
- package/components/skeleton.js +0 -2
- package/components/skeleton.js.map +0 -1
- package/components/slider.d.ts +0 -3
- package/components/slider.js +0 -2
- package/components/slider.js.map +0 -1
- package/components/slideshow.d.ts +0 -7
- package/components/slideshow.js +0 -2
- package/components/slideshow.js.map +0 -1
- package/components/switch.d.ts +0 -3
- package/components/switch.js +0 -2
- package/components/switch.js.map +0 -1
- package/components/table.d.ts +0 -3
- package/components/table.js +0 -2
- package/components/table.js.map +0 -1
- package/components/tabs.d.ts +0 -4
- package/components/tabs.js +0 -2
- package/components/tabs.js.map +0 -1
- package/components/text-field.d.ts +0 -7
- package/components/text-field.js +0 -2
- package/components/text-field.js.map +0 -1
- package/components/text.d.ts +0 -3
- package/components/text.js +0 -2
- package/components/text.js.map +0 -1
- package/components/thumbnail.d.ts +0 -4
- package/components/thumbnail.js +0 -3
- package/components/thumbnail.js.map +0 -1
- package/components/toolbar.d.ts +0 -3
- package/components/toolbar.js +0 -2
- package/components/toolbar.js.map +0 -1
- package/components/tooltip.d.ts +0 -4
- package/components/tooltip.js +0 -2
- package/components/tooltip.js.map +0 -1
- package/components/uploader.d.ts +0 -3
- package/components/uploader.js +0 -2
- package/components/uploader.js.map +0 -1
- package/components/user-block.d.ts +0 -5
- package/components/user-block.js +0 -2
- package/components/user-block.js.map +0 -1
- package/components.d.ts +0 -2
- package/components.js +0 -156
- package/components.js.map +0 -1
package/_internal/6a0e1c77.js
DELETED
|
@@ -1,327 +0,0 @@
|
|
|
1
|
-
import { b as _objectWithoutProperties, c as _extends } from './6340c129.js';
|
|
2
|
-
import { Theme } from '../components.js';
|
|
3
|
-
import React, { forwardRef, useMemo, useRef } from 'react';
|
|
4
|
-
import { g as getRootClassName, c as classnames, h as handleBasicClasses } from './fd867c9d.js';
|
|
5
|
-
import { u as uid } from './fc608bd9.js';
|
|
6
|
-
import { I as InputHelper } from './b0eb3a30.js';
|
|
7
|
-
import { I as InputLabel } from './12ab39e4.js';
|
|
8
|
-
|
|
9
|
-
var useEnhancedEffect = typeof window !== 'undefined' ? React.useLayoutEffect : React.useEffect;
|
|
10
|
-
/**
|
|
11
|
-
* https://github.com/facebook/react/issues/14099#issuecomment-440013892
|
|
12
|
-
*
|
|
13
|
-
* @param fn A function to run
|
|
14
|
-
* @return A React callback
|
|
15
|
-
*/
|
|
16
|
-
|
|
17
|
-
function useEventCallback(fn) {
|
|
18
|
-
var ref = React.useRef(fn);
|
|
19
|
-
useEnhancedEffect(function () {
|
|
20
|
-
ref.current = fn;
|
|
21
|
-
});
|
|
22
|
-
return React.useCallback(function (event) {
|
|
23
|
-
return ref.current(event);
|
|
24
|
-
}, []);
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
/**
|
|
28
|
-
* Clamp value in range.
|
|
29
|
-
*
|
|
30
|
-
* @param value Value to clamp.
|
|
31
|
-
* @param min Minimum value.
|
|
32
|
-
* @param max Maximum value.
|
|
33
|
-
* @return Clamped value.
|
|
34
|
-
*/
|
|
35
|
-
var clamp = function clamp(value, min, max) {
|
|
36
|
-
if (value < min) {
|
|
37
|
-
return min;
|
|
38
|
-
}
|
|
39
|
-
|
|
40
|
-
if (value > max) {
|
|
41
|
-
return max;
|
|
42
|
-
}
|
|
43
|
-
|
|
44
|
-
return value;
|
|
45
|
-
};
|
|
46
|
-
|
|
47
|
-
/**
|
|
48
|
-
* Defines the props of the component.
|
|
49
|
-
*/
|
|
50
|
-
|
|
51
|
-
/**
|
|
52
|
-
* Component display name.
|
|
53
|
-
*/
|
|
54
|
-
var COMPONENT_NAME = 'Slider';
|
|
55
|
-
/**
|
|
56
|
-
* Component default class name and class prefix.
|
|
57
|
-
*/
|
|
58
|
-
|
|
59
|
-
var CLASSNAME = getRootClassName(COMPONENT_NAME);
|
|
60
|
-
/**
|
|
61
|
-
* Component default props.
|
|
62
|
-
*/
|
|
63
|
-
|
|
64
|
-
var DEFAULT_PROPS = {
|
|
65
|
-
precision: 0,
|
|
66
|
-
steps: 0,
|
|
67
|
-
theme: Theme.light
|
|
68
|
-
};
|
|
69
|
-
/**
|
|
70
|
-
* Convert a percent value to a value in range min - max.
|
|
71
|
-
*
|
|
72
|
-
* @param percent Value to convert.
|
|
73
|
-
* @param min Minimum value.
|
|
74
|
-
* @param max Maximum value.
|
|
75
|
-
* @param precision Precision.
|
|
76
|
-
* @return Value in range min - max
|
|
77
|
-
*/
|
|
78
|
-
|
|
79
|
-
var computeValueFromPercent = function computeValueFromPercent(percent, min, max) {
|
|
80
|
-
var precision = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : 0;
|
|
81
|
-
return Number((min + percent * (max - min)).toFixed(precision));
|
|
82
|
-
};
|
|
83
|
-
/**
|
|
84
|
-
* Convert a value in range min - max to a percent value.
|
|
85
|
-
*
|
|
86
|
-
* @param value Value to convert.
|
|
87
|
-
* @param min Minimum value.
|
|
88
|
-
* @param max Maximum value.
|
|
89
|
-
* @return Value in percent
|
|
90
|
-
*/
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
var computePercentFromValue = function computePercentFromValue(value, min, max) {
|
|
94
|
-
return Number((value - min) / (max - min));
|
|
95
|
-
};
|
|
96
|
-
/**
|
|
97
|
-
* Slider component.
|
|
98
|
-
*
|
|
99
|
-
* @param props Component props.
|
|
100
|
-
* @param ref Component ref.
|
|
101
|
-
* @return React element.
|
|
102
|
-
*/
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
var Slider = forwardRef(function (props, ref) {
|
|
106
|
-
var className = props.className,
|
|
107
|
-
disabled = props.disabled,
|
|
108
|
-
helper = props.helper,
|
|
109
|
-
hideMinMaxLabel = props.hideMinMaxLabel,
|
|
110
|
-
id = props.id,
|
|
111
|
-
_props$isDisabled = props.isDisabled,
|
|
112
|
-
isDisabled = _props$isDisabled === void 0 ? disabled : _props$isDisabled,
|
|
113
|
-
label = props.label,
|
|
114
|
-
max = props.max,
|
|
115
|
-
min = props.min,
|
|
116
|
-
name = props.name,
|
|
117
|
-
onChange = props.onChange,
|
|
118
|
-
onMouseDown = props.onMouseDown,
|
|
119
|
-
precision = props.precision,
|
|
120
|
-
steps = props.steps,
|
|
121
|
-
theme = props.theme,
|
|
122
|
-
value = props.value,
|
|
123
|
-
forwardedProps = _objectWithoutProperties(props, ["className", "disabled", "helper", "hideMinMaxLabel", "id", "isDisabled", "label", "max", "min", "name", "onChange", "onMouseDown", "precision", "steps", "theme", "value"]);
|
|
124
|
-
|
|
125
|
-
var sliderId = useMemo(function () {
|
|
126
|
-
return id || "slider-".concat(uid());
|
|
127
|
-
}, [id]);
|
|
128
|
-
var sliderLabelId = useMemo(function () {
|
|
129
|
-
return "label-".concat(sliderId);
|
|
130
|
-
}, [sliderId]);
|
|
131
|
-
var sliderRef = useRef(null); // build a lookup array for the steps.
|
|
132
|
-
|
|
133
|
-
var availableSteps = useMemo(function () {
|
|
134
|
-
if (!steps) return [];
|
|
135
|
-
var available = [0];
|
|
136
|
-
var percentStep = 1 / ((max - min) / steps);
|
|
137
|
-
var ptr = 0;
|
|
138
|
-
|
|
139
|
-
while (ptr + percentStep < 1) {
|
|
140
|
-
ptr += percentStep;
|
|
141
|
-
available.push(ptr);
|
|
142
|
-
}
|
|
143
|
-
|
|
144
|
-
return available;
|
|
145
|
-
}, [steps, min, max]);
|
|
146
|
-
/**
|
|
147
|
-
* Try to find the closest step to the current slider position.
|
|
148
|
-
*
|
|
149
|
-
* @param percentValue Reference value
|
|
150
|
-
* @return The closest step value
|
|
151
|
-
*/
|
|
152
|
-
|
|
153
|
-
var findClosestStep = function findClosestStep(percentValue) {
|
|
154
|
-
var closest = availableSteps.reduce(function (acc, step) {
|
|
155
|
-
var aDst = Math.abs(percentValue - step);
|
|
156
|
-
|
|
157
|
-
if (aDst < acc.dst) {
|
|
158
|
-
return {
|
|
159
|
-
dst: aDst,
|
|
160
|
-
val: step
|
|
161
|
-
};
|
|
162
|
-
}
|
|
163
|
-
|
|
164
|
-
return acc;
|
|
165
|
-
}, {
|
|
166
|
-
dst: Infinity,
|
|
167
|
-
val: -1
|
|
168
|
-
});
|
|
169
|
-
return closest.val;
|
|
170
|
-
};
|
|
171
|
-
/**
|
|
172
|
-
* Convert slider's handle position to percent.
|
|
173
|
-
*
|
|
174
|
-
* @param event The interaction event
|
|
175
|
-
* @param slider the slider element
|
|
176
|
-
* @return The computed percent value
|
|
177
|
-
*/
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
var getPercentValue = function getPercentValue(event, slider) {
|
|
181
|
-
var _slider$getBoundingCl = slider.getBoundingClientRect(),
|
|
182
|
-
width = _slider$getBoundingCl.width,
|
|
183
|
-
left = _slider$getBoundingCl.left;
|
|
184
|
-
|
|
185
|
-
var percent = (event.pageX - left - window.pageXOffset) / width;
|
|
186
|
-
percent = clamp(percent, 0, 1);
|
|
187
|
-
|
|
188
|
-
if (steps) {
|
|
189
|
-
percent = findClosestStep(percent);
|
|
190
|
-
}
|
|
191
|
-
|
|
192
|
-
return percent;
|
|
193
|
-
};
|
|
194
|
-
/**
|
|
195
|
-
* Register a handler for the mouse move event.
|
|
196
|
-
*/
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
var handleMove = useEventCallback(function (event) {
|
|
200
|
-
var slider = sliderRef.current;
|
|
201
|
-
if (!slider || !onChange) return;
|
|
202
|
-
var newValue = getPercentValue(event, slider);
|
|
203
|
-
onChange(computeValueFromPercent(newValue, min, max, precision), name, event);
|
|
204
|
-
});
|
|
205
|
-
/**
|
|
206
|
-
* Register a handler for the mouse up event.
|
|
207
|
-
* Clean a all listeners.
|
|
208
|
-
*/
|
|
209
|
-
|
|
210
|
-
var handleEnd = useEventCallback(function () {
|
|
211
|
-
document.body.removeEventListener('mousemove', handleMove);
|
|
212
|
-
document.body.removeEventListener('mouseup', handleEnd);
|
|
213
|
-
document.body.removeEventListener('touchmove', handleMove);
|
|
214
|
-
document.body.removeEventListener('touchend', handleEnd);
|
|
215
|
-
});
|
|
216
|
-
/**
|
|
217
|
-
* Move to the next or previous value (i.e. + or - 10%) or next step
|
|
218
|
-
* @param previous Should seek the previous value.
|
|
219
|
-
*/
|
|
220
|
-
|
|
221
|
-
var hopToValue = function hopToValue() {
|
|
222
|
-
var previous = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : false;
|
|
223
|
-
var oldPercent = computePercentFromValue(value, min, max);
|
|
224
|
-
var percent = clamp(oldPercent + (previous ? -0.1 : 0.1), 0, 1);
|
|
225
|
-
|
|
226
|
-
if (steps) {
|
|
227
|
-
percent = oldPercent + availableSteps[1] * (previous ? -1 : 1);
|
|
228
|
-
percent = findClosestStep(percent);
|
|
229
|
-
}
|
|
230
|
-
|
|
231
|
-
if (onChange) {
|
|
232
|
-
onChange(computeValueFromPercent(percent, min, max, precision), name);
|
|
233
|
-
}
|
|
234
|
-
};
|
|
235
|
-
/**
|
|
236
|
-
* Register a handler for keyboard interactions
|
|
237
|
-
*/
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
var handleKeyDown = useEventCallback(function (event) {
|
|
241
|
-
if (event.key === 'ArrowRight') {
|
|
242
|
-
hopToValue();
|
|
243
|
-
} else if (event.key === 'ArrowLeft') {
|
|
244
|
-
hopToValue(true);
|
|
245
|
-
}
|
|
246
|
-
});
|
|
247
|
-
/**
|
|
248
|
-
* Register a handler for the mouseDown event.
|
|
249
|
-
*/
|
|
250
|
-
|
|
251
|
-
var handleMouseDown = useEventCallback(function (event) {
|
|
252
|
-
onMouseDown === null || onMouseDown === void 0 ? void 0 : onMouseDown(event);
|
|
253
|
-
var slider = sliderRef.current;
|
|
254
|
-
if (isDisabled || !slider) return;
|
|
255
|
-
var newValue = getPercentValue(event, slider);
|
|
256
|
-
|
|
257
|
-
if (onChange) {
|
|
258
|
-
onChange(computeValueFromPercent(newValue, min, max, precision), name, event);
|
|
259
|
-
}
|
|
260
|
-
|
|
261
|
-
document.body.addEventListener('mousemove', handleMove);
|
|
262
|
-
document.body.addEventListener('mouseup', handleEnd);
|
|
263
|
-
});
|
|
264
|
-
var percentString = "".concat(computePercentFromValue(value, min, max) * 100, "%");
|
|
265
|
-
return React.createElement("div", _extends({
|
|
266
|
-
ref: ref
|
|
267
|
-
}, forwardedProps, {
|
|
268
|
-
className: classnames(className, handleBasicClasses({
|
|
269
|
-
prefix: CLASSNAME,
|
|
270
|
-
theme: theme,
|
|
271
|
-
hasLabel: Boolean(label)
|
|
272
|
-
})),
|
|
273
|
-
onMouseDown: handleMouseDown,
|
|
274
|
-
"aria-disabled": isDisabled
|
|
275
|
-
}), label && React.createElement(InputLabel, {
|
|
276
|
-
id: sliderLabelId,
|
|
277
|
-
htmlFor: sliderId,
|
|
278
|
-
className: "".concat(CLASSNAME, "__label"),
|
|
279
|
-
theme: theme
|
|
280
|
-
}, label), helper && React.createElement(InputHelper, {
|
|
281
|
-
className: "".concat(CLASSNAME, "__helper"),
|
|
282
|
-
theme: theme
|
|
283
|
-
}, helper), React.createElement("div", {
|
|
284
|
-
className: "".concat(CLASSNAME, "__ui-wrapper")
|
|
285
|
-
}, !hideMinMaxLabel && React.createElement("span", {
|
|
286
|
-
className: "".concat(CLASSNAME, "__value-label ").concat(CLASSNAME, "__value-label--min")
|
|
287
|
-
}, min), React.createElement("div", {
|
|
288
|
-
className: "".concat(CLASSNAME, "__wrapper"),
|
|
289
|
-
ref: sliderRef
|
|
290
|
-
}, React.createElement("div", {
|
|
291
|
-
className: "".concat(CLASSNAME, "__track ").concat(CLASSNAME, "__track--background")
|
|
292
|
-
}), React.createElement("div", {
|
|
293
|
-
className: "".concat(CLASSNAME, "__track ").concat(CLASSNAME, "__track--active"),
|
|
294
|
-
style: {
|
|
295
|
-
width: percentString
|
|
296
|
-
}
|
|
297
|
-
}), steps ? React.createElement("div", {
|
|
298
|
-
className: "".concat(CLASSNAME, "__ticks")
|
|
299
|
-
}, availableSteps.map(function (step, idx) {
|
|
300
|
-
return React.createElement("div", {
|
|
301
|
-
key: "tick_".concat(idx),
|
|
302
|
-
className: "".concat(CLASSNAME, "__tick"),
|
|
303
|
-
style: {
|
|
304
|
-
left: "".concat(step * 100, "%")
|
|
305
|
-
}
|
|
306
|
-
});
|
|
307
|
-
})) : null, React.createElement("button", {
|
|
308
|
-
type: "button",
|
|
309
|
-
"aria-labelledby": sliderLabelId,
|
|
310
|
-
name: name,
|
|
311
|
-
id: sliderId,
|
|
312
|
-
className: "".concat(CLASSNAME, "__handle"),
|
|
313
|
-
style: {
|
|
314
|
-
left: percentString
|
|
315
|
-
},
|
|
316
|
-
onKeyDown: handleKeyDown,
|
|
317
|
-
disabled: isDisabled
|
|
318
|
-
})), !hideMinMaxLabel && React.createElement("span", {
|
|
319
|
-
className: "".concat(CLASSNAME, "__value-label ").concat(CLASSNAME, "__value-label--max")
|
|
320
|
-
}, max)));
|
|
321
|
-
});
|
|
322
|
-
Slider.displayName = COMPONENT_NAME;
|
|
323
|
-
Slider.className = CLASSNAME;
|
|
324
|
-
Slider.defaultProps = DEFAULT_PROPS;
|
|
325
|
-
|
|
326
|
-
export { Slider as S, clamp as c };
|
|
327
|
-
//# sourceMappingURL=6a0e1c77.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"6a0e1c77.js","sources":["../../src/hooks/useEventCallback.tsx","../../src/utils/clamp.ts","../../src/components/slider/Slider.tsx"],"sourcesContent":["import React from 'react';\n\nconst useEnhancedEffect = typeof window !== 'undefined' ? React.useLayoutEffect : React.useEffect;\n\n/**\n * https://github.com/facebook/react/issues/14099#issuecomment-440013892\n *\n * @param fn A function to run\n * @return A React callback\n */\nexport default function useEventCallback(fn: (...args: any[]) => any): (event: any) => any {\n const ref = React.useRef(fn);\n useEnhancedEffect(() => {\n ref.current = fn;\n });\n return React.useCallback((event: any) => ref.current(event), []);\n}\n","/**\n * Clamp value in range.\n *\n * @param value Value to clamp.\n * @param min Minimum value.\n * @param max Maximum value.\n * @return Clamped value.\n */\nexport const clamp = (value: number, min: number, max: number): number => {\n if (value < min) {\n return min;\n }\n if (value > max) {\n return max;\n }\n return value;\n};\n","/* eslint-disable jsx-a11y/no-static-element-interactions */\nimport React, { forwardRef, SyntheticEvent, useMemo, useRef } from 'react';\n\nimport classNames from 'classnames';\n\nimport { InputHelper, InputLabel, Theme } from '@lumx/react';\n\nimport useEventCallback from '@lumx/react/hooks/useEventCallback';\nimport { Comp, GenericProps, HasTheme } from '@lumx/react/utils/type';\nimport { getRootClassName, handleBasicClasses } from '@lumx/react/utils/className';\n\nimport { uid } from 'uid';\nimport { clamp } from '@lumx/react/utils/clamp';\n\n/**\n * Defines the props of the component.\n */\nexport interface SliderProps extends GenericProps, HasTheme {\n /** Helper text. */\n helper?: string;\n /** Whether the min and max labels should be hidden or not. */\n hideMinMaxLabel?: boolean;\n /** Whether the component is disabled or not. */\n isDisabled?: boolean;\n /** Label text. */\n label?: string;\n /** Maximum value on the range. */\n max: number;\n /** Minimum value of the range. */\n min: number;\n /** Native input name property. */\n name?: string;\n /** Number of digits in the fractional part of the selected value. */\n precision?: number;\n /** Range step value. */\n steps?: number;\n /** Selected ranged value. */\n value: number;\n /** On change callback. */\n onChange(value: number, name?: string, event?: SyntheticEvent): void;\n /** On click callback. */\n onMouseDown?(event: React.SyntheticEvent): void;\n}\n\n/**\n * Component display name.\n */\nconst COMPONENT_NAME = 'Slider';\n\n/**\n * Component default class name and class prefix.\n */\nconst CLASSNAME = getRootClassName(COMPONENT_NAME);\n\n/**\n * Component default props.\n */\nconst DEFAULT_PROPS: Partial<SliderProps> = {\n precision: 0,\n steps: 0,\n theme: Theme.light,\n};\n\n/**\n * Convert a percent value to a value in range min - max.\n *\n * @param percent Value to convert.\n * @param min Minimum value.\n * @param max Maximum value.\n * @param precision Precision.\n * @return Value in range min - max\n */\nconst computeValueFromPercent = (percent: number, min: number, max: number, precision = 0): number =>\n Number((min + percent * (max - min)).toFixed(precision));\n\n/**\n * Convert a value in range min - max to a percent value.\n *\n * @param value Value to convert.\n * @param min Minimum value.\n * @param max Maximum value.\n * @return Value in percent\n */\nconst computePercentFromValue = (value: number, min: number, max: number): number =>\n Number((value - min) / (max - min));\n\n/**\n * Slider component.\n *\n * @param props Component props.\n * @param ref Component ref.\n * @return React element.\n */\nexport const Slider: Comp<SliderProps, HTMLDivElement> = forwardRef((props, ref) => {\n const {\n className,\n disabled,\n helper,\n hideMinMaxLabel,\n id,\n isDisabled = disabled,\n label,\n max,\n min,\n name,\n onChange,\n onMouseDown,\n precision,\n steps,\n theme,\n value,\n ...forwardedProps\n } = props;\n const sliderId = useMemo(() => id || `slider-${uid()}`, [id]);\n const sliderLabelId = useMemo(() => `label-${sliderId}`, [sliderId]);\n const sliderRef = useRef<HTMLDivElement>(null);\n\n // build a lookup array for the steps.\n const availableSteps = useMemo((): number[] => {\n if (!steps) return [];\n\n const available = [0];\n const percentStep = 1 / ((max - min) / steps);\n let ptr = 0;\n while (ptr + percentStep < 1) {\n ptr += percentStep;\n available.push(ptr);\n }\n return available;\n }, [steps, min, max]);\n\n /**\n * Try to find the closest step to the current slider position.\n *\n * @param percentValue Reference value\n * @return The closest step value\n */\n const findClosestStep = (percentValue: number): number => {\n const closest = availableSteps.reduce(\n (acc, step) => {\n const aDst = Math.abs(percentValue - step);\n if (aDst < acc.dst) {\n return { dst: aDst, val: step };\n }\n return acc;\n },\n { dst: Infinity, val: -1 },\n );\n return closest.val;\n };\n\n /**\n * Convert slider's handle position to percent.\n *\n * @param event The interaction event\n * @param slider the slider element\n * @return The computed percent value\n */\n const getPercentValue = (event: React.MouseEvent, slider: HTMLDivElement): number => {\n const { width, left } = slider.getBoundingClientRect();\n let percent = (event.pageX - left - window.pageXOffset) / width;\n percent = clamp(percent, 0, 1);\n if (steps) {\n percent = findClosestStep(percent);\n }\n return percent;\n };\n\n /**\n * Register a handler for the mouse move event.\n */\n const handleMove = useEventCallback((event: React.MouseEvent) => {\n const { current: slider } = sliderRef;\n if (!slider || !onChange) return;\n const newValue = getPercentValue(event, slider);\n onChange(computeValueFromPercent(newValue, min, max, precision), name, event);\n });\n\n /**\n * Register a handler for the mouse up event.\n * Clean a all listeners.\n */\n const handleEnd = useEventCallback(() => {\n document.body.removeEventListener('mousemove', handleMove);\n document.body.removeEventListener('mouseup', handleEnd);\n document.body.removeEventListener('touchmove', handleMove);\n document.body.removeEventListener('touchend', handleEnd);\n });\n\n /**\n * Move to the next or previous value (i.e. + or - 10%) or next step\n * @param previous Should seek the previous value.\n */\n const hopToValue = (previous = false) => {\n const oldPercent = computePercentFromValue(value, min, max);\n let percent = clamp(oldPercent + (previous ? -0.1 : 0.1), 0, 1);\n if (steps) {\n percent = oldPercent + availableSteps[1] * (previous ? -1 : 1);\n percent = findClosestStep(percent);\n }\n if (onChange) {\n onChange(computeValueFromPercent(percent, min, max, precision), name);\n }\n };\n\n /**\n * Register a handler for keyboard interactions\n */\n const handleKeyDown = useEventCallback((event: React.KeyboardEvent) => {\n if (event.key === 'ArrowRight') {\n hopToValue();\n } else if (event.key === 'ArrowLeft') {\n hopToValue(true);\n }\n });\n\n /**\n * Register a handler for the mouseDown event.\n */\n const handleMouseDown = useEventCallback((event: React.MouseEvent) => {\n onMouseDown?.(event);\n\n const { current: slider } = sliderRef;\n if (isDisabled || !slider) return;\n const newValue = getPercentValue(event, slider);\n if (onChange) {\n onChange(computeValueFromPercent(newValue, min, max, precision), name, event);\n }\n\n document.body.addEventListener('mousemove', handleMove);\n document.body.addEventListener('mouseup', handleEnd);\n });\n\n const percentString = `${computePercentFromValue(value, min, max) * 100}%`;\n return (\n <div\n ref={ref}\n {...forwardedProps}\n className={classNames(\n className,\n handleBasicClasses({ prefix: CLASSNAME, theme, hasLabel: Boolean(label) }),\n )}\n onMouseDown={handleMouseDown}\n aria-disabled={isDisabled}\n >\n {label && (\n <InputLabel id={sliderLabelId} htmlFor={sliderId} className={`${CLASSNAME}__label`} theme={theme}>\n {label}\n </InputLabel>\n )}\n\n {helper && (\n <InputHelper className={`${CLASSNAME}__helper`} theme={theme}>\n {helper}\n </InputHelper>\n )}\n\n <div className={`${CLASSNAME}__ui-wrapper`}>\n {!hideMinMaxLabel && (\n <span className={`${CLASSNAME}__value-label ${CLASSNAME}__value-label--min`}>{min}</span>\n )}\n <div className={`${CLASSNAME}__wrapper`} ref={sliderRef}>\n <div className={`${CLASSNAME}__track ${CLASSNAME}__track--background`} />\n <div\n className={`${CLASSNAME}__track ${CLASSNAME}__track--active`}\n style={{ width: percentString }}\n />\n {steps ? (\n <div className={`${CLASSNAME}__ticks`}>\n {availableSteps.map((step, idx) => (\n <div\n key={`tick_${idx}`}\n className={`${CLASSNAME}__tick`}\n style={{ left: `${step * 100}%` }}\n />\n ))}\n </div>\n ) : null}\n <button\n type=\"button\"\n aria-labelledby={sliderLabelId}\n name={name}\n id={sliderId}\n className={`${CLASSNAME}__handle`}\n style={{ left: percentString }}\n onKeyDown={handleKeyDown}\n disabled={isDisabled}\n />\n </div>\n {!hideMinMaxLabel && (\n <span className={`${CLASSNAME}__value-label ${CLASSNAME}__value-label--max`}>{max}</span>\n )}\n </div>\n </div>\n );\n});\nSlider.displayName = COMPONENT_NAME;\nSlider.className = CLASSNAME;\nSlider.defaultProps = DEFAULT_PROPS;\n"],"names":["useEnhancedEffect","window","React","useLayoutEffect","useEffect","useEventCallback","fn","ref","useRef","current","useCallback","event","clamp","value","min","max","COMPONENT_NAME","CLASSNAME","getRootClassName","DEFAULT_PROPS","precision","steps","theme","Theme","light","computeValueFromPercent","percent","Number","toFixed","computePercentFromValue","Slider","forwardRef","props","className","disabled","helper","hideMinMaxLabel","id","isDisabled","label","name","onChange","onMouseDown","forwardedProps","sliderId","useMemo","uid","sliderLabelId","sliderRef","availableSteps","available","percentStep","ptr","push","findClosestStep","percentValue","closest","reduce","acc","step","aDst","Math","abs","dst","val","Infinity","getPercentValue","slider","getBoundingClientRect","width","left","pageX","pageXOffset","handleMove","newValue","handleEnd","document","body","removeEventListener","hopToValue","previous","oldPercent","handleKeyDown","key","handleMouseDown","addEventListener","percentString","classNames","handleBasicClasses","prefix","hasLabel","Boolean","map","idx","displayName","defaultProps"],"mappings":";;;;;;;;AAEA,IAAMA,iBAAiB,GAAG,OAAOC,MAAP,KAAkB,WAAlB,GAAgCC,KAAK,CAACC,eAAtC,GAAwDD,KAAK,CAACE,SAAxF;AAEA;;;;;;;AAMe,SAASC,gBAAT,CAA0BC,EAA1B,EAA4E;AACvF,MAAMC,GAAG,GAAGL,KAAK,CAACM,MAAN,CAAaF,EAAb,CAAZ;AACAN,EAAAA,iBAAiB,CAAC,YAAM;AACpBO,IAAAA,GAAG,CAACE,OAAJ,GAAcH,EAAd;AACH,GAFgB,CAAjB;AAGA,SAAOJ,KAAK,CAACQ,WAAN,CAAkB,UAACC,KAAD;AAAA,WAAgBJ,GAAG,CAACE,OAAJ,CAAYE,KAAZ,CAAhB;AAAA,GAAlB,EAAsD,EAAtD,CAAP;AACH;;AChBD;;;;;;;;IAQaC,KAAK,GAAG,SAARA,KAAQ,CAACC,KAAD,EAAgBC,GAAhB,EAA6BC,GAA7B,EAAqD;AACtE,MAAIF,KAAK,GAAGC,GAAZ,EAAiB;AACb,WAAOA,GAAP;AACH;;AACD,MAAID,KAAK,GAAGE,GAAZ,EAAiB;AACb,WAAOA,GAAP;AACH;;AACD,SAAOF,KAAP;AACH;;ACFD;;;;AA8BA;;;A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AACI,MAAA,GAAG,iBAAUA,GAAV,CADP;AAEI,MAAA,SAAS,YAAK5E,SAAL,WAFb;AAGI,MAAA,KAAK,EAAE;AAAEqD,QAAAA,IAAI,YAAKX,IAAI,GAAG,GAAZ;AAAN;AAHX,MADgB;AAAA,GAAnB,CADL,CADE,GAUF,IAhBR,EAiBI;AACI,IAAA,IAAI,EAAC,QADT;AAEI,uBAAiBZ,aAFrB;AAGI,IAAA,IAAI,EAAEP,IAHV;AAII,IAAA,EAAE,EAAEI,QAJR;AAKI,IAAA,SAAS,YAAK3B,SAAL,aALb;AAMI,IAAA,KAAK,EAAE;AAAEqD,MAAAA,IAAI,EAAEgB;AAAR,KANX;AAOI,IAAA,SAAS,EAAEJ,aAPf;AAQI,IAAA,QAAQ,EAAE5C;AARd,IAjBJ,CAJJ,EAgCK,CAACF,eAAD,IACG;AAAM,IAAA,SAAS,YAAKnB,SAAL,2BAA+BA,SAA/B;AAAf,KAA8EF,GAA9E,CAjCR,CAtBJ,CADJ;AA6DH,CA1MkE;AA2MnEe,MAAM,CAACgE,WAAP,GAAqB9E,cAArB;AACAc,MAAM,CAACG,SAAP,GAAmBhB,SAAnB;AACAa,MAAM,CAACiE,YAAP,GAAsB5E,aAAtB;;;;"}
|
package/_internal/701c20b0.d.ts
DELETED
|
@@ -1,24 +0,0 @@
|
|
|
1
|
-
import { ReactNode } from 'react';
|
|
2
|
-
import { l as GenericProps, k as Comp } from './eca6d4dc.js';
|
|
3
|
-
|
|
4
|
-
/**
|
|
5
|
-
* Defines the props of the component.
|
|
6
|
-
*/
|
|
7
|
-
interface ToolbarProps extends GenericProps {
|
|
8
|
-
/** After content (placed after the label). */
|
|
9
|
-
after?: ReactNode;
|
|
10
|
-
/** Before content (placed before the label). */
|
|
11
|
-
before?: ReactNode;
|
|
12
|
-
/** Label content. */
|
|
13
|
-
label?: ReactNode;
|
|
14
|
-
}
|
|
15
|
-
/**
|
|
16
|
-
* Toolbar component.
|
|
17
|
-
*
|
|
18
|
-
* @param props Component props.
|
|
19
|
-
* @param ref Component ref.
|
|
20
|
-
* @return React element.
|
|
21
|
-
*/
|
|
22
|
-
declare const Toolbar: Comp<ToolbarProps, HTMLDivElement>;
|
|
23
|
-
|
|
24
|
-
export { ToolbarProps as T, Toolbar as a };
|
package/_internal/7391188a.js
DELETED
|
@@ -1,81 +0,0 @@
|
|
|
1
|
-
import { b as _objectWithoutProperties, c as _extends } from './6340c129.js';
|
|
2
|
-
import { Theme } from '../components.js';
|
|
3
|
-
import React, { forwardRef } from 'react';
|
|
4
|
-
import { g as getRootClassName, c as classnames, h as handleBasicClasses } from './fd867c9d.js';
|
|
5
|
-
|
|
6
|
-
/**
|
|
7
|
-
* Progress variants.
|
|
8
|
-
*/
|
|
9
|
-
|
|
10
|
-
var ProgressVariant = {
|
|
11
|
-
linear: 'linear',
|
|
12
|
-
circular: 'circular'
|
|
13
|
-
};
|
|
14
|
-
|
|
15
|
-
/**
|
|
16
|
-
* Component display name.
|
|
17
|
-
*/
|
|
18
|
-
var COMPONENT_NAME = 'Progress';
|
|
19
|
-
/**
|
|
20
|
-
* Component default class name and class prefix.
|
|
21
|
-
*/
|
|
22
|
-
|
|
23
|
-
var CLASSNAME = getRootClassName(COMPONENT_NAME);
|
|
24
|
-
/**
|
|
25
|
-
* Component default props.
|
|
26
|
-
*/
|
|
27
|
-
|
|
28
|
-
var DEFAULT_PROPS = {
|
|
29
|
-
theme: Theme.light,
|
|
30
|
-
variant: ProgressVariant.circular
|
|
31
|
-
};
|
|
32
|
-
/**
|
|
33
|
-
* Progress component.
|
|
34
|
-
*
|
|
35
|
-
* @param props Component props.
|
|
36
|
-
* @param ref Component ref.
|
|
37
|
-
* @return React element.
|
|
38
|
-
*/
|
|
39
|
-
|
|
40
|
-
var Progress = forwardRef(function (props, ref) {
|
|
41
|
-
var className = props.className,
|
|
42
|
-
theme = props.theme,
|
|
43
|
-
variant = props.variant,
|
|
44
|
-
forwardedProps = _objectWithoutProperties(props, ["className", "theme", "variant"]);
|
|
45
|
-
|
|
46
|
-
return React.createElement("div", _extends({
|
|
47
|
-
ref: ref
|
|
48
|
-
}, forwardedProps, {
|
|
49
|
-
className: classnames(className, handleBasicClasses({
|
|
50
|
-
prefix: CLASSNAME,
|
|
51
|
-
theme: theme,
|
|
52
|
-
variant: variant
|
|
53
|
-
}))
|
|
54
|
-
}), React.createElement("div", {
|
|
55
|
-
className: classnames("".concat(CLASSNAME, "-").concat(variant))
|
|
56
|
-
}, variant === ProgressVariant.circular && React.createElement(React.Fragment, null, React.createElement("div", {
|
|
57
|
-
className: "lumx-progress-circular__double-bounce1"
|
|
58
|
-
}), React.createElement("div", {
|
|
59
|
-
className: "lumx-progress-circular__double-bounce2"
|
|
60
|
-
}), React.createElement("svg", {
|
|
61
|
-
className: "lumx-progress-circular__svg",
|
|
62
|
-
viewBox: "25 25 50 50"
|
|
63
|
-
}, React.createElement("circle", {
|
|
64
|
-
className: "lumx-progress-circular__path",
|
|
65
|
-
cx: "50",
|
|
66
|
-
cy: "50",
|
|
67
|
-
r: "20",
|
|
68
|
-
fill: "none",
|
|
69
|
-
strokeWidth: "5"
|
|
70
|
-
}))), variant === ProgressVariant.linear && React.createElement(React.Fragment, null, React.createElement("div", {
|
|
71
|
-
className: "lumx-progress-linear__line1"
|
|
72
|
-
}), React.createElement("div", {
|
|
73
|
-
className: "lumx-progress-linear__line2"
|
|
74
|
-
}))));
|
|
75
|
-
});
|
|
76
|
-
Progress.displayName = COMPONENT_NAME;
|
|
77
|
-
Progress.className = CLASSNAME;
|
|
78
|
-
Progress.defaultProps = DEFAULT_PROPS;
|
|
79
|
-
|
|
80
|
-
export { ProgressVariant as P, Progress as a };
|
|
81
|
-
//# sourceMappingURL=7391188a.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"7391188a.js","sources":["../../src/components/progress/Progress.tsx"],"sourcesContent":["import React, { forwardRef } from 'react';\n\nimport classNames from 'classnames';\n\nimport { Theme } from '@lumx/react';\n\nimport { Comp, GenericProps, HasTheme, ValueOf } from '@lumx/react/utils/type';\nimport { getRootClassName, handleBasicClasses } from '@lumx/react/utils/className';\n\n/**\n * Progress variants.\n */\nexport const ProgressVariant = { linear: 'linear', circular: 'circular' } as const;\nexport type ProgressVariant = ValueOf<typeof ProgressVariant>;\n\n/**\n * Defines the props of the component.\n */\nexport interface ProgressProps extends GenericProps, HasTheme {\n /** Progress variant. */\n variant?: ProgressVariant;\n}\n\n/**\n * Component display name.\n */\nconst COMPONENT_NAME = 'Progress';\n\n/**\n * Component default class name and class prefix.\n */\nconst CLASSNAME = getRootClassName(COMPONENT_NAME);\n\n/**\n * Component default props.\n */\nconst DEFAULT_PROPS: Partial<ProgressProps> = {\n theme: Theme.light,\n variant: ProgressVariant.circular,\n};\n/**\n * Progress component.\n *\n * @param props Component props.\n * @param ref Component ref.\n * @return React element.\n */\nexport const Progress: Comp<ProgressProps, HTMLDivElement> = forwardRef((props, ref) => {\n const { className, theme, variant, ...forwardedProps } = props;\n\n return (\n <div\n ref={ref}\n {...forwardedProps}\n className={classNames(className, handleBasicClasses({ prefix: CLASSNAME, theme, variant }))}\n >\n <div className={classNames(`${CLASSNAME}-${variant}`)}>\n {variant === ProgressVariant.circular && (\n <>\n <div className=\"lumx-progress-circular__double-bounce1\" />\n <div className=\"lumx-progress-circular__double-bounce2\" />\n\n <svg className=\"lumx-progress-circular__svg\" viewBox=\"25 25 50 50\">\n <circle\n className=\"lumx-progress-circular__path\"\n cx=\"50\"\n cy=\"50\"\n r=\"20\"\n fill=\"none\"\n strokeWidth=\"5\"\n />\n </svg>\n </>\n )}\n {variant === ProgressVariant.linear && (\n <>\n <div className=\"lumx-progress-linear__line1\" />\n <div className=\"lumx-progress-linear__line2\" />\n </>\n )}\n </div>\n </div>\n );\n});\nProgress.displayName = COMPONENT_NAME;\nProgress.className = CLASSNAME;\nProgress.defaultProps = DEFAULT_PROPS;\n"],"names":["ProgressVariant","linear","circular","COMPONENT_NAME","CLASSNAME","getRootClassName","DEFAULT_PROPS","theme","Theme","light","variant","Progress","forwardRef","props","ref","className","forwardedProps","classNames","handleBasicClasses","prefix","displayName","defaultProps"],"mappings":";;;;;AASA;;;;IAGaA,eAAe,GAAG;AAAEC,EAAAA,MAAM,EAAE,QAAV;AAAoBC,EAAAA,QAAQ,EAAE;AAA9B;;AAW/B;;;AAGA,IAAMC,cAAc,GAAG,UAAvB;AAEA;;;;AAGA,IAAMC,SAAS,GAAGC,gBAAgB,CAACF,cAAD,CAAlC;AAEA;;;;AAGA,IAAMG,aAAqC,GAAG;AAC1CC,EAAAA,KAAK,EAAEC,KAAK,CAACC,KAD6B;AAE1CC,EAAAA,OAAO,EAAEV,eAAe,CAACE;AAFiB,CAA9C;AAIA;;;;;;;;IAOaS,QAA6C,GAAGC,UAAU,CAAC,UAACC,KAAD,EAAQC,GAAR,EAAgB;AAAA,MAC5EC,SAD4E,GAC3BF,KAD2B,CAC5EE,SAD4E;AAAA,MACjER,KADiE,GAC3BM,KAD2B,CACjEN,KADiE;AAAA,MAC1DG,OAD0D,GAC3BG,KAD2B,CAC1DH,OAD0D;AAAA,MAC9CM,cAD8C,4BAC3BH,KAD2B;;AAGpF,SACI;AACI,IAAA,GAAG,EAAEC;AADT,KAEQE,cAFR;AAGI,IAAA,SAAS,EAAEC,UAAU,CAACF,SAAD,EAAYG,kBAAkB,CAAC;AAAEC,MAAAA,MAAM,EAAEf,SAAV;AAAqBG,MAAAA,KAAK,EAALA,KAArB;AAA4BG,MAAAA,OAAO,EAAPA;AAA5B,KAAD,CAA9B;AAHzB,MAKI;AAAK,IAAA,SAAS,EAAEO,UAAU,WAAIb,SAAJ,cAAiBM,OAAjB;AAA1B,KACKA,OAAO,KAAKV,eAAe,CAACE,QAA5B,IACG,0CACI;AAAK,IAAA,SAAS,EAAC;AAAf,IADJ,EAEI;AAAK,IAAA,SAAS,EAAC;AAAf,IAFJ,EAII;AAAK,IAAA,SAAS,EAAC,6BAAf;AAA6C,IAAA,OAAO,EAAC;AAArD,KACI;AACI,IAAA,SAAS,EAAC,8BADd;AAEI,IAAA,EAAE,EAAC,IAFP;AAGI,IAAA,EAAE,EAAC,IAHP;AAII,IAAA,CAAC,EAAC,IAJN;AAKI,IAAA,IAAI,EAAC,MALT;AAMI,IAAA,WAAW,EAAC;AANhB,IADJ,CAJJ,CAFR,EAkBKQ,OAAO,KAAKV,eAAe,CAACC,MAA5B,IACG,0CACI;AAAK,IAAA,SAAS,EAAC;AAAf,IADJ,EAEI;AAAK,IAAA,SAAS,EAAC;AAAf,IAFJ,CAnBR,CALJ,CADJ;AAiCH,CApCsE;AAqCvEU,QAAQ,CAACS,WAAT,GAAuBjB,cAAvB;AACAQ,QAAQ,CAACI,SAAT,GAAqBX,SAArB;AACAO,QAAQ,CAACU,YAAT,GAAwBf,aAAxB;;;;"}
|
package/_internal/74cb6c26.js
DELETED
|
@@ -1,136 +0,0 @@
|
|
|
1
|
-
import { b as _objectWithoutProperties, _ as _objectSpread2, c as _extends } from './6340c129.js';
|
|
2
|
-
import { Emphasis, ColorPalette, Theme } from '../components.js';
|
|
3
|
-
import React, { forwardRef } from 'react';
|
|
4
|
-
import { c as classnames, h as handleBasicClasses, C as CSS_PREFIX } from './fd867c9d.js';
|
|
5
|
-
import 'lodash/kebabCase';
|
|
6
|
-
import isEmpty from 'lodash/isEmpty';
|
|
7
|
-
import { r as renderLink } from './329a01d3.js';
|
|
8
|
-
|
|
9
|
-
/**
|
|
10
|
-
* Component display name.
|
|
11
|
-
*/
|
|
12
|
-
var COMPONENT_NAME = 'ButtonRoot';
|
|
13
|
-
var BUTTON_WRAPPER_CLASSNAME = "".concat(CSS_PREFIX, "-button-wrapper");
|
|
14
|
-
var BUTTON_CLASSNAME = "".concat(CSS_PREFIX, "-button");
|
|
15
|
-
/**
|
|
16
|
-
* Render a button wrapper with the ButtonRoot inside.
|
|
17
|
-
*
|
|
18
|
-
* @param props Component props.
|
|
19
|
-
* @return React element.
|
|
20
|
-
*/
|
|
21
|
-
|
|
22
|
-
var renderButtonWrapper = function renderButtonWrapper(props) {
|
|
23
|
-
var color = props.color,
|
|
24
|
-
emphasis = props.emphasis,
|
|
25
|
-
variant = props.variant,
|
|
26
|
-
fullWidth = props.fullWidth;
|
|
27
|
-
var adaptedColor = emphasis === Emphasis.low && (color === ColorPalette.light ? ColorPalette.dark : ColorPalette.light);
|
|
28
|
-
var wrapperClassName = classnames(handleBasicClasses({
|
|
29
|
-
color: adaptedColor,
|
|
30
|
-
prefix: BUTTON_WRAPPER_CLASSNAME,
|
|
31
|
-
variant: variant,
|
|
32
|
-
fullWidth: fullWidth
|
|
33
|
-
}));
|
|
34
|
-
|
|
35
|
-
var buttonProps = _objectSpread2({}, props, {
|
|
36
|
-
hasBackground: false
|
|
37
|
-
});
|
|
38
|
-
|
|
39
|
-
return React.createElement("div", {
|
|
40
|
-
className: wrapperClassName
|
|
41
|
-
}, React.createElement(ButtonRoot, buttonProps));
|
|
42
|
-
};
|
|
43
|
-
/**
|
|
44
|
-
* ButtonRoot component.
|
|
45
|
-
*
|
|
46
|
-
* @param props Component props.
|
|
47
|
-
* @param ref Component ref.
|
|
48
|
-
* @return React element.
|
|
49
|
-
*/
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
var ButtonRoot = forwardRef(function (props, ref) {
|
|
53
|
-
var ariaLabel = props['aria-label'],
|
|
54
|
-
children = props.children,
|
|
55
|
-
className = props.className,
|
|
56
|
-
color = props.color,
|
|
57
|
-
disabled = props.disabled,
|
|
58
|
-
emphasis = props.emphasis,
|
|
59
|
-
hasBackground = props.hasBackground,
|
|
60
|
-
href = props.href,
|
|
61
|
-
_props$isDisabled = props.isDisabled,
|
|
62
|
-
isDisabled = _props$isDisabled === void 0 ? disabled : _props$isDisabled,
|
|
63
|
-
isSelected = props.isSelected,
|
|
64
|
-
isActive = props.isActive,
|
|
65
|
-
isFocused = props.isFocused,
|
|
66
|
-
isHovered = props.isHovered,
|
|
67
|
-
linkAs = props.linkAs,
|
|
68
|
-
name = props.name,
|
|
69
|
-
size = props.size,
|
|
70
|
-
target = props.target,
|
|
71
|
-
theme = props.theme,
|
|
72
|
-
variant = props.variant,
|
|
73
|
-
_props$type = props.type,
|
|
74
|
-
type = _props$type === void 0 ? 'button' : _props$type,
|
|
75
|
-
fullWidth = props.fullWidth,
|
|
76
|
-
forwardedProps = _objectWithoutProperties(props, ["aria-label", "children", "className", "color", "disabled", "emphasis", "hasBackground", "href", "isDisabled", "isSelected", "isActive", "isFocused", "isHovered", "linkAs", "name", "size", "target", "theme", "variant", "type", "fullWidth"]);
|
|
77
|
-
|
|
78
|
-
var adaptedColor = color || emphasis !== Emphasis.high && theme === Theme.dark && ColorPalette.light || emphasis === Emphasis.high && ColorPalette.primary || ColorPalette.dark;
|
|
79
|
-
|
|
80
|
-
if (hasBackground) {
|
|
81
|
-
return renderButtonWrapper(_objectSpread2({}, props, {
|
|
82
|
-
ref: ref,
|
|
83
|
-
variant: variant,
|
|
84
|
-
color: adaptedColor
|
|
85
|
-
}));
|
|
86
|
-
}
|
|
87
|
-
|
|
88
|
-
var buttonClassName = classnames(className, handleBasicClasses({
|
|
89
|
-
color: adaptedColor,
|
|
90
|
-
emphasis: emphasis,
|
|
91
|
-
isSelected: isSelected,
|
|
92
|
-
isDisabled: isDisabled,
|
|
93
|
-
isActive: isActive,
|
|
94
|
-
isFocused: isFocused,
|
|
95
|
-
isHovered: isHovered,
|
|
96
|
-
prefix: BUTTON_CLASSNAME,
|
|
97
|
-
size: size,
|
|
98
|
-
theme: emphasis === Emphasis.high && theme,
|
|
99
|
-
variant: variant,
|
|
100
|
-
fullWidth: fullWidth
|
|
101
|
-
}));
|
|
102
|
-
/**
|
|
103
|
-
* If the linkAs prop is used, we use the linkAs component instead of a <button>.
|
|
104
|
-
* If there is an href attribute, we display an <a> instead of a <button>.
|
|
105
|
-
*
|
|
106
|
-
* However, in any case, if the component is disabled, we returned a <button> since disabled is not compatible with <a>.
|
|
107
|
-
*/
|
|
108
|
-
|
|
109
|
-
if ((linkAs || !isEmpty(props.href)) && !isDisabled) {
|
|
110
|
-
return renderLink(_objectSpread2({
|
|
111
|
-
linkAs: linkAs
|
|
112
|
-
}, forwardedProps, {
|
|
113
|
-
'aria-label': ariaLabel,
|
|
114
|
-
href: href,
|
|
115
|
-
target: target,
|
|
116
|
-
className: buttonClassName,
|
|
117
|
-
ref: ref
|
|
118
|
-
}), children);
|
|
119
|
-
}
|
|
120
|
-
|
|
121
|
-
return React.createElement("button", _extends({}, forwardedProps, {
|
|
122
|
-
disabled: isDisabled,
|
|
123
|
-
"aria-disabled": isDisabled,
|
|
124
|
-
"aria-label": ariaLabel,
|
|
125
|
-
ref: ref,
|
|
126
|
-
className: buttonClassName,
|
|
127
|
-
name: name,
|
|
128
|
-
type: // eslint-disable-next-line react/button-has-type
|
|
129
|
-
type
|
|
130
|
-
}), children);
|
|
131
|
-
});
|
|
132
|
-
ButtonRoot.displayName = COMPONENT_NAME;
|
|
133
|
-
ButtonRoot.defaultProps = {};
|
|
134
|
-
|
|
135
|
-
export { ButtonRoot as B };
|
|
136
|
-
//# sourceMappingURL=74cb6c26.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"74cb6c26.js","sources":["../../src/components/button/ButtonRoot.tsx"],"sourcesContent":["import React, { AriaAttributes, ButtonHTMLAttributes, DetailedHTMLProps, forwardRef, RefObject } from 'react';\n\nimport isEmpty from 'lodash/isEmpty';\n\nimport classNames from 'classnames';\n\nimport { Color, ColorPalette, Emphasis, Size, Theme } from '@lumx/react';\nimport { CSS_PREFIX } from '@lumx/react/constants';\nimport { Comp, GenericProps, HasTheme } from '@lumx/react/utils/type';\nimport { handleBasicClasses } from '@lumx/react/utils/className';\nimport { renderLink } from '@lumx/react/utils/renderLink';\n\ntype HTMLButtonProps = DetailedHTMLProps<ButtonHTMLAttributes<HTMLButtonElement>, HTMLButtonElement>;\n\n/**\n * Button size definition.\n */\nexport type ButtonSize = Extract<Size, 's' | 'm'>;\n\nexport interface BaseButtonProps\n extends GenericProps,\n Pick<AriaAttributes, 'aria-expanded' | 'aria-haspopup' | 'aria-pressed' | 'aria-label'>,\n HasTheme {\n /** Color variant. */\n color?: Color;\n /** Emphasis variant. */\n emphasis?: Emphasis;\n /** Whether or not the button has a background color in low emphasis. */\n hasBackground?: boolean;\n /** Native anchor href property. It determines whether the Button will be a <button> or an <a>. */\n href?: string;\n /** Whether the component is disabled or not. */\n isDisabled?: boolean;\n /** Whether the component is selected or not. */\n isSelected?: boolean;\n /** Native button name property. */\n name?: string;\n /** Size variant. */\n size?: ButtonSize;\n /** Native anchor target property. */\n target?: '_self' | '_blank' | '_parent' | '_top';\n /** Native button type. */\n type?: HTMLButtonProps['type'];\n /** Custom react component for the link (can be used to inject react router Link). */\n linkAs?: 'a' | any;\n}\n\nexport interface ButtonRootProps extends BaseButtonProps {\n variant: 'button' | 'icon';\n}\n\n/**\n * Component display name.\n */\nconst COMPONENT_NAME = 'ButtonRoot';\n\nexport const BUTTON_WRAPPER_CLASSNAME = `${CSS_PREFIX}-button-wrapper`;\nexport const BUTTON_CLASSNAME = `${CSS_PREFIX}-button`;\n\n/**\n * Render a button wrapper with the ButtonRoot inside.\n *\n * @param props Component props.\n * @return React element.\n */\nconst renderButtonWrapper: React.FC<ButtonRootProps> = (props) => {\n const { color, emphasis, variant, fullWidth } = props;\n\n const adaptedColor =\n emphasis === Emphasis.low && (color === ColorPalette.light ? ColorPalette.dark : ColorPalette.light);\n\n const wrapperClassName = classNames(\n handleBasicClasses({\n color: adaptedColor,\n prefix: BUTTON_WRAPPER_CLASSNAME,\n variant,\n fullWidth,\n }),\n );\n const buttonProps = { ...props, hasBackground: false };\n\n return (\n <div className={wrapperClassName}>\n {/* eslint-disable-next-line @typescript-eslint/no-use-before-define */}\n <ButtonRoot {...buttonProps} />\n </div>\n );\n};\n\n/**\n * ButtonRoot component.\n *\n * @param props Component props.\n * @param ref Component ref.\n * @return React element.\n */\nexport const ButtonRoot: Comp<ButtonRootProps, HTMLButtonElement | HTMLAnchorElement> = forwardRef((props, ref) => {\n const {\n 'aria-label': ariaLabel,\n children,\n className,\n color,\n disabled,\n emphasis,\n hasBackground,\n href,\n isDisabled = disabled,\n isSelected,\n isActive,\n isFocused,\n isHovered,\n linkAs,\n name,\n size,\n target,\n theme,\n variant,\n type = 'button',\n fullWidth,\n ...forwardedProps\n } = props;\n\n const adaptedColor =\n color ||\n (emphasis !== Emphasis.high && theme === Theme.dark && ColorPalette.light) ||\n (emphasis === Emphasis.high && ColorPalette.primary) ||\n ColorPalette.dark;\n\n if (hasBackground) {\n return renderButtonWrapper({ ...props, ref, variant, color: adaptedColor });\n }\n\n const buttonClassName = classNames(\n className,\n handleBasicClasses({\n color: adaptedColor,\n emphasis,\n isSelected,\n isDisabled,\n isActive,\n isFocused,\n isHovered,\n prefix: BUTTON_CLASSNAME,\n size,\n theme: emphasis === Emphasis.high && theme,\n variant,\n fullWidth,\n }),\n );\n\n /**\n * If the linkAs prop is used, we use the linkAs component instead of a <button>.\n * If there is an href attribute, we display an <a> instead of a <button>.\n *\n * However, in any case, if the component is disabled, we returned a <button> since disabled is not compatible with <a>.\n */\n if ((linkAs || !isEmpty(props.href)) && !isDisabled) {\n return renderLink(\n {\n linkAs,\n ...forwardedProps,\n 'aria-label': ariaLabel,\n href,\n target,\n className: buttonClassName,\n ref: ref as RefObject<HTMLAnchorElement>,\n },\n children,\n );\n }\n return (\n <button\n {...forwardedProps}\n disabled={isDisabled}\n aria-disabled={isDisabled}\n aria-label={ariaLabel}\n ref={ref as RefObject<HTMLButtonElement>}\n className={buttonClassName}\n name={name}\n type={\n // eslint-disable-next-line react/button-has-type\n type\n }\n >\n {children}\n </button>\n );\n});\nButtonRoot.displayName = COMPONENT_NAME;\nButtonRoot.defaultProps = {};\n"],"names":["COMPONENT_NAME","BUTTON_WRAPPER_CLASSNAME","CSS_PREFIX","BUTTON_CLASSNAME","renderButtonWrapper","props","color","emphasis","variant","fullWidth","adaptedColor","Emphasis","low","ColorPalette","light","dark","wrapperClassName","classNames","handleBasicClasses","prefix","buttonProps","hasBackground","ButtonRoot","forwardRef","ref","ariaLabel","children","className","disabled","href","isDisabled","isSelected","isActive","isFocused","isHovered","linkAs","name","size","target","theme","type","forwardedProps","high","Theme","primary","buttonClassName","isEmpty","renderLink","displayName","defaultProps"],"mappings":";;;;;;;;AAmDA;;;AAGA,IAAMA,cAAc,GAAG,YAAvB;AAEO,IAAMC,wBAAwB,aAAMC,UAAN,oBAA9B;AACA,IAAMC,gBAAgB,aAAMD,UAAN,YAAtB;AAEP;;;;;;;AAMA,IAAME,mBAA8C,GAAG,SAAjDA,mBAAiD,CAACC,KAAD,EAAW;AAAA,MACtDC,KADsD,GACdD,KADc,CACtDC,KADsD;AAAA,MAC/CC,QAD+C,GACdF,KADc,CAC/CE,QAD+C;AAAA,MACrCC,OADqC,GACdH,KADc,CACrCG,OADqC;AAAA,MAC5BC,SAD4B,GACdJ,KADc,CAC5BI,SAD4B;AAG9D,MAAMC,YAAY,GACdH,QAAQ,KAAKI,QAAQ,CAACC,GAAtB,KAA8BN,KAAK,KAAKO,YAAY,CAACC,KAAvB,GAA+BD,YAAY,CAACE,IAA5C,GAAmDF,YAAY,CAACC,KAA9F,CADJ;AAGA,MAAME,gBAAgB,GAAGC,UAAU,CAC/BC,kBAAkB,CAAC;AACfZ,IAAAA,KAAK,EAAEI,YADQ;AAEfS,IAAAA,MAAM,EAAElB,wBAFO;AAGfO,IAAAA,OAAO,EAAPA,OAHe;AAIfC,IAAAA,SAAS,EAATA;AAJe,GAAD,CADa,CAAnC;;AAQA,MAAMW,WAAW,sBAAQf,KAAR;AAAegB,IAAAA,aAAa,EAAE;AAA9B,IAAjB;;AAEA,SACI;AAAK,IAAA,SAAS,EAAEL;AAAhB,KAEI,oBAAC,UAAD,EAAgBI,WAAhB,CAFJ,CADJ;AAMH,CAtBD;AAwBA;;;;;;;;;IAOaE,UAAwE,GAAGC,UAAU,CAAC,UAAClB,KAAD,EAAQmB,GAAR,EAAgB;AAAA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