@chayns-components/core 5.0.0-beta.830 → 5.0.0-beta.831
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/lib/cjs/components/slider/Slider.js +30 -14
- package/lib/cjs/components/slider/Slider.js.map +1 -1
- package/lib/cjs/utils/slider.js +5 -3
- package/lib/cjs/utils/slider.js.map +1 -1
- package/lib/esm/components/slider/Slider.js +30 -14
- package/lib/esm/components/slider/Slider.js.map +1 -1
- package/lib/esm/utils/slider.js +5 -3
- package/lib/esm/utils/slider.js.map +1 -1
- package/lib/types/utils/slider.d.ts +3 -1
- package/package.json +2 -2
|
@@ -80,51 +80,67 @@ const Slider = ({
|
|
|
80
80
|
if (!fromSliderRef.current || !toSliderRef.current) {
|
|
81
81
|
return;
|
|
82
82
|
}
|
|
83
|
-
|
|
84
|
-
|
|
83
|
+
let newValue = Number(event.target.value);
|
|
84
|
+
if (newValue > maxValue || newValue > maxValue - maxValue % steps) {
|
|
85
|
+
newValue = maxValue;
|
|
86
|
+
} else if (newValue < minValue) {
|
|
87
|
+
newValue = minValue;
|
|
88
|
+
} else {
|
|
89
|
+
newValue = Math.round(newValue / steps) * steps;
|
|
90
|
+
}
|
|
91
|
+
setFromValue(newValue);
|
|
85
92
|
const to = Number(toSliderRef.current.value);
|
|
86
93
|
if (typeof onChange === 'function') {
|
|
87
94
|
onChange(undefined, {
|
|
88
95
|
maxValue: to,
|
|
89
|
-
minValue:
|
|
96
|
+
minValue: newValue
|
|
90
97
|
});
|
|
91
98
|
}
|
|
92
99
|
(0, _slider.fillSlider)({
|
|
93
100
|
toSlider: toSliderRef.current,
|
|
94
101
|
fromSlider: fromSliderRef.current,
|
|
102
|
+
fromValue: newValue,
|
|
95
103
|
theme
|
|
96
104
|
});
|
|
97
|
-
if (
|
|
105
|
+
if (newValue > to) {
|
|
98
106
|
fromSliderRef.current.value = String(to);
|
|
99
107
|
} else {
|
|
100
|
-
fromSliderRef.current.value = String(
|
|
108
|
+
fromSliderRef.current.value = String(newValue);
|
|
101
109
|
}
|
|
102
|
-
}, [onChange, theme]);
|
|
110
|
+
}, [maxValue, minValue, onChange, steps, theme]);
|
|
103
111
|
const handleControlToSlider = (0, _react.useCallback)(event => {
|
|
104
112
|
void (0, _chaynsApi.setRefreshScrollEnabled)(false);
|
|
105
113
|
if (!fromSliderRef.current || !toSliderRef.current) {
|
|
106
114
|
return;
|
|
107
115
|
}
|
|
108
|
-
|
|
116
|
+
let newValue = Number(event.target.value);
|
|
117
|
+
if (newValue > maxValue || newValue > maxValue - maxValue % steps) {
|
|
118
|
+
newValue = maxValue;
|
|
119
|
+
} else if (newValue < minValue) {
|
|
120
|
+
newValue = minValue;
|
|
121
|
+
} else {
|
|
122
|
+
newValue = Math.round(newValue / steps) * steps;
|
|
123
|
+
}
|
|
124
|
+
setToValue(newValue);
|
|
109
125
|
const from = Number(fromSliderRef.current.value);
|
|
110
|
-
const to = Number(toSliderRef.current.value);
|
|
111
126
|
if (typeof onChange === 'function') {
|
|
112
127
|
onChange(undefined, {
|
|
113
|
-
maxValue:
|
|
128
|
+
maxValue: newValue,
|
|
114
129
|
minValue: from
|
|
115
130
|
});
|
|
116
131
|
}
|
|
117
132
|
(0, _slider.fillSlider)({
|
|
118
133
|
toSlider: toSliderRef.current,
|
|
119
134
|
fromSlider: fromSliderRef.current,
|
|
135
|
+
toValue: newValue,
|
|
120
136
|
theme
|
|
121
137
|
});
|
|
122
|
-
if (from <=
|
|
123
|
-
toSliderRef.current.value = String(
|
|
138
|
+
if (from <= newValue) {
|
|
139
|
+
toSliderRef.current.value = String(newValue);
|
|
124
140
|
} else {
|
|
125
141
|
toSliderRef.current.value = String(from);
|
|
126
142
|
}
|
|
127
|
-
}, [onChange, theme]);
|
|
143
|
+
}, [maxValue, minValue, onChange, steps, theme]);
|
|
128
144
|
(0, _react.useEffect)(() => {
|
|
129
145
|
if (!fromSliderRef.current || !toSliderRef.current || !interval) {
|
|
130
146
|
return;
|
|
@@ -282,14 +298,14 @@ const Slider = ({
|
|
|
282
298
|
$isInterval: !!interval,
|
|
283
299
|
type: "range",
|
|
284
300
|
value: toValue,
|
|
285
|
-
step:
|
|
301
|
+
step: 0.01,
|
|
286
302
|
max: maxValue,
|
|
287
303
|
min: minValue,
|
|
288
304
|
onTouchStart: handleTouchStart,
|
|
289
305
|
onTouchEnd: handleTouchEnd,
|
|
290
306
|
onChange: handleControlToSlider,
|
|
291
307
|
onMouseUp: handleMouseUp
|
|
292
|
-
})), [isBigSlider, interval, fromValue, maxValue, minValue, handleTouchStart, handleTouchEnd, handleInputChange, handleMouseUp, fromSliderThumbPosition, shouldShowThumbLabel, thumbWidth, fromSliderThumbContentPosition, thumbLabelFormatter, toSliderThumbPosition, toSliderThumbContentPosition, toValue,
|
|
308
|
+
})), [isBigSlider, interval, fromValue, maxValue, minValue, handleTouchStart, handleTouchEnd, handleInputChange, handleMouseUp, fromSliderThumbPosition, shouldShowThumbLabel, thumbWidth, fromSliderThumbContentPosition, thumbLabelFormatter, toSliderThumbPosition, toSliderThumbContentPosition, toValue, handleControlToSlider]);
|
|
293
309
|
};
|
|
294
310
|
Slider.displayName = 'Slider';
|
|
295
311
|
var _default = exports.default = Slider;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Slider.js","names":["_chaynsApi","require","_react","_interopRequireWildcard","_styledComponents","_useElementSize","_slider","_Slider","_getRequireWildcardCache","e","WeakMap","r","t","__esModule","default","has","get","n","__proto__","a","Object","defineProperty","getOwnPropertyDescriptor","u","hasOwnProperty","call","i","set","Slider","maxValue","minValue","value","onSelect","onChange","interval","thumbLabelFormatter","shouldShowThumbLabel","steps","fromValue","setFromValue","useState","toValue","setToValue","thumbWidth","setThumbWidth","isBigSlider","setIsBigSlider","fromSliderRef","useRef","toSliderRef","fromSliderThumbRef","toSliderThumbRef","fromSliderThumbContentRef","toSliderThumbContentRef","sliderWrapperRef","sliderWrapperSize","useElementSize","theme","useTheme","useEffect","getThumbMaxWidth","maxNumber","handleMouseUp","useCallback","_fromSliderRef$curren","_toSliderRef$current","setRefreshScrollEnabled","from","Number","current","to","undefined","handleControlFromSlider","event","target","fillSlider","toSlider","fromSlider","String","handleControlToSlider","handleInputChange","newValue","Math","round","fromSliderThumbPosition","useMemo","calculateGradientOffset","max","min","containerWidth","offsetWidth","toSliderThumbPosition","toSliderThumbContentPosition","calculatePopupPosition","sliderValue","popupWidth","fromSliderThumbContentPosition","handleTouchStart","handleTouchEnd","_fromSliderRef$curren2","_toSliderRef$current2","createElement","StyledSlider","ref","StyledSliderInput","animate","height","initial","exit","$thumbWidth","$isInterval","type","step","onTouchStart","onTouchEnd","onMouseUp","$max","$min","$value","StyledSliderThumb","$position","$isBigSlider","StyledSliderThumbLabel","$width","displayName","_default","exports"],"sources":["../../../../src/components/slider/Slider.tsx"],"sourcesContent":["import { setRefreshScrollEnabled } from 'chayns-api';\nimport React, { ChangeEvent, FC, useCallback, useEffect, useMemo, useRef, useState } from 'react';\nimport { useTheme } from 'styled-components';\nimport { useElementSize } from '../../hooks/useElementSize';\nimport {\n calculateGradientOffset,\n calculatePopupPosition,\n fillSlider,\n getThumbMaxWidth,\n} from '../../utils/slider';\nimport {\n StyledSlider,\n StyledSliderInput,\n StyledSliderThumb,\n StyledSliderThumbLabel,\n} from './Slider.styles';\n\nexport interface SliderInterval {\n maxValue: number;\n minValue: number;\n}\n\nexport type SliderProps = {\n /**\n * The range that can be selected with two thumbs..\n */\n interval?: SliderInterval;\n /**\n * The maximum value of the slider.\n */\n maxValue: number;\n /**\n * The minimum value of the slider.\n */\n minValue: number;\n /**\n * Function that will be executed when the value is selected.\n */\n onSelect?: (value?: number, interval?: SliderInterval) => void;\n /**\n * Function that will be executed when the value is changed.\n */\n onChange?: (value?: number, interval?: SliderInterval) => void;\n /**\n * Whether the current value should be displayed inside the slider thumb.\n */\n shouldShowThumbLabel?: boolean;\n /**\n * The steps of the slider.\n */\n steps?: number;\n /**\n * A function to format the thumb label.\n */\n thumbLabelFormatter?: (value: number) => string;\n /**\n * the Value that the slider should have.\n */\n value?: number;\n};\n\nconst Slider: FC<SliderProps> = ({\n maxValue,\n minValue,\n value,\n onSelect,\n onChange,\n interval,\n thumbLabelFormatter,\n shouldShowThumbLabel = false,\n steps = 1,\n}) => {\n const [fromValue, setFromValue] = useState(0);\n const [toValue, setToValue] = useState(maxValue);\n const [thumbWidth, setThumbWidth] = useState(20);\n const [isBigSlider, setIsBigSlider] = useState(false);\n\n const fromSliderRef = useRef<HTMLInputElement>(null);\n const toSliderRef = useRef<HTMLInputElement>(null);\n const fromSliderThumbRef = useRef<HTMLDivElement>(null);\n const toSliderThumbRef = useRef<HTMLDivElement>(null);\n const fromSliderThumbContentRef = useRef<HTMLDivElement>(null);\n const toSliderThumbContentRef = useRef<HTMLDivElement>(null);\n const sliderWrapperRef = useRef<HTMLDivElement>(null);\n\n const sliderWrapperSize = useElementSize(sliderWrapperRef);\n\n const theme = useTheme();\n\n useEffect(() => {\n if (shouldShowThumbLabel) {\n setThumbWidth(getThumbMaxWidth({ maxNumber: maxValue, thumbLabelFormatter }));\n }\n }, [maxValue, shouldShowThumbLabel, thumbLabelFormatter]);\n\n /**\n * This function sets the value\n */\n useEffect(() => {\n if (typeof value !== 'number') {\n return;\n }\n\n if (value >= minValue && value <= maxValue) {\n setFromValue(value);\n }\n }, [maxValue, minValue, value]);\n\n useEffect(() => {\n if (fromValue > toValue) {\n setFromValue(toValue);\n }\n\n if (toValue < fromValue) {\n setToValue(fromValue);\n }\n }, [fromValue, toValue]);\n\n const handleMouseUp = useCallback(() => {\n void setRefreshScrollEnabled(true);\n\n const from = Number(fromSliderRef.current?.value);\n const to = Number(toSliderRef.current?.value);\n\n if (typeof onSelect === 'function') {\n onSelect(\n interval ? undefined : from,\n interval ? { maxValue: to, minValue: from } : undefined,\n );\n }\n }, [interval, onSelect]);\n\n const handleControlFromSlider = useCallback(\n (event: ChangeEvent<HTMLInputElement>) => {\n if (!fromSliderRef.current || !toSliderRef.current) {\n return;\n }\n\n setFromValue(Number(event.target.value));\n\n const from = Number(fromSliderRef.current.value);\n const to = Number(toSliderRef.current.value);\n\n if (typeof onChange === 'function') {\n onChange(undefined, { maxValue: to, minValue: from });\n }\n\n fillSlider({\n toSlider: toSliderRef.current,\n fromSlider: fromSliderRef.current,\n theme,\n });\n\n if (from > to) {\n fromSliderRef.current.value = String(to);\n } else {\n fromSliderRef.current.value = String(from);\n }\n },\n [onChange, theme],\n );\n\n const handleControlToSlider = useCallback(\n (event: ChangeEvent<HTMLInputElement>) => {\n void setRefreshScrollEnabled(false);\n\n if (!fromSliderRef.current || !toSliderRef.current) {\n return;\n }\n\n setToValue(Number(event.target.value));\n\n const from = Number(fromSliderRef.current.value);\n const to = Number(toSliderRef.current.value);\n\n if (typeof onChange === 'function') {\n onChange(undefined, { maxValue: to, minValue: from });\n }\n\n fillSlider({\n toSlider: toSliderRef.current,\n fromSlider: fromSliderRef.current,\n theme,\n });\n\n if (from <= to) {\n toSliderRef.current.value = String(to);\n } else {\n toSliderRef.current.value = String(from);\n }\n },\n [onChange, theme],\n );\n\n useEffect(() => {\n if (!fromSliderRef.current || !toSliderRef.current || !interval) {\n return;\n }\n\n setFromValue(interval.minValue);\n setToValue(interval.maxValue);\n\n fromSliderRef.current.value = String(interval.minValue);\n toSliderRef.current.value = String(interval.maxValue);\n\n fillSlider({\n fromSlider: fromSliderRef.current,\n toSlider: toSliderRef.current,\n theme,\n });\n // Note: interval can´t be in the deps because of rerender\n // eslint-disable-next-line react-hooks/exhaustive-deps\n }, [theme]);\n\n /**\n * This function updates the value\n */\n const handleInputChange = useCallback(\n (event: ChangeEvent<HTMLInputElement>) => {\n void setRefreshScrollEnabled(false);\n\n let newValue = Number(event.target.value);\n\n if (newValue > maxValue || newValue > maxValue - (maxValue % steps)) {\n newValue = maxValue;\n } else if (newValue < minValue) {\n newValue = minValue;\n } else {\n newValue = Math.round(newValue / steps) * steps;\n }\n\n if (interval) {\n handleControlFromSlider(event);\n\n return;\n }\n\n setFromValue(newValue);\n\n if (onChange) {\n onChange(newValue);\n }\n },\n [handleControlFromSlider, interval, maxValue, minValue, onChange, steps],\n );\n\n const fromSliderThumbPosition = useMemo(() => {\n if (fromSliderRef.current && fromSliderThumbRef.current && sliderWrapperSize) {\n return calculateGradientOffset({\n max: maxValue,\n min: minValue,\n value: fromValue,\n thumbWidth: 20,\n containerWidth: fromSliderRef.current.offsetWidth,\n });\n }\n\n return 0;\n }, [fromValue, maxValue, minValue, sliderWrapperSize]);\n\n const toSliderThumbPosition = useMemo(() => {\n if (toSliderRef.current && toSliderThumbRef.current && sliderWrapperSize) {\n return calculateGradientOffset({\n max: maxValue,\n min: minValue,\n value: toValue,\n thumbWidth: 20,\n containerWidth: toSliderRef.current.offsetWidth,\n });\n }\n return 0;\n }, [toValue, minValue, maxValue, sliderWrapperSize]);\n\n const toSliderThumbContentPosition = useMemo(\n () =>\n calculatePopupPosition({\n min: minValue,\n max: maxValue,\n sliderValue: toValue,\n popupWidth: thumbWidth,\n }),\n [maxValue, minValue, thumbWidth, toValue],\n );\n\n const fromSliderThumbContentPosition = useMemo(\n () =>\n calculatePopupPosition({\n min: minValue,\n max: maxValue,\n sliderValue: fromValue,\n popupWidth: thumbWidth,\n }),\n [fromValue, maxValue, minValue, thumbWidth],\n );\n\n const handleTouchStart = useCallback(() => {\n if (shouldShowThumbLabel) {\n setIsBigSlider(true);\n }\n }, [shouldShowThumbLabel]);\n\n const handleTouchEnd = useCallback(() => {\n const from = Number(fromSliderRef.current?.value);\n const to = Number(toSliderRef.current?.value);\n\n if (typeof onSelect === 'function') {\n onSelect(\n interval ? undefined : from,\n interval ? { maxValue: to, minValue: from } : undefined,\n );\n }\n\n if (shouldShowThumbLabel) {\n setIsBigSlider(false);\n }\n }, [interval, onSelect, shouldShowThumbLabel]);\n\n return useMemo(\n () => (\n <StyledSlider ref={sliderWrapperRef}>\n <StyledSliderInput\n animate={{ height: isBigSlider ? 30 : 10 }}\n initial={{ height: 10 }}\n exit={{ height: 10 }}\n $thumbWidth={40}\n ref={fromSliderRef}\n $isInterval={!!interval}\n type=\"range\"\n value={fromValue}\n step={0.01}\n max={maxValue}\n min={minValue}\n onTouchStart={handleTouchStart}\n onTouchEnd={handleTouchEnd}\n onChange={handleInputChange}\n onMouseUp={handleMouseUp}\n $max={maxValue}\n $min={minValue}\n $value={fromValue}\n />\n <StyledSliderThumb\n ref={fromSliderThumbRef}\n $position={fromSliderThumbPosition}\n $isBigSlider={isBigSlider}\n >\n {shouldShowThumbLabel && (\n <StyledSliderThumbLabel\n $width={thumbWidth}\n $isBigSlider={isBigSlider}\n $position={fromSliderThumbContentPosition}\n ref={fromSliderThumbContentRef}\n >\n {typeof thumbLabelFormatter === 'function'\n ? thumbLabelFormatter(fromValue)\n : fromValue}\n </StyledSliderThumbLabel>\n )}\n </StyledSliderThumb>\n {interval && (\n <StyledSliderThumb\n ref={toSliderThumbRef}\n $position={toSliderThumbPosition}\n $isBigSlider={isBigSlider}\n >\n {shouldShowThumbLabel && (\n <StyledSliderThumbLabel\n $width={thumbWidth}\n $isBigSlider={isBigSlider}\n $position={toSliderThumbContentPosition}\n ref={toSliderThumbContentRef}\n >\n {typeof thumbLabelFormatter === 'function'\n ? thumbLabelFormatter(toValue)\n : toValue}\n </StyledSliderThumbLabel>\n )}\n </StyledSliderThumb>\n )}\n {interval && (\n <StyledSliderInput\n animate={{ height: isBigSlider ? 30 : 10 }}\n initial={{ height: 10 }}\n exit={{ height: 10 }}\n $thumbWidth={40}\n $max={maxValue}\n $min={minValue}\n $value={toValue}\n ref={toSliderRef}\n $isInterval={!!interval}\n type=\"range\"\n value={toValue}\n step={steps}\n max={maxValue}\n min={minValue}\n onTouchStart={handleTouchStart}\n onTouchEnd={handleTouchEnd}\n onChange={handleControlToSlider}\n onMouseUp={handleMouseUp}\n />\n )}\n </StyledSlider>\n ),\n [\n isBigSlider,\n interval,\n fromValue,\n maxValue,\n minValue,\n handleTouchStart,\n handleTouchEnd,\n handleInputChange,\n handleMouseUp,\n fromSliderThumbPosition,\n shouldShowThumbLabel,\n thumbWidth,\n fromSliderThumbContentPosition,\n thumbLabelFormatter,\n toSliderThumbPosition,\n toSliderThumbContentPosition,\n toValue,\n steps,\n handleControlToSlider,\n ],\n );\n};\n\nSlider.displayName = 'Slider';\n\nexport default Slider;\n"],"mappings":";;;;;;AAAA,IAAAA,UAAA,GAAAC,OAAA;AACA,IAAAC,MAAA,GAAAC,uBAAA,CAAAF,OAAA;AACA,IAAAG,iBAAA,GAAAH,OAAA;AACA,IAAAI,eAAA,GAAAJ,OAAA;AACA,IAAAK,OAAA,GAAAL,OAAA;AAMA,IAAAM,OAAA,GAAAN,OAAA;AAKyB,SAAAO,yBAAAC,CAAA,6BAAAC,OAAA,mBAAAC,CAAA,OAAAD,OAAA,IAAAE,CAAA,OAAAF,OAAA,YAAAF,wBAAA,YAAAA,CAAAC,CAAA,WAAAA,CAAA,GAAAG,CAAA,GAAAD,CAAA,KAAAF,CAAA;AAAA,SAAAN,wBAAAM,CAAA,EAAAE,CAAA,SAAAA,CAAA,IAAAF,CAAA,IAAAA,CAAA,CAAAI,UAAA,SAAAJ,CAAA,eAAAA,CAAA,uBAAAA,CAAA,yBAAAA,CAAA,WAAAK,OAAA,EAAAL,CAAA,QAAAG,CAAA,GAAAJ,wBAAA,CAAAG,CAAA,OAAAC,CAAA,IAAAA,CAAA,CAAAG,GAAA,CAAAN,CAAA,UAAAG,CAAA,CAAAI,GAAA,CAAAP,CAAA,OAAAQ,CAAA,KAAAC,SAAA,UAAAC,CAAA,GAAAC,MAAA,CAAAC,cAAA,IAAAD,MAAA,CAAAE,wBAAA,WAAAC,CAAA,IAAAd,CAAA,oBAAAc,CAAA,OAAAC,cAAA,CAAAC,IAAA,CAAAhB,CAAA,EAAAc,CAAA,SAAAG,CAAA,GAAAP,CAAA,GAAAC,MAAA,CAAAE,wBAAA,CAAAb,CAAA,EAAAc,CAAA,UAAAG,CAAA,KAAAA,CAAA,CAAAV,GAAA,IA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c,EACdlB,iBAAiB,EACjBlB,aAAa,EACbsB,uBAAuB,EACvBhD,oBAAoB,EACpBO,UAAU,EACVqD,8BAA8B,EAC9B7D,mBAAmB,EACnBwD,qBAAqB,EACrBC,4BAA4B,EAC5BnD,OAAO,EACPJ,KAAK,EACL0C,qBAAqB,CAE7B,CAAC;AACL,CAAC;AAEDnD,MAAM,CAACgG,WAAW,GAAG,QAAQ;AAAC,IAAAC,QAAA,GAAAC,OAAA,CAAAhH,OAAA,GAEfc,MAAM","ignoreList":[]}
|
|
1
|
+
{"version":3,"file":"Slider.js","names":["_chaynsApi","require","_react","_interopRequireWildcard","_styledComponents","_useElementSize","_slider","_Slider","_getRequireWildcardCache","e","WeakMap","r","t","__esModule","default","has","get","n","__proto__","a","Object","defineProperty","getOwnPropertyDescriptor","u","hasOwnProperty","call","i","set","Slider","maxValue","minValue","value","onSelect","onChange","interval","thumbLabelFormatter","shouldShowThumbLabel","steps","fromValue","setFromValue","useState","toValue","setToValue","thumbWidth","setThumbWidth","isBigSlider","setIsBigSlider","fromSliderRef","useRef","toSliderRef","fromSliderThumbRef","toSliderThumbRef","fromSliderThumbContentRef","toSliderThumbContentRef","sliderWrapperRef","sliderWrapperSize","useElementSize","theme","useTheme","useEffect","getThumbMaxWidth","maxNumber","handleMouseUp","useCallback","_fromSliderRef$curren","_toSliderRef$current","setRefreshScrollEnabled","from","Number","current","to","undefined","handleControlFromSlider","event","newValue","target","Math","round","fillSlider","toSlider","fromSlider","String","handleControlToSlider","handleInputChange","fromSliderThumbPosition","useMemo","calculateGradientOffset","max","min","containerWidth","offsetWidth","toSliderThumbPosition","toSliderThumbContentPosition","calculatePopupPosition","sliderValue","popupWidth","fromSliderThumbContentPosition","handleTouchStart","handleTouchEnd","_fromSliderRef$curren2","_toSliderRef$current2","createElement","StyledSlider","ref","StyledSliderInput","animate","height","initial","exit","$thumbWidth","$isInterval","type","step","onTouchStart","onTouchEnd","onMouseUp","$max","$min","$value","StyledSliderThumb","$position","$isBigSlider","StyledSliderThumbLabel","$width","displayName","_default","exports"],"sources":["../../../../src/components/slider/Slider.tsx"],"sourcesContent":["import { setRefreshScrollEnabled } from 'chayns-api';\nimport React, { ChangeEvent, FC, useCallback, useEffect, useMemo, useRef, useState } from 'react';\nimport { useTheme } from 'styled-components';\nimport { useElementSize } from '../../hooks/useElementSize';\nimport {\n calculateGradientOffset,\n calculatePopupPosition,\n fillSlider,\n getThumbMaxWidth,\n} from '../../utils/slider';\nimport {\n StyledSlider,\n StyledSliderInput,\n StyledSliderThumb,\n StyledSliderThumbLabel,\n} from './Slider.styles';\n\nexport interface SliderInterval {\n maxValue: number;\n minValue: number;\n}\n\nexport type SliderProps = {\n /**\n * The range that can be selected with two thumbs..\n */\n interval?: SliderInterval;\n /**\n * The maximum value of the slider.\n */\n maxValue: number;\n /**\n * The minimum value of the slider.\n */\n minValue: number;\n /**\n * Function that will be executed when the value is selected.\n */\n onSelect?: (value?: number, interval?: SliderInterval) => void;\n /**\n * Function that will be executed when the value is changed.\n */\n onChange?: (value?: number, interval?: SliderInterval) => void;\n /**\n * Whether the current value should be displayed inside the slider thumb.\n */\n shouldShowThumbLabel?: boolean;\n /**\n * The steps of the slider.\n */\n steps?: number;\n /**\n * A function to format the thumb label.\n */\n thumbLabelFormatter?: (value: number) => string;\n /**\n * the Value that the slider should have.\n */\n value?: number;\n};\n\nconst Slider: FC<SliderProps> = ({\n maxValue,\n minValue,\n value,\n onSelect,\n onChange,\n interval,\n thumbLabelFormatter,\n shouldShowThumbLabel = false,\n steps = 1,\n}) => {\n const [fromValue, setFromValue] = useState(0);\n const [toValue, setToValue] = useState(maxValue);\n const [thumbWidth, setThumbWidth] = useState(20);\n const [isBigSlider, setIsBigSlider] = useState(false);\n\n const fromSliderRef = useRef<HTMLInputElement>(null);\n const toSliderRef = useRef<HTMLInputElement>(null);\n const fromSliderThumbRef = useRef<HTMLDivElement>(null);\n const toSliderThumbRef = useRef<HTMLDivElement>(null);\n const fromSliderThumbContentRef = useRef<HTMLDivElement>(null);\n const toSliderThumbContentRef = useRef<HTMLDivElement>(null);\n const sliderWrapperRef = useRef<HTMLDivElement>(null);\n\n const sliderWrapperSize = useElementSize(sliderWrapperRef);\n\n const theme = useTheme();\n\n useEffect(() => {\n if (shouldShowThumbLabel) {\n setThumbWidth(getThumbMaxWidth({ maxNumber: maxValue, thumbLabelFormatter }));\n }\n }, [maxValue, shouldShowThumbLabel, thumbLabelFormatter]);\n\n /**\n * This function sets the value\n */\n useEffect(() => {\n if (typeof value !== 'number') {\n return;\n }\n\n if (value >= minValue && value <= maxValue) {\n setFromValue(value);\n }\n }, [maxValue, minValue, value]);\n\n useEffect(() => {\n if (fromValue > toValue) {\n setFromValue(toValue);\n }\n\n if (toValue < fromValue) {\n setToValue(fromValue);\n }\n }, [fromValue, toValue]);\n\n const handleMouseUp = useCallback(() => {\n void setRefreshScrollEnabled(true);\n\n const from = Number(fromSliderRef.current?.value);\n const to = Number(toSliderRef.current?.value);\n\n if (typeof onSelect === 'function') {\n onSelect(\n interval ? undefined : from,\n interval ? { maxValue: to, minValue: from } : undefined,\n );\n }\n }, [interval, onSelect]);\n\n const handleControlFromSlider = useCallback(\n (event: ChangeEvent<HTMLInputElement>) => {\n if (!fromSliderRef.current || !toSliderRef.current) {\n return;\n }\n\n let newValue = Number(event.target.value);\n\n if (newValue > maxValue || newValue > maxValue - (maxValue % steps)) {\n newValue = maxValue;\n } else if (newValue < minValue) {\n newValue = minValue;\n } else {\n newValue = Math.round(newValue / steps) * steps;\n }\n\n setFromValue(newValue);\n\n const to = Number(toSliderRef.current.value);\n\n if (typeof onChange === 'function') {\n onChange(undefined, { maxValue: to, minValue: newValue });\n }\n\n fillSlider({\n toSlider: toSliderRef.current,\n fromSlider: fromSliderRef.current,\n fromValue: newValue,\n theme,\n });\n\n if (newValue > to) {\n fromSliderRef.current.value = String(to);\n } else {\n fromSliderRef.current.value = String(newValue);\n }\n },\n [maxValue, minValue, onChange, steps, theme],\n );\n\n const handleControlToSlider = useCallback(\n (event: ChangeEvent<HTMLInputElement>) => {\n void setRefreshScrollEnabled(false);\n\n if (!fromSliderRef.current || !toSliderRef.current) {\n return;\n }\n\n let newValue = Number(event.target.value);\n\n if (newValue > maxValue || newValue > maxValue - (maxValue % steps)) {\n newValue = maxValue;\n } else if (newValue < minValue) {\n newValue = minValue;\n } else {\n newValue = Math.round(newValue / steps) * steps;\n }\n\n setToValue(newValue);\n\n const from = Number(fromSliderRef.current.value);\n\n if (typeof onChange === 'function') {\n onChange(undefined, { maxValue: newValue, minValue: from });\n }\n\n fillSlider({\n toSlider: toSliderRef.current,\n fromSlider: fromSliderRef.current,\n toValue: newValue,\n theme,\n });\n\n if (from <= newValue) {\n toSliderRef.current.value = String(newValue);\n } else {\n toSliderRef.current.value = String(from);\n }\n },\n [maxValue, minValue, onChange, steps, theme],\n );\n\n useEffect(() => {\n if (!fromSliderRef.current || !toSliderRef.current || !interval) {\n return;\n }\n\n setFromValue(interval.minValue);\n setToValue(interval.maxValue);\n\n fromSliderRef.current.value = String(interval.minValue);\n toSliderRef.current.value = String(interval.maxValue);\n\n fillSlider({\n fromSlider: fromSliderRef.current,\n toSlider: toSliderRef.current,\n theme,\n });\n // Note: interval can´t be in the deps because of rerender\n // eslint-disable-next-line react-hooks/exhaustive-deps\n }, [theme]);\n\n /**\n * This function updates the value\n */\n const handleInputChange = useCallback(\n (event: ChangeEvent<HTMLInputElement>) => {\n void setRefreshScrollEnabled(false);\n\n let newValue = Number(event.target.value);\n\n if (newValue > maxValue || newValue > maxValue - (maxValue % steps)) {\n newValue = maxValue;\n } else if (newValue < minValue) {\n newValue = minValue;\n } else {\n newValue = Math.round(newValue / steps) * steps;\n }\n\n if (interval) {\n handleControlFromSlider(event);\n\n return;\n }\n\n setFromValue(newValue);\n\n if (onChange) {\n onChange(newValue);\n }\n },\n [handleControlFromSlider, interval, maxValue, minValue, onChange, steps],\n );\n\n const fromSliderThumbPosition = useMemo(() => {\n if (fromSliderRef.current && fromSliderThumbRef.current && sliderWrapperSize) {\n return calculateGradientOffset({\n max: maxValue,\n min: minValue,\n value: fromValue,\n thumbWidth: 20,\n containerWidth: fromSliderRef.current.offsetWidth,\n });\n }\n\n return 0;\n }, [fromValue, maxValue, minValue, sliderWrapperSize]);\n\n const toSliderThumbPosition = useMemo(() => {\n if (toSliderRef.current && toSliderThumbRef.current && sliderWrapperSize) {\n return calculateGradientOffset({\n max: maxValue,\n min: minValue,\n value: toValue,\n thumbWidth: 20,\n containerWidth: toSliderRef.current.offsetWidth,\n });\n }\n return 0;\n }, [toValue, minValue, maxValue, sliderWrapperSize]);\n\n const toSliderThumbContentPosition = useMemo(\n () =>\n calculatePopupPosition({\n min: minValue,\n max: maxValue,\n sliderValue: toValue,\n popupWidth: thumbWidth,\n }),\n [maxValue, minValue, thumbWidth, toValue],\n );\n\n const fromSliderThumbContentPosition = useMemo(\n () =>\n calculatePopupPosition({\n min: minValue,\n max: maxValue,\n sliderValue: fromValue,\n popupWidth: thumbWidth,\n }),\n [fromValue, maxValue, minValue, thumbWidth],\n );\n\n const handleTouchStart = useCallback(() => {\n if (shouldShowThumbLabel) {\n setIsBigSlider(true);\n }\n }, [shouldShowThumbLabel]);\n\n const handleTouchEnd = useCallback(() => {\n const from = Number(fromSliderRef.current?.value);\n const to = Number(toSliderRef.current?.value);\n\n if (typeof onSelect === 'function') {\n onSelect(\n interval ? undefined : from,\n interval ? { maxValue: to, minValue: from } : undefined,\n );\n }\n\n if (shouldShowThumbLabel) {\n setIsBigSlider(false);\n }\n }, [interval, onSelect, shouldShowThumbLabel]);\n\n return useMemo(\n () => (\n <StyledSlider ref={sliderWrapperRef}>\n <StyledSliderInput\n animate={{ height: isBigSlider ? 30 : 10 }}\n initial={{ height: 10 }}\n exit={{ height: 10 }}\n $thumbWidth={40}\n ref={fromSliderRef}\n $isInterval={!!interval}\n type=\"range\"\n value={fromValue}\n step={0.01}\n max={maxValue}\n min={minValue}\n onTouchStart={handleTouchStart}\n onTouchEnd={handleTouchEnd}\n onChange={handleInputChange}\n onMouseUp={handleMouseUp}\n $max={maxValue}\n $min={minValue}\n $value={fromValue}\n />\n <StyledSliderThumb\n ref={fromSliderThumbRef}\n $position={fromSliderThumbPosition}\n $isBigSlider={isBigSlider}\n >\n {shouldShowThumbLabel && (\n <StyledSliderThumbLabel\n $width={thumbWidth}\n $isBigSlider={isBigSlider}\n $position={fromSliderThumbContentPosition}\n ref={fromSliderThumbContentRef}\n >\n {typeof thumbLabelFormatter === 'function'\n ? thumbLabelFormatter(fromValue)\n : fromValue}\n </StyledSliderThumbLabel>\n )}\n </StyledSliderThumb>\n {interval && (\n <StyledSliderThumb\n ref={toSliderThumbRef}\n $position={toSliderThumbPosition}\n $isBigSlider={isBigSlider}\n >\n {shouldShowThumbLabel && (\n <StyledSliderThumbLabel\n $width={thumbWidth}\n $isBigSlider={isBigSlider}\n $position={toSliderThumbContentPosition}\n ref={toSliderThumbContentRef}\n >\n {typeof thumbLabelFormatter === 'function'\n ? thumbLabelFormatter(toValue)\n : toValue}\n </StyledSliderThumbLabel>\n )}\n </StyledSliderThumb>\n )}\n {interval && (\n <StyledSliderInput\n animate={{ height: isBigSlider ? 30 : 10 }}\n initial={{ height: 10 }}\n exit={{ height: 10 }}\n $thumbWidth={40}\n $max={maxValue}\n $min={minValue}\n $value={toValue}\n ref={toSliderRef}\n $isInterval={!!interval}\n type=\"range\"\n value={toValue}\n step={0.01}\n max={maxValue}\n min={minValue}\n onTouchStart={handleTouchStart}\n onTouchEnd={handleTouchEnd}\n onChange={handleControlToSlider}\n onMouseUp={handleMouseUp}\n />\n )}\n </StyledSlider>\n ),\n [\n isBigSlider,\n interval,\n fromValue,\n maxValue,\n minValue,\n handleTouchStart,\n handleTouchEnd,\n handleInputChange,\n handleMouseUp,\n fromSliderThumbPosition,\n shouldShowThumbLabel,\n thumbWidth,\n fromSliderThumbContentPosition,\n thumbLabelFormatter,\n toSliderThumbPosition,\n toSliderThumbContentPosition,\n toValue,\n handleControlToSlider,\n ],\n );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AE;IAAG,CAAE;IACrBG,WAAW,EAAE,EAAG;IAChBO,IAAI,EAAEvF,QAAS;IACfwF,IAAI,EAAEvF,QAAS;IACfwF,MAAM,EAAE7E,OAAQ;IAChB8D,GAAG,EAAEtD,WAAY;IACjB6D,WAAW,EAAE,CAAC,CAAC5E,QAAS;IACxB6E,IAAI,EAAC,OAAO;IACZhF,KAAK,EAAEU,OAAQ;IACfuE,IAAI,EAAE,IAAK;IACXzB,GAAG,EAAE1D,QAAS;IACd2D,GAAG,EAAE1D,QAAS;IACdmF,YAAY,EAAEhB,gBAAiB;IAC/BiB,UAAU,EAAEhB,cAAe;IAC3BjE,QAAQ,EAAEiD,qBAAsB;IAChCiC,SAAS,EAAErD;EAAc,CAC5B,CAEK,CACjB,EACD,CACIjB,WAAW,EACXX,QAAQ,EACRI,SAAS,EACTT,QAAQ,EACRC,QAAQ,EACRmE,gBAAgB,EAChBC,cAAc,EACdf,iBAAiB,EACjBrB,aAAa,EACbsB,uBAAuB,EACvBhD,oBAAoB,EACpBO,UAAU,EACVqD,8BAA8B,EAC9B7D,mBAAmB,EACnBwD,qBAAqB,EACrBC,4BAA4B,EAC5BnD,OAAO,EACPyC,qBAAqB,CAE7B,CAAC;AACL,CAAC;AAEDtD,MAAM,CAACgG,WAAW,GAAG,QAAQ;AAAC,IAAAC,QAAA,GAAAC,OAAA,CAAAhH,OAAA,GAEfc,MAAM","ignoreList":[]}
|
package/lib/cjs/utils/slider.js
CHANGED
|
@@ -7,11 +7,13 @@ exports.getThumbMaxWidth = exports.fillSlider = exports.calculatePopupPosition =
|
|
|
7
7
|
const fillSlider = ({
|
|
8
8
|
fromSlider,
|
|
9
9
|
toSlider,
|
|
10
|
-
theme
|
|
10
|
+
theme,
|
|
11
|
+
fromValue,
|
|
12
|
+
toValue
|
|
11
13
|
}) => {
|
|
12
14
|
const rangeDistance = Number(toSlider.max) - Number(toSlider.min);
|
|
13
|
-
const fromPosition = Number(fromSlider.value) - Number(toSlider.min);
|
|
14
|
-
const toPosition = Number(toSlider.value) - Number(toSlider.min);
|
|
15
|
+
const fromPosition = Number(fromValue ?? fromSlider.value) - Number(toSlider.min);
|
|
16
|
+
const toPosition = Number(toValue ?? toSlider.value) - Number(toSlider.min);
|
|
15
17
|
const backgroundColor = theme['403'];
|
|
16
18
|
const trackColor = theme['409'];
|
|
17
19
|
if (!backgroundColor || !trackColor) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"slider.js","names":["fillSlider","fromSlider","toSlider","theme","rangeDistance","Number","max","min","fromPosition","value","toPosition","backgroundColor","trackColor","gradient","style","background","exports","calculateGradientOffset","thumbWidth","containerWidth","percentage","adjustedWidth","calculatePopupPosition","sliderValue","popupWidth","leftAtMin","leftAtMax","getThumbMaxWidth","maxNumber","thumbLabelFormatter","element","document","createElement","height","display","padding","whiteSpace","minWidth","opacity","position","textContent","String","body","appendChild","width","offsetWidth","removeChild"],"sources":["../../../src/utils/slider.ts"],"sourcesContent":["import type { Theme } from '../components/color-scheme-provider/ColorSchemeProvider';\n\nexport interface FillSlider {\n fromSlider: HTMLInputElement;\n toSlider: HTMLInputElement;\n theme: Theme;\n}\n\nexport const fillSlider = ({ fromSlider, toSlider, theme }: FillSlider) => {\n const rangeDistance = Number(toSlider.max) - Number(toSlider.min);\n const fromPosition = Number(fromSlider.value) - Number(toSlider.min);\n const toPosition = Number(toSlider.value) - Number(toSlider.min);\n\n const backgroundColor = theme['403'];\n const trackColor = theme['409'];\n\n if (!backgroundColor || !trackColor) {\n return;\n }\n\n const gradient = `linear-gradient(\n to right,\n ${backgroundColor} 0%,\n ${backgroundColor} ${(fromPosition / rangeDistance) * 100}%,\n ${trackColor} ${(fromPosition / rangeDistance) * 100}%,\n ${trackColor} ${(toPosition / rangeDistance) * 100}%,\n ${backgroundColor} ${(toPosition / rangeDistance) * 100}%,\n ${backgroundColor} 100%)`;\n\n // Apply the gradient to the appropriate slider\n // eslint-disable-next-line no-param-reassign\n toSlider.style.background = gradient;\n // eslint-disable-next-line no-param-reassign\n fromSlider.style.background = gradient;\n};\n\ninterface CalculateGradientOffset {\n value: number;\n min: number;\n max: number;\n thumbWidth: number;\n containerWidth: number;\n}\n\nexport const calculateGradientOffset = ({\n value,\n min,\n max,\n thumbWidth,\n containerWidth,\n}: CalculateGradientOffset): number => {\n const percentage = (value - min) / (max - min);\n\n const adjustedWidth = containerWidth - thumbWidth / 2;\n\n return percentage * adjustedWidth + thumbWidth / 2;\n};\n\ninterface GetThumbMaxWidthOptions {\n maxNumber: number;\n thumbLabelFormatter?: (value: number) => string;\n}\n\ninterface CalculatePopupPositionOptions {\n sliderValue: number;\n min: number;\n max: number;\n popupWidth: number;\n}\n\nexport const calculatePopupPosition = ({\n sliderValue,\n min,\n max,\n popupWidth,\n}: CalculatePopupPositionOptions) => {\n // Berechnung des Prozentwerts des Sliders zwischen min und max\n const percentage = (sliderValue - min) / (max - min);\n\n // Berechnung des linken Versatzes bei 0% (-10px) und bei 100% (-popupWidth + 20px)\n const leftAtMin = -10;\n const leftAtMax = -popupWidth + 25;\n\n // Berechnung des dynamischen Left-Werts basierend auf dem Slider-Prozentwert\n return leftAtMin + percentage * (leftAtMax - leftAtMin);\n};\n\nexport const getThumbMaxWidth = ({ maxNumber, thumbLabelFormatter }: GetThumbMaxWidthOptions) => {\n const element = document.createElement('span');\n\n element.style.height = '20px';\n element.style.display = 'flex';\n element.style.padding = '16px';\n element.style.whiteSpace = 'nowrap';\n element.style.minWidth = '20px';\n element.style.opacity = '0';\n element.style.position = 'absolute';\n\n element.textContent =\n typeof thumbLabelFormatter === 'function'\n ? thumbLabelFormatter(maxNumber)\n : String(maxNumber);\n\n document.body.appendChild(element);\n\n const width = element.offsetWidth;\n\n document.body.removeChild(element);\n\n return width;\n};\n"],"mappings":";;;;;;
|
|
1
|
+
{"version":3,"file":"slider.js","names":["fillSlider","fromSlider","toSlider","theme","fromValue","toValue","rangeDistance","Number","max","min","fromPosition","value","toPosition","backgroundColor","trackColor","gradient","style","background","exports","calculateGradientOffset","thumbWidth","containerWidth","percentage","adjustedWidth","calculatePopupPosition","sliderValue","popupWidth","leftAtMin","leftAtMax","getThumbMaxWidth","maxNumber","thumbLabelFormatter","element","document","createElement","height","display","padding","whiteSpace","minWidth","opacity","position","textContent","String","body","appendChild","width","offsetWidth","removeChild"],"sources":["../../../src/utils/slider.ts"],"sourcesContent":["import type { Theme } from '../components/color-scheme-provider/ColorSchemeProvider';\n\nexport interface FillSlider {\n fromSlider: HTMLInputElement;\n toSlider: HTMLInputElement;\n fromValue?: number;\n toValue?: number;\n theme: Theme;\n}\n\nexport const fillSlider = ({ fromSlider, toSlider, theme, fromValue, toValue }: FillSlider) => {\n const rangeDistance = Number(toSlider.max) - Number(toSlider.min);\n const fromPosition = Number(fromValue ?? fromSlider.value) - Number(toSlider.min);\n const toPosition = Number(toValue ?? toSlider.value) - Number(toSlider.min);\n\n const backgroundColor = theme['403'];\n const trackColor = theme['409'];\n\n if (!backgroundColor || !trackColor) {\n return;\n }\n\n const gradient = `linear-gradient(\n to right,\n ${backgroundColor} 0%,\n ${backgroundColor} ${(fromPosition / rangeDistance) * 100}%,\n ${trackColor} ${(fromPosition / rangeDistance) * 100}%,\n ${trackColor} ${(toPosition / rangeDistance) * 100}%,\n ${backgroundColor} ${(toPosition / rangeDistance) * 100}%,\n ${backgroundColor} 100%)`;\n\n // Apply the gradient to the appropriate slider\n // eslint-disable-next-line no-param-reassign\n toSlider.style.background = gradient;\n // eslint-disable-next-line no-param-reassign\n fromSlider.style.background = gradient;\n};\n\ninterface CalculateGradientOffset {\n value: number;\n min: number;\n max: number;\n thumbWidth: number;\n containerWidth: number;\n}\n\nexport const calculateGradientOffset = ({\n value,\n min,\n max,\n thumbWidth,\n containerWidth,\n}: CalculateGradientOffset): number => {\n const percentage = (value - min) / (max - min);\n\n const adjustedWidth = containerWidth - thumbWidth / 2;\n\n return percentage * adjustedWidth + thumbWidth / 2;\n};\n\ninterface GetThumbMaxWidthOptions {\n maxNumber: number;\n thumbLabelFormatter?: (value: number) => string;\n}\n\ninterface CalculatePopupPositionOptions {\n sliderValue: number;\n min: number;\n max: number;\n popupWidth: number;\n}\n\nexport const calculatePopupPosition = ({\n sliderValue,\n min,\n max,\n popupWidth,\n}: CalculatePopupPositionOptions) => {\n // Berechnung des Prozentwerts des Sliders zwischen min und max\n const percentage = (sliderValue - min) / (max - min);\n\n // Berechnung des linken Versatzes bei 0% (-10px) und bei 100% (-popupWidth + 20px)\n const leftAtMin = -10;\n const leftAtMax = -popupWidth + 25;\n\n // Berechnung des dynamischen Left-Werts basierend auf dem Slider-Prozentwert\n return leftAtMin + percentage * (leftAtMax - leftAtMin);\n};\n\nexport const getThumbMaxWidth = ({ maxNumber, thumbLabelFormatter }: GetThumbMaxWidthOptions) => {\n const element = document.createElement('span');\n\n element.style.height = '20px';\n element.style.display = 'flex';\n element.style.padding = '16px';\n element.style.whiteSpace = 'nowrap';\n element.style.minWidth = '20px';\n element.style.opacity = '0';\n element.style.position = 'absolute';\n\n element.textContent =\n typeof thumbLabelFormatter === 'function'\n ? thumbLabelFormatter(maxNumber)\n : String(maxNumber);\n\n document.body.appendChild(element);\n\n const width = element.offsetWidth;\n\n document.body.removeChild(element);\n\n return width;\n};\n"],"mappings":";;;;;;AAUO,MAAMA,UAAU,GAAGA,CAAC;EAAEC,UAAU;EAAEC,QAAQ;EAAEC,KAAK;EAAEC,SAAS;EAAEC;AAAoB,CAAC,KAAK;EAC3F,MAAMC,aAAa,GAAGC,MAAM,CAACL,QAAQ,CAACM,GAAG,CAAC,GAAGD,MAAM,CAACL,QAAQ,CAACO,GAAG,CAAC;EACjE,MAAMC,YAAY,GAAGH,MAAM,CAACH,SAAS,IAAIH,UAAU,CAACU,KAAK,CAAC,GAAGJ,MAAM,CAACL,QAAQ,CAACO,GAAG,CAAC;EACjF,MAAMG,UAAU,GAAGL,MAAM,CAACF,OAAO,IAAIH,QAAQ,CAACS,KAAK,CAAC,GAAGJ,MAAM,CAACL,QAAQ,CAACO,G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
|
75
|
+
let newValue = Number(event.target.value);
|
|
76
|
+
if (newValue > maxValue || newValue > maxValue - maxValue % steps) {
|
|
77
|
+
newValue = maxValue;
|
|
78
|
+
} else if (newValue < minValue) {
|
|
79
|
+
newValue = minValue;
|
|
80
|
+
} else {
|
|
81
|
+
newValue = Math.round(newValue / steps) * steps;
|
|
82
|
+
}
|
|
83
|
+
setFromValue(newValue);
|
|
77
84
|
const to = Number(toSliderRef.current.value);
|
|
78
85
|
if (typeof onChange === 'function') {
|
|
79
86
|
onChange(undefined, {
|
|
80
87
|
maxValue: to,
|
|
81
|
-
minValue:
|
|
88
|
+
minValue: newValue
|
|
82
89
|
});
|
|
83
90
|
}
|
|
84
91
|
fillSlider({
|
|
85
92
|
toSlider: toSliderRef.current,
|
|
86
93
|
fromSlider: fromSliderRef.current,
|
|
94
|
+
fromValue: newValue,
|
|
87
95
|
theme
|
|
88
96
|
});
|
|
89
|
-
if (
|
|
97
|
+
if (newValue > to) {
|
|
90
98
|
fromSliderRef.current.value = String(to);
|
|
91
99
|
} else {
|
|
92
|
-
fromSliderRef.current.value = String(
|
|
100
|
+
fromSliderRef.current.value = String(newValue);
|
|
93
101
|
}
|
|
94
|
-
}, [onChange, theme]);
|
|
102
|
+
}, [maxValue, minValue, onChange, steps, theme]);
|
|
95
103
|
const handleControlToSlider = useCallback(event => {
|
|
96
104
|
void setRefreshScrollEnabled(false);
|
|
97
105
|
if (!fromSliderRef.current || !toSliderRef.current) {
|
|
98
106
|
return;
|
|
99
107
|
}
|
|
100
|
-
|
|
108
|
+
let newValue = Number(event.target.value);
|
|
109
|
+
if (newValue > maxValue || newValue > maxValue - maxValue % steps) {
|
|
110
|
+
newValue = maxValue;
|
|
111
|
+
} else if (newValue < minValue) {
|
|
112
|
+
newValue = minValue;
|
|
113
|
+
} else {
|
|
114
|
+
newValue = Math.round(newValue / steps) * steps;
|
|
115
|
+
}
|
|
116
|
+
setToValue(newValue);
|
|
101
117
|
const from = Number(fromSliderRef.current.value);
|
|
102
|
-
const to = Number(toSliderRef.current.value);
|
|
103
118
|
if (typeof onChange === 'function') {
|
|
104
119
|
onChange(undefined, {
|
|
105
|
-
maxValue:
|
|
120
|
+
maxValue: newValue,
|
|
106
121
|
minValue: from
|
|
107
122
|
});
|
|
108
123
|
}
|
|
109
124
|
fillSlider({
|
|
110
125
|
toSlider: toSliderRef.current,
|
|
111
126
|
fromSlider: fromSliderRef.current,
|
|
127
|
+
toValue: newValue,
|
|
112
128
|
theme
|
|
113
129
|
});
|
|
114
|
-
if (from <=
|
|
115
|
-
toSliderRef.current.value = String(
|
|
130
|
+
if (from <= newValue) {
|
|
131
|
+
toSliderRef.current.value = String(newValue);
|
|
116
132
|
} else {
|
|
117
133
|
toSliderRef.current.value = String(from);
|
|
118
134
|
}
|
|
119
|
-
}, [onChange, theme]);
|
|
135
|
+
}, [maxValue, minValue, onChange, steps, theme]);
|
|
120
136
|
useEffect(() => {
|
|
121
137
|
if (!fromSliderRef.current || !toSliderRef.current || !interval) {
|
|
122
138
|
return;
|
|
@@ -273,14 +289,14 @@ const Slider = _ref => {
|
|
|
273
289
|
$isInterval: !!interval,
|
|
274
290
|
type: "range",
|
|
275
291
|
value: toValue,
|
|
276
|
-
step:
|
|
292
|
+
step: 0.01,
|
|
277
293
|
max: maxValue,
|
|
278
294
|
min: minValue,
|
|
279
295
|
onTouchStart: handleTouchStart,
|
|
280
296
|
onTouchEnd: handleTouchEnd,
|
|
281
297
|
onChange: handleControlToSlider,
|
|
282
298
|
onMouseUp: handleMouseUp
|
|
283
|
-
})), [isBigSlider, interval, fromValue, maxValue, minValue, handleTouchStart, handleTouchEnd, handleInputChange, handleMouseUp, fromSliderThumbPosition, shouldShowThumbLabel, thumbWidth, fromSliderThumbContentPosition, thumbLabelFormatter, toSliderThumbPosition, toSliderThumbContentPosition, toValue,
|
|
299
|
+
})), [isBigSlider, interval, fromValue, maxValue, minValue, handleTouchStart, handleTouchEnd, handleInputChange, handleMouseUp, fromSliderThumbPosition, shouldShowThumbLabel, thumbWidth, fromSliderThumbContentPosition, thumbLabelFormatter, toSliderThumbPosition, toSliderThumbContentPosition, toValue, handleControlToSlider]);
|
|
284
300
|
};
|
|
285
301
|
Slider.displayName = 'Slider';
|
|
286
302
|
export default Slider;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Slider.js","names":["setRefreshScrollEnabled","React","useCallback","useEffect","useMemo","useRef","useState","useTheme","useElementSize","calculateGradientOffset","calculatePopupPosition","fillSlider","getThumbMaxWidth","StyledSlider","StyledSliderInput","StyledSliderThumb","StyledSliderThumbLabel","Slider","_ref","maxValue","minValue","value","onSelect","onChange","interval","thumbLabelFormatter","shouldShowThumbLabel","steps","fromValue","setFromValue","toValue","setToValue","thumbWidth","setThumbWidth","isBigSlider","setIsBigSlider","fromSliderRef","toSliderRef","fromSliderThumbRef","toSliderThumbRef","fromSliderThumbContentRef","toSliderThumbContentRef","sliderWrapperRef","sliderWrapperSize","theme","maxNumber","handleMouseUp","from","Number","current","to","undefined","handleControlFromSlider","event","target","toSlider","fromSlider","String","handleControlToSlider","handleInputChange","newValue","Math","round","fromSliderThumbPosition","max","min","containerWidth","offsetWidth","toSliderThumbPosition","toSliderThumbContentPosition","sliderValue","popupWidth","fromSliderThumbContentPosition","handleTouchStart","handleTouchEnd","createElement","ref","animate","height","initial","exit","$thumbWidth","$isInterval","type","step","onTouchStart","onTouchEnd","onMouseUp","$max","$min","$value","$position","$isBigSlider","$width","displayName"],"sources":["../../../../src/components/slider/Slider.tsx"],"sourcesContent":["import { setRefreshScrollEnabled } from 'chayns-api';\nimport React, { ChangeEvent, FC, useCallback, useEffect, useMemo, useRef, useState } from 'react';\nimport { useTheme } from 'styled-components';\nimport { useElementSize } from '../../hooks/useElementSize';\nimport {\n calculateGradientOffset,\n calculatePopupPosition,\n fillSlider,\n getThumbMaxWidth,\n} from '../../utils/slider';\nimport {\n StyledSlider,\n StyledSliderInput,\n StyledSliderThumb,\n StyledSliderThumbLabel,\n} from './Slider.styles';\n\nexport interface SliderInterval {\n maxValue: number;\n minValue: number;\n}\n\nexport type SliderProps = {\n /**\n * The range that can be selected with two thumbs..\n */\n interval?: SliderInterval;\n /**\n * The maximum value of the slider.\n */\n maxValue: number;\n /**\n * The minimum value of the slider.\n */\n minValue: number;\n /**\n * Function that will be executed when the value is selected.\n */\n onSelect?: (value?: number, interval?: SliderInterval) => void;\n /**\n * Function that will be executed when the value is changed.\n */\n onChange?: (value?: number, interval?: SliderInterval) => void;\n /**\n * Whether the current value should be displayed inside the slider thumb.\n */\n shouldShowThumbLabel?: boolean;\n /**\n * The steps of the slider.\n */\n steps?: number;\n /**\n * A function to format the thumb label.\n */\n thumbLabelFormatter?: (value: number) => string;\n /**\n * the Value that the slider should have.\n */\n value?: number;\n};\n\nconst Slider: FC<SliderProps> = ({\n maxValue,\n minValue,\n value,\n onSelect,\n onChange,\n interval,\n thumbLabelFormatter,\n shouldShowThumbLabel = false,\n steps = 1,\n}) => {\n const [fromValue, setFromValue] = useState(0);\n const [toValue, setToValue] = useState(maxValue);\n const [thumbWidth, setThumbWidth] = useState(20);\n const [isBigSlider, setIsBigSlider] = useState(false);\n\n const fromSliderRef = useRef<HTMLInputElement>(null);\n const toSliderRef = useRef<HTMLInputElement>(null);\n const fromSliderThumbRef = useRef<HTMLDivElement>(null);\n const toSliderThumbRef = useRef<HTMLDivElement>(null);\n const fromSliderThumbContentRef = useRef<HTMLDivElement>(null);\n const toSliderThumbContentRef = useRef<HTMLDivElement>(null);\n const sliderWrapperRef = useRef<HTMLDivElement>(null);\n\n const sliderWrapperSize = useElementSize(sliderWrapperRef);\n\n const theme = useTheme();\n\n useEffect(() => {\n if (shouldShowThumbLabel) {\n setThumbWidth(getThumbMaxWidth({ maxNumber: maxValue, thumbLabelFormatter }));\n }\n }, [maxValue, shouldShowThumbLabel, thumbLabelFormatter]);\n\n /**\n * This function sets the value\n */\n useEffect(() => {\n if (typeof value !== 'number') {\n return;\n }\n\n if (value >= minValue && value <= maxValue) {\n setFromValue(value);\n }\n }, [maxValue, minValue, value]);\n\n useEffect(() => {\n if (fromValue > toValue) {\n setFromValue(toValue);\n }\n\n if (toValue < fromValue) {\n setToValue(fromValue);\n }\n }, [fromValue, toValue]);\n\n const handleMouseUp = useCallback(() => {\n void setRefreshScrollEnabled(true);\n\n const from = Number(fromSliderRef.current?.value);\n const to = Number(toSliderRef.current?.value);\n\n if (typeof onSelect === 'function') {\n onSelect(\n interval ? undefined : from,\n interval ? { maxValue: to, minValue: from } : undefined,\n );\n }\n }, [interval, onSelect]);\n\n const handleControlFromSlider = useCallback(\n (event: ChangeEvent<HTMLInputElement>) => {\n if (!fromSliderRef.current || !toSliderRef.current) {\n return;\n }\n\n setFromValue(Number(event.target.value));\n\n const from = Number(fromSliderRef.current.value);\n const to = Number(toSliderRef.current.value);\n\n if (typeof onChange === 'function') {\n onChange(undefined, { maxValue: to, minValue: from });\n }\n\n fillSlider({\n toSlider: toSliderRef.current,\n fromSlider: fromSliderRef.current,\n theme,\n });\n\n if (from > to) {\n fromSliderRef.current.value = String(to);\n } else {\n fromSliderRef.current.value = String(from);\n }\n },\n [onChange, theme],\n );\n\n const handleControlToSlider = useCallback(\n (event: ChangeEvent<HTMLInputElement>) => {\n void setRefreshScrollEnabled(false);\n\n if (!fromSliderRef.current || !toSliderRef.current) {\n return;\n }\n\n setToValue(Number(event.target.value));\n\n const from = Number(fromSliderRef.current.value);\n const to = Number(toSliderRef.current.value);\n\n if (typeof onChange === 'function') {\n onChange(undefined, { maxValue: to, minValue: from });\n }\n\n fillSlider({\n toSlider: toSliderRef.current,\n fromSlider: fromSliderRef.current,\n theme,\n });\n\n if (from <= to) {\n toSliderRef.current.value = String(to);\n } else {\n toSliderRef.current.value = String(from);\n }\n },\n [onChange, theme],\n );\n\n useEffect(() => {\n if (!fromSliderRef.current || !toSliderRef.current || !interval) {\n return;\n }\n\n setFromValue(interval.minValue);\n setToValue(interval.maxValue);\n\n fromSliderRef.current.value = String(interval.minValue);\n toSliderRef.current.value = String(interval.maxValue);\n\n fillSlider({\n fromSlider: fromSliderRef.current,\n toSlider: toSliderRef.current,\n theme,\n });\n // Note: interval can´t be in the deps because of rerender\n // eslint-disable-next-line react-hooks/exhaustive-deps\n }, [theme]);\n\n /**\n * This function updates the value\n */\n const handleInputChange = useCallback(\n (event: ChangeEvent<HTMLInputElement>) => {\n void setRefreshScrollEnabled(false);\n\n let newValue = Number(event.target.value);\n\n if (newValue > maxValue || newValue > maxValue - (maxValue % steps)) {\n newValue = maxValue;\n } else if (newValue < minValue) {\n newValue = minValue;\n } else {\n newValue = Math.round(newValue / steps) * steps;\n }\n\n if (interval) {\n handleControlFromSlider(event);\n\n return;\n }\n\n setFromValue(newValue);\n\n if (onChange) {\n onChange(newValue);\n }\n },\n [handleControlFromSlider, interval, maxValue, minValue, onChange, steps],\n );\n\n const fromSliderThumbPosition = useMemo(() => {\n if (fromSliderRef.current && fromSliderThumbRef.current && sliderWrapperSize) {\n return calculateGradientOffset({\n max: maxValue,\n min: minValue,\n value: fromValue,\n thumbWidth: 20,\n containerWidth: fromSliderRef.current.offsetWidth,\n });\n }\n\n return 0;\n }, [fromValue, maxValue, minValue, sliderWrapperSize]);\n\n const toSliderThumbPosition = useMemo(() => {\n if (toSliderRef.current && toSliderThumbRef.current && sliderWrapperSize) {\n return calculateGradientOffset({\n max: maxValue,\n min: minValue,\n value: toValue,\n thumbWidth: 20,\n containerWidth: toSliderRef.current.offsetWidth,\n });\n }\n return 0;\n }, [toValue, minValue, maxValue, sliderWrapperSize]);\n\n const toSliderThumbContentPosition = useMemo(\n () =>\n calculatePopupPosition({\n min: minValue,\n max: maxValue,\n sliderValue: toValue,\n popupWidth: thumbWidth,\n }),\n [maxValue, minValue, thumbWidth, toValue],\n );\n\n const fromSliderThumbContentPosition = useMemo(\n () =>\n calculatePopupPosition({\n min: minValue,\n max: maxValue,\n sliderValue: fromValue,\n popupWidth: thumbWidth,\n }),\n [fromValue, maxValue, minValue, thumbWidth],\n );\n\n const handleTouchStart = useCallback(() => {\n if (shouldShowThumbLabel) {\n setIsBigSlider(true);\n }\n }, [shouldShowThumbLabel]);\n\n const handleTouchEnd = useCallback(() => {\n const from = Number(fromSliderRef.current?.value);\n const to = Number(toSliderRef.current?.value);\n\n if (typeof onSelect === 'function') {\n onSelect(\n interval ? undefined : from,\n interval ? { maxValue: to, minValue: from } : undefined,\n );\n }\n\n if (shouldShowThumbLabel) {\n setIsBigSlider(false);\n }\n }, [interval, onSelect, shouldShowThumbLabel]);\n\n return useMemo(\n () => (\n <StyledSlider ref={sliderWrapperRef}>\n <StyledSliderInput\n animate={{ height: isBigSlider ? 30 : 10 }}\n initial={{ height: 10 }}\n exit={{ height: 10 }}\n $thumbWidth={40}\n ref={fromSliderRef}\n $isInterval={!!interval}\n type=\"range\"\n value={fromValue}\n step={0.01}\n max={maxValue}\n min={minValue}\n onTouchStart={handleTouchStart}\n onTouchEnd={handleTouchEnd}\n onChange={handleInputChange}\n onMouseUp={handleMouseUp}\n $max={maxValue}\n $min={minValue}\n $value={fromValue}\n />\n <StyledSliderThumb\n ref={fromSliderThumbRef}\n $position={fromSliderThumbPosition}\n $isBigSlider={isBigSlider}\n >\n {shouldShowThumbLabel && (\n <StyledSliderThumbLabel\n $width={thumbWidth}\n $isBigSlider={isBigSlider}\n $position={fromSliderThumbContentPosition}\n ref={fromSliderThumbContentRef}\n >\n {typeof thumbLabelFormatter === 'function'\n ? thumbLabelFormatter(fromValue)\n : fromValue}\n </StyledSliderThumbLabel>\n )}\n </StyledSliderThumb>\n {interval && (\n <StyledSliderThumb\n ref={toSliderThumbRef}\n $position={toSliderThumbPosition}\n $isBigSlider={isBigSlider}\n >\n {shouldShowThumbLabel && (\n <StyledSliderThumbLabel\n $width={thumbWidth}\n $isBigSlider={isBigSlider}\n $position={toSliderThumbContentPosition}\n ref={toSliderThumbContentRef}\n >\n {typeof thumbLabelFormatter === 'function'\n ? thumbLabelFormatter(toValue)\n : toValue}\n </StyledSliderThumbLabel>\n )}\n </StyledSliderThumb>\n )}\n {interval && (\n <StyledSliderInput\n animate={{ height: isBigSlider ? 30 : 10 }}\n initial={{ height: 10 }}\n exit={{ height: 10 }}\n $thumbWidth={40}\n $max={maxValue}\n $min={minValue}\n $value={toValue}\n ref={toSliderRef}\n $isInterval={!!interval}\n type=\"range\"\n value={toValue}\n step={steps}\n max={maxValue}\n min={minValue}\n onTouchStart={handleTouchStart}\n onTouchEnd={handleTouchEnd}\n onChange={handleControlToSlider}\n onMouseUp={handleMouseUp}\n />\n )}\n </StyledSlider>\n ),\n [\n isBigSlider,\n interval,\n fromValue,\n maxValue,\n minValue,\n handleTouchStart,\n handleTouchEnd,\n handleInputChange,\n handleMouseUp,\n fromSliderThumbPosition,\n shouldShowThumbLabel,\n thumbWidth,\n fromSliderThumbContentPosition,\n thumbLabelFormatter,\n toSliderThumbPosition,\n toSliderThumbContentPosition,\n toValue,\n steps,\n handleControlToSlider,\n ],\n );\n};\n\nSlider.displayName = 'Slider';\n\nexport default Slider;\n"],"mappings":"AAAA,SAASA,uBAAuB,QAAQ,YAAY;AACpD,OAAOC,KAAK,IAAqBC,WAAW,EAAEC,SAAS,EAAEC,OAAO,EAAEC,MAAM,EAAEC,QAAQ,QAAQ,OAAO;AACjG,SAASC,QAAQ,QAAQ,mBAAmB;AAC5C,SAASC,cAAc,QAAQ,4BAA4B;AAC3D,SACIC,uBAAuB,EACvBC,sBAAsB,EACtBC,UAAU,EACVC,gBAAgB,QACb,oBAAoB;AAC3B,SACIC,YAAY,EACZC,iBAAiB,EACjBC,iBAAiB,EACjBC,sBAAsB,QACnB,iBAAiB;AA8CxB,MAAMC,MAAuB,GAAGC,IAAA,IAU1B;EAAA,IAV2B;IAC7BC,QAAQ;IACRC,QAAQ;IACRC,KAAK;IACLC,QAAQ;IACRC,QAAQ;IACRC,QAAQ;IACRC,mBAAmB;IACnBC,oBAAoB,GAAG,KAAK;IAC5BC,KAAK,GAAG;EACZ,CAAC,GAAAT,IAAA;EACG,MAAM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AS,EACTT,QAAQ,EACRC,QAAQ,EACRqD,gBAAgB,EAChBC,cAAc,EACdf,iBAAiB,EACjBb,aAAa,EACbiB,uBAAuB,EACvBrC,oBAAoB,EACpBM,UAAU,EACVwC,8BAA8B,EAC9B/C,mBAAmB,EACnB2C,qBAAqB,EACrBC,4BAA4B,EAC5BvC,OAAO,EACPH,KAAK,EACL+B,qBAAqB,CAE7B,CAAC;AACL,CAAC;AAEDzC,MAAM,CAAC6E,WAAW,GAAG,QAAQ;AAE7B,eAAe7E,MAAM","ignoreList":[]}
|
|
1
|
+
{"version":3,"file":"Slider.js","names":["setRefreshScrollEnabled","React","useCallback","useEffect","useMemo","useRef","useState","useTheme","useElementSize","calculateGradientOffset","calculatePopupPosition","fillSlider","getThumbMaxWidth","StyledSlider","StyledSliderInput","StyledSliderThumb","StyledSliderThumbLabel","Slider","_ref","maxValue","minValue","value","onSelect","onChange","interval","thumbLabelFormatter","shouldShowThumbLabel","steps","fromValue","setFromValue","toValue","setToValue","thumbWidth","setThumbWidth","isBigSlider","setIsBigSlider","fromSliderRef","toSliderRef","fromSliderThumbRef","toSliderThumbRef","fromSliderThumbContentRef","toSliderThumbContentRef","sliderWrapperRef","sliderWrapperSize","theme","maxNumber","handleMouseUp","from","Number","current","to","undefined","handleControlFromSlider","event","newValue","target","Math","round","toSlider","fromSlider","String","handleControlToSlider","handleInputChange","fromSliderThumbPosition","max","min","containerWidth","offsetWidth","toSliderThumbPosition","toSliderThumbContentPosition","sliderValue","popupWidth","fromSliderThumbContentPosition","handleTouchStart","handleTouchEnd","createElement","ref","animate","height","initial","exit","$thumbWidth","$isInterval","type","step","onTouchStart","onTouchEnd","onMouseUp","$max","$min","$value","$position","$isBigSlider","$width","displayName"],"sources":["../../../../src/components/slider/Slider.tsx"],"sourcesContent":["import { setRefreshScrollEnabled } from 'chayns-api';\nimport React, { ChangeEvent, FC, useCallback, useEffect, useMemo, useRef, useState } from 'react';\nimport { useTheme } from 'styled-components';\nimport { useElementSize } from '../../hooks/useElementSize';\nimport {\n calculateGradientOffset,\n calculatePopupPosition,\n fillSlider,\n getThumbMaxWidth,\n} from '../../utils/slider';\nimport {\n StyledSlider,\n StyledSliderInput,\n StyledSliderThumb,\n StyledSliderThumbLabel,\n} from './Slider.styles';\n\nexport interface SliderInterval {\n maxValue: number;\n minValue: number;\n}\n\nexport type SliderProps = {\n /**\n * The range that can be selected with two thumbs..\n */\n interval?: SliderInterval;\n /**\n * The maximum value of the slider.\n */\n maxValue: number;\n /**\n * The minimum value of the slider.\n */\n minValue: number;\n /**\n * Function that will be executed when the value is selected.\n */\n onSelect?: (value?: number, interval?: SliderInterval) => void;\n /**\n * Function that will be executed when the value is changed.\n */\n onChange?: (value?: number, interval?: SliderInterval) => void;\n /**\n * Whether the current value should be displayed inside the slider thumb.\n */\n shouldShowThumbLabel?: boolean;\n /**\n * The steps of the slider.\n */\n steps?: number;\n /**\n * A function to format the thumb label.\n */\n thumbLabelFormatter?: (value: number) => string;\n /**\n * the Value that the slider should have.\n */\n value?: number;\n};\n\nconst Slider: FC<SliderProps> = ({\n maxValue,\n minValue,\n value,\n onSelect,\n onChange,\n interval,\n thumbLabelFormatter,\n shouldShowThumbLabel = false,\n steps = 1,\n}) => {\n const [fromValue, setFromValue] = useState(0);\n const [toValue, setToValue] = useState(maxValue);\n const [thumbWidth, setThumbWidth] = useState(20);\n const [isBigSlider, setIsBigSlider] = useState(false);\n\n const fromSliderRef = useRef<HTMLInputElement>(null);\n const toSliderRef = useRef<HTMLInputElement>(null);\n const fromSliderThumbRef = useRef<HTMLDivElement>(null);\n const toSliderThumbRef = useRef<HTMLDivElement>(null);\n const fromSliderThumbContentRef = useRef<HTMLDivElement>(null);\n const toSliderThumbContentRef = useRef<HTMLDivElement>(null);\n const sliderWrapperRef = useRef<HTMLDivElement>(null);\n\n const sliderWrapperSize = useElementSize(sliderWrapperRef);\n\n const theme = useTheme();\n\n useEffect(() => {\n if (shouldShowThumbLabel) {\n setThumbWidth(getThumbMaxWidth({ maxNumber: maxValue, thumbLabelFormatter }));\n }\n }, [maxValue, shouldShowThumbLabel, thumbLabelFormatter]);\n\n /**\n * This function sets the value\n */\n useEffect(() => {\n if (typeof value !== 'number') {\n return;\n }\n\n if (value >= minValue && value <= maxValue) {\n setFromValue(value);\n }\n }, [maxValue, minValue, value]);\n\n useEffect(() => {\n if (fromValue > toValue) {\n setFromValue(toValue);\n }\n\n if (toValue < fromValue) {\n setToValue(fromValue);\n }\n }, [fromValue, toValue]);\n\n const handleMouseUp = useCallback(() => {\n void setRefreshScrollEnabled(true);\n\n const from = Number(fromSliderRef.current?.value);\n const to = Number(toSliderRef.current?.value);\n\n if (typeof onSelect === 'function') {\n onSelect(\n interval ? undefined : from,\n interval ? { maxValue: to, minValue: from } : undefined,\n );\n }\n }, [interval, onSelect]);\n\n const handleControlFromSlider = useCallback(\n (event: ChangeEvent<HTMLInputElement>) => {\n if (!fromSliderRef.current || !toSliderRef.current) {\n return;\n }\n\n let newValue = Number(event.target.value);\n\n if (newValue > maxValue || newValue > maxValue - (maxValue % steps)) {\n newValue = maxValue;\n } else if (newValue < minValue) {\n newValue = minValue;\n } else {\n newValue = Math.round(newValue / steps) * steps;\n }\n\n setFromValue(newValue);\n\n const to = Number(toSliderRef.current.value);\n\n if (typeof onChange === 'function') {\n onChange(undefined, { maxValue: to, minValue: newValue });\n }\n\n fillSlider({\n toSlider: toSliderRef.current,\n fromSlider: fromSliderRef.current,\n fromValue: newValue,\n theme,\n });\n\n if (newValue > to) {\n fromSliderRef.current.value = String(to);\n } else {\n fromSliderRef.current.value = String(newValue);\n }\n },\n [maxValue, minValue, onChange, steps, theme],\n );\n\n const handleControlToSlider = useCallback(\n (event: ChangeEvent<HTMLInputElement>) => {\n void setRefreshScrollEnabled(false);\n\n if (!fromSliderRef.current || !toSliderRef.current) {\n return;\n }\n\n let newValue = Number(event.target.value);\n\n if (newValue > maxValue || newValue > maxValue - (maxValue % steps)) {\n newValue = maxValue;\n } else if (newValue < minValue) {\n newValue = minValue;\n } else {\n newValue = Math.round(newValue / steps) * steps;\n }\n\n setToValue(newValue);\n\n const from = Number(fromSliderRef.current.value);\n\n if (typeof onChange === 'function') {\n onChange(undefined, { maxValue: newValue, minValue: from });\n }\n\n fillSlider({\n toSlider: toSliderRef.current,\n fromSlider: fromSliderRef.current,\n toValue: newValue,\n theme,\n });\n\n if (from <= newValue) {\n toSliderRef.current.value = String(newValue);\n } else {\n toSliderRef.current.value = String(from);\n }\n },\n [maxValue, minValue, onChange, steps, theme],\n );\n\n useEffect(() => {\n if (!fromSliderRef.current || !toSliderRef.current || !interval) {\n return;\n }\n\n setFromValue(interval.minValue);\n setToValue(interval.maxValue);\n\n fromSliderRef.current.value = String(interval.minValue);\n toSliderRef.current.value = String(interval.maxValue);\n\n fillSlider({\n fromSlider: fromSliderRef.current,\n toSlider: toSliderRef.current,\n theme,\n });\n // Note: interval can´t be in the deps because of rerender\n // eslint-disable-next-line react-hooks/exhaustive-deps\n }, [theme]);\n\n /**\n * This function updates the value\n */\n const handleInputChange = useCallback(\n (event: ChangeEvent<HTMLInputElement>) => {\n void setRefreshScrollEnabled(false);\n\n let newValue = Number(event.target.value);\n\n if (newValue > maxValue || newValue > maxValue - (maxValue % steps)) {\n newValue = maxValue;\n } else if (newValue < minValue) {\n newValue = minValue;\n } else {\n newValue = Math.round(newValue / steps) * steps;\n }\n\n if (interval) {\n handleControlFromSlider(event);\n\n return;\n }\n\n setFromValue(newValue);\n\n if (onChange) {\n onChange(newValue);\n }\n },\n [handleControlFromSlider, interval, maxValue, minValue, onChange, steps],\n );\n\n const fromSliderThumbPosition = useMemo(() => {\n if (fromSliderRef.current && fromSliderThumbRef.current && sliderWrapperSize) {\n return calculateGradientOffset({\n max: maxValue,\n min: minValue,\n value: fromValue,\n thumbWidth: 20,\n containerWidth: fromSliderRef.current.offsetWidth,\n });\n }\n\n return 0;\n }, [fromValue, maxValue, minValue, sliderWrapperSize]);\n\n const toSliderThumbPosition = useMemo(() => {\n if (toSliderRef.current && toSliderThumbRef.current && sliderWrapperSize) {\n return calculateGradientOffset({\n max: maxValue,\n min: minValue,\n value: toValue,\n thumbWidth: 20,\n containerWidth: toSliderRef.current.offsetWidth,\n });\n }\n return 0;\n }, [toValue, minValue, maxValue, sliderWrapperSize]);\n\n const toSliderThumbContentPosition = useMemo(\n () =>\n calculatePopupPosition({\n min: minValue,\n max: maxValue,\n sliderValue: toValue,\n popupWidth: thumbWidth,\n }),\n [maxValue, minValue, thumbWidth, toValue],\n );\n\n const fromSliderThumbContentPosition = useMemo(\n () =>\n calculatePopupPosition({\n min: minValue,\n max: maxValue,\n sliderValue: fromValue,\n popupWidth: thumbWidth,\n }),\n [fromValue, maxValue, minValue, thumbWidth],\n );\n\n const handleTouchStart = useCallback(() => {\n if (shouldShowThumbLabel) {\n setIsBigSlider(true);\n }\n }, [shouldShowThumbLabel]);\n\n const handleTouchEnd = useCallback(() => {\n const from = Number(fromSliderRef.current?.value);\n const to = Number(toSliderRef.current?.value);\n\n if (typeof onSelect === 'function') {\n onSelect(\n interval ? undefined : from,\n interval ? { maxValue: to, minValue: from } : undefined,\n );\n }\n\n if (shouldShowThumbLabel) {\n setIsBigSlider(false);\n }\n }, [interval, onSelect, shouldShowThumbLabel]);\n\n return useMemo(\n () => (\n <StyledSlider ref={sliderWrapperRef}>\n <StyledSliderInput\n animate={{ height: isBigSlider ? 30 : 10 }}\n initial={{ height: 10 }}\n exit={{ height: 10 }}\n $thumbWidth={40}\n ref={fromSliderRef}\n $isInterval={!!interval}\n type=\"range\"\n value={fromValue}\n step={0.01}\n max={maxValue}\n min={minValue}\n onTouchStart={handleTouchStart}\n onTouchEnd={handleTouchEnd}\n onChange={handleInputChange}\n onMouseUp={handleMouseUp}\n $max={maxValue}\n $min={minValue}\n $value={fromValue}\n />\n <StyledSliderThumb\n ref={fromSliderThumbRef}\n $position={fromSliderThumbPosition}\n $isBigSlider={isBigSlider}\n >\n {shouldShowThumbLabel && (\n <StyledSliderThumbLabel\n $width={thumbWidth}\n $isBigSlider={isBigSlider}\n $position={fromSliderThumbContentPosition}\n ref={fromSliderThumbContentRef}\n >\n {typeof thumbLabelFormatter === 'function'\n ? thumbLabelFormatter(fromValue)\n : fromValue}\n </StyledSliderThumbLabel>\n )}\n </StyledSliderThumb>\n {interval && (\n <StyledSliderThumb\n ref={toSliderThumbRef}\n $position={toSliderThumbPosition}\n $isBigSlider={isBigSlider}\n >\n {shouldShowThumbLabel && (\n <StyledSliderThumbLabel\n $width={thumbWidth}\n $isBigSlider={isBigSlider}\n $position={toSliderThumbContentPosition}\n ref={toSliderThumbContentRef}\n >\n {typeof thumbLabelFormatter === 'function'\n ? thumbLabelFormatter(toValue)\n : toValue}\n </StyledSliderThumbLabel>\n )}\n </StyledSliderThumb>\n )}\n {interval && (\n <StyledSliderInput\n animate={{ height: isBigSlider ? 30 : 10 }}\n initial={{ height: 10 }}\n exit={{ height: 10 }}\n $thumbWidth={40}\n $max={maxValue}\n $min={minValue}\n $value={toValue}\n ref={toSliderRef}\n $isInterval={!!interval}\n type=\"range\"\n value={toValue}\n step={0.01}\n max={maxValue}\n min={minValue}\n onTouchStart={handleTouchStart}\n onTouchEnd={handleTouchEnd}\n onChange={handleControlToSlider}\n onMouseUp={handleMouseUp}\n />\n )}\n </StyledSlider>\n ),\n [\n isBigSlider,\n interval,\n fromValue,\n maxValue,\n minValue,\n handleTouchStart,\n handleTouchEnd,\n handleInputChange,\n handleMouseUp,\n fromSliderThumbPosition,\n shouldShowThumbLabel,\n thumbWidth,\n fromSliderThumbContentPosition,\n thumbLabelFormatter,\n toSliderThumbPosition,\n toSliderThumbContentPosition,\n toValue,\n handleControlToSlider,\n ],\n );\n};\n\nSlider.displayName = 'Slider';\n\nexport default Slider;\n"],"mappings":"AAAA,SAASA,uBAAuB,QAAQ,YAAY;AACpD,OAAOC,KAAK,IAAqBC,WAAW,EAAEC,SAAS,EAAEC,OAAO,EAAEC,MAAM,EAAEC,QAAQ,QAAQ,OAAO;AACjG,SAASC,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,cAAc,EACdZ,iBAAiB,EACjBhB,aAAa,EACbiB,uBAAuB,EACvBrC,oBAAoB,EACpBM,UAAU,EACVwC,8BAA8B,EAC9B/C,mBAAmB,EACnB2C,qBAAqB,EACrBC,4BAA4B,EAC5BvC,OAAO,EACP+B,qBAAqB,CAE7B,CAAC;AACL,CAAC;AAED5C,MAAM,CAAC6E,WAAW,GAAG,QAAQ;AAE7B,eAAe7E,MAAM","ignoreList":[]}
|
package/lib/esm/utils/slider.js
CHANGED
|
@@ -2,11 +2,13 @@ export const fillSlider = _ref => {
|
|
|
2
2
|
let {
|
|
3
3
|
fromSlider,
|
|
4
4
|
toSlider,
|
|
5
|
-
theme
|
|
5
|
+
theme,
|
|
6
|
+
fromValue,
|
|
7
|
+
toValue
|
|
6
8
|
} = _ref;
|
|
7
9
|
const rangeDistance = Number(toSlider.max) - Number(toSlider.min);
|
|
8
|
-
const fromPosition = Number(fromSlider.value) - Number(toSlider.min);
|
|
9
|
-
const toPosition = Number(toSlider.value) - Number(toSlider.min);
|
|
10
|
+
const fromPosition = Number(fromValue ?? fromSlider.value) - Number(toSlider.min);
|
|
11
|
+
const toPosition = Number(toValue ?? toSlider.value) - Number(toSlider.min);
|
|
10
12
|
const backgroundColor = theme['403'];
|
|
11
13
|
const trackColor = theme['409'];
|
|
12
14
|
if (!backgroundColor || !trackColor) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"slider.js","names":["fillSlider","_ref","fromSlider","toSlider","theme","rangeDistance","Number","max","min","fromPosition","value","toPosition","backgroundColor","trackColor","gradient","style","background","calculateGradientOffset","_ref2","thumbWidth","containerWidth","percentage","adjustedWidth","calculatePopupPosition","_ref3","sliderValue","popupWidth","leftAtMin","leftAtMax","getThumbMaxWidth","_ref4","maxNumber","thumbLabelFormatter","element","document","createElement","height","display","padding","whiteSpace","minWidth","opacity","position","textContent","String","body","appendChild","width","offsetWidth","removeChild"],"sources":["../../../src/utils/slider.ts"],"sourcesContent":["import type { Theme } from '../components/color-scheme-provider/ColorSchemeProvider';\n\nexport interface FillSlider {\n fromSlider: HTMLInputElement;\n toSlider: HTMLInputElement;\n theme: Theme;\n}\n\nexport const fillSlider = ({ fromSlider, toSlider, theme }: FillSlider) => {\n const rangeDistance = Number(toSlider.max) - Number(toSlider.min);\n const fromPosition = Number(fromSlider.value) - Number(toSlider.min);\n const toPosition = Number(toSlider.value) - Number(toSlider.min);\n\n const backgroundColor = theme['403'];\n const trackColor = theme['409'];\n\n if (!backgroundColor || !trackColor) {\n return;\n }\n\n const gradient = `linear-gradient(\n to right,\n ${backgroundColor} 0%,\n ${backgroundColor} ${(fromPosition / rangeDistance) * 100}%,\n ${trackColor} ${(fromPosition / rangeDistance) * 100}%,\n ${trackColor} ${(toPosition / rangeDistance) * 100}%,\n ${backgroundColor} ${(toPosition / rangeDistance) * 100}%,\n ${backgroundColor} 100%)`;\n\n // Apply the gradient to the appropriate slider\n // eslint-disable-next-line no-param-reassign\n toSlider.style.background = gradient;\n // eslint-disable-next-line no-param-reassign\n fromSlider.style.background = gradient;\n};\n\ninterface CalculateGradientOffset {\n value: number;\n min: number;\n max: number;\n thumbWidth: number;\n containerWidth: number;\n}\n\nexport const calculateGradientOffset = ({\n value,\n min,\n max,\n thumbWidth,\n containerWidth,\n}: CalculateGradientOffset): number => {\n const percentage = (value - min) / (max - min);\n\n const adjustedWidth = containerWidth - thumbWidth / 2;\n\n return percentage * adjustedWidth + thumbWidth / 2;\n};\n\ninterface GetThumbMaxWidthOptions {\n maxNumber: number;\n thumbLabelFormatter?: (value: number) => string;\n}\n\ninterface CalculatePopupPositionOptions {\n sliderValue: number;\n min: number;\n max: number;\n popupWidth: number;\n}\n\nexport const calculatePopupPosition = ({\n sliderValue,\n min,\n max,\n popupWidth,\n}: CalculatePopupPositionOptions) => {\n // Berechnung des Prozentwerts des Sliders zwischen min und max\n const percentage = (sliderValue - min) / (max - min);\n\n // Berechnung des linken Versatzes bei 0% (-10px) und bei 100% (-popupWidth + 20px)\n const leftAtMin = -10;\n const leftAtMax = -popupWidth + 25;\n\n // Berechnung des dynamischen Left-Werts basierend auf dem Slider-Prozentwert\n return leftAtMin + percentage * (leftAtMax - leftAtMin);\n};\n\nexport const getThumbMaxWidth = ({ maxNumber, thumbLabelFormatter }: GetThumbMaxWidthOptions) => {\n const element = document.createElement('span');\n\n element.style.height = '20px';\n element.style.display = 'flex';\n element.style.padding = '16px';\n element.style.whiteSpace = 'nowrap';\n element.style.minWidth = '20px';\n element.style.opacity = '0';\n element.style.position = 'absolute';\n\n element.textContent =\n typeof thumbLabelFormatter === 'function'\n ? thumbLabelFormatter(maxNumber)\n : String(maxNumber);\n\n document.body.appendChild(element);\n\n const width = element.offsetWidth;\n\n document.body.removeChild(element);\n\n return width;\n};\n"],"mappings":"
|
|
1
|
+
{"version":3,"file":"slider.js","names":["fillSlider","_ref","fromSlider","toSlider","theme","fromValue","toValue","rangeDistance","Number","max","min","fromPosition","value","toPosition","backgroundColor","trackColor","gradient","style","background","calculateGradientOffset","_ref2","thumbWidth","containerWidth","percentage","adjustedWidth","calculatePopupPosition","_ref3","sliderValue","popupWidth","leftAtMin","leftAtMax","getThumbMaxWidth","_ref4","maxNumber","thumbLabelFormatter","element","document","createElement","height","display","padding","whiteSpace","minWidth","opacity","position","textContent","String","body","appendChild","width","offsetWidth","removeChild"],"sources":["../../../src/utils/slider.ts"],"sourcesContent":["import type { Theme } from '../components/color-scheme-provider/ColorSchemeProvider';\n\nexport interface FillSlider {\n fromSlider: HTMLInputElement;\n toSlider: HTMLInputElement;\n fromValue?: number;\n toValue?: number;\n theme: Theme;\n}\n\nexport const fillSlider = ({ fromSlider, toSlider, theme, fromValue, toValue }: FillSlider) => {\n const rangeDistance = Number(toSlider.max) - Number(toSlider.min);\n const fromPosition = Number(fromValue ?? fromSlider.value) - Number(toSlider.min);\n const toPosition = Number(toValue ?? toSlider.value) - Number(toSlider.min);\n\n const backgroundColor = theme['403'];\n const trackColor = theme['409'];\n\n if (!backgroundColor || !trackColor) {\n return;\n }\n\n const gradient = `linear-gradient(\n to right,\n ${backgroundColor} 0%,\n ${backgroundColor} ${(fromPosition / rangeDistance) * 100}%,\n ${trackColor} ${(fromPosition / rangeDistance) * 100}%,\n ${trackColor} ${(toPosition / rangeDistance) * 100}%,\n ${backgroundColor} ${(toPosition / rangeDistance) * 100}%,\n ${backgroundColor} 100%)`;\n\n // Apply the gradient to the appropriate slider\n // eslint-disable-next-line no-param-reassign\n toSlider.style.background = gradient;\n // eslint-disable-next-line no-param-reassign\n fromSlider.style.background = gradient;\n};\n\ninterface CalculateGradientOffset {\n value: number;\n min: number;\n max: number;\n thumbWidth: number;\n containerWidth: number;\n}\n\nexport const calculateGradientOffset = ({\n value,\n min,\n max,\n thumbWidth,\n containerWidth,\n}: CalculateGradientOffset): number => {\n const percentage = (value - min) / (max - min);\n\n const adjustedWidth = containerWidth - thumbWidth / 2;\n\n return percentage * adjustedWidth + thumbWidth / 2;\n};\n\ninterface GetThumbMaxWidthOptions {\n maxNumber: number;\n thumbLabelFormatter?: (value: number) => string;\n}\n\ninterface CalculatePopupPositionOptions {\n sliderValue: number;\n min: number;\n max: number;\n popupWidth: number;\n}\n\nexport const calculatePopupPosition = ({\n sliderValue,\n min,\n max,\n popupWidth,\n}: CalculatePopupPositionOptions) => {\n // Berechnung des Prozentwerts des Sliders zwischen min und max\n const percentage = (sliderValue - min) / (max - min);\n\n // Berechnung des linken Versatzes bei 0% (-10px) und bei 100% (-popupWidth + 20px)\n const leftAtMin = -10;\n const leftAtMax = -popupWidth + 25;\n\n // Berechnung des dynamischen Left-Werts basierend auf dem Slider-Prozentwert\n return leftAtMin + percentage * (leftAtMax - leftAtMin);\n};\n\nexport const getThumbMaxWidth = ({ maxNumber, thumbLabelFormatter }: GetThumbMaxWidthOptions) => {\n const element = document.createElement('span');\n\n element.style.height = '20px';\n element.style.display = 'flex';\n element.style.padding = '16px';\n element.style.whiteSpace = 'nowrap';\n element.style.minWidth = '20px';\n element.style.opacity = '0';\n element.style.position = 'absolute';\n\n element.textContent =\n typeof thumbLabelFormatter === 'function'\n ? thumbLabelFormatter(maxNumber)\n : String(maxNumber);\n\n document.body.appendChild(element);\n\n const width = element.offsetWidth;\n\n document.body.removeChild(element);\n\n return width;\n};\n"],"mappings":"AAUA,OAAO,MAAMA,UAAU,GAAGC,IAAA,IAAqE;EAAA,IAApE;IAAEC,UAAU;IAAEC,QAAQ;IAAEC,KAAK;IAAEC,SAAS;IAAEC;EAAoB,CAAC,GAAAL,IAAA;EACtF,MAAMM,aAAa,GAAGC,MAAM,CAACL,QAAQ,CAACM,GAAG,CAAC,GAAGD,MAAM,CAACL,QAAQ,CAACO,GAAG,CAAC;EACjE,MAAMC,YAAY,GAAGH,MAAM,CAACH,SAAS,IAAIH,UAAU,CAACU,KAAK,CAAC,GAAGJ,MAAM,CAACL,QAAQ,CAACO,GAAG,CAAC;EACjF,MAAMG,UAAU,GAAGL,MAAM,CAACF,OAAO,IAAIH,QAAQ,CAACS,KAAK,CAAC,GAAGJ,MAAM,CAACL,QAAQ,CAACO,GAAG,CAAC;EAE3E,MAAMI,eAAe,GAAGV,KAAK,CAAC,KAAK,CAAC;EACpC,MAAMW,UAAU,GAAGX,KAAK,CAAC,KAAK,CAAC;EAE/B,IAAI,CAACU,eAAe,IAAI,CAACC,UAAU,EAAE;IACjC;EACJ;EAEA,MAAMC,QAAQ,GAAG;AACrB;AACA,QAAQF,eAAe;AACvB,QAAQA,eAAe,IAAKH,YAAY,GAAGJ,aAAa,GAAI,GAAG;AAC/D,QAAQQ,UAAU,IAAKJ,YAAY,GAAGJ,aAAa,GAAI,GAAG;AAC1D,QAAQQ,UAAU,IAAKF,UAAU,GAAGN,aAAa,GAAI,GAAG;AACxD,QAAQO,eAAe,IAAKD,UAAU,GAAGN,aAAa,GAAI,GAAG;AAC7D,QAAQO,eAAe,QAAQ;;EAE3B;EACA;EACAX,QAAQ,CAACc,KAAK,CAACC,UAAU,GAAGF,QAAQ;EACpC;EACAd,UAAU,C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AAM;EAC/BP,OAAO,CAAClB,KAAK,CAAC0B,OAAO,GAAG,GAAG;EAC3BR,OAAO,CAAClB,KAAK,CAAC2B,QAAQ,GAAG,UAAU;EAEnCT,OAAO,CAACU,WAAW,GACf,OAAOX,mBAAmB,KAAK,UAAU,GACnCA,mBAAmB,CAACD,SAAS,CAAC,GAC9Ba,MAAM,CAACb,SAAS,CAAC;EAE3BG,QAAQ,CAACW,IAAI,CAACC,WAAW,CAACb,OAAO,CAAC;EAElC,MAAMc,KAAK,GAAGd,OAAO,CAACe,WAAW;EAEjCd,QAAQ,CAACW,IAAI,CAACI,WAAW,CAAChB,OAAO,CAAC;EAElC,OAAOc,KAAK;AAChB,CAAC","ignoreList":[]}
|
|
@@ -2,9 +2,11 @@ import type { Theme } from '../components/color-scheme-provider/ColorSchemeProvi
|
|
|
2
2
|
export interface FillSlider {
|
|
3
3
|
fromSlider: HTMLInputElement;
|
|
4
4
|
toSlider: HTMLInputElement;
|
|
5
|
+
fromValue?: number;
|
|
6
|
+
toValue?: number;
|
|
5
7
|
theme: Theme;
|
|
6
8
|
}
|
|
7
|
-
export declare const fillSlider: ({ fromSlider, toSlider, theme }: FillSlider) => void;
|
|
9
|
+
export declare const fillSlider: ({ fromSlider, toSlider, theme, fromValue, toValue }: FillSlider) => void;
|
|
8
10
|
interface CalculateGradientOffset {
|
|
9
11
|
value: number;
|
|
10
12
|
min: number;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@chayns-components/core",
|
|
3
|
-
"version": "5.0.0-beta.
|
|
3
|
+
"version": "5.0.0-beta.831",
|
|
4
4
|
"description": "A set of beautiful React components for developing your own applications with chayns.",
|
|
5
5
|
"sideEffects": false,
|
|
6
6
|
"browserslist": [
|
|
@@ -85,5 +85,5 @@
|
|
|
85
85
|
"publishConfig": {
|
|
86
86
|
"access": "public"
|
|
87
87
|
},
|
|
88
|
-
"gitHead": "
|
|
88
|
+
"gitHead": "af9f3867b9d85d07d960858ec6f81d28f726bb0a"
|
|
89
89
|
}
|