Skip to content

Commit 2ed9f39

Browse files
authored
Merge pull request #302 from performant-software/feature/basira254_slider_facets
BASIRA #254 - Slider facets
2 parents c78c21b + e4be564 commit 2ed9f39

File tree

9 files changed

+31
-37
lines changed

9 files changed

+31
-37
lines changed

packages/controlled-vocabulary/package.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@performant-software/controlled-vocabulary",
3-
"version": "2.2.16",
3+
"version": "2.2.17",
44
"description": "A package of components to allow user to configure dropdown elements. Use with the \"controlled_vocabulary\" gem.",
55
"license": "MIT",
66
"main": "./dist/index.cjs.js",
@@ -23,8 +23,8 @@
2323
"underscore": "^1.13.2"
2424
},
2525
"peerDependencies": {
26-
"@performant-software/semantic-components": "^2.2.16",
27-
"@performant-software/shared-components": "^2.2.16",
26+
"@performant-software/semantic-components": "^2.2.17",
27+
"@performant-software/shared-components": "^2.2.17",
2828
"react": ">= 16.13.1 < 19.0.0",
2929
"react-dom": ">= 16.13.1 < 19.0.0"
3030
},

packages/core-data/package.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@performant-software/core-data",
3-
"version": "2.2.16",
3+
"version": "2.2.17",
44
"description": "A package of components used with the Core Data platform.",
55
"license": "MIT",
66
"main": "./dist/index.cjs.js",
@@ -40,8 +40,8 @@
4040
"underscore": "^1.13.2"
4141
},
4242
"peerDependencies": {
43-
"@performant-software/geospatial": "^2.2.16",
44-
"@performant-software/shared-components": "^2.2.16",
43+
"@performant-software/geospatial": "^2.2.17",
44+
"@performant-software/shared-components": "^2.2.17",
4545
"@peripleo/maplibre": "^0.5.2",
4646
"@peripleo/peripleo": "^0.5.2",
4747
"react": ">= 16.13.1 < 19.0.0",

packages/geospatial/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@performant-software/geospatial",
3-
"version": "2.2.16",
3+
"version": "2.2.17",
44
"description": "A package of components for all things map-related.",
55
"license": "MIT",
66
"main": "./dist/index.cjs.js",

packages/semantic-ui/package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@performant-software/semantic-components",
3-
"version": "2.2.16",
3+
"version": "2.2.17",
44
"description": "A package of shared components based on the Semantic UI Framework.",
55
"license": "MIT",
66
"main": "./dist/index.cjs.js",
@@ -35,7 +35,7 @@
3535
"zotero-translation-client": "^5.0.1"
3636
},
3737
"peerDependencies": {
38-
"@performant-software/shared-components": "^2.2.16",
38+
"@performant-software/shared-components": "^2.2.17",
3939
"@samvera/clover-iiif": "^2.3.2",
4040
"react": ">= 16.13.1 < 19.0.0",
4141
"react-dnd": "^11.1.3",

packages/semantic-ui/src/components/FacetSlider.js

Lines changed: 16 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@ import Slider from 'rc-slider';
44
import React, {
55
forwardRef,
66
useEffect,
7-
useMemo,
87
useState
98
} from 'react';
109
import { Grid } from 'semantic-ui-react';
@@ -22,34 +21,28 @@ const FacetSlider = forwardRef(({ useRangeSlider, ...props }: Props, ref: HTMLEl
2221
const {
2322
start,
2423
range,
25-
refine,
24+
canRefine = true,
25+
refine
2626
} = useRangeSlider(props);
2727

28-
const [valueView, setValueView] = useState < Array < number >> ([range.min, range.max]);
28+
const { min, max } = range;
2929

30-
/**
31-
* Sets the visibility variable based on the range min and max.
32-
*
33-
* @type {unknown}
34-
*/
35-
const visible = useMemo(() => range.min !== 0 && range.max !== 0, [range.min, range.max]);
30+
const [value, setValue] = useState([min, max]);
31+
32+
const from = Math.max(min, Number.isFinite(start[0]) ? start[0] : min);
33+
const to = Math.min(max, Number.isFinite(start[1]) ? start[1] : max);
3634

37-
/**
38-
* Resets the value and valueView when the current refinement is cleared.
39-
*/
4035
useEffect(() => {
41-
if (start[0] <= range.min && start[1] >= range.max) {
42-
setValueView([range.min, range.max]);
43-
}
44-
}, [range, start]);
36+
setValue([from, to]);
37+
}, [from, to]);
4538

4639
return (
4740
<Facet
4841
defaultActive={props.defaultActive}
4942
divided={props.divided}
5043
innerRef={ref}
5144
title={props.title}
52-
visible={visible}
45+
visible={props.visible}
5346
>
5447
<div
5548
className='facet-slider'
@@ -60,24 +53,25 @@ const FacetSlider = forwardRef(({ useRangeSlider, ...props }: Props, ref: HTMLEl
6053
<Slider
6154
allowCross={false}
6255
defaultValue={start}
56+
disabled={!canRefine}
6357
max={range.max}
6458
min={range.min}
65-
onAfterChange={(v) => refine(v)}
66-
onChange={(v) => setValueView(v)}
59+
onChangeComplete={(v) => refine(v)}
60+
onChange={(v) => setValue(v)}
6761
range
68-
value={valueView}
62+
value={value}
6963
/>
7064
</div>
7165
<Grid
7266
columns={2}
7367
>
7468
<Grid.Column>
75-
{valueView[0]}
69+
{ value[0] }
7670
</Grid.Column>
7771
<Grid.Column
7872
textAlign='right'
7973
>
80-
{valueView[1]}
74+
{ value[1] }
8175
</Grid.Column>
8276
</Grid>
8377
</div>

packages/shared/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@performant-software/shared-components",
3-
"version": "2.2.16",
3+
"version": "2.2.17",
44
"description": "A package of shared, framework agnostic, components.",
55
"license": "MIT",
66
"main": "./dist/index.cjs.js",

packages/user-defined-fields/package.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@performant-software/user-defined-fields",
3-
"version": "2.2.16",
3+
"version": "2.2.17",
44
"description": "A package of components used for allowing end users to define fields on models. Use with the \"user_defined_fields\" gem.",
55
"license": "MIT",
66
"main": "./dist/index.cjs.js",
@@ -23,8 +23,8 @@
2323
"underscore": "^1.13.2"
2424
},
2525
"peerDependencies": {
26-
"@performant-software/semantic-components": "^2.2.16",
27-
"@performant-software/shared-components": "^2.2.16",
26+
"@performant-software/semantic-components": "^2.2.17",
27+
"@performant-software/shared-components": "^2.2.17",
2828
"react": ">= 16.13.1 < 19.0.0",
2929
"react-dom": ">= 16.13.1 < 19.0.0"
3030
},

packages/visualize/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@performant-software/visualize",
3-
"version": "2.2.16",
3+
"version": "2.2.17",
44
"description": "A package of components used for data visualization",
55
"license": "MIT",
66
"main": "./dist/index.cjs.js",

react-components.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,5 +8,5 @@
88
"packages/user-defined-fields",
99
"packages/visualize"
1010
],
11-
"version": "2.2.16"
11+
"version": "2.2.17"
1212
}

0 commit comments

Comments
 (0)