@codeleap/web 3.22.0 → 3.22.1

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@codeleap/web",
3
- "version": "3.22.0",
3
+ "version": "3.22.1",
4
4
  "main": "src/index.ts",
5
5
  "repository": {
6
6
  "url": "https://github.com/codeleap-uk/internal-libs-monorepo.git",
@@ -21,7 +21,6 @@ import {
21
21
  export * from './styles'
22
22
 
23
23
  export type SliderProps = Partial<Omit<PrimitiveSliderProps, 'value' | 'onValueChange'>> & Pick<InputBaseProps, 'disabled' | 'debugName' | 'description' | 'label'> & {
24
- debounce?: number | null
25
24
  indicatorLabel?: {
26
25
  order?: number[]
27
26
  separator?: string
@@ -44,7 +43,7 @@ export type TrackMarkProps = {
44
43
  }
45
44
 
46
45
  const DefaultSliderTrackMark = (props: TrackMarkProps) => {
47
- const { index, content, style } = props
46
+ const { style } = props
48
47
 
49
48
  if (!TypeGuards.isString(props.content)) {
50
49
  return <React.Fragment>
@@ -65,8 +64,8 @@ export const Slider = (props: SliderProps) => {
65
64
  } = selectInputBaseProps(props)
66
65
 
67
66
  const {
68
- debounce = null,
69
67
  onValueChange,
68
+ onValueCommit,
70
69
  value: _value,
71
70
  label,
72
71
  debugName,
@@ -82,7 +81,7 @@ export const Slider = (props: SliderProps) => {
82
81
  min = 0,
83
82
  indicatorLabel = null,
84
83
  description = null,
85
- minStepsBetweenThumbs = 8,
84
+ minStepsBetweenThumbs = 0,
86
85
  step = 1,
87
86
  onPressThumbSetValue = false,
88
87
  onPressThumb = null,
@@ -91,6 +90,7 @@ export const Slider = (props: SliderProps) => {
91
90
 
92
91
  const isUniqueValue = !TypeGuards.isArray(_value)
93
92
  const value = isUniqueValue ? [_value] : _value
93
+
94
94
  const _defaultValue = TypeGuards.isArray(defaultSliderValue) ? defaultSliderValue : [defaultSliderValue]
95
95
 
96
96
  const defaultValueRef = useRef<PrimitiveSliderProps['defaultValue']>(_defaultValue)
@@ -104,34 +104,12 @@ export const Slider = (props: SliderProps) => {
104
104
 
105
105
  const SliderTrackMark = trackMarkComponent
106
106
 
107
- const currentThumbRef = useRef(null)
108
-
109
107
  const handleChange: SliderProps['onValueChange'] = (newValue: Array<number>) => {
110
- if (isUniqueValue) {
111
- onValueChange(newValue?.[0])
112
- return
113
- }
114
-
115
- const copyValue = [...value]
116
-
117
- const i = currentThumbRef.current
118
- const _newValue = newValue[currentThumbRef.current]
119
-
120
- const hasLeftThumb = i !== 0
121
- const hasRightThumb = i + 1 < newValue.length
122
-
123
- const previousThumbValue = hasLeftThumb ? (copyValue[i - 1] + minStepsBetweenThumbs) : null
124
- const nextThumbValue = hasRightThumb ? (copyValue[i + 1] - minStepsBetweenThumbs) : null
125
-
126
- if (previousThumbValue && _newValue <= previousThumbValue) {
127
- copyValue[i] = previousThumbValue
128
- } else if (nextThumbValue && _newValue >= nextThumbValue) {
129
- copyValue[i] = nextThumbValue
130
- } else {
131
- copyValue[i] = _newValue
132
- }
108
+ onValueChange(isUniqueValue ? newValue?.[0] : newValue)
109
+ }
133
110
 
134
- onValueChange(copyValue)
111
+ const handleValueCommit = (newValue: Array<number>) => {
112
+ onValueCommit?.(newValue)
135
113
  }
136
114
 
137
115
  const variantStyles = useDefaultComponentStyle<'u:Slider', typeof SliderPresets>('u:Slider', {
@@ -234,15 +212,15 @@ export const Slider = (props: SliderProps) => {
234
212
  <SliderContainer
235
213
  {...sliderProps}
236
214
  step={step}
237
- minStepsBetweenThumbs={minStepsBetweenThumbs}
238
- style={containerStyle}
239
- defaultValue={defaultValue}
240
- value={value}
241
- onValueCommit={() => null}
242
- onValueChange={handleChange}
243
215
  min={min}
244
216
  max={max}
245
217
  disabled={disabled}
218
+ defaultValue={defaultValue}
219
+ onValueCommit={handleValueCommit}
220
+ onValueChange={handleChange}
221
+ style={containerStyle}
222
+ value={value}
223
+ minStepsBetweenThumbs={minStepsBetweenThumbs}
246
224
  >
247
225
  <SliderTrack style={trackStyle}>
248
226
  <SliderRange style={selectedTrackStyle} />
@@ -256,10 +234,7 @@ export const Slider = (props: SliderProps) => {
256
234
  onClick={() => {
257
235
  if (onPressThumbSetValue) onValueChange?.(value)
258
236
  if (TypeGuards.isFunction(onPressThumb)) onPressThumb?.(value, i)
259
-
260
- currentThumbRef.current = i
261
237
  }}
262
- onMouseEnter={() => currentThumbRef.current = i}
263
238
  />
264
239
  ))}
265
240
  </SliderContainer>