@lumx/react 3.20.1-alpha.36 → 3.20.1-alpha.37

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 (105) hide show
  1. package/index.js +13990 -64
  2. package/index.js.map +1 -0
  3. package/package.json +3 -3
  4. package/utils/index.js +159 -3
  5. package/utils/index.js.map +1 -0
  6. package/_internal/035c132d.js +0 -314
  7. package/_internal/0b9c76cb.js +0 -5
  8. package/_internal/0ea95af1.js +0 -819
  9. package/_internal/230173a8.js +0 -12
  10. package/_internal/2a3d237c.js +0 -11
  11. package/_internal/2c2b6a89.js +0 -51
  12. package/_internal/3181f000.js +0 -13
  13. package/_internal/36bd7352.js +0 -218
  14. package/_internal/3864a6c1.js +0 -436
  15. package/_internal/3a1facc0.js +0 -17
  16. package/_internal/49bbeed3.js +0 -5
  17. package/_internal/4daccdd5.js +0 -24
  18. package/_internal/4f4c0582.js +0 -2169
  19. package/_internal/5cef5e8c.js +0 -74
  20. package/_internal/6a60381c.js +0 -117
  21. package/_internal/6f084a40.js +0 -111
  22. package/_internal/76ddefd4.js +0 -61
  23. package/_internal/78df9309.js +0 -19
  24. package/_internal/7ad474e4.js +0 -98
  25. package/_internal/7b293665.js +0 -19
  26. package/_internal/7daf0f24.js +0 -76
  27. package/_internal/825ac334.js +0 -129
  28. package/_internal/827b804a.js +0 -5
  29. package/_internal/8bce732e.js +0 -8
  30. package/_internal/9d1336a1.js +0 -18
  31. package/_internal/a38bdcd0.js +0 -49
  32. package/_internal/b326655a.js +0 -682
  33. package/_internal/b83e864b.js +0 -76
  34. package/_internal/bace1bf1.js +0 -103
  35. package/_internal/c57190eb.js +0 -146
  36. package/_internal/components/alert-dialog/index-284fed80.js +0 -163
  37. package/_internal/components/autocomplete/__mockData__/index-96fc7ea7.js +0 -27
  38. package/_internal/components/autocomplete/index-27a49d5d.js +0 -261
  39. package/_internal/components/avatar/index-b8bc3cae.js +0 -83
  40. package/_internal/components/badge/index-9880f056.js +0 -81
  41. package/_internal/components/button/index-d919f96d.js +0 -47
  42. package/_internal/components/checkbox/index-dd478de9.js +0 -143
  43. package/_internal/components/chip/index-7f84cdbd.js +0 -102
  44. package/_internal/components/comment-block/index-e942de30.js +0 -138
  45. package/_internal/components/date-picker/index-a258d3ce.js +0 -596
  46. package/_internal/components/dialog/index-c7066813.js +0 -238
  47. package/_internal/components/divider/index-b6934baf.js +0 -50
  48. package/_internal/components/drag-handle/index-80e5af6c.js +0 -52
  49. package/_internal/components/dropdown/index-cebfc268.js +0 -147
  50. package/_internal/components/expansion-panel/index-9d45a211.js +0 -167
  51. package/_internal/components/flag/index-33e9d909.js +0 -59
  52. package/_internal/components/flex-box/index-0d6b6b43.js +0 -56
  53. package/_internal/components/generic-block/index-836c4352.js +0 -124
  54. package/_internal/components/grid/index-8c16a4f1.js +0 -104
  55. package/_internal/components/grid-column/index-4a2f56bb.js +0 -59
  56. package/_internal/components/heading/index-fd558a9a.js +0 -53
  57. package/_internal/components/icon/index-e7b9b40e.js +0 -1
  58. package/_internal/components/image-block/index-7021c2f1.js +0 -110
  59. package/_internal/components/image-lightbox/index-27017547.js +0 -759
  60. package/_internal/components/inline-list/index-52efec7f.js +0 -74
  61. package/_internal/components/input-helper/index-5a837e7c.js +0 -71
  62. package/_internal/components/input-label/index-0113f382.js +0 -59
  63. package/_internal/components/lightbox/index-fad5a9f2.js +0 -155
  64. package/_internal/components/link/index-008bae4b.js +0 -72
  65. package/_internal/components/link-preview/index-3e9c32f2.js +0 -117
  66. package/_internal/components/list/index-da88c6e9.js +0 -71
  67. package/_internal/components/message/index-17b568f2.js +0 -98
  68. package/_internal/components/mosaic/index-2d40e01c.js +0 -95
  69. package/_internal/components/navigation/index-dc17c639.js +0 -225
  70. package/_internal/components/notification/index-a1101015.js +0 -146
  71. package/_internal/components/popover/index-dbca63f1.js +0 -2
  72. package/_internal/components/popover-dialog/index-654d2abc.js +0 -66
  73. package/_internal/components/post-block/index-4b6b4dcb.js +0 -109
  74. package/_internal/components/progress/index-6f578c31.js +0 -182
  75. package/_internal/components/progress-tracker/index-700bc4c2.js +0 -309
  76. package/_internal/components/radio-button/index-89b725af.js +0 -149
  77. package/_internal/components/select/index-2755aa32.js +0 -458
  78. package/_internal/components/side-navigation/index-0bbe1fdd.js +0 -165
  79. package/_internal/components/skeleton/index-b2f8501c.js +0 -166
  80. package/_internal/components/slider/index-4f9b891b.js +0 -311
  81. package/_internal/components/slideshow/index-d4604589.js +0 -150
  82. package/_internal/components/switch/index-58fe0f0c.js +0 -122
  83. package/_internal/components/table/index-d541aa88.js +0 -297
  84. package/_internal/components/tabs/index-af1538d6.js +0 -298
  85. package/_internal/components/text/index-5bfc6d5e.js +0 -1
  86. package/_internal/components/text-field/index-47c98d09.js +0 -360
  87. package/_internal/components/thumbnail/index-71545d95.js +0 -41
  88. package/_internal/components/toolbar/index-7041a5a6.js +0 -61
  89. package/_internal/components/tooltip/index-8bb97e60.js +0 -327
  90. package/_internal/components/uploader/index-8f6f55de.js +0 -153
  91. package/_internal/components/user-block/index-70d4ce8f.js +0 -145
  92. package/_internal/d0e3f49e.js +0 -23
  93. package/_internal/de24f857.js +0 -3
  94. package/_internal/e806b848.js +0 -8
  95. package/_internal/e913a3af.js +0 -117
  96. package/_internal/ea04260d.js +0 -28
  97. package/_internal/eaf6c45a.js +0 -3
  98. package/_internal/ebdcb0c7.js +0 -60
  99. package/_internal/ef5d1aac.js +0 -3
  100. package/_internal/f0d7d6ea.js +0 -29
  101. package/_internal/utils/ClickAwayProvider/index-1234ce76.js +0 -94
  102. package/_internal/utils/MaterialThemeSwitcher/index-8d22de5a.js +0 -48
  103. package/_internal/utils/Portal/index-6e0a7404.js +0 -44
  104. package/_internal/utils/disabled/index-075b99c3.js +0 -36
  105. package/_internal/utils/type/index-ea9fc197.js +0 -2
@@ -1,165 +0,0 @@
1
- import { Children } from 'react';
2
- import classNames from 'classnames';
3
- import { getRootClassName, handleBasicClasses } from '@lumx/core/js/utils/className';
4
- import { u as useTheme } from '../../3181f000.js';
5
- import { f as forwardRef } from '../../8bce732e.js';
6
- import { jsx, jsxs } from 'react/jsx-runtime';
7
- import { i as isComponent } from '../../78df9309.js';
8
- import isEmpty from 'lodash/isEmpty';
9
- import { u as useId } from '../../3a1facc0.js';
10
- import { R as RawClickable } from '../../2c2b6a89.js';
11
- import { Theme, Emphasis, Size } from '@lumx/core/js/constants';
12
- import { I as Icon } from '../../bace1bf1.js';
13
- import { I as IconButton } from '../../b83e864b.js';
14
- import { m as mdiChevronUp, a as mdiChevronDown } from '../../0b9c76cb.js';
15
-
16
- /**
17
- * Component display name.
18
- */
19
- const COMPONENT_NAME$1 = 'SideNavigation';
20
-
21
- /**
22
- * Component default class name and class prefix.
23
- */
24
- const CLASSNAME$1 = getRootClassName(COMPONENT_NAME$1);
25
-
26
- /**
27
- * SideNavigation component.
28
- *
29
- * @param props Component props.
30
- * @param ref Component ref.
31
- * @return React element.
32
- */
33
- const SideNavigation = forwardRef((props, ref) => {
34
- const defaultTheme = useTheme();
35
- const {
36
- children,
37
- className,
38
- theme = defaultTheme,
39
- ...forwardedProps
40
- } = props;
41
- const content = Children.toArray(children).filter(isComponent(SideNavigationItem));
42
- return /*#__PURE__*/jsx("ul", {
43
- ref: ref,
44
- ...forwardedProps,
45
- className: classNames(className, theme === Theme.dark && 'lumx-color-font-light-N', CLASSNAME$1),
46
- children: content
47
- });
48
- });
49
- SideNavigation.displayName = COMPONENT_NAME$1;
50
- SideNavigation.className = CLASSNAME$1;
51
-
52
- /**
53
- * Component display name.
54
- */
55
- const COMPONENT_NAME = 'SideNavigationItem';
56
-
57
- /**
58
- * Component default class name and class prefix.
59
- */
60
- const CLASSNAME = getRootClassName(COMPONENT_NAME);
61
-
62
- /**
63
- * Component default props.
64
- */
65
- const DEFAULT_PROPS = {
66
- emphasis: Emphasis.high,
67
- closeMode: 'unmount'
68
- };
69
-
70
- /**
71
- * SideNavigationItem component.
72
- *
73
- * @param props Component props.
74
- * @param ref Component ref.
75
- * @return React element.
76
- */
77
- const SideNavigationItem = forwardRef((props, ref) => {
78
- const {
79
- children,
80
- className,
81
- emphasis = DEFAULT_PROPS.emphasis,
82
- icon,
83
- isOpen,
84
- isSelected,
85
- label,
86
- linkAs,
87
- linkProps,
88
- onActionClick,
89
- onClick,
90
- toggleButtonProps,
91
- closeMode = DEFAULT_PROPS.closeMode,
92
- ...forwardedProps
93
- } = props;
94
- const content = children && Children.toArray(children).filter(isComponent(SideNavigationItem));
95
- const hasContent = !isEmpty(content);
96
- const shouldSplitActions = Boolean(onActionClick);
97
- const showChildren = hasContent && isOpen;
98
- const contentId = useId();
99
- const ariaProps = {};
100
- if (hasContent) {
101
- ariaProps['aria-expanded'] = !!showChildren;
102
- // Associate with content ID only if in DOM (shown or hidden and not unmounted)
103
- ariaProps['aria-controls'] = showChildren || closeMode === 'hide' ? contentId : undefined;
104
- }
105
- return /*#__PURE__*/jsxs("li", {
106
- ref: ref,
107
- ...forwardedProps,
108
- className: classNames(className, handleBasicClasses({
109
- emphasis,
110
- isOpen: showChildren,
111
- isSelected,
112
- prefix: CLASSNAME
113
- })),
114
- children: [shouldSplitActions ? /*#__PURE__*/jsxs("div", {
115
- className: `${CLASSNAME}__wrapper`,
116
- children: [/*#__PURE__*/jsxs(RawClickable, {
117
- as: linkAs || (linkProps?.href ? 'a' : 'button'),
118
- ...linkProps,
119
- className: `${CLASSNAME}__link`,
120
- onClick: onClick,
121
- children: [icon && /*#__PURE__*/jsx(Icon, {
122
- className: `${CLASSNAME}__icon`,
123
- icon: icon,
124
- size: Size.xs
125
- }), /*#__PURE__*/jsx("span", {
126
- children: label
127
- })]
128
- }), /*#__PURE__*/jsx(IconButton, {
129
- ...toggleButtonProps,
130
- className: `${CLASSNAME}__toggle`,
131
- icon: isOpen ? mdiChevronUp : mdiChevronDown,
132
- size: Size.m,
133
- emphasis: Emphasis.low,
134
- onClick: onActionClick,
135
- ...ariaProps
136
- })]
137
- }) : /*#__PURE__*/jsxs(RawClickable, {
138
- as: linkAs || (linkProps?.href ? 'a' : 'button'),
139
- ...linkProps,
140
- className: `${CLASSNAME}__link`,
141
- onClick: onClick,
142
- ...ariaProps,
143
- children: [icon && /*#__PURE__*/jsx(Icon, {
144
- className: `${CLASSNAME}__icon`,
145
- icon: icon,
146
- size: Size.xs
147
- }), /*#__PURE__*/jsx("span", {
148
- children: label
149
- }), hasContent && /*#__PURE__*/jsx(Icon, {
150
- className: `${CLASSNAME}__chevron`,
151
- icon: isOpen ? mdiChevronUp : mdiChevronDown,
152
- size: Size.xs
153
- })]
154
- }), (closeMode === 'hide' || showChildren) && /*#__PURE__*/jsx("ul", {
155
- className: `${CLASSNAME}__children`,
156
- id: contentId,
157
- children: content
158
- })]
159
- });
160
- });
161
- SideNavigationItem.displayName = COMPONENT_NAME;
162
- SideNavigationItem.className = CLASSNAME;
163
- SideNavigationItem.defaultProps = DEFAULT_PROPS;
164
-
165
- export { SideNavigation, SideNavigationItem };
@@ -1,166 +0,0 @@
1
- import classNames from 'classnames';
2
- import { getRootClassName, handleBasicClasses } from '@lumx/core/js/utils/className';
3
- import { u as useTheme } from '../../3181f000.js';
4
- import { f as forwardRef } from '../../8bce732e.js';
5
- import { jsx } from 'react/jsx-runtime';
6
- import { Theme } from '@lumx/core/js/constants';
7
-
8
- const DEFAULT_PROPS$2 = {};
9
-
10
- /**
11
- * Component display name.
12
- */
13
- const COMPONENT_NAME$2 = 'SkeletonCircle';
14
-
15
- /**
16
- * Component default class name and class prefix.
17
- */
18
- const CLASSNAME$2 = getRootClassName(COMPONENT_NAME$2);
19
-
20
- /**
21
- * SkeletonCircle component.
22
- *
23
- * @param props Component props.
24
- * @param ref Component ref.
25
- * @return React element.
26
- */
27
- const SkeletonCircle = forwardRef((props, ref) => {
28
- const defaultTheme = useTheme() || Theme.light;
29
- const {
30
- className,
31
- size,
32
- color,
33
- theme = defaultTheme,
34
- ...forwardedProps
35
- } = props;
36
- return /*#__PURE__*/jsx("div", {
37
- ref: ref,
38
- ...forwardedProps,
39
- className: classNames(className, handleBasicClasses({
40
- prefix: CLASSNAME$2,
41
- size,
42
- color,
43
- theme
44
- }))
45
- });
46
- });
47
- SkeletonCircle.displayName = COMPONENT_NAME$2;
48
- SkeletonCircle.defaultProps = DEFAULT_PROPS$2;
49
- SkeletonCircle.className = CLASSNAME$2;
50
-
51
- const SkeletonRectangleVariant = {
52
- squared: 'squared',
53
- rounded: 'rounded',
54
- pill: 'pill'
55
- };
56
-
57
- /**
58
- * Defines the props of the component.
59
- */
60
-
61
- const DEFAULT_PROPS$1 = {
62
- variant: SkeletonRectangleVariant.squared
63
- };
64
-
65
- /**
66
- * Component display name.
67
- */
68
- const COMPONENT_NAME$1 = 'SkeletonRectangle';
69
-
70
- /**
71
- * Component default class name and class prefix.
72
- */
73
- const CLASSNAME$1 = getRootClassName(COMPONENT_NAME$1);
74
-
75
- /**
76
- * SkeletonRectangle component.
77
- *
78
- * @param props Component props.
79
- * @param ref Component ref.
80
- * @return React element.
81
- */
82
- const SkeletonRectangle = forwardRef((props, ref) => {
83
- const defaultTheme = useTheme() || Theme.light;
84
- const {
85
- aspectRatio,
86
- className,
87
- height,
88
- theme = defaultTheme,
89
- variant = DEFAULT_PROPS$1.variant,
90
- width,
91
- color,
92
- ...forwardedProps
93
- } = props;
94
- return /*#__PURE__*/jsx("div", {
95
- ref: ref,
96
- ...forwardedProps,
97
- className: classNames(className, handleBasicClasses({
98
- prefix: CLASSNAME$1,
99
- aspectRatio,
100
- height: aspectRatio ? undefined : height,
101
- theme,
102
- variant,
103
- width,
104
- color
105
- })),
106
- children: /*#__PURE__*/jsx("div", {
107
- className: `${CLASSNAME$1}__inner`
108
- })
109
- });
110
- });
111
- SkeletonRectangle.displayName = COMPONENT_NAME$1;
112
- SkeletonRectangle.className = CLASSNAME$1;
113
- SkeletonRectangle.defaultProps = DEFAULT_PROPS$1;
114
-
115
- const DEFAULT_PROPS = {};
116
-
117
- /**
118
- * Component display name.
119
- */
120
- const COMPONENT_NAME = 'SkeletonTypography';
121
-
122
- /**
123
- * Component default class name and class prefix.
124
- */
125
- const CLASSNAME = getRootClassName(COMPONENT_NAME);
126
-
127
- /**
128
- * SkeletonTypography component.
129
- *
130
- * @param props Component props.
131
- * @param ref Component ref.
132
- * @return React element.
133
- */
134
- const SkeletonTypography = forwardRef((props, ref) => {
135
- const defaultTheme = useTheme() || Theme.light;
136
- const {
137
- className,
138
- theme = defaultTheme,
139
- typography,
140
- width,
141
- color,
142
- ...forwardedProps
143
- } = props;
144
- return /*#__PURE__*/jsx("div", {
145
- ref: ref,
146
- ...forwardedProps,
147
- className: classNames(className, handleBasicClasses({
148
- prefix: CLASSNAME,
149
- theme,
150
- typography,
151
- color
152
- })),
153
- style: {
154
- ...forwardedProps.style,
155
- width
156
- },
157
- children: /*#__PURE__*/jsx("div", {
158
- className: `${CLASSNAME}__inner`
159
- })
160
- });
161
- });
162
- SkeletonTypography.displayName = COMPONENT_NAME;
163
- SkeletonTypography.defaultProps = DEFAULT_PROPS;
164
- SkeletonTypography.className = CLASSNAME;
165
-
166
- export { SkeletonCircle, SkeletonRectangle, SkeletonRectangleVariant, SkeletonTypography };
@@ -1,311 +0,0 @@
1
- import React__default, { useMemo, useRef } from 'react';
2
- import classNames from 'classnames';
3
- import { getRootClassName, handleBasicClasses } from '@lumx/core/js/utils/className';
4
- import { u as useId } from '../../3a1facc0.js';
5
- import { u as useTheme } from '../../3181f000.js';
6
- import { f as forwardRef } from '../../8bce732e.js';
7
- import { useDisableStateProps } from '../../utils/disabled/index-075b99c3.js';
8
- import { jsxs, jsx } from 'react/jsx-runtime';
9
- import { Theme } from '@lumx/core/js/constants';
10
- import { InputLabel } from '../input-label/index-0113f382.js';
11
- import { InputHelper } from '../input-helper/index-5a837e7c.js';
12
-
13
- const useEnhancedEffect = typeof window !== 'undefined' ? React__default.useLayoutEffect : React__default.useEffect;
14
-
15
- /**
16
- * https://github.com/facebook/react/issues/14099#issuecomment-440013892
17
- *
18
- * @param fn A function to run
19
- * @return A React callback
20
- */
21
- function useEventCallback(fn) {
22
- const ref = React__default.useRef(fn);
23
- useEnhancedEffect(() => {
24
- ref.current = fn;
25
- });
26
- return React__default.useCallback(event => ref.current(event), []);
27
- }
28
-
29
- /**
30
- * Clamp value in range.
31
- *
32
- * @param value Value to clamp.
33
- * @param min Minimum value.
34
- * @param max Maximum value.
35
- * @return Clamped value.
36
- */
37
- const clamp = (value, min, max) => {
38
- if (value < min) {
39
- return min;
40
- }
41
- if (value > max) {
42
- return max;
43
- }
44
- return value;
45
- };
46
-
47
- /* eslint-disable jsx-a11y/no-static-element-interactions */
48
- /**
49
- * Component display name.
50
- */
51
- const COMPONENT_NAME = 'Slider';
52
-
53
- /**
54
- * Component default class name and class prefix.
55
- */
56
- const CLASSNAME = getRootClassName(COMPONENT_NAME);
57
-
58
- /**
59
- * Component default props.
60
- */
61
- const DEFAULT_PROPS = {
62
- precision: 0,
63
- steps: 0
64
- };
65
-
66
- /**
67
- * Convert a percent value to a value in range min - max.
68
- *
69
- * @param percent Value to convert.
70
- * @param min Minimum value.
71
- * @param max Maximum value.
72
- * @param precision Precision.
73
- * @return Value in range min - max
74
- */
75
- const computeValueFromPercent = (percent, min, max, precision = 0) => Number((min + percent * (max - min)).toFixed(precision));
76
-
77
- /**
78
- * Convert a value in range min - max to a percent value.
79
- *
80
- * @param value Value to convert.
81
- * @param min Minimum value.
82
- * @param max Maximum value.
83
- * @return Value in percent
84
- */
85
- const computePercentFromValue = (value, min, max) => Number((value - min) / (max - min));
86
-
87
- /**
88
- * Slider component.
89
- *
90
- * @param props Component props.
91
- * @param ref Component ref.
92
- * @return React element.
93
- */
94
- const Slider = forwardRef((props, ref) => {
95
- const {
96
- isAnyDisabled,
97
- disabledStateProps,
98
- otherProps
99
- } = useDisableStateProps(props);
100
- const defaultTheme = useTheme() || Theme.light;
101
- const {
102
- className,
103
- helper,
104
- hideMinMaxLabel,
105
- id,
106
- label,
107
- max,
108
- min,
109
- name,
110
- onChange,
111
- onMouseDown,
112
- precision = DEFAULT_PROPS.precision,
113
- steps = DEFAULT_PROPS.steps,
114
- theme = defaultTheme,
115
- value,
116
- ...forwardedProps
117
- } = otherProps;
118
- const generatedId = useId();
119
- const sliderId = id || generatedId;
120
- const sliderLabelId = useMemo(() => `label-${sliderId}`, [sliderId]);
121
- const sliderRef = useRef(null);
122
-
123
- // build a lookup array for the steps.
124
- const availableSteps = useMemo(() => {
125
- if (!steps) return [];
126
- const available = [0];
127
- const percentStep = 1 / ((max - min) / steps);
128
- let ptr = 0;
129
- while (ptr + percentStep < 1) {
130
- ptr += percentStep;
131
- available.push(ptr);
132
- }
133
- return available;
134
- }, [steps, min, max]);
135
-
136
- /**
137
- * Try to find the closest step to the current slider position.
138
- *
139
- * @param percentValue Reference value
140
- * @return The closest step value
141
- */
142
- const findClosestStep = percentValue => {
143
- const closest = availableSteps.reduce((acc, step) => {
144
- const aDst = Math.abs(percentValue - step);
145
- if (aDst < acc.dst) {
146
- return {
147
- dst: aDst,
148
- val: step
149
- };
150
- }
151
- return acc;
152
- }, {
153
- dst: Infinity,
154
- val: -1
155
- });
156
- return closest.val;
157
- };
158
-
159
- /**
160
- * Convert slider's handle position to percent.
161
- *
162
- * @param event The interaction event
163
- * @param slider the slider element
164
- * @return The computed percent value
165
- */
166
- const getPercentValue = (event, slider) => {
167
- const {
168
- width,
169
- left
170
- } = slider.getBoundingClientRect();
171
- let percent = (event.pageX - left - window.pageXOffset) / width;
172
- percent = clamp(percent, 0, 1);
173
- if (steps) {
174
- percent = findClosestStep(percent);
175
- }
176
- return percent;
177
- };
178
-
179
- /**
180
- * Register a handler for the mouse move event.
181
- */
182
- const handleMove = useEventCallback(event => {
183
- const {
184
- current: slider
185
- } = sliderRef;
186
- if (!slider || !onChange) return;
187
- const newValue = getPercentValue(event, slider);
188
- onChange(computeValueFromPercent(newValue, min, max, precision), name, event);
189
- });
190
-
191
- /**
192
- * Register a handler for the mouse up event.
193
- * Clean a all listeners.
194
- */
195
- const handleEnd = useEventCallback(() => {
196
- document.body.removeEventListener('mousemove', handleMove);
197
- document.body.removeEventListener('mouseup', handleEnd);
198
- document.body.removeEventListener('touchmove', handleMove);
199
- document.body.removeEventListener('touchend', handleEnd);
200
- });
201
-
202
- /**
203
- * Move to the next or previous value (i.e. + or - 10%) or next step
204
- * @param previous Should seek the previous value.
205
- */
206
- const hopToValue = (previous = false) => {
207
- const oldPercent = computePercentFromValue(value, min, max);
208
- let percent = clamp(oldPercent + (previous ? -0.1 : 0.1), 0, 1);
209
- if (steps) {
210
- percent = oldPercent + availableSteps[1] * (previous ? -1 : 1);
211
- percent = findClosestStep(percent);
212
- }
213
- if (onChange) {
214
- onChange(computeValueFromPercent(percent, min, max, precision), name);
215
- }
216
- };
217
-
218
- /**
219
- * Register a handler for keyboard interactions
220
- */
221
- const handleKeyDown = useEventCallback(event => {
222
- if (event.key === 'ArrowRight') {
223
- hopToValue();
224
- } else if (event.key === 'ArrowLeft') {
225
- hopToValue(true);
226
- }
227
- });
228
-
229
- /**
230
- * Register a handler for the mouseDown event.
231
- */
232
- const handleMouseDown = useEventCallback(event => {
233
- onMouseDown?.(event);
234
- const {
235
- current: slider
236
- } = sliderRef;
237
- if (isAnyDisabled || !slider) return;
238
- const newValue = getPercentValue(event, slider);
239
- if (onChange) {
240
- onChange(computeValueFromPercent(newValue, min, max, precision), name, event);
241
- }
242
- document.body.addEventListener('mousemove', handleMove);
243
- document.body.addEventListener('mouseup', handleEnd);
244
- });
245
- const percentString = `${computePercentFromValue(value, min, max) * 100}%`;
246
- return /*#__PURE__*/jsxs("div", {
247
- ref: ref,
248
- ...forwardedProps,
249
- className: classNames(className, handleBasicClasses({
250
- prefix: CLASSNAME,
251
- theme,
252
- hasLabel: Boolean(label)
253
- })),
254
- onMouseDown: handleMouseDown,
255
- children: [label && /*#__PURE__*/jsx(InputLabel, {
256
- id: sliderLabelId,
257
- htmlFor: sliderId,
258
- className: `${CLASSNAME}__label`,
259
- theme: theme,
260
- children: label
261
- }), helper && /*#__PURE__*/jsx(InputHelper, {
262
- className: `${CLASSNAME}__helper`,
263
- theme: theme,
264
- children: helper
265
- }), /*#__PURE__*/jsxs("div", {
266
- className: `${CLASSNAME}__ui-wrapper`,
267
- children: [!hideMinMaxLabel && /*#__PURE__*/jsx("span", {
268
- className: `${CLASSNAME}__value-label ${CLASSNAME}__value-label--min`,
269
- children: min
270
- }), /*#__PURE__*/jsxs("div", {
271
- className: `${CLASSNAME}__wrapper`,
272
- ref: sliderRef,
273
- children: [/*#__PURE__*/jsx("div", {
274
- className: `${CLASSNAME}__track ${CLASSNAME}__track--background`
275
- }), /*#__PURE__*/jsx("div", {
276
- className: `${CLASSNAME}__track ${CLASSNAME}__track--active`,
277
- style: {
278
- width: percentString
279
- }
280
- }), steps ? /*#__PURE__*/jsx("div", {
281
- className: `${CLASSNAME}__ticks`,
282
- children: availableSteps.map((step, idx) => /*#__PURE__*/jsx("div", {
283
- className: `${CLASSNAME}__tick`,
284
- style: {
285
- left: `${step * 100}%`
286
- }
287
- }, `tick_${idx}`))
288
- }) : null, /*#__PURE__*/jsx("button", {
289
- type: "button",
290
- "aria-labelledby": sliderLabelId,
291
- name: name,
292
- id: sliderId,
293
- className: `${CLASSNAME}__handle`,
294
- style: {
295
- left: percentString
296
- },
297
- onKeyDown: isAnyDisabled ? undefined : handleKeyDown,
298
- ...disabledStateProps
299
- })]
300
- }), !hideMinMaxLabel && /*#__PURE__*/jsx("span", {
301
- className: `${CLASSNAME}__value-label ${CLASSNAME}__value-label--max`,
302
- children: max
303
- })]
304
- })]
305
- });
306
- });
307
- Slider.displayName = COMPONENT_NAME;
308
- Slider.className = CLASSNAME;
309
- Slider.defaultProps = DEFAULT_PROPS;
310
-
311
- export { Slider, clamp };