@nordicsemiconductor/pc-nrfconnect-shared 167.0.0 → 168.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.
package/Changelog.md CHANGED
@@ -7,6 +7,12 @@ This project does _not_ adhere to
7
7
  [Semantic Versioning](https://semver.org/spec/v2.0.0.html) but contrary to it
8
8
  every new version is a new major version.
9
9
 
10
+ ## 168.0.0 - 2024-03-22
11
+
12
+ ### Fixed
13
+
14
+ - `Slider` with range handle never reached max
15
+
10
16
  ## 167.0.0 - 2024-03-08
11
17
 
12
18
  ### Fixed
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@nordicsemiconductor/pc-nrfconnect-shared",
3
- "version": "167.0.0",
3
+ "version": "168.0.0",
4
4
  "description": "Shared commodities for developing pc-nrfconnect-* packages",
5
5
  "repository": {
6
6
  "type": "git",
@@ -12,17 +12,20 @@ export const constrainedToPercentage = (percentage: number) => {
12
12
  return percentage;
13
13
  };
14
14
 
15
- export const toPercentage = (value: number, rangeOrValues: RangeOrValues) => {
15
+ export const toPercentage = (
16
+ valueOrIndex: number,
17
+ rangeOrValues: RangeOrValues
18
+ ) => {
16
19
  if (isValues(rangeOrValues)) {
17
- const max = rangeOrValues.length;
20
+ const max = Math.max(0, rangeOrValues.length - 1);
18
21
 
19
22
  // value is an index in the case of explicit values
20
- return (value * 100) / max;
23
+ return (valueOrIndex * 100) / max;
21
24
  }
22
25
  const min = getMin(rangeOrValues);
23
26
  const max = getMax(rangeOrValues);
24
27
 
25
- return ((value - min) * 100) / (max - min);
28
+ return ((valueOrIndex - min) * 100) / (max - min);
26
29
  };
27
30
 
28
31
  export const fromPercentage = (
@@ -57,7 +60,6 @@ export const fromPercentage = (
57
60
  : closestPrevIndex;
58
61
  }
59
62
 
60
- console.log(computedValue, closestIndex);
61
63
  return closestIndex;
62
64
  }
63
65
 
@@ -1,5 +1,5 @@
1
1
  import { RangeOrValues } from './range';
2
2
  export declare const constrainedToPercentage: (percentage: number) => number;
3
- export declare const toPercentage: (value: number, rangeOrValues: RangeOrValues) => number;
3
+ export declare const toPercentage: (valueOrIndex: number, rangeOrValues: RangeOrValues) => number;
4
4
  export declare const fromPercentage: (lastValue: number, value: number, rangeOrValues: RangeOrValues, directionForward: boolean) => number;
5
5
  //# sourceMappingURL=percentage.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"percentage.d.ts","sourceRoot":"","sources":["../../../../src/Slider/percentage.ts"],"names":[],"mappings":"AAMA,OAAO,EAA4B,aAAa,EAAE,MAAM,SAAS,CAAC;AAElE,eAAO,MAAM,uBAAuB,eAAgB,MAAM,WAIzD,CAAC;AAEF,eAAO,MAAM,YAAY,UAAW,MAAM,iBAAiB,aAAa,WAWvE,CAAC;AAEF,eAAO,MAAM,cAAc,cACZ,MAAM,SACV,MAAM,iBACE,aAAa,oBACV,OAAO,WAyC5B,CAAC"}
1
+ {"version":3,"file":"percentage.d.ts","sourceRoot":"","sources":["../../../../src/Slider/percentage.ts"],"names":[],"mappings":"AAMA,OAAO,EAA4B,aAAa,EAAE,MAAM,SAAS,CAAC;AAElE,eAAO,MAAM,uBAAuB,eAAgB,MAAM,WAIzD,CAAC;AAEF,eAAO,MAAM,YAAY,iBACP,MAAM,iBACL,aAAa,WAY/B,CAAC;AAEF,eAAO,MAAM,cAAc,cACZ,MAAM,SACV,MAAM,iBACE,aAAa,oBACV,OAAO,WAwC5B,CAAC"}