@veeqo/ui 13.11.2 → 13.12.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/components/Slider/Slider.cjs +71 -109
- package/dist/components/Slider/Slider.cjs.map +1 -1
- package/dist/components/Slider/Slider.d.ts +6 -2
- package/dist/components/Slider/Slider.js +72 -110
- package/dist/components/Slider/Slider.js.map +1 -1
- package/dist/components/Slider/Slider.module.scss.cjs +9 -0
- package/dist/components/Slider/Slider.module.scss.cjs.map +1 -0
- package/dist/components/Slider/Slider.module.scss.js +7 -0
- package/dist/components/Slider/Slider.module.scss.js.map +1 -0
- package/dist/components/Slider/components/SliderHandle/SliderHandle.cjs +24 -0
- package/dist/components/Slider/components/SliderHandle/SliderHandle.cjs.map +1 -0
- package/dist/components/Slider/components/SliderHandle/SliderHandle.d.ts +7 -0
- package/dist/components/Slider/components/SliderHandle/SliderHandle.js +18 -0
- package/dist/components/Slider/components/SliderHandle/SliderHandle.js.map +1 -0
- package/dist/components/Slider/components/SliderHandle/SliderHandle.module.scss.cjs +9 -0
- package/dist/components/Slider/components/SliderHandle/SliderHandle.module.scss.cjs.map +1 -0
- package/dist/components/Slider/components/SliderHandle/SliderHandle.module.scss.js +7 -0
- package/dist/components/Slider/components/SliderHandle/SliderHandle.module.scss.js.map +1 -0
- package/dist/components/Slider/components/SliderHandle/index.d.ts +1 -0
- package/dist/components/Slider/components/SliderHandle/types.d.ts +19 -0
- package/dist/components/Slider/components/SliderTrack/SliderTrack.cjs +18 -0
- package/dist/components/Slider/components/SliderTrack/SliderTrack.cjs.map +1 -0
- package/dist/components/Slider/components/SliderTrack/SliderTrack.d.ts +7 -0
- package/dist/components/Slider/components/SliderTrack/SliderTrack.js +12 -0
- package/dist/components/Slider/components/SliderTrack/SliderTrack.js.map +1 -0
- package/dist/components/Slider/components/SliderTrack/SliderTrack.module.scss.cjs +9 -0
- package/dist/components/Slider/components/SliderTrack/SliderTrack.module.scss.cjs.map +1 -0
- package/dist/components/Slider/components/SliderTrack/SliderTrack.module.scss.js +7 -0
- package/dist/components/Slider/components/SliderTrack/SliderTrack.module.scss.js.map +1 -0
- package/dist/components/Slider/components/SliderTrack/index.d.ts +1 -0
- package/dist/components/Slider/components/SliderTrack/types.d.ts +6 -0
- package/dist/components/Slider/hooks/index.d.ts +2 -0
- package/dist/components/Slider/hooks/types.d.ts +24 -0
- package/dist/components/Slider/hooks/useSliderDrag.cjs +85 -0
- package/dist/components/Slider/hooks/useSliderDrag.cjs.map +1 -0
- package/dist/components/Slider/hooks/useSliderDrag.d.ts +11 -0
- package/dist/components/Slider/hooks/useSliderDrag.js +83 -0
- package/dist/components/Slider/hooks/useSliderDrag.js.map +1 -0
- package/dist/components/Slider/hooks/useSliderKeyboard.cjs +85 -0
- package/dist/components/Slider/hooks/useSliderKeyboard.cjs.map +1 -0
- package/dist/components/Slider/hooks/useSliderKeyboard.d.ts +9 -0
- package/dist/components/Slider/hooks/useSliderKeyboard.js +83 -0
- package/dist/components/Slider/hooks/useSliderKeyboard.js.map +1 -0
- package/dist/components/Slider/types.d.ts +7 -8
- package/dist/components/Slider/utils/calculateSliderValue.cjs +32 -0
- package/dist/components/Slider/utils/calculateSliderValue.cjs.map +1 -0
- package/dist/components/Slider/utils/calculateSliderValue.d.ts +5 -0
- package/dist/components/Slider/utils/calculateSliderValue.js +30 -0
- package/dist/components/Slider/utils/calculateSliderValue.js.map +1 -0
- package/dist/components/Slider/utils/index.d.ts +1 -0
- package/dist/components/Slider/utils/types.d.ts +7 -0
- package/package.json +1 -1
- package/dist/components/Slider/styled.cjs +0 -23
- package/dist/components/Slider/styled.cjs.map +0 -1
- package/dist/components/Slider/styled.d.ts +0 -8
- package/dist/components/Slider/styled.js +0 -14
- package/dist/components/Slider/styled.js.map +0 -1
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var React = require('react');
|
|
4
|
+
var buildClassnames = require('../../../../utils/buildClassnames.cjs');
|
|
5
|
+
var SliderHandle_module = require('./SliderHandle.module.scss.cjs');
|
|
6
|
+
|
|
7
|
+
function _interopDefaultCompat (e) { return e && typeof e === 'object' && 'default' in e ? e : { default: e }; }
|
|
8
|
+
|
|
9
|
+
var React__default = /*#__PURE__*/_interopDefaultCompat(React);
|
|
10
|
+
|
|
11
|
+
/**
|
|
12
|
+
* Slider handle component that renders the draggable handle and optional value label.
|
|
13
|
+
* Positioned dynamically based on the slider value.
|
|
14
|
+
*/
|
|
15
|
+
const SliderHandle = React__default.default.forwardRef(({ horizontalPosition, value, min, max, disabled, isActive, showLabel, className, ariaLabel, ariaLabelledBy, onMouseDown, onMouseEnter, onMouseLeave, onFocus, onBlur, onKeyDown, }, ref) => {
|
|
16
|
+
const positionStyle = { left: `${horizontalPosition}%` };
|
|
17
|
+
return (React__default.default.createElement(React__default.default.Fragment, null,
|
|
18
|
+
showLabel && (React__default.default.createElement("div", { className: SliderHandle_module.valueLabel, style: positionStyle, "data-testid": "slider-value-label" }, value)),
|
|
19
|
+
React__default.default.createElement("div", { ref: ref, role: "slider", "aria-orientation": "horizontal", "aria-label": ariaLabel, "aria-labelledby": ariaLabelledBy, className: buildClassnames.buildClassnames([SliderHandle_module.slider, className]), style: positionStyle, "data-disabled": disabled, "data-active": isActive, "data-testid": "slider-handle", tabIndex: disabled ? -1 : 0, "aria-valuemin": min, "aria-valuemax": max, "aria-valuenow": value, "aria-disabled": disabled, onMouseDown: onMouseDown, onMouseEnter: onMouseEnter, onMouseLeave: onMouseLeave, onFocus: onFocus, onBlur: onBlur, onKeyDown: onKeyDown })));
|
|
20
|
+
});
|
|
21
|
+
SliderHandle.displayName = 'SliderHandle';
|
|
22
|
+
|
|
23
|
+
exports.SliderHandle = SliderHandle;
|
|
24
|
+
//# sourceMappingURL=SliderHandle.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"SliderHandle.cjs","sources":["../../../../../src/components/Slider/components/SliderHandle/SliderHandle.tsx"],"sourcesContent":["import React from 'react';\nimport { buildClassnames } from '../../../../utils/buildClassnames';\nimport styles from './SliderHandle.module.scss';\nimport { SliderHandleProps } from './types';\n\n/**\n * Slider handle component that renders the draggable handle and optional value label.\n * Positioned dynamically based on the slider value.\n */\nexport const SliderHandle = React.forwardRef<HTMLDivElement, SliderHandleProps>(\n (\n {\n horizontalPosition,\n value,\n min,\n max,\n disabled,\n isActive,\n showLabel,\n className,\n ariaLabel,\n ariaLabelledBy,\n onMouseDown,\n onMouseEnter,\n onMouseLeave,\n onFocus,\n onBlur,\n onKeyDown,\n },\n ref,\n ) => {\n const positionStyle = { left: `${horizontalPosition}%` };\n\n return (\n <>\n {showLabel && (\n <div className={styles.valueLabel} style={positionStyle} data-testid=\"slider-value-label\">\n {value}\n </div>\n )}\n <div\n ref={ref}\n role=\"slider\"\n aria-orientation=\"horizontal\"\n aria-label={ariaLabel}\n aria-labelledby={ariaLabelledBy}\n className={buildClassnames([styles.slider, className])}\n style={positionStyle}\n data-disabled={disabled}\n data-active={isActive}\n data-testid=\"slider-handle\"\n tabIndex={disabled ? -1 : 0}\n aria-valuemin={min}\n aria-valuemax={max}\n aria-valuenow={value}\n aria-disabled={disabled}\n onMouseDown={onMouseDown}\n onMouseEnter={onMouseEnter}\n onMouseLeave={onMouseLeave}\n onFocus={onFocus}\n onBlur={onBlur}\n onKeyDown={onKeyDown}\n />\n </>\n );\n },\n);\n\nSliderHandle.displayName = 'SliderHandle';\n"],"names":["React","styles","buildClassnames"],"mappings":";;;;;;;;;;AAKA;;;AAGG;MACU,YAAY,GAAGA,sBAAK,CAAC,UAAU,CAC1C,CACE,EACE,kBAAkB,EAClB,KAAK,EACL,GAAG,EACH,GAAG,EACH,QAAQ,EACR,QAAQ,EACR,SAAS,EACT,SAAS,EACT,SAAS,EACT,cAAc,EACd,WAAW,EACX,YAAY,EACZ,YAAY,EACZ,OAAO,EACP,MAAM,EACN,SAAS,GACV,EACD,GAAG,KACD;IACF,MAAM,aAAa,GAAG,EAAE,IAAI,EAAE,CAAG,EAAA,kBAAkB,CAAG,CAAA,CAAA,EAAE;AAExD,IAAA,QACEA,sBAAA,CAAA,aAAA,CAAAA,sBAAA,CAAA,QAAA,EAAA,IAAA;AACG,QAAA,SAAS,KACRA,sBAAA,CAAA,aAAA,CAAA,KAAA,EAAA,EAAK,SAAS,EAAEC,mBAAM,CAAC,UAAU,EAAE,KAAK,EAAE,aAAa,EAAA,aAAA,EAAc,oBAAoB,EACtF,EAAA,KAAK,CACF,CACP;AACD,QAAAD,sBAAA,CAAA,aAAA,CAAA,KAAA,EAAA,EACE,GAAG,EAAE,GAAG,EACR,IAAI,EAAC,QAAQ,EACI,kBAAA,EAAA,YAAY,EACjB,YAAA,EAAA,SAAS,qBACJ,cAAc,EAC/B,SAAS,EAAEE,+BAAe,CAAC,CAACD,mBAAM,CAAC,MAAM,EAAE,SAAS,CAAC,CAAC,EACtD,KAAK,EAAE,aAAa,EAAA,eAAA,EACL,QAAQ,EAAA,aAAA,EACV,QAAQ,EACT,aAAA,EAAA,eAAe,EAC3B,QAAQ,EAAE,QAAQ,GAAG,EAAE,GAAG,CAAC,EAAA,eAAA,EACZ,GAAG,EACH,eAAA,EAAA,GAAG,EACH,eAAA,EAAA,KAAK,mBACL,QAAQ,EACvB,WAAW,EAAE,WAAW,EACxB,YAAY,EAAE,YAAY,EAC1B,YAAY,EAAE,YAAY,EAC1B,OAAO,EAAE,OAAO,EAChB,MAAM,EAAE,MAAM,EACd,SAAS,EAAE,SAAS,EACpB,CAAA,CACD;AAEP,CAAC;AAGH,YAAY,CAAC,WAAW,GAAG,cAAc;;;;"}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { SliderHandleProps } from './types';
|
|
3
|
+
/**
|
|
4
|
+
* Slider handle component that renders the draggable handle and optional value label.
|
|
5
|
+
* Positioned dynamically based on the slider value.
|
|
6
|
+
*/
|
|
7
|
+
export declare const SliderHandle: React.ForwardRefExoticComponent<SliderHandleProps & React.RefAttributes<HTMLDivElement>>;
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import React__default from 'react';
|
|
2
|
+
import { buildClassnames } from '../../../../utils/buildClassnames.js';
|
|
3
|
+
import styles from './SliderHandle.module.scss.js';
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* Slider handle component that renders the draggable handle and optional value label.
|
|
7
|
+
* Positioned dynamically based on the slider value.
|
|
8
|
+
*/
|
|
9
|
+
const SliderHandle = React__default.forwardRef(({ horizontalPosition, value, min, max, disabled, isActive, showLabel, className, ariaLabel, ariaLabelledBy, onMouseDown, onMouseEnter, onMouseLeave, onFocus, onBlur, onKeyDown, }, ref) => {
|
|
10
|
+
const positionStyle = { left: `${horizontalPosition}%` };
|
|
11
|
+
return (React__default.createElement(React__default.Fragment, null,
|
|
12
|
+
showLabel && (React__default.createElement("div", { className: styles.valueLabel, style: positionStyle, "data-testid": "slider-value-label" }, value)),
|
|
13
|
+
React__default.createElement("div", { ref: ref, role: "slider", "aria-orientation": "horizontal", "aria-label": ariaLabel, "aria-labelledby": ariaLabelledBy, className: buildClassnames([styles.slider, className]), style: positionStyle, "data-disabled": disabled, "data-active": isActive, "data-testid": "slider-handle", tabIndex: disabled ? -1 : 0, "aria-valuemin": min, "aria-valuemax": max, "aria-valuenow": value, "aria-disabled": disabled, onMouseDown: onMouseDown, onMouseEnter: onMouseEnter, onMouseLeave: onMouseLeave, onFocus: onFocus, onBlur: onBlur, onKeyDown: onKeyDown })));
|
|
14
|
+
});
|
|
15
|
+
SliderHandle.displayName = 'SliderHandle';
|
|
16
|
+
|
|
17
|
+
export { SliderHandle };
|
|
18
|
+
//# sourceMappingURL=SliderHandle.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"SliderHandle.js","sources":["../../../../../src/components/Slider/components/SliderHandle/SliderHandle.tsx"],"sourcesContent":["import React from 'react';\nimport { buildClassnames } from '../../../../utils/buildClassnames';\nimport styles from './SliderHandle.module.scss';\nimport { SliderHandleProps } from './types';\n\n/**\n * Slider handle component that renders the draggable handle and optional value label.\n * Positioned dynamically based on the slider value.\n */\nexport const SliderHandle = React.forwardRef<HTMLDivElement, SliderHandleProps>(\n (\n {\n horizontalPosition,\n value,\n min,\n max,\n disabled,\n isActive,\n showLabel,\n className,\n ariaLabel,\n ariaLabelledBy,\n onMouseDown,\n onMouseEnter,\n onMouseLeave,\n onFocus,\n onBlur,\n onKeyDown,\n },\n ref,\n ) => {\n const positionStyle = { left: `${horizontalPosition}%` };\n\n return (\n <>\n {showLabel && (\n <div className={styles.valueLabel} style={positionStyle} data-testid=\"slider-value-label\">\n {value}\n </div>\n )}\n <div\n ref={ref}\n role=\"slider\"\n aria-orientation=\"horizontal\"\n aria-label={ariaLabel}\n aria-labelledby={ariaLabelledBy}\n className={buildClassnames([styles.slider, className])}\n style={positionStyle}\n data-disabled={disabled}\n data-active={isActive}\n data-testid=\"slider-handle\"\n tabIndex={disabled ? -1 : 0}\n aria-valuemin={min}\n aria-valuemax={max}\n aria-valuenow={value}\n aria-disabled={disabled}\n onMouseDown={onMouseDown}\n onMouseEnter={onMouseEnter}\n onMouseLeave={onMouseLeave}\n onFocus={onFocus}\n onBlur={onBlur}\n onKeyDown={onKeyDown}\n />\n </>\n );\n },\n);\n\nSliderHandle.displayName = 'SliderHandle';\n"],"names":["React"],"mappings":";;;;AAKA;;;AAGG;MACU,YAAY,GAAGA,cAAK,CAAC,UAAU,CAC1C,CACE,EACE,kBAAkB,EAClB,KAAK,EACL,GAAG,EACH,GAAG,EACH,QAAQ,EACR,QAAQ,EACR,SAAS,EACT,SAAS,EACT,SAAS,EACT,cAAc,EACd,WAAW,EACX,YAAY,EACZ,YAAY,EACZ,OAAO,EACP,MAAM,EACN,SAAS,GACV,EACD,GAAG,KACD;IACF,MAAM,aAAa,GAAG,EAAE,IAAI,EAAE,CAAG,EAAA,kBAAkB,CAAG,CAAA,CAAA,EAAE;AAExD,IAAA,QACEA,cAAA,CAAA,aAAA,CAAAA,cAAA,CAAA,QAAA,EAAA,IAAA;AACG,QAAA,SAAS,KACRA,cAAA,CAAA,aAAA,CAAA,KAAA,EAAA,EAAK,SAAS,EAAE,MAAM,CAAC,UAAU,EAAE,KAAK,EAAE,aAAa,EAAA,aAAA,EAAc,oBAAoB,EACtF,EAAA,KAAK,CACF,CACP;AACD,QAAAA,cAAA,CAAA,aAAA,CAAA,KAAA,EAAA,EACE,GAAG,EAAE,GAAG,EACR,IAAI,EAAC,QAAQ,EACI,kBAAA,EAAA,YAAY,EACjB,YAAA,EAAA,SAAS,qBACJ,cAAc,EAC/B,SAAS,EAAE,eAAe,CAAC,CAAC,MAAM,CAAC,MAAM,EAAE,SAAS,CAAC,CAAC,EACtD,KAAK,EAAE,aAAa,EAAA,eAAA,EACL,QAAQ,EAAA,aAAA,EACV,QAAQ,EACT,aAAA,EAAA,eAAe,EAC3B,QAAQ,EAAE,QAAQ,GAAG,EAAE,GAAG,CAAC,EAAA,eAAA,EACZ,GAAG,EACH,eAAA,EAAA,GAAG,EACH,eAAA,EAAA,KAAK,mBACL,QAAQ,EACvB,WAAW,EAAE,WAAW,EACxB,YAAY,EAAE,YAAY,EAC1B,YAAY,EAAE,YAAY,EAC1B,OAAO,EAAE,OAAO,EAChB,MAAM,EAAE,MAAM,EACd,SAAS,EAAE,SAAS,EACpB,CAAA,CACD;AAEP,CAAC;AAGH,YAAY,CAAC,WAAW,GAAG,cAAc;;;;"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var ___$insertStyle = require('../../../../_virtual/____insertStyle.cjs');
|
|
4
|
+
|
|
5
|
+
___$insertStyle("._slider_19zn5_1 {\n position: absolute;\n top: calc((var(--slider-size) - var(--track-height)) / 2);\n width: var(--slider-size);\n height: var(--slider-size);\n background: white;\n border: var(--border-size) solid var(--colors-secondary-blue-base);\n border-radius: var(--radius-full);\n cursor: pointer;\n pointer-events: auto;\n transform: translateX(-50%);\n}\n\n._slider_19zn5_1[data-active=true] {\n box-shadow: 0 0 0 var(--sizes-1) var(--colors-secondary-blue-light);\n}\n\n._slider_19zn5_1:focus-visible {\n outline: none;\n box-shadow: 0 0 0 var(--sizes-1) var(--colors-secondary-blue-light);\n}\n\n._slider_19zn5_1[data-disabled=true] {\n border-color: var(--colors-neutral-grey-base);\n cursor: not-allowed;\n pointer-events: none;\n}\n\n._valueLabel_19zn5_29 {\n position: absolute;\n top: calc(var(--sizes-7) * -1);\n transform: translateX(-50%);\n background: var(--colors-secondary-blue-base);\n color: white;\n padding: var(--sizes-1) var(--sizes-2);\n border-radius: var(--sizes-1);\n font-size: var(--sizes-3);\n white-space: nowrap;\n}");
|
|
6
|
+
var styles = {"slider":"_slider_19zn5_1","valueLabel":"_valueLabel_19zn5_29"};
|
|
7
|
+
|
|
8
|
+
module.exports = styles;
|
|
9
|
+
//# sourceMappingURL=SliderHandle.module.scss.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"SliderHandle.module.scss.cjs","sources":["../../../../../src/components/Slider/components/SliderHandle/SliderHandle.module.scss"],"sourcesContent":[".slider {\n position: absolute;\n top: calc((var(--slider-size) - var(--track-height)) / 2);\n width: var(--slider-size);\n height: var(--slider-size);\n background: white;\n border: var(--border-size) solid var(--colors-secondary-blue-base);\n border-radius: var(--radius-full);\n cursor: pointer;\n pointer-events: auto;\n transform: translateX(-50%);\n}\n\n.slider[data-active='true'] {\n box-shadow: 0 0 0 var(--sizes-1) var(--colors-secondary-blue-light);\n}\n\n.slider:focus-visible {\n outline: none;\n box-shadow: 0 0 0 var(--sizes-1) var(--colors-secondary-blue-light);\n}\n\n.slider[data-disabled='true'] {\n border-color: var(--colors-neutral-grey-base);\n cursor: not-allowed;\n pointer-events: none;\n}\n\n.valueLabel {\n position: absolute;\n top: calc(var(--sizes-7) * -1);\n transform: translateX(-50%);\n background: var(--colors-secondary-blue-base);\n color: white;\n padding: var(--sizes-1) var(--sizes-2);\n border-radius: var(--sizes-1);\n font-size: var(--sizes-3);\n white-space: nowrap;\n}\n"],"names":[],"mappings":";;;;AACE,eAAA,CAAA,2jCAAA;AACA,aAAA,CAAA,QAAA,CAAA,iBAAA,CAAA,YAAA,CAAA,sBAAA;;;;"}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import insertStyle from '../../../../_virtual/____insertStyle.js';
|
|
2
|
+
|
|
3
|
+
insertStyle("._slider_19zn5_1 {\n position: absolute;\n top: calc((var(--slider-size) - var(--track-height)) / 2);\n width: var(--slider-size);\n height: var(--slider-size);\n background: white;\n border: var(--border-size) solid var(--colors-secondary-blue-base);\n border-radius: var(--radius-full);\n cursor: pointer;\n pointer-events: auto;\n transform: translateX(-50%);\n}\n\n._slider_19zn5_1[data-active=true] {\n box-shadow: 0 0 0 var(--sizes-1) var(--colors-secondary-blue-light);\n}\n\n._slider_19zn5_1:focus-visible {\n outline: none;\n box-shadow: 0 0 0 var(--sizes-1) var(--colors-secondary-blue-light);\n}\n\n._slider_19zn5_1[data-disabled=true] {\n border-color: var(--colors-neutral-grey-base);\n cursor: not-allowed;\n pointer-events: none;\n}\n\n._valueLabel_19zn5_29 {\n position: absolute;\n top: calc(var(--sizes-7) * -1);\n transform: translateX(-50%);\n background: var(--colors-secondary-blue-base);\n color: white;\n padding: var(--sizes-1) var(--sizes-2);\n border-radius: var(--sizes-1);\n font-size: var(--sizes-3);\n white-space: nowrap;\n}");
|
|
4
|
+
var styles = {"slider":"_slider_19zn5_1","valueLabel":"_valueLabel_19zn5_29"};
|
|
5
|
+
|
|
6
|
+
export { styles as default };
|
|
7
|
+
//# sourceMappingURL=SliderHandle.module.scss.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"SliderHandle.module.scss.js","sources":["../../../../../src/components/Slider/components/SliderHandle/SliderHandle.module.scss"],"sourcesContent":[".slider {\n position: absolute;\n top: calc((var(--slider-size) - var(--track-height)) / 2);\n width: var(--slider-size);\n height: var(--slider-size);\n background: white;\n border: var(--border-size) solid var(--colors-secondary-blue-base);\n border-radius: var(--radius-full);\n cursor: pointer;\n pointer-events: auto;\n transform: translateX(-50%);\n}\n\n.slider[data-active='true'] {\n box-shadow: 0 0 0 var(--sizes-1) var(--colors-secondary-blue-light);\n}\n\n.slider:focus-visible {\n outline: none;\n box-shadow: 0 0 0 var(--sizes-1) var(--colors-secondary-blue-light);\n}\n\n.slider[data-disabled='true'] {\n border-color: var(--colors-neutral-grey-base);\n cursor: not-allowed;\n pointer-events: none;\n}\n\n.valueLabel {\n position: absolute;\n top: calc(var(--sizes-7) * -1);\n transform: translateX(-50%);\n background: var(--colors-secondary-blue-base);\n color: white;\n padding: var(--sizes-1) var(--sizes-2);\n border-radius: var(--sizes-1);\n font-size: var(--sizes-3);\n white-space: nowrap;\n}\n"],"names":["___$insertStyle"],"mappings":";;AACEA,WAAA,CAAA,2jCAAA;AACA,aAAA,CAAA,QAAA,CAAA,iBAAA,CAAA,YAAA,CAAA,sBAAA;;;;"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { SliderHandle } from './SliderHandle';
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
/// <reference types="react" />
|
|
2
|
+
export type SliderHandleProps = {
|
|
3
|
+
horizontalPosition: number;
|
|
4
|
+
value: number;
|
|
5
|
+
min: number;
|
|
6
|
+
max: number;
|
|
7
|
+
disabled: boolean;
|
|
8
|
+
isActive: boolean;
|
|
9
|
+
showLabel: boolean;
|
|
10
|
+
className?: string;
|
|
11
|
+
ariaLabel?: string;
|
|
12
|
+
ariaLabelledBy?: string;
|
|
13
|
+
onMouseDown: (e: React.MouseEvent) => void;
|
|
14
|
+
onMouseEnter: () => void;
|
|
15
|
+
onMouseLeave: () => void;
|
|
16
|
+
onFocus: () => void;
|
|
17
|
+
onBlur: () => void;
|
|
18
|
+
onKeyDown: (e: React.KeyboardEvent) => void;
|
|
19
|
+
};
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var React = require('react');
|
|
4
|
+
var buildClassnames = require('../../../../utils/buildClassnames.cjs');
|
|
5
|
+
var SliderTrack_module = require('./SliderTrack.module.scss.cjs');
|
|
6
|
+
|
|
7
|
+
function _interopDefaultCompat (e) { return e && typeof e === 'object' && 'default' in e ? e : { default: e }; }
|
|
8
|
+
|
|
9
|
+
var React__default = /*#__PURE__*/_interopDefaultCompat(React);
|
|
10
|
+
|
|
11
|
+
/**
|
|
12
|
+
* SliderTrack component renders the blue, filled track portion of a slider.
|
|
13
|
+
* It visually represents the active range between slider handles.
|
|
14
|
+
*/
|
|
15
|
+
const SliderTrack = ({ left, width, disabled, className }) => (React__default.default.createElement("div", { className: buildClassnames.buildClassnames([SliderTrack_module.range, className]), style: { left: `${left}%`, width: `${width}%` }, "data-disabled": disabled, "data-testid": "slider-track" }));
|
|
16
|
+
|
|
17
|
+
exports.SliderTrack = SliderTrack;
|
|
18
|
+
//# sourceMappingURL=SliderTrack.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"SliderTrack.cjs","sources":["../../../../../src/components/Slider/components/SliderTrack/SliderTrack.tsx"],"sourcesContent":["import React from 'react';\nimport { buildClassnames } from '../../../../utils/buildClassnames';\nimport styles from './SliderTrack.module.scss';\nimport { SliderTrackProps } from './types';\n\n/**\n * SliderTrack component renders the blue, filled track portion of a slider.\n * It visually represents the active range between slider handles.\n */\nexport const SliderTrack = ({ left, width, disabled, className }: SliderTrackProps) => (\n <div\n className={buildClassnames([styles.range, className])}\n style={{ left: `${left}%`, width: `${width}%` }}\n data-disabled={disabled}\n data-testid=\"slider-track\"\n />\n);\n"],"names":["React","buildClassnames","styles"],"mappings":";;;;;;;;;;AAKA;;;AAGG;AACU,MAAA,WAAW,GAAG,CAAC,EAAE,IAAI,EAAE,KAAK,EAAE,QAAQ,EAAE,SAAS,EAAoB,MAChFA,sBAAA,CAAA,aAAA,CAAA,KAAA,EAAA,EACE,SAAS,EAAEC,+BAAe,CAAC,CAACC,kBAAM,CAAC,KAAK,EAAE,SAAS,CAAC,CAAC,EACrD,KAAK,EAAE,EAAE,IAAI,EAAE,CAAA,EAAG,IAAI,CAAA,CAAA,CAAG,EAAE,KAAK,EAAE,CAAG,EAAA,KAAK,CAAG,CAAA,CAAA,EAAE,EAChC,eAAA,EAAA,QAAQ,EACX,aAAA,EAAA,cAAc,EAC1B,CAAA;;;;"}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { SliderTrackProps } from './types';
|
|
3
|
+
/**
|
|
4
|
+
* SliderTrack component renders the blue, filled track portion of a slider.
|
|
5
|
+
* It visually represents the active range between slider handles.
|
|
6
|
+
*/
|
|
7
|
+
export declare const SliderTrack: ({ left, width, disabled, className }: SliderTrackProps) => React.JSX.Element;
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import React__default from 'react';
|
|
2
|
+
import { buildClassnames } from '../../../../utils/buildClassnames.js';
|
|
3
|
+
import styles from './SliderTrack.module.scss.js';
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* SliderTrack component renders the blue, filled track portion of a slider.
|
|
7
|
+
* It visually represents the active range between slider handles.
|
|
8
|
+
*/
|
|
9
|
+
const SliderTrack = ({ left, width, disabled, className }) => (React__default.createElement("div", { className: buildClassnames([styles.range, className]), style: { left: `${left}%`, width: `${width}%` }, "data-disabled": disabled, "data-testid": "slider-track" }));
|
|
10
|
+
|
|
11
|
+
export { SliderTrack };
|
|
12
|
+
//# sourceMappingURL=SliderTrack.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"SliderTrack.js","sources":["../../../../../src/components/Slider/components/SliderTrack/SliderTrack.tsx"],"sourcesContent":["import React from 'react';\nimport { buildClassnames } from '../../../../utils/buildClassnames';\nimport styles from './SliderTrack.module.scss';\nimport { SliderTrackProps } from './types';\n\n/**\n * SliderTrack component renders the blue, filled track portion of a slider.\n * It visually represents the active range between slider handles.\n */\nexport const SliderTrack = ({ left, width, disabled, className }: SliderTrackProps) => (\n <div\n className={buildClassnames([styles.range, className])}\n style={{ left: `${left}%`, width: `${width}%` }}\n data-disabled={disabled}\n data-testid=\"slider-track\"\n />\n);\n"],"names":["React"],"mappings":";;;;AAKA;;;AAGG;AACU,MAAA,WAAW,GAAG,CAAC,EAAE,IAAI,EAAE,KAAK,EAAE,QAAQ,EAAE,SAAS,EAAoB,MAChFA,cAAA,CAAA,aAAA,CAAA,KAAA,EAAA,EACE,SAAS,EAAE,eAAe,CAAC,CAAC,MAAM,CAAC,KAAK,EAAE,SAAS,CAAC,CAAC,EACrD,KAAK,EAAE,EAAE,IAAI,EAAE,CAAA,EAAG,IAAI,CAAA,CAAA,CAAG,EAAE,KAAK,EAAE,CAAG,EAAA,KAAK,CAAG,CAAA,CAAA,EAAE,EAChC,eAAA,EAAA,QAAQ,EACX,aAAA,EAAA,cAAc,EAC1B,CAAA;;;;"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var ___$insertStyle = require('../../../../_virtual/____insertStyle.cjs');
|
|
4
|
+
|
|
5
|
+
___$insertStyle("._range_1wyjy_1 {\n position: relative;\n background: var(--colors-secondary-blue-light);\n height: var(--track-height);\n bottom: var(--track-height);\n border-radius: var(--radius-base);\n}\n\n._range_1wyjy_1[data-disabled=true] {\n background: var(--colors-neutral-grey-base);\n}");
|
|
6
|
+
var styles = {"range":"_range_1wyjy_1"};
|
|
7
|
+
|
|
8
|
+
module.exports = styles;
|
|
9
|
+
//# sourceMappingURL=SliderTrack.module.scss.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"SliderTrack.module.scss.cjs","sources":["../../../../../src/components/Slider/components/SliderTrack/SliderTrack.module.scss"],"sourcesContent":[".range {\n position: relative;\n background: var(--colors-secondary-blue-light);\n height: var(--track-height);\n bottom: var(--track-height);\n border-radius: var(--radius-base);\n}\n\n.range[data-disabled='true'] {\n background: var(--colors-neutral-grey-base);\n}\n"],"names":[],"mappings":";;;;AACE,eAAA,CAAA,kSAAA;AACA,aAAA,CAAA,OAAA,CAAA,gBAAA;;;;"}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import insertStyle from '../../../../_virtual/____insertStyle.js';
|
|
2
|
+
|
|
3
|
+
insertStyle("._range_1wyjy_1 {\n position: relative;\n background: var(--colors-secondary-blue-light);\n height: var(--track-height);\n bottom: var(--track-height);\n border-radius: var(--radius-base);\n}\n\n._range_1wyjy_1[data-disabled=true] {\n background: var(--colors-neutral-grey-base);\n}");
|
|
4
|
+
var styles = {"range":"_range_1wyjy_1"};
|
|
5
|
+
|
|
6
|
+
export { styles as default };
|
|
7
|
+
//# sourceMappingURL=SliderTrack.module.scss.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"SliderTrack.module.scss.js","sources":["../../../../../src/components/Slider/components/SliderTrack/SliderTrack.module.scss"],"sourcesContent":[".range {\n position: relative;\n background: var(--colors-secondary-blue-light);\n height: var(--track-height);\n bottom: var(--track-height);\n border-radius: var(--radius-base);\n}\n\n.range[data-disabled='true'] {\n background: var(--colors-neutral-grey-base);\n}\n"],"names":["___$insertStyle"],"mappings":";;AACEA,WAAA,CAAA,kSAAA;AACA,aAAA,CAAA,OAAA,CAAA,gBAAA;;;;"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { SliderTrack } from './SliderTrack';
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { RefObject } from 'react';
|
|
2
|
+
import { DraggingHandle } from '../types';
|
|
3
|
+
export type UseSliderDragProps = {
|
|
4
|
+
containerRef: RefObject<HTMLDivElement>;
|
|
5
|
+
value: number | number[];
|
|
6
|
+
min: number;
|
|
7
|
+
max: number;
|
|
8
|
+
step: number;
|
|
9
|
+
disabled: boolean;
|
|
10
|
+
onChange: (value: number | number[]) => void;
|
|
11
|
+
onSlideStart?: () => void;
|
|
12
|
+
onSlideEnd?: () => void;
|
|
13
|
+
};
|
|
14
|
+
export type UseSliderKeyboardProps = {
|
|
15
|
+
value: number | number[];
|
|
16
|
+
min: number;
|
|
17
|
+
max: number;
|
|
18
|
+
step: number;
|
|
19
|
+
disabled: boolean;
|
|
20
|
+
onChange: (value: number | number[]) => void;
|
|
21
|
+
setFocusedHandle: (handle: DraggingHandle) => void;
|
|
22
|
+
startHandleRef: React.RefObject<HTMLDivElement>;
|
|
23
|
+
endHandleRef: React.RefObject<HTMLDivElement>;
|
|
24
|
+
};
|
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var React = require('react');
|
|
4
|
+
var calculateSliderValue = require('../utils/calculateSliderValue.cjs');
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* Hook that manages mouse drag interactions for slider handles.
|
|
8
|
+
* Handles value updates, step snapping, boundary constraints, and handle crossing logic.
|
|
9
|
+
* Returns the current dragging state and a mouseDown handler to attach to slider handles.
|
|
10
|
+
*/
|
|
11
|
+
const useSliderDrag = ({ containerRef, value, min, max, step, disabled, onChange, onSlideStart, onSlideEnd, }) => {
|
|
12
|
+
const [isDraggingHandle, setIsDraggingHandle] = React.useState(null);
|
|
13
|
+
/**
|
|
14
|
+
* Calculates new value based on mouse position and updates slider state.
|
|
15
|
+
* Applies step snapping, boundary constraints, and handles crossing when values equal.
|
|
16
|
+
*/
|
|
17
|
+
const handleMouseMove = React.useCallback((e) => {
|
|
18
|
+
if (!isDraggingHandle || !containerRef.current)
|
|
19
|
+
return;
|
|
20
|
+
let sliderValue;
|
|
21
|
+
if (Array.isArray(value)) {
|
|
22
|
+
sliderValue = isDraggingHandle === 'start' ? value[0] : value[1];
|
|
23
|
+
}
|
|
24
|
+
else {
|
|
25
|
+
sliderValue = value;
|
|
26
|
+
}
|
|
27
|
+
const containerRect = containerRef.current.getBoundingClientRect();
|
|
28
|
+
// Slider position relative to the container in percentage
|
|
29
|
+
const positionPercent = ((e.pageX - containerRect.x) * 100) / containerRect.width;
|
|
30
|
+
// Calculate new value from mouse position
|
|
31
|
+
const targetValue = (max - min) * (positionPercent / 100) + min;
|
|
32
|
+
const newValue = calculateSliderValue.calculateSliderValue({
|
|
33
|
+
currentValue: sliderValue,
|
|
34
|
+
targetValue,
|
|
35
|
+
min,
|
|
36
|
+
max,
|
|
37
|
+
step,
|
|
38
|
+
});
|
|
39
|
+
if (sliderValue === newValue)
|
|
40
|
+
return;
|
|
41
|
+
let resultValue;
|
|
42
|
+
if (Array.isArray(value)) {
|
|
43
|
+
const newStart = isDraggingHandle === 'start' ? newValue : value[0];
|
|
44
|
+
const newEnd = isDraggingHandle === 'end' ? newValue : value[1];
|
|
45
|
+
// If handles cross, swap them and switch dragging to continue movement
|
|
46
|
+
if (newStart > newEnd) {
|
|
47
|
+
resultValue = [newEnd, newStart];
|
|
48
|
+
setIsDraggingHandle(isDraggingHandle === 'start' ? 'end' : 'start');
|
|
49
|
+
}
|
|
50
|
+
else {
|
|
51
|
+
resultValue = [newStart, newEnd];
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
else {
|
|
55
|
+
resultValue = newValue;
|
|
56
|
+
}
|
|
57
|
+
onChange(resultValue);
|
|
58
|
+
}, [containerRef, isDraggingHandle, max, min, onChange, step, value]);
|
|
59
|
+
const handleMouseUp = React.useCallback(() => {
|
|
60
|
+
setIsDraggingHandle(null);
|
|
61
|
+
onSlideEnd === null || onSlideEnd === undefined ? undefined : onSlideEnd();
|
|
62
|
+
}, [onSlideEnd]);
|
|
63
|
+
const handleMouseDown = React.useCallback((handle) => (e) => {
|
|
64
|
+
if (disabled)
|
|
65
|
+
return;
|
|
66
|
+
onSlideStart === null || onSlideStart === undefined ? undefined : onSlideStart();
|
|
67
|
+
setIsDraggingHandle(handle);
|
|
68
|
+
e.preventDefault();
|
|
69
|
+
}, [onSlideStart, disabled]);
|
|
70
|
+
React.useEffect(() => {
|
|
71
|
+
document.addEventListener('mousemove', handleMouseMove);
|
|
72
|
+
document.addEventListener('mouseup', handleMouseUp);
|
|
73
|
+
return () => {
|
|
74
|
+
document.removeEventListener('mousemove', handleMouseMove);
|
|
75
|
+
document.removeEventListener('mouseup', handleMouseUp);
|
|
76
|
+
};
|
|
77
|
+
}, [handleMouseMove, handleMouseUp]);
|
|
78
|
+
return {
|
|
79
|
+
isDraggingHandle,
|
|
80
|
+
handleMouseDown,
|
|
81
|
+
};
|
|
82
|
+
};
|
|
83
|
+
|
|
84
|
+
exports.useSliderDrag = useSliderDrag;
|
|
85
|
+
//# sourceMappingURL=useSliderDrag.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useSliderDrag.cjs","sources":["../../../../src/components/Slider/hooks/useSliderDrag.ts"],"sourcesContent":["import { useCallback, useEffect, useState } from 'react';\nimport { DraggingHandle } from '../types';\nimport { UseSliderDragProps } from './types';\nimport { calculateSliderValue } from '../utils';\n\n/**\n * Hook that manages mouse drag interactions for slider handles.\n * Handles value updates, step snapping, boundary constraints, and handle crossing logic.\n * Returns the current dragging state and a mouseDown handler to attach to slider handles.\n */\nexport const useSliderDrag = ({\n containerRef,\n value,\n min,\n max,\n step,\n disabled,\n onChange,\n onSlideStart,\n onSlideEnd,\n}: UseSliderDragProps) => {\n const [isDraggingHandle, setIsDraggingHandle] = useState<DraggingHandle>(null);\n\n /**\n * Calculates new value based on mouse position and updates slider state.\n * Applies step snapping, boundary constraints, and handles crossing when values equal.\n */\n const handleMouseMove = useCallback(\n (e: MouseEvent) => {\n if (!isDraggingHandle || !containerRef.current) return;\n\n let sliderValue: number;\n if (Array.isArray(value)) {\n sliderValue = isDraggingHandle === 'start' ? value[0] : value[1];\n } else {\n sliderValue = value as number;\n }\n\n const containerRect = containerRef.current.getBoundingClientRect();\n\n // Slider position relative to the container in percentage\n const positionPercent = ((e.pageX - containerRect.x) * 100) / containerRect.width;\n\n // Calculate new value from mouse position\n const targetValue = (max - min) * (positionPercent / 100) + min;\n\n const newValue = calculateSliderValue({\n currentValue: sliderValue,\n targetValue,\n min,\n max,\n step,\n });\n\n if (sliderValue === newValue) return;\n\n let resultValue: number | number[];\n\n if (Array.isArray(value)) {\n const newStart = isDraggingHandle === 'start' ? newValue : value[0];\n const newEnd = isDraggingHandle === 'end' ? newValue : value[1];\n\n // If handles cross, swap them and switch dragging to continue movement\n if (newStart > newEnd) {\n resultValue = [newEnd, newStart];\n setIsDraggingHandle(isDraggingHandle === 'start' ? 'end' : 'start');\n } else {\n resultValue = [newStart, newEnd];\n }\n } else {\n resultValue = newValue;\n }\n\n onChange(resultValue);\n },\n [containerRef, isDraggingHandle, max, min, onChange, step, value],\n );\n\n const handleMouseUp = useCallback(() => {\n setIsDraggingHandle(null);\n onSlideEnd?.();\n }, [onSlideEnd]);\n\n const handleMouseDown = useCallback(\n (handle: DraggingHandle) => (e: React.MouseEvent) => {\n if (disabled) return;\n onSlideStart?.();\n setIsDraggingHandle(handle);\n e.preventDefault();\n },\n [onSlideStart, disabled],\n );\n\n useEffect(() => {\n document.addEventListener('mousemove', handleMouseMove);\n document.addEventListener('mouseup', handleMouseUp);\n return () => {\n document.removeEventListener('mousemove', handleMouseMove);\n document.removeEventListener('mouseup', handleMouseUp);\n };\n }, [handleMouseMove, handleMouseUp]);\n\n return {\n isDraggingHandle,\n handleMouseDown,\n };\n};\n"],"names":["useState","useCallback","calculateSliderValue","useEffect"],"mappings":";;;;;AAKA;;;;AAIG;AACU,MAAA,aAAa,GAAG,CAAC,EAC5B,YAAY,EACZ,KAAK,EACL,GAAG,EACH,GAAG,EACH,IAAI,EACJ,QAAQ,EACR,QAAQ,EACR,YAAY,EACZ,UAAU,GACS,KAAI;IACvB,MAAM,CAAC,gBAAgB,EAAE,mBAAmB,CAAC,GAAGA,cAAQ,CAAiB,IAAI,CAAC;AAE9E;;;AAGG;AACH,IAAA,MAAM,eAAe,GAAGC,iBAAW,CACjC,CAAC,CAAa,KAAI;AAChB,QAAA,IAAI,CAAC,gBA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types';
|
|
2
|
+
import { UseSliderDragProps } from './types';
|
|
3
|
+
/**
|
|
4
|
+
* Hook that manages mouse drag interactions for slider handles.
|
|
5
|
+
* Handles value updates, step snapping, boundary constraints, and handle crossing logic.
|
|
6
|
+
* Returns the current dragging state and a mouseDown handler to attach to slider handles.
|
|
7
|
+
*/
|
|
8
|
+
export declare const useSliderDrag: ({ containerRef, value, min, max, step, disabled, onChange, onSlideStart, onSlideEnd, }: UseSliderDragProps) => {
|
|
9
|
+
isDraggingHandle: DraggingHandle;
|
|
10
|
+
handleMouseDown: (handle: DraggingHandle) => (e: React.MouseEvent) => void;
|
|
11
|
+
};
|
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
import { useState, useCallback, useEffect } from 'react';
|
|
2
|
+
import { calculateSliderValue } from '../utils/calculateSliderValue.js';
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* Hook that manages mouse drag interactions for slider handles.
|
|
6
|
+
* Handles value updates, step snapping, boundary constraints, and handle crossing logic.
|
|
7
|
+
* Returns the current dragging state and a mouseDown handler to attach to slider handles.
|
|
8
|
+
*/
|
|
9
|
+
const useSliderDrag = ({ containerRef, value, min, max, step, disabled, onChange, onSlideStart, onSlideEnd, }) => {
|
|
10
|
+
const [isDraggingHandle, setIsDraggingHandle] = useState(null);
|
|
11
|
+
/**
|
|
12
|
+
* Calculates new value based on mouse position and updates slider state.
|
|
13
|
+
* Applies step snapping, boundary constraints, and handles crossing when values equal.
|
|
14
|
+
*/
|
|
15
|
+
const handleMouseMove = useCallback((e) => {
|
|
16
|
+
if (!isDraggingHandle || !containerRef.current)
|
|
17
|
+
return;
|
|
18
|
+
let sliderValue;
|
|
19
|
+
if (Array.isArray(value)) {
|
|
20
|
+
sliderValue = isDraggingHandle === 'start' ? value[0] : value[1];
|
|
21
|
+
}
|
|
22
|
+
else {
|
|
23
|
+
sliderValue = value;
|
|
24
|
+
}
|
|
25
|
+
const containerRect = containerRef.current.getBoundingClientRect();
|
|
26
|
+
// Slider position relative to the container in percentage
|
|
27
|
+
const positionPercent = ((e.pageX - containerRect.x) * 100) / containerRect.width;
|
|
28
|
+
// Calculate new value from mouse position
|
|
29
|
+
const targetValue = (max - min) * (positionPercent / 100) + min;
|
|
30
|
+
const newValue = calculateSliderValue({
|
|
31
|
+
currentValue: sliderValue,
|
|
32
|
+
targetValue,
|
|
33
|
+
min,
|
|
34
|
+
max,
|
|
35
|
+
step,
|
|
36
|
+
});
|
|
37
|
+
if (sliderValue === newValue)
|
|
38
|
+
return;
|
|
39
|
+
let resultValue;
|
|
40
|
+
if (Array.isArray(value)) {
|
|
41
|
+
const newStart = isDraggingHandle === 'start' ? newValue : value[0];
|
|
42
|
+
const newEnd = isDraggingHandle === 'end' ? newValue : value[1];
|
|
43
|
+
// If handles cross, swap them and switch dragging to continue movement
|
|
44
|
+
if (newStart > newEnd) {
|
|
45
|
+
resultValue = [newEnd, newStart];
|
|
46
|
+
setIsDraggingHandle(isDraggingHandle === 'start' ? 'end' : 'start');
|
|
47
|
+
}
|
|
48
|
+
else {
|
|
49
|
+
resultValue = [newStart, newEnd];
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
else {
|
|
53
|
+
resultValue = newValue;
|
|
54
|
+
}
|
|
55
|
+
onChange(resultValue);
|
|
56
|
+
}, [containerRef, isDraggingHandle, max, min, onChange, step, value]);
|
|
57
|
+
const handleMouseUp = useCallback(() => {
|
|
58
|
+
setIsDraggingHandle(null);
|
|
59
|
+
onSlideEnd === null || onSlideEnd === undefined ? undefined : onSlideEnd();
|
|
60
|
+
}, [onSlideEnd]);
|
|
61
|
+
const handleMouseDown = useCallback((handle) => (e) => {
|
|
62
|
+
if (disabled)
|
|
63
|
+
return;
|
|
64
|
+
onSlideStart === null || onSlideStart === undefined ? undefined : onSlideStart();
|
|
65
|
+
setIsDraggingHandle(handle);
|
|
66
|
+
e.preventDefault();
|
|
67
|
+
}, [onSlideStart, disabled]);
|
|
68
|
+
useEffect(() => {
|
|
69
|
+
document.addEventListener('mousemove', handleMouseMove);
|
|
70
|
+
document.addEventListener('mouseup', handleMouseUp);
|
|
71
|
+
return () => {
|
|
72
|
+
document.removeEventListener('mousemove', handleMouseMove);
|
|
73
|
+
document.removeEventListener('mouseup', handleMouseUp);
|
|
74
|
+
};
|
|
75
|
+
}, [handleMouseMove, handleMouseUp]);
|
|
76
|
+
return {
|
|
77
|
+
isDraggingHandle,
|
|
78
|
+
handleMouseDown,
|
|
79
|
+
};
|
|
80
|
+
};
|
|
81
|
+
|
|
82
|
+
export { useSliderDrag };
|
|
83
|
+
//# sourceMappingURL=useSliderDrag.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useSliderDrag.js","sources":["../../../../src/components/Slider/hooks/useSliderDrag.ts"],"sourcesContent":["import { useCallback, useEffect, useState } from 'react';\nimport { DraggingHandle } from '../types';\nimport { UseSliderDragProps } from './types';\nimport { calculateSliderValue } from '../utils';\n\n/**\n * Hook that manages mouse drag interactions for slider handles.\n * Handles value updates, step snapping, boundary constraints, and handle crossing logic.\n * Returns the current dragging state and a mouseDown handler to attach to slider handles.\n */\nexport const useSliderDrag = ({\n containerRef,\n value,\n min,\n max,\n step,\n disabled,\n onChange,\n onSlideStart,\n onSlideEnd,\n}: UseSliderDragProps) => {\n const [isDraggingHandle, setIsDraggingHandle] = useState<DraggingHandle>(null);\n\n /**\n * Calculates new value based on mouse position and updates slider state.\n * Applies step snapping, boundary constraints, and handles crossing when values equal.\n */\n const handleMouseMove = useCallback(\n (e: MouseEvent) => {\n if (!isDraggingHandle || !containerRef.current) return;\n\n let sliderValue: number;\n if (Array.isArray(value)) {\n sliderValue = isDraggingHandle === 'start' ? value[0] : value[1];\n } else {\n sliderValue = value as number;\n }\n\n const containerRect = containerRef.current.getBoundingClientRect();\n\n // Slider position relative to the container in percentage\n const positionPercent = ((e.pageX - containerRect.x) * 100) / containerRect.width;\n\n // Calculate new value from mouse position\n const targetValue = (max - min) * (positionPercent / 100) + min;\n\n const newValue = calculateSliderValue({\n currentValue: sliderValue,\n targetValue,\n min,\n max,\n step,\n });\n\n if (sliderValue === newValue) return;\n\n let resultValue: number | number[];\n\n if (Array.isArray(value)) {\n const newStart = isDraggingHandle === 'start' ? newValue : value[0];\n const newEnd = isDraggingHandle === 'end' ? newValue : value[1];\n\n // If handles cross, swap them and switch dragging to continue movement\n if (newStart > newEnd) {\n resultValue = [newEnd, newStart];\n setIsDraggingHandle(isDraggingHandle === 'start' ? 'end' : 'start');\n } else {\n resultValue = [newStart, newEnd];\n }\n } else {\n resultValue = newValue;\n }\n\n onChange(resultValue);\n },\n [containerRef, isDraggingHandle, max, min, onChange, step, value],\n );\n\n const handleMouseUp = useCallback(() => {\n setIsDraggingHandle(null);\n onSlideEnd?.();\n }, [onSlideEnd]);\n\n const handleMouseDown = useCallback(\n (handle: DraggingHandle) => (e: React.MouseEvent) => {\n if (disabled) return;\n onSlideStart?.();\n setIsDraggingHandle(handle);\n e.preventDefault();\n },\n [onSlideStart, disabled],\n );\n\n useEffect(() => {\n document.addEventListener('mousemove', handleMouseMove);\n document.addEventListener('mouseup', handleMouseUp);\n return () => {\n document.removeEventListener('mousemove', handleMouseMove);\n document.removeEventListener('mouseup', handleMouseUp);\n };\n }, [handleMouseMove, handleMouseUp]);\n\n return {\n isDraggingHandle,\n handleMouseDown,\n };\n};\n"],"names":[],"mappings":";;;AAKA;;;;AAIG;AACU,MAAA,aAAa,GAAG,CAAC,EAC5B,YAAY,EACZ,KAAK,EACL,GAAG,EACH,GAAG,EACH,IAAI,EACJ,QAAQ,EACR,QAAQ,EACR,YAAY,EACZ,UAAU,GACS,KAAI;IACvB,MAAM,CAAC,gBAAgB,EAAE,mBAAmB,CAAC,GAAG,QAAQ,CAAiB,IAAI,CAAC;AAE9E;;;AAGG;AACH,IAAA,MAAM,eAAe,GAAG,WAAW,CACjC,CAAC,CAAa,KAAI;AAChB,QAAA,IAAI,CAAC,gBAAgB,IAAI,CAAC,YAAY,CAAC,OAAO;YAA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ue = require('../utils/calculateSliderValue.cjs');
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* Hook that manages keyboard navigation for slider handles.
|
|
8
|
+
* Handles arrow keys, Home, and End keys with proper boundary constraints.
|
|
9
|
+
* Returns a keyboard event handler to attach to slider handles.
|
|
10
|
+
*/
|
|
11
|
+
const useSliderKeyboard = ({ value, min, max, step, disabled, onChange, setFocusedHandle, startHandleRef, endHandleRef, }) => {
|
|
12
|
+
const handleKeyDown = React.useCallback((handle) => (e) => {
|
|
13
|
+
var _a;
|
|
14
|
+
if (disabled)
|
|
15
|
+
return;
|
|
16
|
+
let currentValue;
|
|
17
|
+
if (Array.isArray(value)) {
|
|
18
|
+
currentValue = handle === 'start' ? value[0] : value[1];
|
|
19
|
+
}
|
|
20
|
+
else {
|
|
21
|
+
currentValue = value;
|
|
22
|
+
}
|
|
23
|
+
let newValue;
|
|
24
|
+
switch (e.key) {
|
|
25
|
+
case 'ArrowRight':
|
|
26
|
+
case 'ArrowUp':
|
|
27
|
+
e.preventDefault();
|
|
28
|
+
newValue = calculateSliderValue.calculateSliderValue({
|
|
29
|
+
currentValue,
|
|
30
|
+
targetValue: currentValue + step,
|
|
31
|
+
min,
|
|
32
|
+
max,
|
|
33
|
+
step,
|
|
34
|
+
});
|
|
35
|
+
break;
|
|
36
|
+
case 'ArrowLeft':
|
|
37
|
+
case 'ArrowDown':
|
|
38
|
+
e.preventDefault();
|
|
39
|
+
newValue = calculateSliderValue.calculateSliderValue({
|
|
40
|
+
currentValue,
|
|
41
|
+
targetValue: currentValue - step,
|
|
42
|
+
min,
|
|
43
|
+
max,
|
|
44
|
+
step,
|
|
45
|
+
});
|
|
46
|
+
break;
|
|
47
|
+
case 'Home':
|
|
48
|
+
e.preventDefault();
|
|
49
|
+
newValue = min;
|
|
50
|
+
break;
|
|
51
|
+
case 'End':
|
|
52
|
+
e.preventDefault();
|
|
53
|
+
newValue = max;
|
|
54
|
+
break;
|
|
55
|
+
default:
|
|
56
|
+
return;
|
|
57
|
+
}
|
|
58
|
+
let resultValue;
|
|
59
|
+
if (Array.isArray(value)) {
|
|
60
|
+
const newStart = handle === 'start' ? newValue : value[0];
|
|
61
|
+
const newEnd = handle === 'end' ? newValue : value[1];
|
|
62
|
+
// If handles cross, swap them and switch focus to continue movement
|
|
63
|
+
if (newStart > newEnd) {
|
|
64
|
+
resultValue = [newEnd, newStart];
|
|
65
|
+
const newHandle = handle === 'start' ? 'end' : 'start';
|
|
66
|
+
setFocusedHandle(newHandle);
|
|
67
|
+
const targetRef = newHandle === 'start' ? startHandleRef : endHandleRef;
|
|
68
|
+
(_a = targetRef.current) === null || _a === undefined ? undefined : _a.focus();
|
|
69
|
+
}
|
|
70
|
+
else {
|
|
71
|
+
resultValue = [newStart, newEnd];
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
else {
|
|
75
|
+
resultValue = newValue;
|
|
76
|
+
}
|
|
77
|
+
onChange(resultValue);
|
|
78
|
+
}, [value, min, max, step, disabled, onChange, setFocusedHandle, startHandleRef, endHandleRef]);
|
|
79
|
+
return {
|
|
80
|
+
handleKeyDown,
|
|
81
|
+
};
|
|
82
|
+
};
|
|
83
|
+
|
|
84
|
+
exports.useSliderKeyboard = useSliderKeyboard;
|
|
85
|
+
//# sourceMappingURL=useSliderKeyboard.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useSliderKeyboard.cjs","sources":["../../../../src/components/Slider/hooks/useSliderKeyboard.ts"],"sourcesContent":["import { useCallback } from 'react';\nimport { calculateSliderValue } from '../utils';\nimport { UseSliderKeyboardProps } from './types';\n\n/**\n * Hook that manages keyboard navigation for slider handles.\n * Handles arrow keys, Home, and End keys with proper boundary constraints.\n * Returns a keyboard event handler to attach to slider handles.\n */\nexport const useSliderKeyboard = ({\n value,\n min,\n max,\n step,\n disabled,\n onChange,\n setFocusedHandle,\n startHandleRef,\n endHandleRef,\n}: UseSliderKeyboardProps) => {\n const handleKeyDown = useCallback(\n (handle: 'start' | 'end') => (e: React.KeyboardEvent) => {\n if (disabled) return;\n\n let currentValue: number;\n if (Array.isArray(value)) {\n currentValue = handle === 'start' ? value[0] : value[1];\n } else {\n currentValue = value as number;\n }\n\n let newValue: number;\n\n switch (e.key) {\n case 'ArrowRight':\n case 'ArrowUp':\n e.preventDefault();\n newValue = calculateSliderValue({\n currentValue,\n targetValue: currentValue + step,\n min,\n max,\n step,\n });\n break;\n case 'ArrowLeft':\n case 'ArrowDown':\n e.preventDefault();\n newValue = calculateSliderValue({\n currentValue,\n targetValue: currentValue - step,\n min,\n max,\n step,\n });\n break;\n case 'Home':\n e.preventDefault();\n newValue = min;\n break;\n case 'End':\n e.preventDefault();\n newValue = max;\n break;\n default:\n return;\n }\n\n let resultValue: number | number[];\n\n if (Array.isArray(value)) {\n const newStart = handle === 'start' ? newValue : value[0];\n const newEnd = handle === 'end' ? newValue : value[1];\n\n // If handles cross, swap them and switch focus to continue movement\n if (newStart > newEnd) {\n resultValue = [newEnd, newStart];\n const newHandle = handle === 'start' ? 'end' : 'start';\n setFocusedHandle(newHandle);\n const targetRef = newHandle === 'start' ? startHandleRef : endHandleRef;\n targetRef.current?.focus();\n } else {\n resultValue = [newStart, newEnd];\n }\n } else {\n resultValue = newValue;\n }\n\n onChange(resultValue);\n },\n [value, min, max, step, disabled, onChange, setFocusedHandle, startHandleRef, endHandleRef],\n );\n\n return {\n handleKeyDown,\n };\n};\n"],"names":["useCallback","calculateSliderValue"],"mappings":";;;;;AAIA;;;;AAIG;AACU,MAAA,iBAAiB,GAAG,CAAC,EAChC,KAAK,EACL,GAAG,EACH,GAAG,EACH,IAAI,EACJ,QAAQ,EACR,QAAQ,EACR,gBAAgB,EAChB,cAAc,EACd,YAAY,GACW,KAAI;AAC3B,IAAA,MAAM,aAAa,GAAGA,iBAAW,CAC/B,CAAC,MAAuB,KAAK,CAAC,CAAsB,KAAI;;AACtD,QAAA,IAAI,QAAQ;YAAE;AAEd,QAAA,IAAI,YAAoB;AACxB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AW,GAAG,CAAC,MAAM,EAAE,QAAQ,CAAC;AAChC,gBAAA,MAAM,SAAS,GAAG,MAAM,KAAK,OAAO,GAAG,KAAK,GAAG,OAAO;gBACtD,gBAAgB,CAAC,SAAS,CAAC;AAC3B,gBAAA,MAAM,SAAS,GAAG,SAAS,KAAK,OAAO,GAAG,cAAc,GAAG,YAAY;AACvE,gBAAA,CAAA,EAAA,GAAA,SAAS,CAAC,OAAO,MAAE,IAAA,IAAA,EAAA,KAAA,SAAA,GAAA,SAAA,GAAA,EAAA,CAAA,KAAK,EAAE;AAC3B;AAAM,iBAAA;AACL,gBAAA,WAAW,GAAG,CAAC,QAAQ,EAAE,MAAM,CAAC;AACjC;AACF;AAAM,aAAA;YACL,WAAW,GAAG,QAAQ;AACvB;QAED,QAAQ,CAAC,WAAW,CAAC;KACtB,EACD,CAAC,KAAK,EAAE,GAAG,EAAE,GAAG,EAAE,IAAI,EAAE,QAAQ,EAAE,QAAQ,EAAE,gBAAgB,EAAE,cAAc,EAAE,YAAY,CAAC,CAC5F;IAED,OAAO;QACL,aAAa;KACd;AACH;;;;"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { UseSliderKeyboardProps } from './types';
|
|
2
|
+
/**
|
|
3
|
+
* Hook that manages keyboard navigation for slider handles.
|
|
4
|
+
* Handles arrow keys, Home, and End keys with proper boundary constraints.
|
|
5
|
+
* Returns a keyboard event handler to attach to slider handles.
|
|
6
|
+
*/
|
|
7
|
+
export declare const useSliderKeyboard: ({ value, min, max, step, disabled, onChange, setFocusedHandle, startHandleRef, endHandleRef, }: UseSliderKeyboardProps) => {
|
|
8
|
+
handleKeyDown: (handle: 'start' | 'end') => (e: React.KeyboardEvent) => void;
|
|
9
|
+
};
|