@uncinc/uncinc-react-kitchen-sink 2.1.9 → 2.1.13
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/dist/components/MagicLine/index.js +8 -0
- package/dist/components/MagicLine/stories.js +18 -0
- package/dist/components/SearchKit/Query/index.js +12 -4
- package/dist/components/SearchKit/SearchField/index.js +2 -1
- package/dist/components/SearchKit/SearchPage/index.js +1 -2
- package/dist/components/SearchKit/index.js +35 -11
- package/dist/components/SearchKit/stories.js +39 -2
- package/dist/helpers/useValueForCurrentViewPort.js +11 -11
- package/package.json +23 -21
|
@@ -33,11 +33,19 @@ const MagicLine = ({
|
|
|
33
33
|
|
|
34
34
|
const hoverMagicLine = e => {
|
|
35
35
|
currentActiveItem.current = e.target;
|
|
36
|
+
|
|
37
|
+
_setActiveItemInNavigation(true);
|
|
38
|
+
|
|
36
39
|
alignMagicLine();
|
|
37
40
|
};
|
|
38
41
|
|
|
39
42
|
const setInitialMagicLine = () => {
|
|
40
43
|
currentActiveItem.current = document.getElementsByClassName(activeClassName)[0];
|
|
44
|
+
|
|
45
|
+
if (!currentActiveItem.current) {
|
|
46
|
+
_setActiveItemInNavigation(false);
|
|
47
|
+
}
|
|
48
|
+
|
|
41
49
|
alignMagicLine();
|
|
42
50
|
};
|
|
43
51
|
|
|
@@ -30,4 +30,22 @@ export const Default = () => /*#__PURE__*/React.createElement(MagicLine, null, (
|
|
|
30
30
|
}
|
|
31
31
|
}, item);
|
|
32
32
|
}));
|
|
33
|
+
});
|
|
34
|
+
export const NoActiveItem = () => /*#__PURE__*/React.createElement(MagicLine, null, (setInitialMagicLine, hoverMagicLine, setActiveItemInNavigation) => {
|
|
35
|
+
const items = ["one", "two with a longer name", "three"];
|
|
36
|
+
return /*#__PURE__*/React.createElement("div", {
|
|
37
|
+
className: "Menu"
|
|
38
|
+
}, items.map(item => {
|
|
39
|
+
const classes = c('Menu__item');
|
|
40
|
+
return /*#__PURE__*/React.createElement("div", {
|
|
41
|
+
key: item,
|
|
42
|
+
className: classes,
|
|
43
|
+
onMouseEnter: e => {
|
|
44
|
+
hoverMagicLine(e);
|
|
45
|
+
},
|
|
46
|
+
onMouseLeave: e => {
|
|
47
|
+
setInitialMagicLine();
|
|
48
|
+
}
|
|
49
|
+
}, item);
|
|
50
|
+
}));
|
|
33
51
|
});
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import React, { useMemo } from 'react';
|
|
1
|
+
import React, { useMemo, useState, useEffect } from 'react';
|
|
2
2
|
import { gql, useQuery } from '@apollo/client';
|
|
3
3
|
import { useSearchkitVariables } from '@searchkit/client';
|
|
4
4
|
import SearchPage from '../SearchPage';
|
|
@@ -21,13 +21,21 @@ function Query({
|
|
|
21
21
|
loading
|
|
22
22
|
} = useQuery(graphQuery, {
|
|
23
23
|
variables
|
|
24
|
-
});
|
|
24
|
+
}); // In between searches, Searchkit will empty it's results, resulting
|
|
25
|
+
// in a re-render with an empty screen. Use a local state to prevent this.
|
|
26
|
+
|
|
27
|
+
const [dataLoaded, setDataLoaded] = useState(null);
|
|
28
|
+
useEffect(() => {
|
|
29
|
+
if (data) {
|
|
30
|
+
setDataLoaded(data);
|
|
31
|
+
}
|
|
32
|
+
}, [data]);
|
|
25
33
|
|
|
26
34
|
if (!useRouting) {
|
|
27
|
-
return /*#__PURE__*/React.createElement("div", null, children(
|
|
35
|
+
return /*#__PURE__*/React.createElement("div", null, children(dataLoaded, loading));
|
|
28
36
|
}
|
|
29
37
|
|
|
30
|
-
return /*#__PURE__*/React.createElement(SearchPage, null, children(
|
|
38
|
+
return /*#__PURE__*/React.createElement(SearchPage, null, children(dataLoaded, loading));
|
|
31
39
|
}
|
|
32
40
|
|
|
33
41
|
export default Query;
|
|
@@ -26,7 +26,8 @@ const SearchField = ({
|
|
|
26
26
|
initialValues: {
|
|
27
27
|
query: query
|
|
28
28
|
},
|
|
29
|
-
displayRequiredIndicator: "required"
|
|
29
|
+
displayRequiredIndicator: "required",
|
|
30
|
+
enableReinitialize: true
|
|
30
31
|
}, /*#__PURE__*/React.createElement(TextField, {
|
|
31
32
|
fieldName: "query",
|
|
32
33
|
title: "Search",
|
|
@@ -6,7 +6,6 @@ const SearchPage = ({
|
|
|
6
6
|
children
|
|
7
7
|
}) => /*#__PURE__*/React.createElement(EuiPage, null, children);
|
|
8
8
|
|
|
9
|
-
console.log('W', typeof withSearchkitRouting, withSearchkitRouting.getInitialProps);
|
|
10
9
|
export const routeToStateFn = routeState => {
|
|
11
10
|
const value = {
|
|
12
11
|
query: routeState.query || '',
|
|
@@ -31,7 +30,7 @@ export const routeToStateFn = routeState => {
|
|
|
31
30
|
}
|
|
32
31
|
|
|
33
32
|
if (item.boolValue) {
|
|
34
|
-
item.boolValue = !!
|
|
33
|
+
item.boolValue = !!item.boolValue;
|
|
35
34
|
}
|
|
36
35
|
|
|
37
36
|
if (item.geoBoundingBox) {
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import React from 'react';
|
|
1
|
+
import React, { useEffect, useState, useMemo } from 'react';
|
|
2
2
|
import Query from './Query';
|
|
3
3
|
import { ApolloClient, InMemoryCache, ApolloProvider } from '@apollo/client';
|
|
4
4
|
import { SearchkitProvider, SearchkitClient } from '@searchkit/client';
|
|
@@ -24,19 +24,39 @@ const defaultChildren = (data, loading) => /*#__PURE__*/React.createElement(Reac
|
|
|
24
24
|
const SearchKit = ({
|
|
25
25
|
query,
|
|
26
26
|
uri,
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
27
|
+
pageSize = 10,
|
|
28
|
+
useRouting = true,
|
|
29
|
+
defaultFilters = {},
|
|
30
|
+
defaultQuery = '',
|
|
31
|
+
children
|
|
30
32
|
}) => {
|
|
31
|
-
const client =
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
33
|
+
const client = useMemo(() => {
|
|
34
|
+
return new ApolloClient({
|
|
35
|
+
uri: uri,
|
|
36
|
+
cache: new InMemoryCache()
|
|
37
|
+
});
|
|
38
|
+
}, [uri]);
|
|
39
|
+
const skClient = useMemo(() => {
|
|
40
|
+
const skClient = new SearchkitClient();
|
|
41
|
+
|
|
42
|
+
if (!useRouting) {
|
|
43
|
+
skClient.updateBaseSearchState({
|
|
44
|
+
filters: defaultFilters,
|
|
45
|
+
query: defaultQuery,
|
|
46
|
+
page: {
|
|
47
|
+
size: pageSize,
|
|
48
|
+
from: 0
|
|
49
|
+
}
|
|
50
|
+
});
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
return skClient;
|
|
54
|
+
}, [useRouting, defaultFilters, defaultQuery, pageSize]);
|
|
36
55
|
return /*#__PURE__*/React.createElement(ApolloProvider, {
|
|
37
56
|
client: client
|
|
38
57
|
}, /*#__PURE__*/React.createElement(SearchkitProvider, {
|
|
39
|
-
client: skClient
|
|
58
|
+
client: skClient,
|
|
59
|
+
key: `${defaultQuery}-${defaultFilters.toString()}`
|
|
40
60
|
}, /*#__PURE__*/React.createElement(Query, {
|
|
41
61
|
query: query,
|
|
42
62
|
useRouting: useRouting
|
|
@@ -45,6 +65,10 @@ const SearchKit = ({
|
|
|
45
65
|
|
|
46
66
|
SearchKit.propTypes = {
|
|
47
67
|
queryString: PropTypes.string,
|
|
48
|
-
uri: PropTypes.string
|
|
68
|
+
uri: PropTypes.string,
|
|
69
|
+
pageSize: PropTypes.number,
|
|
70
|
+
useRouting: PropTypes.bool,
|
|
71
|
+
defaultFilters: PropTypes.object,
|
|
72
|
+
defaultQuery: PropTypes.string
|
|
49
73
|
};
|
|
50
74
|
export default SearchKit;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import React from 'react';
|
|
1
|
+
import React, { useState } from 'react';
|
|
2
2
|
import { useSearchkit } from '@searchkit/client';
|
|
3
3
|
import classNames from 'classnames';
|
|
4
4
|
import SearchKit from '.';
|
|
@@ -46,7 +46,7 @@ const query = `
|
|
|
46
46
|
}
|
|
47
47
|
query
|
|
48
48
|
}
|
|
49
|
-
hits(page: $page
|
|
49
|
+
hits(page: $page) {
|
|
50
50
|
sortedBy
|
|
51
51
|
page {
|
|
52
52
|
total
|
|
@@ -178,4 +178,41 @@ export const CustomFacets = () => {
|
|
|
178
178
|
}), /*#__PURE__*/React.createElement(SearchPagination, {
|
|
179
179
|
data: data
|
|
180
180
|
})));
|
|
181
|
+
};
|
|
182
|
+
export const Test = () => {
|
|
183
|
+
const [q, setQ] = useState(null);
|
|
184
|
+
return /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement("input", {
|
|
185
|
+
onChange: e => setQ(e.target.value),
|
|
186
|
+
value: q
|
|
187
|
+
}), /*#__PURE__*/React.createElement(SearchKit, {
|
|
188
|
+
uri: "http://localhost:4000/api/graphql",
|
|
189
|
+
query: query,
|
|
190
|
+
useRouting: false,
|
|
191
|
+
filters: [{
|
|
192
|
+
identifier: 'type',
|
|
193
|
+
value: 'article'
|
|
194
|
+
}],
|
|
195
|
+
searchQuery: q
|
|
196
|
+
}, (data, loading) => /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement(SearchResults, {
|
|
197
|
+
data: data,
|
|
198
|
+
renderItem: SearchItem,
|
|
199
|
+
renderHeader: SearchHeader
|
|
200
|
+
}), /*#__PURE__*/React.createElement(SearchPagination, {
|
|
201
|
+
data: data
|
|
202
|
+
}))), /*#__PURE__*/React.createElement(SearchKit, {
|
|
203
|
+
uri: "http://localhost:4000/api/graphql",
|
|
204
|
+
query: query,
|
|
205
|
+
useRouting: false,
|
|
206
|
+
filters: [{
|
|
207
|
+
identifier: 'type',
|
|
208
|
+
value: 'landing_page'
|
|
209
|
+
}],
|
|
210
|
+
searchQuery: q
|
|
211
|
+
}, (data, loading) => /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement(SearchResults, {
|
|
212
|
+
data: data,
|
|
213
|
+
renderItem: SearchItem,
|
|
214
|
+
renderHeader: SearchHeader
|
|
215
|
+
}), /*#__PURE__*/React.createElement(SearchPagination, {
|
|
216
|
+
data: data
|
|
217
|
+
}))));
|
|
181
218
|
};
|
|
@@ -14,17 +14,17 @@ export default function useValueForCurrentViewPort(val1, val2, val3, val4, val5)
|
|
|
14
14
|
return;
|
|
15
15
|
} // 768 & 992
|
|
16
16
|
else if (width >= viewportContext.screenSizes.SCREEN_TABLET && width <= viewportContext.screenSizes.SCREEN_NORMAL) {
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
17
|
+
setValueForCurrentViewPort(val2);
|
|
18
|
+
return;
|
|
19
|
+
} // 992 & 1240
|
|
20
|
+
else if (width >= viewportContext.screenSizes.SCREEN_NORMAL && width <= viewportContext.screenSizes.SCREEN_WIDE) {
|
|
21
|
+
setValueForCurrentViewPort(val3);
|
|
22
|
+
return;
|
|
23
|
+
} // 1240 & 2000
|
|
24
|
+
else if (width >= viewportContext.screenSizes.SCREEN_WIDE && width <= viewportContext.screenSizes.SCREEN_HUGE) {
|
|
25
|
+
setValueForCurrentViewPort(val4);
|
|
26
|
+
return;
|
|
27
|
+
} // SCREEN_HUGE and larger
|
|
28
28
|
|
|
29
29
|
|
|
30
30
|
setValueForCurrentViewPort(val5);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@uncinc/uncinc-react-kitchen-sink",
|
|
3
|
-
"version": "2.1.
|
|
3
|
+
"version": "2.1.13",
|
|
4
4
|
"description": "Default React components that are easily extended.",
|
|
5
5
|
"author": "uncinc",
|
|
6
6
|
"license": "MIT",
|
|
@@ -35,30 +35,13 @@
|
|
|
35
35
|
},
|
|
36
36
|
"dependencies": {
|
|
37
37
|
"@apollo/client": "^3.4.16",
|
|
38
|
-
"@babel/cli": "^7.0.0-beta.44",
|
|
39
|
-
"@babel/helper-define-map": "^7.14.5",
|
|
40
|
-
"@babel/plugin-syntax-dynamic-import": "^7.8.3",
|
|
41
|
-
"@babel/runtime": "^7.9.6",
|
|
42
38
|
"@elastic/datemath": "^5.0.3",
|
|
43
39
|
"@elastic/eui": "^40.0.0",
|
|
44
40
|
"@loadable/component": "^5.15.0",
|
|
45
41
|
"@searchkit/client": "^3.0.0-canary.45",
|
|
46
42
|
"@searchkit/elastic-ui": "^3.0.0-canary.45",
|
|
47
|
-
"@storybook/addon-actions": "^6.2.8",
|
|
48
|
-
"@storybook/addon-info": "^5.3.21",
|
|
49
|
-
"@storybook/addon-links": "^6.2.8",
|
|
50
|
-
"@storybook/addons": "^6.2.8",
|
|
51
|
-
"@storybook/react": "^6.2.8",
|
|
52
|
-
"@storybook/theming": "^6.2.8",
|
|
53
|
-
"@testing-library/jest-dom": "^4.2.4",
|
|
54
|
-
"@testing-library/react": "^9.3.2",
|
|
55
|
-
"@testing-library/user-event": "^7.1.2",
|
|
56
43
|
"apollo-server-micro": "^3.4.0",
|
|
57
44
|
"bootstrap": "^4.3.1",
|
|
58
|
-
"chai": "^4.2.0",
|
|
59
|
-
"cross-env": "^7.0.2",
|
|
60
|
-
"enzyme": "^3.11.0",
|
|
61
|
-
"enzyme-adapter-react-16": "^1.15.2",
|
|
62
45
|
"fork-ts-checker-webpack-plugin-alt": "0.4.14",
|
|
63
46
|
"formik": "^2.2.6",
|
|
64
47
|
"graphql": "^15.7.0",
|
|
@@ -84,16 +67,35 @@
|
|
|
84
67
|
"react-redux": "^7.2.4",
|
|
85
68
|
"react-router": "5.2.0",
|
|
86
69
|
"react-router-dom": "5.2.0",
|
|
87
|
-
"react-scripts": "3.4.1",
|
|
88
70
|
"react-select": "^3.1.0",
|
|
89
71
|
"react-share": "^4.3.1",
|
|
90
72
|
"react-slick": "^0.27.14",
|
|
91
|
-
"react-test-renderer": "^16.13.1",
|
|
92
73
|
"redux": "^4.0.5",
|
|
93
74
|
"sass-loader": "^8.0.2",
|
|
75
|
+
"slick-carousel": "^1.8.1"
|
|
76
|
+
},
|
|
77
|
+
"devDependencies": {
|
|
78
|
+
"@babel/cli": "^7.0.0-beta.44",
|
|
79
|
+
"@babel/helper-define-map": "^7.14.5",
|
|
80
|
+
"@babel/plugin-syntax-dynamic-import": "^7.8.3",
|
|
81
|
+
"@babel/runtime": "^7.9.6",
|
|
82
|
+
"@storybook/addon-actions": "^6.2.8",
|
|
83
|
+
"@storybook/addon-info": "^5.3.21",
|
|
84
|
+
"@storybook/addon-links": "^6.2.8",
|
|
85
|
+
"@storybook/addons": "^6.2.8",
|
|
86
|
+
"@storybook/react": "^6.2.8",
|
|
87
|
+
"@storybook/theming": "^6.2.8",
|
|
88
|
+
"@testing-library/jest-dom": "^4.2.4",
|
|
89
|
+
"@testing-library/react": "^9.3.2",
|
|
90
|
+
"@testing-library/user-event": "^7.1.2",
|
|
91
|
+
"chai": "^4.2.0",
|
|
92
|
+
"cross-env": "^7.0.2",
|
|
93
|
+
"enzyme": "^3.11.0",
|
|
94
|
+
"enzyme-adapter-react-16": "^1.15.2",
|
|
95
|
+
"react-scripts": "3.4.1",
|
|
96
|
+
"react-test-renderer": "^16.13.1",
|
|
94
97
|
"sinon": "^9.0.2",
|
|
95
98
|
"sinon-chai": "^3.5.0",
|
|
96
|
-
"slick-carousel": "^1.8.1",
|
|
97
99
|
"storybook-addon-export-stories": "^1.0.0"
|
|
98
100
|
},
|
|
99
101
|
"eslintConfig": {
|