@toptal/picasso-slider 1.0.6 → 2.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (88) hide show
  1. package/dist-package/src/Slider/Slider.d.ts +20 -20
  2. package/dist-package/src/Slider/Slider.d.ts.map +1 -1
  3. package/dist-package/src/Slider/Slider.js +49 -41
  4. package/dist-package/src/Slider/Slider.js.map +1 -1
  5. package/dist-package/src/Slider/hooks/index.d.ts +2 -0
  6. package/dist-package/src/Slider/hooks/index.d.ts.map +1 -0
  7. package/dist-package/src/Slider/hooks/index.js +2 -0
  8. package/dist-package/src/Slider/hooks/index.js.map +1 -0
  9. package/dist-package/src/Slider/hooks/use-label-overlap.d.ts +8 -0
  10. package/dist-package/src/Slider/hooks/use-label-overlap.d.ts.map +1 -0
  11. package/dist-package/src/Slider/hooks/use-label-overlap.js +35 -0
  12. package/dist-package/src/Slider/hooks/use-label-overlap.js.map +1 -0
  13. package/dist-package/src/Slider/index.d.ts +0 -1
  14. package/dist-package/src/Slider/index.d.ts.map +1 -1
  15. package/dist-package/src/Slider/index.js +0 -1
  16. package/dist-package/src/Slider/index.js.map +1 -1
  17. package/dist-package/src/SliderMark/SliderMark.d.ts +13 -0
  18. package/dist-package/src/SliderMark/SliderMark.d.ts.map +1 -0
  19. package/dist-package/src/SliderMark/SliderMark.js +10 -0
  20. package/dist-package/src/SliderMark/SliderMark.js.map +1 -0
  21. package/dist-package/src/SliderMark/index.d.ts +2 -0
  22. package/dist-package/src/SliderMark/index.d.ts.map +1 -0
  23. package/dist-package/src/SliderMark/index.js +2 -0
  24. package/dist-package/src/SliderMark/index.js.map +1 -0
  25. package/dist-package/src/SliderValueLabel/SliderValueLabel.d.ts +9 -14
  26. package/dist-package/src/SliderValueLabel/SliderValueLabel.d.ts.map +1 -1
  27. package/dist-package/src/SliderValueLabel/SliderValueLabel.js +40 -23
  28. package/dist-package/src/SliderValueLabel/SliderValueLabel.js.map +1 -1
  29. package/dist-package/src/SliderValueLabel/index.d.ts +1 -2
  30. package/dist-package/src/SliderValueLabel/index.d.ts.map +1 -1
  31. package/dist-package/src/SliderValueLabel/index.js +1 -1
  32. package/dist-package/src/SliderValueLabel/index.js.map +1 -1
  33. package/dist-package/src/index.d.ts +0 -1
  34. package/dist-package/src/index.d.ts.map +1 -1
  35. package/dist-package/src/index.js +0 -1
  36. package/dist-package/src/index.js.map +1 -1
  37. package/dist-package/src/utils/check-bg-color.d.ts +7 -0
  38. package/dist-package/src/utils/check-bg-color.d.ts.map +1 -0
  39. package/dist-package/src/utils/check-bg-color.js +15 -0
  40. package/dist-package/src/utils/check-bg-color.js.map +1 -0
  41. package/dist-package/src/utils/check-overlap.d.ts +26 -0
  42. package/dist-package/src/utils/check-overlap.d.ts.map +1 -0
  43. package/dist-package/src/utils/check-overlap.js +32 -0
  44. package/dist-package/src/utils/check-overlap.js.map +1 -0
  45. package/dist-package/src/utils/get-x-placement.d.ts +8 -0
  46. package/dist-package/src/utils/get-x-placement.d.ts.map +1 -0
  47. package/dist-package/src/utils/get-x-placement.js +17 -0
  48. package/dist-package/src/utils/get-x-placement.js.map +1 -0
  49. package/dist-package/src/utils/index.d.ts +4 -0
  50. package/dist-package/src/utils/index.d.ts.map +1 -0
  51. package/dist-package/src/utils/index.js +4 -0
  52. package/dist-package/src/utils/index.js.map +1 -0
  53. package/package.json +5 -7
  54. package/src/Slider/Slider.tsx +114 -101
  55. package/src/Slider/__snapshots__/test.tsx.snap +58 -30
  56. package/src/Slider/hooks/index.ts +1 -0
  57. package/src/Slider/hooks/use-label-overlap.ts +48 -0
  58. package/src/Slider/index.ts +0 -1
  59. package/src/Slider/story/ControlledWithLabel.example.tsx +1 -1
  60. package/src/Slider/story/Marks.example.tsx +13 -4
  61. package/src/Slider/story/Range.example.tsx +0 -1
  62. package/src/Slider/story/RangeWithValueLabel.example.tsx +0 -1
  63. package/src/Slider/story/Tooltip.example.tsx +22 -6
  64. package/src/Slider/story/index.jsx +0 -8
  65. package/src/Slider/test.tsx +6 -0
  66. package/src/SliderMark/SliderMark.tsx +35 -0
  67. package/src/SliderMark/index.ts +1 -0
  68. package/src/SliderValueLabel/SliderValueLabel.tsx +74 -54
  69. package/src/SliderValueLabel/index.ts +1 -5
  70. package/src/index.ts +0 -1
  71. package/src/utils/check-bg-color.test.ts +92 -0
  72. package/src/utils/check-bg-color.ts +28 -0
  73. package/src/utils/check-overlap.test.ts +55 -0
  74. package/src/utils/check-overlap.ts +43 -0
  75. package/src/utils/get-x-placement.test.ts +93 -0
  76. package/src/utils/get-x-placement.ts +28 -0
  77. package/src/utils/index.ts +3 -0
  78. package/dist-package/src/Slider/SliderContext.d.ts +0 -11
  79. package/dist-package/src/Slider/SliderContext.d.ts.map +0 -1
  80. package/dist-package/src/Slider/SliderContext.js +0 -38
  81. package/dist-package/src/Slider/SliderContext.js.map +0 -1
  82. package/dist-package/src/Slider/styles.d.ts +0 -4
  83. package/dist-package/src/Slider/styles.d.ts.map +0 -1
  84. package/dist-package/src/Slider/styles.js +0 -68
  85. package/dist-package/src/Slider/styles.js.map +0 -1
  86. package/src/Slider/SliderContext.tsx +0 -80
  87. package/src/Slider/story/CustomTooltip.example.tsx +0 -36
  88. package/src/Slider/styles.ts +0 -71
@@ -1,47 +1,47 @@
1
- import type { ChangeEvent, ComponentProps } from 'react';
2
1
  import React from 'react';
3
- import { Slider as MUISlider } from '@material-ui/core';
4
- import type { ValueLabelProps } from '../SliderValueLabel';
5
- declare type Value = number | number[];
6
- declare type ValueLabelDisplay = 'on' | 'auto' | 'off';
7
- export interface Props extends ComponentProps<typeof MUISlider> {
2
+ import type { BaseProps } from '@toptal/picasso-shared';
3
+ export interface Props extends BaseProps {
8
4
  /** Minimum slider value */
9
5
  min?: number;
10
6
  /** Maximum slider value */
11
7
  max?: number;
12
8
  /** Controlled value of the component */
13
- value?: Value;
14
- /** The default value. Use when the component is not controlled. */
15
- defaultValue?: Value;
9
+ value?: number | number[];
10
+ /** The default value. Use when the component is not controlled */
11
+ defaultValue?: number | number[];
16
12
  /** Step for the thumb movement */
17
13
  step?: number;
18
14
  /** Whether marks are shown or not */
19
15
  marks?: boolean;
20
16
  /** Whether component is disabled or not */
21
17
  disabled?: boolean;
22
- /** The tooltip component. */
23
- TooltipComponent?: React.ElementType<ValueLabelProps & {
24
- index: number;
25
- }>;
26
18
  /** Controls when tooltip is displayed:
27
19
  - **auto** the value tooltip will display when the thumb is hovered or focused.
28
20
  - **on** will display persistently.
29
21
  - **off** will never display
30
22
  */
31
- tooltip?: ValueLabelDisplay;
23
+ tooltip?: 'on' | 'auto' | 'off';
32
24
  /** The format function the value tooltip's value. */
33
25
  tooltipFormat?: string | ((value: number, index: number) => React.ReactNode);
34
- /** Show a compact tooltip */
35
- compact?: boolean;
36
- /** Disable the portal behavior of the tooltip. The children stay within it's parent */
37
- disablePortal?: boolean;
38
26
  /** Callback invoked when slider changes its state. */
39
- onChange?: (event: ChangeEvent<{}>, value: Value) => void;
27
+ onChange?: (event: Event, value: number | number[], activeThumb: number) => void;
28
+ /** Callback invoked on focus */
29
+ onFocus?: (event: React.FocusEvent<HTMLElement>) => void;
30
+ /** Callback invoked on blur */
31
+ onBlur?: (event: React.FocusEvent<HTMLElement>) => void;
40
32
  /** Hide thumb when value is undefined or null. Works only when the component is controlled. */
41
33
  hideThumbOnEmpty?: boolean;
42
34
  /** Disable track highlight. */
43
35
  disableTrackHighlight?: boolean;
36
+ /**
37
+ * Name attribute of the `input` element.
38
+ */
39
+ name?: string;
40
+ /**
41
+ * Id attribute of the `input` element.
42
+ */
43
+ id?: string;
44
44
  }
45
- export declare const Slider: React.ForwardRefExoticComponent<Pick<Props, "tooltip" | "disablePortal" | "compact" | "children" | "value" | "valueLabelDisplay" | "slot" | "style" | "title" | "track" | "classes" | "defaultChecked" | "defaultValue" | "suppressContentEditableWarning" | "suppressHydrationWarning" | "accessKey" | "className" | "contentEditable" | "contextMenu" | "dir" | "draggable" | "hidden" | "id" | "lang" | "placeholder" | "spellCheck" | "tabIndex" | "translate" | "radioGroup" | "role" | "about" | "datatype" | "inlist" | "prefix" | "property" | "resource" | "typeof" | "vocab" | "autoCapitalize" | "autoCorrect" | "autoSave" | "color" | "itemProp" | "itemScope" | "itemType" | "itemID" | "itemRef" | "results" | "security" | "unselectable" | "inputMode" | "is" | "aria-activedescendant" | "aria-atomic" | "aria-autocomplete" | "aria-busy" | "aria-checked" | "aria-colcount" | "aria-colindex" | "aria-colspan" | "aria-controls" | "aria-current" | "aria-describedby" | "aria-details" | "aria-disabled" | "aria-dropeffect" | "aria-errormessage" | "aria-expanded" | "aria-flowto" | "aria-grabbed" | "aria-haspopup" | "aria-hidden" | "aria-invalid" | "aria-keyshortcuts" | "aria-label" | "aria-labelledby" | "aria-level" | "aria-live" | "aria-modal" | "aria-multiline" | "aria-multiselectable" | "aria-orientation" | "aria-owns" | "aria-placeholder" | "aria-posinset" | "aria-pressed" | "aria-readonly" | "aria-relevant" | "aria-required" | "aria-roledescription" | "aria-rowcount" | "aria-rowindex" | "aria-rowspan" | "aria-selected" | "aria-setsize" | "aria-sort" | "aria-valuemax" | "aria-valuemin" | "aria-valuenow" | "aria-valuetext" | "dangerouslySetInnerHTML" | "onCopy" | "onCopyCapture" | "onCut" | "onCutCapture" | "onPaste" | "onPasteCapture" | "onCompositionEnd" | "onCompositionEndCapture" | "onCompositionStart" | "onCompositionStartCapture" | "onCompositionUpdate" | "onCompositionUpdateCapture" | "onFocus" | "onFocusCapture" | "onBlur" | "onBlurCapture" | "onChange" | "onChangeCapture" | "onBeforeInput" | "onBeforeInputCapture" | "onInput" | "onInputCapture" | "onReset" | "onResetCapture" | "onSubmit" | "onSubmitCapture" | "onInvalid" | "onInvalidCapture" | "onLoad" | "onLoadCapture" | "onError" | "onErrorCapture" | "onKeyDown" | "onKeyDownCapture" | "onKeyPress" | "onKeyPressCapture" | "onKeyUp" | "onKeyUpCapture" | "onAbort" | "onAbortCapture" | "onCanPlay" | "onCanPlayCapture" | "onCanPlayThrough" | "onCanPlayThroughCapture" | "onDurationChange" | "onDurationChangeCapture" | "onEmptied" | "onEmptiedCapture" | "onEncrypted" | "onEncryptedCapture" | "onEnded" | "onEndedCapture" | "onLoadedData" | "onLoadedDataCapture" | "onLoadedMetadata" | "onLoadedMetadataCapture" | "onLoadStart" | "onLoadStartCapture" | "onPause" | "onPauseCapture" | "onPlay" | "onPlayCapture" | "onPlaying" | "onPlayingCapture" | "onProgress" | "onProgressCapture" | "onRateChange" | "onRateChangeCapture" | "onSeeked" | "onSeekedCapture" | "onSeeking" | "onSeekingCapture" | "onStalled" | "onStalledCapture" | "onSuspend" | "onSuspendCapture" | "onTimeUpdate" | "onTimeUpdateCapture" | "onVolumeChange" | "onVolumeChangeCapture" | "onWaiting" | "onWaitingCapture" | "onAuxClick" | "onAuxClickCapture" | "onClick" | "onClickCapture" | "onContextMenu" | "onContextMenuCapture" | "onDoubleClick" | "onDoubleClickCapture" | "onDrag" | "onDragCapture" | "onDragEnd" | "onDragEndCapture" | "onDragEnter" | "onDragEnterCapture" | "onDragExit" | "onDragExitCapture" | "onDragLeave" | "onDragLeaveCapture" | "onDragOver" | "onDragOverCapture" | "onDragStart" | "onDragStartCapture" | "onDrop" | "onDropCapture" | "onMouseDown" | "onMouseDownCapture" | "onMouseEnter" | "onMouseLeave" | "onMouseMove" | "onMouseMoveCapture" | "onMouseOut" | "onMouseOutCapture" | "onMouseOver" | "onMouseOverCapture" | "onMouseUp" | "onMouseUpCapture" | "onSelect" | "onSelectCapture" | "onTouchCancel" | "onTouchCancelCapture" | "onTouchEnd" | "onTouchEndCapture" | "onTouchMove" | "onTouchMoveCapture" | "onTouchStart" | "onTouchStartCapture" | "onPointerDown" | "onPointerDownCapture" | "onPointerMove" | "onPointerMoveCapture" | "onPointerUp" | "onPointerUpCapture" | "onPointerCancel" | "onPointerCancelCapture" | "onPointerEnter" | "onPointerEnterCapture" | "onPointerLeave" | "onPointerLeaveCapture" | "onPointerOver" | "onPointerOverCapture" | "onPointerOut" | "onPointerOutCapture" | "onGotPointerCapture" | "onGotPointerCaptureCapture" | "onLostPointerCapture" | "onLostPointerCaptureCapture" | "onScroll" | "onScrollCapture" | "onWheel" | "onWheelCapture" | "onAnimationStart" | "onAnimationStartCapture" | "onAnimationEnd" | "onAnimationEndCapture" | "onAnimationIteration" | "onAnimationIterationCapture" | "onTransitionEnd" | "onTransitionEndCapture" | "disabled" | "scale" | "innerRef" | "key" | "getAriaLabel" | "getAriaValueText" | "marks" | "max" | "min" | "name" | "onChangeCommitted" | "orientation" | "step" | "ThumbComponent" | "ValueLabelComponent" | "valueLabelFormat" | "TooltipComponent" | "tooltipFormat" | "hideThumbOnEmpty" | "disableTrackHighlight"> & React.RefAttributes<HTMLElement>>;
45
+ export declare const Slider: React.ForwardRefExoticComponent<Props & React.RefAttributes<HTMLElement>>;
46
46
  export default Slider;
47
47
  //# sourceMappingURL=Slider.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"Slider.d.ts","sourceRoot":"","sources":["../../../src/Slider/Slider.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,cAAc,EAAE,MAAM,OAAO,CAAA;AACxD,OAAO,KAAsC,MAAM,OAAO,CAAA;AAI1D,OAAO,EAAE,MAAM,IAAI,SAAS,EAAE,MAAM,mBAAmB,CAAA;AAIvD,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,qBAAqB,CAAA;AAO1D,aAAK,KAAK,GAAG,MAAM,GAAG,MAAM,EAAE,CAAA;AAC9B,aAAK,iBAAiB,GAAG,IAAI,GAAG,MAAM,GAAG,KAAK,CAAA;AAE9C,MAAM,WAAW,KAAM,SAAQ,cAAc,CAAC,OAAO,SAAS,CAAC;IAC7D,2BAA2B;IAC3B,GAAG,CAAC,EAAE,MAAM,CAAA;IACZ,2BAA2B;IAC3B,GAAG,CAAC,EAAE,MAAM,CAAA;IACZ,wCAAwC;IACxC,KAAK,CAAC,EAAE,KAAK,CAAA;IACb,mEAAmE;IACnE,Y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asOwnProperty.call(s, p) && e.indexOf(p) < 0)
4
- t[p] = s[p];
5
- if (s != null && typeof Object.getOwnPropertySymbols === "function")
6
- for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
7
- if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
8
- t[p[i]] = s[p[i]];
9
- }
10
- return t;
11
- };
12
- import React, { forwardRef, useRef, useMemo } from 'react';
13
- import { makeStyles } from '@material-ui/core/styles';
14
- import { Slider as MUISlider } from '@material-ui/core';
15
- import cx from 'classnames';
16
- import { useCombinedRefs } from '@toptal/picasso-utils';
17
- import { SliderValueLabel } from '../SliderValueLabel';
18
- import { SliderContextProvider } from './SliderContext';
19
- import styles from './styles';
20
- const useStyles = makeStyles(styles);
21
- const createDefaultValueLabelComponent = (tooltip, disablePortal, compact) => {
22
- const ValueLableComponent = (props) => (React.createElement(SliderValueLabel, Object.assign({}, props, { tooltip: tooltip, disablePortal: disablePortal, compact: compact })));
23
- return ValueLableComponent;
24
- };
1
+ // import type { ComponentProps } from 'react'
2
+ import React, { forwardRef, useRef } from 'react';
3
+ import { Slider as MUIBaseSlider } from '@mui/base/Slider';
4
+ import { useCombinedRefs, useOnScreen } from '@toptal/picasso-utils';
5
+ import { twJoin, twMerge } from 'tailwind-merge';
6
+ import SliderMark from '../SliderMark';
7
+ import SliderValueLabel from '../SliderValueLabel';
8
+ import { useLabelOverlap } from './hooks';
25
9
  export const Slider = forwardRef(function Slider(props, ref) {
26
- const { min, max, marks, value, defaultValue = 0, tooltip, tooltipFormat, compact, TooltipComponent: UserDefinedTooltip, step, disabled, disablePortal, onChange, hideThumbOnEmpty, disableTrackHighlight } = props, rest = __rest(props, ["min", "max", "marks", "value", "defaultValue", "tooltip", "tooltipFormat", "compact", "TooltipComponent", "step", "disabled", "disablePortal", "onChange", "hideThumbOnEmpty", "disableTrackHighlight"]);
27
- const _a = useStyles(), { wrapper, markTrack, hideThumb, markInactive, unmarkTrack } = _a, classes = __rest(_a, ["wrapper", "markTrack", "hideThumb", "markInactive", "unmarkTrack"]);
10
+ const { min, max, marks, value, defaultValue = 0, tooltip = 'off', tooltipFormat, step, disabled, onChange, onBlur, onFocus, hideThumbOnEmpty, disableTrackHighlight, className, style, name, id, 'data-private': dataPrivate, 'data-testid': dataTestid, } = props;
11
+ const containerRef = useRef(null);
28
12
  const sliderRef = useCombinedRefs(ref, useRef(null));
13
+ const { isPartiallyOverlapped, handleValueLabelOnRender } = useLabelOverlap({
14
+ value,
15
+ });
29
16
  const isThumbHidden = hideThumbOnEmpty && (typeof value === 'undefined' || value === null);
30
- const DefaultValueLabelComponent = useMemo(() => createDefaultValueLabelComponent(tooltip, disablePortal, compact), [tooltip, disablePortal, compact]);
31
- // From Workaround for https://github.com/mui-org/material-ui/issues/21889
32
- const ValueLabelComponent = (UserDefinedTooltip ||
33
- DefaultValueLabelComponent);
34
- return (React.createElement(SliderContextProvider, null,
35
- React.createElement("div", { className: wrapper },
36
- React.createElement(MUISlider, Object.assign({}, rest, { ref: sliderRef, defaultValue: defaultValue, value: value, min: min, max: max, step: step, marks: marks, disabled: disabled, classes: Object.assign(Object.assign({}, classes), { track: cx(classes.track, {
37
- [markTrack]: marks,
38
- [unmarkTrack]: disableTrackHighlight,
39
- }), thumb: cx(classes.thumb, {
40
- [hideThumb]: isThumbHidden,
41
- }), markActive: cx(classes.markActive, {
42
- [markInactive]: isThumbHidden || disableTrackHighlight,
43
- }) }), ValueLabelComponent: ValueLabelComponent, valueLabelFormat: tooltipFormat, valueLabelDisplay: tooltip, onChange: onChange })))));
17
+ // The rootMargin is not working correctly in the storybooks iframe
18
+ // To test properly we can open the iframe in new window
19
+ const isContainerOnScreen = useOnScreen({
20
+ ref: containerRef,
21
+ rootMargin: '-24px 0px 0px 0px',
22
+ threshold: 1,
23
+ });
24
+ return (React.createElement("div", { ref: containerRef, className: twMerge('my-[6px] mx-0', className), style: style },
25
+ React.createElement(MUIBaseSlider, { ref: sliderRef, defaultValue: defaultValue, value: value, min: min, max: max, step: step, marks: marks, disabled: disabled, "data-testid": dataTestid, "data-private": dataPrivate, onFocus: onFocus, onBlur: onBlur, name: name, id: id, slots: {
26
+ mark: SliderMark,
27
+ valueLabel: SliderValueLabel,
28
+ }, slotProps: {
29
+ mark: {
30
+ // @ts-expect-error we have custom Mark component, where we extend props and MUI does not understand it
31
+ forceInactive: disableTrackHighlight,
32
+ },
33
+ root: {
34
+ className: 'block cursor-pointer width-full relative py-[6px] -my-[6px]',
35
+ },
36
+ rail: {
37
+ className: 'block absolute w-full h-[1px] opacity-[0.24] rounded-none bg-gray-500',
38
+ },
39
+ thumb: {
40
+ className: twJoin('group/thumb flex justify-center items-center w-[15px] h-[15px]', 'rounded-[50%] bg-blue-500 border-[2px] border-solid border-white', '-mt-[7px] -ml-[6px] outline-0 absolute transition-shadow cursor-pointer', isThumbHidden && 'hidden'),
41
+ role: 'slider',
42
+ },
43
+ track: {
44
+ className: twJoin('block absolute h-[1px]', disableTrackHighlight ? 'bg-gray-200' : 'bg-blue-500'),
45
+ },
46
+ valueLabel: {
47
+ tooltip,
48
+ onRender: handleValueLabelOnRender,
49
+ yPlacement: isContainerOnScreen ? 'top' : 'bottom',
50
+ isOverlaped: isPartiallyOverlapped,
51
+ },
52
+ }, valueLabelFormat: tooltipFormat, onChange: onChange })));
44
53
  });
45
54
  Slider.displayName = 'Slider';
46
55
  Slider.defaultProps = {
@@ -48,7 +57,6 @@ Slider.defaultProps = {
48
57
  min: 0,
49
58
  max: 100,
50
59
  tooltip: 'off',
51
- disablePortal: false,
52
60
  };
53
61
  export default Slider;
54
62
  //# sourceMappingURL=Slider.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"Slider.js","sourceRoot":"","sources":["../../../src/Slider/Slider.tsx"],"names":[],"mappings":";;;;;;;;;;;AACA,OAAO,KAAK,EAAE,EAAE,UAAU,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,OAAO,CAAA;AAE1D,OAAO,EAAE,UAAU,EAA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iBACf;gBACD,KAAK,EAAE;oBACL,SAAS,EAAE,MAAM,CACf,wBAAwB,EACxB,qBAAqB,CAAC,CAAC,CAAC,aAAa,CAAC,CAAC,CAAC,aAAa,CACtD;iBACF;gBACD,UAAU,EAAE;oBACV,OAAO;oBACP,QAAQ,EAAE,wBAAwB;oBAClC,UAAU,EAAE,mBAAmB,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,QAAQ;oBAClD,WAAW,EAAE,qBAAqB;iBACnC;aACF,EACD,gBAAgB,EAAE,aAAa,EAC/B,QAAQ,EAAE,QAAQ,GAClB,CACE,CACP,CAAA;AACH,CAAC,CAAC,CAAA;AAEF,MAAM,CAAC,WAAW,GAAG,QAAQ,CAAA;AAE7B,MAAM,CAAC,YAAY,GAAG;IACpB,YAAY,EAAE,CAAC;IACf,GAAG,EAAE,CAAC;IACN,GAAG,EAAE,GAAG;IACR,OAAO,EAAE,KAAK;CACf,CAAA;AAED,eAAe,MAAM,CAAA"}
@@ -0,0 +1,2 @@
1
+ export * from './use-label-overlap';
2
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/Slider/hooks/index.ts"],"names":[],"mappings":"AAAA,cAAc,qBAAqB,CAAA"}
@@ -0,0 +1,2 @@
1
+ export * from './use-label-overlap';
2
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/Slider/hooks/index.ts"],"names":[],"mappings":"AAAA,cAAc,qBAAqB,CAAA"}
@@ -0,0 +1,8 @@
1
+ import type { RefObject } from 'react';
2
+ export declare const useLabelOverlap: ({ value }: {
3
+ value?: number | number[] | undefined;
4
+ }) => {
5
+ isPartiallyOverlapped: boolean;
6
+ handleValueLabelOnRender: (index: number, labelRef: RefObject<HTMLSpanElement>) => void;
7
+ };
8
+ //# sourceMappingURL=use-label-overlap.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"use-label-overlap.d.ts","sourceRoot":"","sources":["../../../../src/Slider/hooks/use-label-overlap.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,OAAO,CAAA;AAKtC,eAAO,MAAM,eAAe;;;;sCA+BhB,MAAM,YAAY,UAAU,eAAe,CAAC;CAWvD,CAAA"}
@@ -0,0 +1,35 @@
1
+ import { useCallback, useEffect, useState } from 'react';
2
+ import { checkOverlap } from '../../utils';
3
+ export const useLabelOverlap = ({ value }) => {
4
+ const [isPartiallyOverlapped, setIsPartiallyOverlapped] = useState(false);
5
+ const [valueLabels, setValueLabels] = useState([]);
6
+ const isRangeSlider = Array.isArray(value);
7
+ useEffect(() => {
8
+ var _a, _b;
9
+ if (!isRangeSlider) {
10
+ return;
11
+ }
12
+ const isFullyOverlaped = value[0] === value[1];
13
+ if (isFullyOverlaped) {
14
+ setIsPartiallyOverlapped(false);
15
+ }
16
+ else {
17
+ if (!(((_a = valueLabels[0]) === null || _a === void 0 ? void 0 : _a.current) && ((_b = valueLabels[1]) === null || _b === void 0 ? void 0 : _b.current))) {
18
+ return;
19
+ }
20
+ setIsPartiallyOverlapped(checkOverlap({
21
+ firstLabelRect: valueLabels[0].current.getBoundingClientRect(),
22
+ secondLabelRect: valueLabels[1].current.getBoundingClientRect(),
23
+ previousResult: isPartiallyOverlapped,
24
+ }));
25
+ }
26
+ }, [value, isRangeSlider, isPartiallyOverlapped, valueLabels]);
27
+ const handleValueLabelOnRender = useCallback((index, labelRef) => {
28
+ setValueLabels(valLabels => {
29
+ valLabels[index] = labelRef;
30
+ return valLabels;
31
+ });
32
+ }, [setValueLabels]);
33
+ return { isPartiallyOverlapped, handleValueLabelOnRender };
34
+ };
35
+ //# sourceMappingURL=use-label-overlap.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"use-label-overlap.js","sourceRoot":"","sources":["../../../../src/Slider/hooks/use-label-overlap.ts"],"names":[],"mappings":"AACA,OAAO,E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,SAAS,CAAC,EAAE;YACzB,SAAS,CAAC,KAAK,CAAC,GAAG,QAAQ,CAAA;YAE3B,OAAO,SAAS,CAAA;QAClB,CAAC,CAAC,CAAA;IACJ,CAAC,EACD,CAAC,cAAc,CAAC,CACjB,CAAA;IAED,OAAO,EAAE,qBAAqB,EAAE,wBAAwB,EAAE,CAAA;AAC5D,CAAC,CAAA"}
@@ -1,6 +1,5 @@
1
1
  import type { OmitInternalProps } from '@toptal/picasso-shared';
2
2
  import type { Props } from './Slider';
3
3
  export { default as Slider } from './Slider';
4
- export { useSliderContext } from './SliderContext';
5
4
  export declare type SliderProps = OmitInternalProps<Props>;
6
5
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/Slider/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,wBAAwB,CAAA;AAE/D,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,UAAU,CAAA;AAErC,OAAO,EAAE,OAAO,IAAI,MAAM,EAAE,MAAM,UAAU,CAAA;AAC5C,OAAO,EAAE,gBAAgB,EAAE,MAAM,iBAAiB,CAAA;AAClD,oBAAY,WAAW,GAAG,iBAAiB,CAAC,KAAK,CAAC,CAAA"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/Slider/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,wBAAwB,CAAA;AAE/D,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,UAAU,CAAA;AAErC,OAAO,EAAE,OAAO,IAAI,MAAM,EAAE,MAAM,UAAU,CAAA;AAC5C,oBAAY,WAAW,GAAG,iBAAiB,CAAC,KAAK,CAAC,CAAA"}
@@ -1,3 +1,2 @@
1
1
  export { default as Slider } from './Slider';
2
- export { useSliderContext } from './SliderContext';
3
2
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/Slider/index.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,OAAO,IAAI,MAAM,EAAE,MAAM,UAAU,CAAA;AAC5C,OAAO,EAAE,gBAAgB,EAAE,MAAM,iBAAiB,CAAA"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/Slider/index.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,OAAO,IAAI,MAAM,EAAE,MAAM,UAAU,CAAA"}
@@ -0,0 +1,13 @@
1
+ import React from 'react';
2
+ export declare type SliderMarkProps = {
3
+ markActive: boolean;
4
+ ownerState: {
5
+ value: number;
6
+ };
7
+ style: React.CSSProperties;
8
+ 'data-index': number;
9
+ forceInactive: boolean;
10
+ };
11
+ declare const SliderMark: ({ markActive, ownerState, "data-index": dataIndex, style, forceInactive, }: SliderMarkProps) => JSX.Element;
12
+ export default SliderMark;
13
+ //# sourceMappingURL=SliderMark.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"SliderMark.d.ts","sourceRoot":"","sources":["../../../src/SliderMark/SliderMark.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAA;AAKzB,oBAAY,eAAe,GAAG;IAC5B,UAAU,EAAE,OAAO,CAAA;IACnB,UAAU,EAAE;QAAE,KAAK,EAAE,MAAM,CAAA;KAAE,CAAA;IAC7B,KAAK,EAAE,KAAK,CAAC,aAAa,CAAA;IAC1B,YAAY,EAAE,MAAM,CAAA;IACpB,aAAa,EAAE,OAAO,CAAA;CACvB,CAAA;AAID,QAAA,MAAM,UAAU,+EAMb,eAAe,gBAWjB,CAAA;AAED,eAAe,UAAU,CAAA"}
@@ -0,0 +1,10 @@
1
+ import React from 'react';
2
+ import { twJoin } from 'tailwind-merge';
3
+ import { getBgColor } from '../utils';
4
+ // We need custom Mark component because we have
5
+ // different bg color based on value of the Slider
6
+ const SliderMark = ({ markActive, ownerState, 'data-index': dataIndex, style, forceInactive, }) => {
7
+ return (React.createElement("span", { "data-index": dataIndex, style: style, className: twJoin('absolute w-[6px] h-[6px] rounded-[50%] border-[2px] top-[1.5px] border-solid border-white opacity-100 -translate-x-2/4 box-content', getBgColor({ markActive, forceInactive, value: ownerState.value })) }));
8
+ };
9
+ export default SliderMark;
10
+ //# sourceMappingURL=SliderMark.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"SliderMark.js","sourceRoot":"","sources":["../../../src/SliderMark/SliderMark.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAA;AACzB,OAAO,EAAE,MAAM,EAAE,MAAM,gBAAgB,CAAA;AAEvC,OAAO,EAAE,UAAU,EAAE,MAAM,UAAU,CAAA;AAUrC,gDAAgD;AAChD,kDAAkD;AAClD,MAAM,UAAU,GAAG,CAAC,EAClB,UAAU,EACV,UAAU,EACV,YAAY,EAAE,SAAS,EACvB,KAAK,EACL,aAAa,GACG,EAAE,EAAE;IACpB,OAAO,CACL,4CACc,SAAS,EACrB,KAAK,EAAE,KAAK,EACZ,SAAS,EAAE,MAAM,CACf,oIAAoI,EACpI,UAAU,CAAC,EAAE,UAAU,EAAE,aAAa,EAAE,KAAK,EAAE,UAAU,CAAC,KAAK,EAAE,CAAC,CACnE,GACD,CACH,CAAA;AACH,CAAC,CAAA;AAED,eAAe,UAAU,CAAA"}
@@ -0,0 +1,2 @@
1
+ export { default } from './SliderMark';
2
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/SliderMark/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,cAAc,CAAA"}
@@ -0,0 +1,2 @@
1
+ export { default } from './SliderMark';
2
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/SliderMark/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,cAAc,CAAA"}
@@ -1,17 +1,12 @@
1
- /// <reference types="react" />
2
- import type { ValueLabelProps as MUIValueLabelProps } from '@material-ui/core/Slider';
1
+ import type { SliderValueLabelSlotProps } from '@mui/base/Slider';
2
+ import type { RefObject } from 'react';
3
3
  declare type ValueLabelDisplay = 'on' | 'auto' | 'off';
4
- export declare type ValueLabelProps = MUIValueLabelProps & {
5
- valueLabelDisplay: ValueLabelDisplay;
6
- index: number;
7
- };
8
- export interface Props extends ValueLabelProps {
9
- tooltip?: ValueLabelDisplay;
10
- disablePortal?: boolean;
11
- compact?: boolean;
12
- valueLabelDisplay: ValueLabelDisplay;
13
- index: number;
14
- }
15
- declare const SliderValueLabel: ({ tooltip, disablePortal, compact, children, open, value, valueLabelDisplay, index, }: Props) => JSX.Element;
4
+ declare const SliderValueLabel: ({ children, index, tooltip, onRender, yPlacement, isOverlaped, ownerState: { value }, }: SliderValueLabelSlotProps & {
5
+ tooltip: ValueLabelDisplay;
6
+ yPlacement: 'top' | 'bottom';
7
+ /** indicates if there are two SliderValueLabels that overlap each other */
8
+ isOverlaped: boolean;
9
+ onRender: (index: number, ref: RefObject<HTMLSpanElement>) => void;
10
+ }) => JSX.Element;
16
11
  export default SliderValueLabel;
17
12
  //# sourceMappingURL=SliderValueLabel.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"SliderValueLabel.d.ts","sourceRoot":"","sources":["../../../src/SliderValueLabel/SliderValueLabel.tsx"],"names":[],"mappings":";AACA,OAAO,KAAK,EAAE,eAAe,IAAI,kBAAkB,EAAE,MAAM,0BAA0B,CAAA;AAKrF,aAAK,iBAAiB,GAAG,IAAI,GAAG,MAAM,GAAG,KAAK,CAAA;AAG9C,oBAAY,eAAe,GAAG,kBAAkB,GAAG;IACjD,iBAAiB,EAAE,iBAAiB,CAAA;IACpC,KAAK,EAAE,MAAM,CAAA;CACd,CAAA;AAED,MAAM,WAAW,KAAM,SAAQ,eAAe;IAC5C,OAAO,CAAC,EAAE,iBAAiB,CAAA;IAC3B,aAAa,CAAC,EAAE,OAAO,CAAA;IACvB,OAAO,CAAC,EAAE,OAAO,CAAA;IACjB,iBAAiB,EAAE,iBAAiB,CAAA;IACpC,KAAK,EAAE,MAAM,CAAA;CACd;AAED,QAAA,MAAM,gBAAgB,0FASnB,KAAK,gBAwCP,CAAA;AAED,eAAe,gBAAgB,CAAA"}
1
+ {"version":3,"file":"SliderValueLabel.d.ts","sourceRoot":"","sources":["../../../src/SliderValueLabel/SliderValueLabel.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,yBAAyB,EAAE,MAAM,kBAAkB,CAAA;AACjE,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,OAAO,CAAA;AAMtC,aAAK,iBAAiB,GAAG,IAAI,GAAG,MAAM,GAAG,KAAK,CAAA;AAqB9C,QAAA,MAAM,gBAAgB;aASX,iBAAiB;gBACd,KAAK,GAAG,QAAQ;IAC5B,2EAA2E;iBAC9D,OAAO;sBACF,MAAM,OAAO,UAAU,eAAe,CAAC,KAAK,IAAI;iBAkDnE,CAAA;AAED,eAAe,gBAAgB,CAAA"}
@@ -1,27 +1,44 @@
1
- import React, { useRef } from 'react';
2
- import { Tooltip } from '@toptal/picasso-tooltip';
3
- import { useSliderContext } from '../Slider';
4
- const SliderValueLabel = ({ tooltip, disablePortal, compact, children, open, value, valueLabelDisplay, index, }) => {
5
- const thumbRef = useRef(null);
6
- const { registerValueLabel, hasTooltipOverlow } = useSliderContext();
7
- const isTooltipAlwaysVisible = tooltip === 'on';
8
- if (valueLabelDisplay === 'off') {
9
- return children;
10
- }
11
- const getPlacement = () => {
12
- if (hasTooltipOverlow) {
13
- return index === 0 ? 'top-end' : 'top-start';
14
- }
15
- return 'top';
16
- };
17
- const handleTooltipRef = (tooltipElement) => {
18
- // At this moment, both thumb and tooltip refs are set so we can register them in the context
19
- const thumbElement = thumbRef.current;
20
- if (tooltipElement && thumbElement) {
21
- registerValueLabel(index, tooltipElement, thumbElement);
1
+ import React, { useEffect, useRef, useState } from 'react';
2
+ import { twJoin } from 'tailwind-merge';
3
+ import { getXPlacement } from '../utils';
4
+ const classesByTooltip = {
5
+ off: 'hidden',
6
+ // We need to use visibility: hidden instead of display: none to keep the
7
+ // label visible for javascript calculations.
8
+ auto: 'invisible group-hover/thumb:visible flex justify-center items-center',
9
+ on: 'flex justify-center items-center',
10
+ };
11
+ const xPlacementClasses = {
12
+ left: 'right-[calc(100%-13px)]',
13
+ right: 'left-[calc(100%-13px)]',
14
+ center: '',
15
+ };
16
+ const yPlacementClasses = {
17
+ bottom: 'top-[calc(100%+2px)]',
18
+ top: 'bottom-[calc(100%+2px)]',
19
+ };
20
+ const SliderValueLabel = ({ children, index = -1, tooltip = 'off', onRender, yPlacement, isOverlaped, ownerState: { value }, }) => {
21
+ const ref = useRef(null);
22
+ // we need to change the placement of the label if it is overlaped
23
+ // or if it is out of the viewport
24
+ const [xPlacement, setXPlacement] = useState('center');
25
+ useEffect(() => {
26
+ onRender(index, ref);
27
+ }, [index, onRender]);
28
+ useEffect(() => {
29
+ if (!ref.current) {
30
+ return;
22
31
  }
23
- };
24
- return (React.createElement(Tooltip, { ref: thumbRef, tooltipRef: handleTooltipRef, content: value, open: open || valueLabelDisplay === 'on', placement: getPlacement(), preventOverflow: isTooltipAlwaysVisible, disablePortal: disablePortal, compact: compact }, children));
32
+ setXPlacement(getXPlacement({
33
+ rect: ref.current.getBoundingClientRect(),
34
+ isOverlaped: isOverlaped,
35
+ isFirstLabel: index === 0,
36
+ currentPlacement: xPlacement,
37
+ }));
38
+ // we need to recalculate on value change to get new rect
39
+ }, [isOverlaped, index, xPlacement, value]);
40
+ return (React.createElement("span", { ref: ref, className: twJoin('absolute will-change-transform transition-transform', classesByTooltip[tooltip], yPlacementClasses[yPlacement], xPlacementClasses[xPlacement]) },
41
+ React.createElement("span", { className: twJoin('shadow-4 text-sm text-white bg-graphite-800', 'm-1 rounded-sm py-[2px] px-2 max-w-[300px] break-words') }, children)));
25
42
  };
26
43
  export default SliderValueLabel;
27
44
  //# sourceMappingURL=SliderValueLabel.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"SliderValueLabel.js","sourceRoot":"","sources":["../../../src/SliderValueLabel/SliderValueLabel.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,EAAE,MAAM,EAAE,MAAM,OAAO,CAAA;AAErC,OAAO,EAAE,OAAO,EAAE,MAAM,yBAAyB,CAAA;AAEjD,OAAO,EAAE,gBAAgB,EAAE,MAAM,WAAW,CAAA;AAkB5C,MAAM,gBAAgB,GAAG,CAAC,EACxB,OAAO,EACP,aAAa,EACb,OAAO,EACP,QAAQ,EACR,IAAI,EACJ,KAAK,EACL,iBAAiB,EACjB,KAAK,GACC,EAAE,EAAE;IACV,MAAM,QAAQ,GAAG,MAAM,CAAiB,IAAI,CAAC,CAAA;IAC7C,MAAM,EAAE,kBAAkB,EAAE,iBAAiB,EAAE,GAAG,gBAAgB,EAAE,CAAA;IACpE,MAAM,sBAAsB,GAAG,OAAO,KAAK,IAAI,CAAA;IAE/C,IAAI,iBAAiB,KAAK,KAAK,EAAE;QAC/B,OAAO,QAAQ,CAAA;KAChB;IAED,MAAM,YAAY,GAAG,GAAG,EAAE;QACxB,IAAI,iBAAiB,EAAE;YACrB,OAAO,KAAK,KAAK,CAAC,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,WAAW,CAAA;SAC7C;QAED,OAAO,KAAK,CAAA;IACd,CAAC,CAAA;IAED,MAAM,gBAAgB,GAAG,CAAC,cAA8B,EAAE,EAAE;QAC1D,6FAA6F;QAC7F,MAAM,YAAY,GAAG,QAAQ,CAAC,OAAO,CAAA;QAErC,IAAI,cAAc,IAAI,YAAY,EAAE;YAClC,kBAAkB,CAAC,KAAK,EAAE,cAAc,EAAE,YAAY,CAAC,CAAA;SACxD;IACH,CAAC,CAAA;IAED,OAAO,CACL,oBAAC,OAAO,IACN,GAAG,EAAE,QAAQ,EACb,UAAU,EAAE,gBAAgB,EAC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CAAA;IAED,SAAS,CAAC,GAAG,EAAE;QACb,QAAQ,CAAC,KAAK,EAAE,GAAG,CAAC,CAAA;IACtB,CAAC,EAAE,CAAC,KAAK,EAAE,QAAQ,CAAC,CAAC,CAAA;IAErB,SAAS,CAAC,GAAG,EAAE;QACb,IAAI,CAAC,GAAG,CAAC,OAAO,EAAE;YAChB,OAAM;SACP;QAED,aAAa,CACX,aAAa,CAAC;YACZ,IAAI,EAAE,GAAG,CAAC,OAAO,CAAC,qBAAqB,EAAE;YACzC,WAAW,EAAE,WAAW;YACxB,YAAY,EAAE,KAAK,KAAK,CAAC;YACzB,gBAAgB,EAAE,UAAU;SAC7B,CAAC,CACH,CAAA;QACD,yDAAyD;IAC3D,CAAC,EAAE,CAAC,WAAW,EAAE,KAAK,EAAE,UAAU,EAAE,KAAK,CAAC,CAAC,CAAA;IAE3C,OAAO,CACL,8BACE,GAAG,EAAE,GAAG,EACR,SAAS,EAAE,MAAM,CACf,qDAAqD,EACrD,gBAAgB,CAAC,OAAO,CAAC,EACzB,iBAAiB,CAAC,UAAU,CAAC,EAC7B,iBAAiB,CAAC,UAAU,CAAC,CAC9B;QAED,8BACE,SAAS,EAAE,MAAM,CACf,6CAA6C,EAC7C,wDAAwD,CACzD,IAEA,QAAQ,CACJ,CACF,CACR,CAAA;AACH,CAAC,CAAA;AAED,eAAe,gBAAgB,CAAA"}
@@ -1,3 +1,2 @@
1
- export { default as SliderValueLabel } from './SliderValueLabel';
2
- export type { Props as SliderValueLabelProps, ValueLabelProps, } from './SliderValueLabel';
1
+ export { default } from './SliderValueLabel';
3
2
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/SliderValueLabel/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,IAAI,gBAAgB,EAAE,MAAM,oBAAoB,CAAA;AAChE,YAAY,EACV,KAAK,IAAI,qBAAqB,EAC9B,eAAe,GAChB,MAAM,oBAAoB,CAAA"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/SliderValueLabel/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,oBAAoB,CAAA"}
@@ -1,2 +1,2 @@
1
- export { default as SliderValueLabel } from './SliderValueLabel';
1
+ export { default } from './SliderValueLabel';
2
2
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/SliderValueLabel/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,IAAI,gBAAgB,EAAE,MAAM,oBAAoB,CAAA"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/SliderValueLabel/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,oBAAoB,CAAA"}
@@ -1,3 +1,2 @@
1
1
  export * from './Slider';
2
- export * from './SliderValueLabel';
3
2
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,UAAU,CAAA;AACxB,cAAc,oBAAoB,CAAA"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,UAAU,CAAA"}
@@ -1,3 +1,2 @@
1
1
  export * from './Slider';
2
- export * from './SliderValueLabel';
3
2
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,UAAU,CAAA;AACxB,cAAc,oBAAoB,CAAA"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,UAAU,CAAA"}
@@ -0,0 +1,7 @@
1
+ export declare type GetBgColorProps = {
2
+ markActive?: boolean;
3
+ forceInactive?: boolean;
4
+ value?: number | readonly number[];
5
+ };
6
+ export declare const getBgColor: ({ markActive, forceInactive, value, }: GetBgColorProps) => "bg-gray-500" | "bg-blue-500";
7
+ //# sourceMappingURL=check-bg-color.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"check-bg-color.d.ts","sourceRoot":"","sources":["../../../src/utils/check-bg-color.ts"],"names":[],"mappings":"AAAA,oBAAY,eAAe,GAAG;IAC5B,UAAU,CAAC,EAAE,OAAO,CAAA;IACpB,aAAa,CAAC,EAAE,OAAO,CAAA;IACvB,KAAK,CAAC,EAAE,MAAM,GAAG,SAAS,MAAM,EAAE,CAAA;CACnC,CAAA;AAED,eAAO,MAAM,UAAU,0CAIpB,eAAe,kCAiBjB,CAAA"}
@@ -0,0 +1,15 @@
1
+ export const getBgColor = ({ markActive, forceInactive, value, }) => {
2
+ const inactive = 'bg-gray-500';
3
+ const active = 'bg-blue-500';
4
+ if (forceInactive) {
5
+ return inactive;
6
+ }
7
+ if (markActive) {
8
+ if (value === undefined) {
9
+ return inactive;
10
+ }
11
+ return active;
12
+ }
13
+ return inactive;
14
+ };
15
+ //# sourceMappingURL=check-bg-color.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"check-bg-color.js","sourceRoot":"","sources":["../../../src/utils/check-bg-color.ts"],"names":[],"mappings":"AAMA,MAAM,CAAC,MAAM,UAAU,GAAG,CAAC,EACzB,UAAU,EACV,aAAa,EACb,KAAK,GACW,EAAE,EAAE;IACpB,MAAM,QAAQ,GAAG,aAAa,CAAA;IAC9B,MAAM,MAAM,GAAG,aAAa,CAAA;IAE5B,IAAI,aAAa,EAAE;QACjB,OAAO,QAAQ,CAAA;KAChB;IAED,IAAI,UAAU,EAAE;QACd,IAAI,KAAK,KAAK,SAAS,EAAE;YACvB,OAAO,QAAQ,CAAA;SAChB;QAED,OAAO,MAAM,CAAA;KACd;IAED,OAAO,QAAQ,CAAA;AACjB,CAAC,CAAA"}
@@ -0,0 +1,26 @@
1
+ export declare type CheckOverlapProps = {
2
+ firstLabelRect: DOMRect;
3
+ secondLabelRect: DOMRect;
4
+ previousResult: boolean;
5
+ };
6
+ /**
7
+ * if we have range slider, there is a chance
8
+ * when we select values next to each other
9
+ * that the lables might overlap each other. Like this example:
10
+ * [ [ ] ]
11
+ * A B
12
+ *
13
+ * In that case we need to reposition the labels to the edges of the thumb.
14
+ * [ ] [ ]
15
+ * A B
16
+ *
17
+ * In next rerender when we recalculate the position of the labels the
18
+ * above example would end with result as not overlapping as the position was already changed.
19
+ * So we need to work with the previous result of this function `previousResult`. When
20
+ * true we need to add half of the width of the label to simulate the center position.
21
+ *
22
+ * This function checks and returns if the labels overlap.
23
+ * It is called on each render of the component and everytime the Slider changes value.
24
+ **/
25
+ export declare const checkOverlap: ({ firstLabelRect, secondLabelRect, previousResult, }: CheckOverlapProps) => boolean;
26
+ //# sourceMappingURL=check-overlap.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"check-overlap.d.ts","sourceRoot":"","sources":["../../../src/utils/check-overlap.ts"],"names":[],"mappings":"AAAA,oBAAY,iBAAiB,GAAG;IAC9B,cAAc,EAAE,OAAO,CAAA;IACvB,eAAe,EAAE,OAAO,CAAA;IACxB,cAAc,EAAE,OAAO,CAAA;CACxB,CAAA;AAED;;;;;;;;;;;;;;;;;;IAkBI;AACJ,eAAO,MAAM,YAAY,yDAItB,iBAAiB,KAAG,OAatB,CAAA"}