@performant-software/semantic-components 1.0.17 → 1.0.18-beta.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/build/index.js +1 -1
- package/build/index.js.map +1 -1
- package/package.json +6 -6
- package/src/components/BibliographyForm.js +121 -0
- package/src/components/BibliographyList.js +21 -2
- package/src/components/BibliographyModal.js +18 -112
- package/src/components/BibliographySearchInput.js +13 -0
- package/src/components/CurrentFacetLabels.js +4 -0
- package/src/components/CurrentFacets.js +6 -0
- package/src/components/CurrentFacetsModal.js +14 -0
- package/src/components/Facet.js +19 -1
- package/src/components/FacetClearButton.js +6 -2
- package/src/components/FacetList.js +43 -2
- package/src/components/FacetSlider.js +7 -5
- package/src/components/FacetToggle.js +5 -0
- package/src/components/SearchBox.js +7 -3
- package/src/components/SearchPagination.js +8 -0
- package/src/components/SearchResults.js +39 -0
- package/src/components/SearchResultsPerPage.js +7 -0
- package/src/components/SearchStats.js +4 -0
- package/src/components/StyleSelector.js +12 -1
- package/src/i18n/en.json +2 -0
- package/src/index.js +3 -0
- package/src/types/InstantSearch.js +30 -0
- package/types/components/BibliographyForm.js.flow +121 -0
- package/types/components/BibliographyList.js.flow +21 -2
- package/types/components/BibliographyModal.js.flow +18 -112
- package/types/components/BibliographySearchInput.js.flow +13 -0
- package/types/components/CurrentFacetLabels.js.flow +4 -0
- package/types/components/CurrentFacets.js.flow +6 -0
- package/types/components/CurrentFacetsModal.js.flow +14 -0
- package/types/components/Facet.js.flow +19 -1
- package/types/components/FacetClearButton.js.flow +6 -2
- package/types/components/FacetList.js.flow +43 -2
- package/types/components/FacetSlider.js.flow +7 -5
- package/types/components/FacetToggle.js.flow +5 -0
- package/types/components/SearchBox.js.flow +7 -3
- package/types/components/SearchPagination.js.flow +8 -0
- package/types/components/SearchResults.js.flow +39 -0
- package/types/components/SearchResultsPerPage.js.flow +7 -0
- package/types/components/SearchStats.js.flow +4 -0
- package/types/components/StyleSelector.js.flow +12 -1
- package/types/index.js.flow +3 -0
- package/types/types/InstantSearch.js.flow +30 -0
|
@@ -21,11 +21,37 @@ import LinkButton from './LinkButton';
|
|
|
21
21
|
import { type RefinementListProps } from '../types/InstantSearch';
|
|
22
22
|
|
|
23
23
|
type Props = FacetProps & RefinementListProps & {
|
|
24
|
+
/**
|
|
25
|
+
* The default value for the `operator` prop. If not provided, this will default to `or`.
|
|
26
|
+
*/
|
|
27
|
+
defaultOperator?: string,
|
|
28
|
+
|
|
29
|
+
/**
|
|
30
|
+
* Default value of the facet list.
|
|
31
|
+
*/
|
|
24
32
|
defaultValue?: string,
|
|
25
|
-
|
|
33
|
+
|
|
34
|
+
/**
|
|
35
|
+
* If "true", the component will render a search box for searching individual facet values.
|
|
36
|
+
*/
|
|
37
|
+
searchable?: boolean,
|
|
38
|
+
|
|
39
|
+
/**
|
|
40
|
+
* If "true", the component will render a toggle to change the behavior of the list from "or" to "and" logic.
|
|
41
|
+
*/
|
|
42
|
+
toggleable?: boolean
|
|
26
43
|
};
|
|
27
44
|
|
|
45
|
+
const OPERATOR_OR = 'or';
|
|
46
|
+
const OPERATOR_AND = 'and';
|
|
47
|
+
|
|
48
|
+
/**
|
|
49
|
+
* This component is used with the `useRefinementList` hook from Instant Search Hooks. If the `searchable` prop
|
|
50
|
+
* is "true", the component will also render a search box used to filter the list of facet values.
|
|
51
|
+
*/
|
|
28
52
|
const FacetList = ({ useRefinementList, ...props }: Props) => {
|
|
53
|
+
const [operator, setOperator] = useState(props.defaultOperator || OPERATOR_OR);
|
|
54
|
+
|
|
29
55
|
const {
|
|
30
56
|
items,
|
|
31
57
|
refine,
|
|
@@ -33,7 +59,7 @@ const FacetList = ({ useRefinementList, ...props }: Props) => {
|
|
|
33
59
|
isShowingMore,
|
|
34
60
|
searchForItems,
|
|
35
61
|
toggleShowMore,
|
|
36
|
-
} = useRefinementList(props);
|
|
62
|
+
} = useRefinementList({ ...props, operator });
|
|
37
63
|
|
|
38
64
|
const ref = useRef();
|
|
39
65
|
const [query, setQuery] = useState('');
|
|
@@ -152,8 +178,23 @@ const FacetList = ({ useRefinementList, ...props }: Props) => {
|
|
|
152
178
|
/>
|
|
153
179
|
</>
|
|
154
180
|
)}
|
|
181
|
+
{ props.toggleable && (
|
|
182
|
+
<Checkbox
|
|
183
|
+
checked={operator === OPERATOR_AND}
|
|
184
|
+
label={operator === OPERATOR_OR
|
|
185
|
+
? i18n.t('FacetList.labels.matchAny')
|
|
186
|
+
: i18n.t('FacetList.labels.matchAll')}
|
|
187
|
+
onClick={() => setOperator((prevOperator) => (prevOperator === OPERATOR_OR ? OPERATOR_AND : OPERATOR_OR))}
|
|
188
|
+
toggle
|
|
189
|
+
/>
|
|
190
|
+
)}
|
|
155
191
|
</Facet>
|
|
156
192
|
);
|
|
157
193
|
};
|
|
158
194
|
|
|
195
|
+
FacetList.defaultProps = {
|
|
196
|
+
...Facet.defaultProps,
|
|
197
|
+
defaultOperator: OPERATOR_OR
|
|
198
|
+
};
|
|
199
|
+
|
|
159
200
|
export default FacetList;
|
|
@@ -4,11 +4,15 @@ import Slider from 'rc-slider';
|
|
|
4
4
|
import React, { useEffect, useState } from 'react';
|
|
5
5
|
import { Grid } from 'semantic-ui-react';
|
|
6
6
|
import Facet, { type Props as FacetProps } from './Facet';
|
|
7
|
-
import { type
|
|
7
|
+
import { type RangeSliderProps } from '../types/InstantSearch';
|
|
8
|
+
import 'rc-slider/assets/index.css';
|
|
8
9
|
import './FacetSlider.css';
|
|
9
10
|
|
|
10
|
-
type Props = FacetProps &
|
|
11
|
+
type Props = FacetProps & RangeSliderProps;
|
|
11
12
|
|
|
13
|
+
/**
|
|
14
|
+
* This component can be used with the `useRange` hook from Instant Search Hooks.
|
|
15
|
+
*/
|
|
12
16
|
const FacetSlider = ({ useRangeSlider, ...props }: Props) => {
|
|
13
17
|
const {
|
|
14
18
|
start,
|
|
@@ -74,8 +78,6 @@ const FacetSlider = ({ useRangeSlider, ...props }: Props) => {
|
|
|
74
78
|
);
|
|
75
79
|
};
|
|
76
80
|
|
|
77
|
-
FacetSlider.defaultProps =
|
|
78
|
-
defaultValue: undefined
|
|
79
|
-
};
|
|
81
|
+
FacetSlider.defaultProps = Facet.defaultProps;
|
|
80
82
|
|
|
81
83
|
export default FacetSlider;
|
|
@@ -7,6 +7,9 @@ import { type ToggleRefinementProps } from '../types/InstantSearch';
|
|
|
7
7
|
|
|
8
8
|
type Props = FacetProps & ToggleRefinementProps;
|
|
9
9
|
|
|
10
|
+
/**
|
|
11
|
+
* This component is used with the `useToggleRefinement` hook from Instant Search Hooks.
|
|
12
|
+
*/
|
|
10
13
|
const FacetToggle = ({ useToggleRefinement, ...props }: Props) => {
|
|
11
14
|
const {
|
|
12
15
|
value: {
|
|
@@ -44,4 +47,6 @@ const FacetToggle = ({ useToggleRefinement, ...props }: Props) => {
|
|
|
44
47
|
);
|
|
45
48
|
};
|
|
46
49
|
|
|
50
|
+
FacetToggle.defaultProps = Facet.defaultProps;
|
|
51
|
+
|
|
47
52
|
export default FacetToggle;
|
|
@@ -2,13 +2,17 @@
|
|
|
2
2
|
|
|
3
3
|
import { Timer } from '@performant-software/shared-components';
|
|
4
4
|
import React, { useCallback, useRef, useState } from 'react';
|
|
5
|
-
import { Icon, Input, InputProps } from 'semantic-ui-react';
|
|
5
|
+
import { Icon, Input, type InputProps } from 'semantic-ui-react';
|
|
6
6
|
import _ from 'underscore';
|
|
7
7
|
import { type SearchBoxProps } from '../types/InstantSearch';
|
|
8
8
|
|
|
9
|
-
type Props =
|
|
9
|
+
type Props = InputProps & SearchBoxProps;
|
|
10
10
|
|
|
11
|
-
|
|
11
|
+
/**
|
|
12
|
+
* This component is used with the `useSearchBox` function from Instant Search Hooks and renders an input element that
|
|
13
|
+
* when changed will execute a new query.
|
|
14
|
+
*/
|
|
15
|
+
const SearchBox = ({ useSearchBox, ...props }: Props) => {
|
|
12
16
|
const {
|
|
13
17
|
query,
|
|
14
18
|
refine,
|
|
@@ -5,9 +5,17 @@ import { Pagination } from 'semantic-ui-react';
|
|
|
5
5
|
import { type PaginationProps } from '../types/InstantSearch';
|
|
6
6
|
|
|
7
7
|
type Props = PaginationProps & {
|
|
8
|
+
/**
|
|
9
|
+
* If `true`, we'll scroll to the top of the page after applying the new page value.
|
|
10
|
+
*/
|
|
8
11
|
scrollToTop?: boolean
|
|
9
12
|
};
|
|
10
13
|
|
|
14
|
+
/**
|
|
15
|
+
* This component is used with the `usePagination` hook from Instant Search Hooks and renders a list of page numbers
|
|
16
|
+
* that can be selected by the user. If the `scrollToTop` prop is set to `true`, the window will scroll to the top
|
|
17
|
+
* after applying a new value.
|
|
18
|
+
*/
|
|
11
19
|
const SearchPagination = ({ usePagination, ...props }: Props) => {
|
|
12
20
|
const { currentRefinement, nbPages: pages, refine } = usePagination(props);
|
|
13
21
|
const onPageChange = useCallback((e, { activePage }) => refine(activePage - 1), [refine]);
|
|
@@ -5,17 +5,56 @@ import ItemCollection from './ItemCollection';
|
|
|
5
5
|
import { type HitsProps } from '../types/InstantSearch';
|
|
6
6
|
|
|
7
7
|
type Props = HitsProps & {
|
|
8
|
+
/**
|
|
9
|
+
* Renders the component as the passed `as` prop.
|
|
10
|
+
*/
|
|
8
11
|
as?: Element<any>,
|
|
12
|
+
|
|
13
|
+
/**
|
|
14
|
+
* Additional props to pass to the container component.
|
|
15
|
+
*/
|
|
9
16
|
asProps?: any,
|
|
17
|
+
|
|
18
|
+
/**
|
|
19
|
+
* If `true` each item will be rendered as a Link.
|
|
20
|
+
*/
|
|
10
21
|
link?: boolean,
|
|
22
|
+
|
|
23
|
+
/**
|
|
24
|
+
* Renders the description for the passed item.
|
|
25
|
+
*/
|
|
11
26
|
renderDescription?: (item: any) => Node,
|
|
27
|
+
|
|
28
|
+
/**
|
|
29
|
+
* Component to render if the list contains no records.
|
|
30
|
+
*/
|
|
12
31
|
renderEmptyList?: () => Node,
|
|
32
|
+
|
|
33
|
+
/**
|
|
34
|
+
* Renders the extra content for the passed item.
|
|
35
|
+
*/
|
|
13
36
|
renderExtra?: (item: any) => Node,
|
|
37
|
+
|
|
38
|
+
/**
|
|
39
|
+
* Renders the header for the passed item.
|
|
40
|
+
*/
|
|
14
41
|
renderHeader?: (item: any) => Node,
|
|
42
|
+
|
|
43
|
+
/**
|
|
44
|
+
* Renders the image for the passed item.
|
|
45
|
+
*/
|
|
15
46
|
renderImage?: (item: any) => Node,
|
|
47
|
+
|
|
48
|
+
/**
|
|
49
|
+
* Renders the meta for the passed item.
|
|
50
|
+
*/
|
|
16
51
|
renderMeta?: (item: any) => Node
|
|
17
52
|
};
|
|
18
53
|
|
|
54
|
+
/**
|
|
55
|
+
* This component is used with the `useHits` hook from Instant Search Hooks and renders a pass-through to the
|
|
56
|
+
* `ItemCollection` component.
|
|
57
|
+
*/
|
|
19
58
|
const SearchResults = ({ useHits, ...props }: Props) => {
|
|
20
59
|
const { hits } = useHits(props);
|
|
21
60
|
|
|
@@ -7,9 +7,16 @@ import i18n from '../i18n/i18n';
|
|
|
7
7
|
import { type HitsPerPageProps } from '../types/InstantSearch';
|
|
8
8
|
|
|
9
9
|
type Props = HitsPerPageProps & {
|
|
10
|
+
/**
|
|
11
|
+
* An array of numeric values to present to the user as the number of records to display per page.
|
|
12
|
+
*/
|
|
10
13
|
options: Array<number>
|
|
11
14
|
};
|
|
12
15
|
|
|
16
|
+
/**
|
|
17
|
+
* This component is used with the `useHitsPerPage` hook from Instant Search Hooks and renders a dropdown with
|
|
18
|
+
* options for the number of records to display per page.
|
|
19
|
+
*/
|
|
13
20
|
const SearchResultsPerPage = ({ useHitsPerPage, options }: Props) => {
|
|
14
21
|
const { items, refine } = useHitsPerPage({
|
|
15
22
|
items: _.map(options, (option, index) => ({
|
|
@@ -7,6 +7,10 @@ import type { StatsProps } from '../types/InstantSearch';
|
|
|
7
7
|
const MsToS = 1000.0;
|
|
8
8
|
const DECIMAL_PLACES = 2;
|
|
9
9
|
|
|
10
|
+
/**
|
|
11
|
+
* This component is used with the `useStats` hook from Instant Search Hooks and renders a label of the number of
|
|
12
|
+
* records returned and the time it took to execute the request.
|
|
13
|
+
*/
|
|
10
14
|
const SearchStats = ({ useStats, ...props }: StatsProps) => {
|
|
11
15
|
const { nbHits: count, processingTimeMS } = useStats(props);
|
|
12
16
|
const seconds = (processingTimeMS / MsToS).toFixed(DECIMAL_PLACES);
|
|
@@ -6,10 +6,21 @@ import { Dropdown } from 'semantic-ui-react';
|
|
|
6
6
|
import _ from 'underscore';
|
|
7
7
|
|
|
8
8
|
type Props = {
|
|
9
|
+
/**
|
|
10
|
+
* Callback fired when the style selector is changed.
|
|
11
|
+
*/
|
|
9
12
|
onChange: (name: string, xml: string) => void,
|
|
10
|
-
|
|
13
|
+
|
|
14
|
+
/**
|
|
15
|
+
* Default style value.
|
|
16
|
+
*/
|
|
17
|
+
value?: string
|
|
11
18
|
};
|
|
12
19
|
|
|
20
|
+
/**
|
|
21
|
+
* This component can be used, along with the `useCitationStyles` hook, to display a list of bibliographic styles
|
|
22
|
+
* supported by Zotero.
|
|
23
|
+
*/
|
|
13
24
|
const StyleSelector = (props: Props) => {
|
|
14
25
|
const { onStyleChange, style, styles } = useCitationStyles(props.value);
|
|
15
26
|
|
package/types/index.js.flow
CHANGED
|
@@ -10,7 +10,9 @@ export { default as AccordionSelector } from './components/AccordionSelector';
|
|
|
10
10
|
export { default as ArrowButtons } from './components/ArrowButtons';
|
|
11
11
|
export { default as AssociatedDropdown } from './components/AssociatedDropdown';
|
|
12
12
|
export { default as AudioPlayer } from './components/AudioPlayer';
|
|
13
|
+
export { default as BibliographyForm } from './components/BibliographyForm';
|
|
13
14
|
export { default as BibliographyList } from './components/BibliographyList';
|
|
15
|
+
export { default as BibliographySearchInput } from './components/BibliographySearchInput';
|
|
14
16
|
export { default as BooleanIcon } from './components/BooleanIcon';
|
|
15
17
|
export { default as CancelButton } from './components/CancelButton';
|
|
16
18
|
export { default as ColorButton } from './components/ColorButton';
|
|
@@ -85,6 +87,7 @@ export { default as Section } from './components/Section';
|
|
|
85
87
|
export { default as Selectize } from './components/Selectize';
|
|
86
88
|
export { default as SelectizeHeader } from './components/SelectizeHeader';
|
|
87
89
|
export { default as SelectizeImageHeader } from './components/SelectizeImageHeader';
|
|
90
|
+
export { default as StyleSelector } from './components/StyleSelector';
|
|
88
91
|
export { default as TabbedModal } from './components/TabbedModal';
|
|
89
92
|
export { default as TabsMenu } from './components/TabsMenu';
|
|
90
93
|
export { default as TagsList } from './components/TagsList';
|
|
@@ -1,14 +1,23 @@
|
|
|
1
1
|
// @flow
|
|
2
2
|
|
|
3
3
|
export type ClearRefinementsProps = {
|
|
4
|
+
/**
|
|
5
|
+
* Instant-Search hook to clear current refinements values.
|
|
6
|
+
*/
|
|
4
7
|
useClearRefinements: (props: any) => ({ canRefine: boolean, refine: () => void })
|
|
5
8
|
};
|
|
6
9
|
|
|
7
10
|
export type CurrentRefinementsProps = {
|
|
11
|
+
/**
|
|
12
|
+
* Instant-Search hook to provide current refinements values.
|
|
13
|
+
*/
|
|
8
14
|
useCurrentRefinements: (props: any) => ({ items: Array<any> })
|
|
9
15
|
};
|
|
10
16
|
|
|
11
17
|
export type HitsPerPageProps = {
|
|
18
|
+
/**
|
|
19
|
+
* Instant-Search hook to provide number of hits per page values.
|
|
20
|
+
*/
|
|
12
21
|
useHitsPerPage: (props: any) => ({
|
|
13
22
|
items: Array<{ value: number, label: string, default: boolean}>,
|
|
14
23
|
refine: (value: number) => void
|
|
@@ -16,12 +25,18 @@ export type HitsPerPageProps = {
|
|
|
16
25
|
};
|
|
17
26
|
|
|
18
27
|
export type HitsProps = {
|
|
28
|
+
/**
|
|
29
|
+
* Instant-Search hook to provide search hits values.
|
|
30
|
+
*/
|
|
19
31
|
useHits: (props: any) => ({
|
|
20
32
|
hits: Array<any>
|
|
21
33
|
})
|
|
22
34
|
};
|
|
23
35
|
|
|
24
36
|
export type PaginationProps = {
|
|
37
|
+
/**
|
|
38
|
+
* Instant-Search hook to provide pagination values.
|
|
39
|
+
*/
|
|
25
40
|
usePagination: (props: any) => ({
|
|
26
41
|
currentRefinement: number,
|
|
27
42
|
nbPages: number,
|
|
@@ -30,6 +45,9 @@ export type PaginationProps = {
|
|
|
30
45
|
};
|
|
31
46
|
|
|
32
47
|
export type RangeSliderProps = {
|
|
48
|
+
/**
|
|
49
|
+
* Instant-Search hook to provide range values.
|
|
50
|
+
*/
|
|
33
51
|
useRangeSlider: (props: any) => ({
|
|
34
52
|
start: Array<number>,
|
|
35
53
|
range: {
|
|
@@ -41,6 +59,9 @@ export type RangeSliderProps = {
|
|
|
41
59
|
};
|
|
42
60
|
|
|
43
61
|
export type RefinementListProps = {
|
|
62
|
+
/**
|
|
63
|
+
* Instant-Search hook to provide refinement list values.
|
|
64
|
+
*/
|
|
44
65
|
useRefinementList: (props: any) => ({
|
|
45
66
|
items: Array<any>,
|
|
46
67
|
refine: (value: any) => void,
|
|
@@ -51,6 +72,9 @@ export type RefinementListProps = {
|
|
|
51
72
|
};
|
|
52
73
|
|
|
53
74
|
export type SearchBoxProps = {
|
|
75
|
+
/**
|
|
76
|
+
* Instant-Search hook to provide search box values.
|
|
77
|
+
*/
|
|
54
78
|
useSearchBox: (props: any) => ({
|
|
55
79
|
query: string,
|
|
56
80
|
refine: (value: string) => void,
|
|
@@ -60,6 +84,9 @@ export type SearchBoxProps = {
|
|
|
60
84
|
};
|
|
61
85
|
|
|
62
86
|
export type StatsProps = {
|
|
87
|
+
/**
|
|
88
|
+
* Instant-Search hook to provide search statistic values.
|
|
89
|
+
*/
|
|
63
90
|
useStats: (props: any) => ({
|
|
64
91
|
nbHits: number,
|
|
65
92
|
processingTimeMS: number
|
|
@@ -67,6 +94,9 @@ export type StatsProps = {
|
|
|
67
94
|
};
|
|
68
95
|
|
|
69
96
|
export type ToggleRefinementProps = {
|
|
97
|
+
/**
|
|
98
|
+
* Instant-Search hook to provide toggle refinement values.
|
|
99
|
+
*/
|
|
70
100
|
useToggleRefinement: (props: any) => ({
|
|
71
101
|
value: {
|
|
72
102
|
isRefined: boolean,
|