@urbanos/react-discovery-ui 2.1.43
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/LICENSE +201 -0
- package/README.md +118 -0
- package/lib/ReactDiscoveryUI.js +103 -0
- package/lib/ReactDiscoveryUI.scss +13 -0
- package/lib/assets/arrow.svg +6 -0
- package/lib/assets/blk-database.svg +48 -0
- package/lib/assets/chart.svg +1 -0
- package/lib/assets/down.png +0 -0
- package/lib/assets/down.svg +1 -0
- package/lib/assets/folder_icon.png +0 -0
- package/lib/assets/folder_icon.svg +1 -0
- package/lib/assets/ic_arrow.svg +15 -0
- package/lib/assets/loadingicon.svg +57 -0
- package/lib/assets/no_image.png +0 -0
- package/lib/assets/plus.png +0 -0
- package/lib/assets/plus.svg +1 -0
- package/lib/assets/user.svg +1 -0
- package/lib/auth/auth0-client-provider.js +37 -0
- package/lib/auth/auth0-client-provider.test.js +33 -0
- package/lib/auth/auth0-wrapper.js +155 -0
- package/lib/auth/auth0-wrapper.test.js +100 -0
- package/lib/components/auth0-login-zone/auth0-login-zone.js +147 -0
- package/lib/components/auth0-login-zone/auth0-login-zone.test.js +177 -0
- package/lib/components/auth0-login-zone/index.js +9 -0
- package/lib/components/code-editor/code-editor.css +173 -0
- package/lib/components/code-editor/code-editor.js +64 -0
- package/lib/components/code-editor/index.js +9 -0
- package/lib/components/collapsable-box/collapsable-box.js +81 -0
- package/lib/components/collapsable-box/collapsable-box.scss +39 -0
- package/lib/components/collapsable-box/collapsable-box.test.js +87 -0
- package/lib/components/collapsable-box/index.js +9 -0
- package/lib/components/data-card/data-card.js +63 -0
- package/lib/components/data-card/data-card.scss +93 -0
- package/lib/components/data-card/data-card.test.js +74 -0
- package/lib/components/data-card/index.js +9 -0
- package/lib/components/data-view/data-view.js +194 -0
- package/lib/components/data-view/data-view.scss +39 -0
- package/lib/components/data-view/data-view.test.js +155 -0
- package/lib/components/data-view/index.js +9 -0
- package/lib/components/dataset-api-doc/api-example.js +120 -0
- package/lib/components/dataset-api-doc/api-example.scss +84 -0
- package/lib/components/dataset-api-doc/api-example.test.js +88 -0
- package/lib/components/dataset-api-doc/dataset-api-doc.js +117 -0
- package/lib/components/dataset-api-doc/dataset-api-doc.scss +8 -0
- package/lib/components/dataset-api-doc/dataset-api-doc.test.js +42 -0
- package/lib/components/dataset-api-doc/index.js +9 -0
- package/lib/components/dataset-details/dataset-details.js +64 -0
- package/lib/components/dataset-details/dataset-details.scss +58 -0
- package/lib/components/dataset-details/dataset-details.test.js +38 -0
- package/lib/components/dataset-details/index.js +9 -0
- package/lib/components/dataset-dictionary/dataset-dictionary.js +127 -0
- package/lib/components/dataset-dictionary/dataset-dictionary.scss +42 -0
- package/lib/components/dataset-dictionary/dataset-dictionary.test.js +286 -0
- package/lib/components/dataset-dictionary/index.js +9 -0
- package/lib/components/dataset-list/dataset-list.js +22 -0
- package/lib/components/dataset-list/dataset-list.scss +9 -0
- package/lib/components/dataset-list/dataset-list.test.js +16 -0
- package/lib/components/dataset-list/index.js +9 -0
- package/lib/components/dataset-metadata/dataset-metadata.js +169 -0
- package/lib/components/dataset-metadata/dataset-metadata.scss +34 -0
- package/lib/components/dataset-metadata/dataset-metadata.test.js +24 -0
- package/lib/components/dataset-metadata/index.js +9 -0
- package/lib/components/dataset-preview/connector.js +26 -0
- package/lib/components/dataset-preview/dataset-preview.js +58 -0
- package/lib/components/dataset-preview/dataset-preview.scss +24 -0
- package/lib/components/dataset-preview/dataset-preview.test.js +34 -0
- package/lib/components/dataset-preview/index.js +9 -0
- package/lib/components/dataset-quality/dataset-quality.js +56 -0
- package/lib/components/dataset-quality/dataset-quality.scss +24 -0
- package/lib/components/dataset-quality/dataset-quality.test.js +34 -0
- package/lib/components/dataset-quality/index.js +9 -0
- package/lib/components/dataset-recommendations/connector.js +24 -0
- package/lib/components/dataset-recommendations/dataset-recommendations.js +47 -0
- package/lib/components/dataset-recommendations/dataset-recommendations.scss +17 -0
- package/lib/components/dataset-recommendations/dataset-recommendations.test.js +37 -0
- package/lib/components/dataset-recommendations/index.js +9 -0
- package/lib/components/detail-toggle-icon/detail-toggle-icon.js +41 -0
- package/lib/components/detail-toggle-icon/detail-toggle-icon.scss +13 -0
- package/lib/components/detail-toggle-icon/detail-toggle-icon.test.js +20 -0
- package/lib/components/detail-toggle-icon/index.js +9 -0
- package/lib/components/facet-list/facet-list.js +47 -0
- package/lib/components/facet-list/facet-list.scss +19 -0
- package/lib/components/facet-list/facet-list.test.js +94 -0
- package/lib/components/facet-list/index.js +9 -0
- package/lib/components/facet-sidebar/facet-sidebar.js +101 -0
- package/lib/components/facet-sidebar/facet-sidebar.scss +129 -0
- package/lib/components/facet-sidebar/facet-sidebar.test.js +93 -0
- package/lib/components/facet-sidebar/index.js +9 -0
- package/lib/components/generic-elements/alert-component/alert-component.js +51 -0
- package/lib/components/generic-elements/alert-component/alert-component.scss +26 -0
- package/lib/components/generic-elements/alert-component/alert-component.test.js +26 -0
- package/lib/components/generic-elements/alert-component/index.js +9 -0
- package/lib/components/generic-elements/arrow-button/arrow-button.js +30 -0
- package/lib/components/generic-elements/arrow-button/index.js +9 -0
- package/lib/components/generic-elements/auto-anchoring-popover/index.js +61 -0
- package/lib/components/generic-elements/back-button/back-button.js +14 -0
- package/lib/components/generic-elements/back-button/back-button.scss +14 -0
- package/lib/components/generic-elements/back-button/index.js +9 -0
- package/lib/components/generic-elements/call-to-action-button/call-to-action-button.js +118 -0
- package/lib/components/generic-elements/call-to-action-button/call-to-action-button.scss +19 -0
- package/lib/components/generic-elements/call-to-action-button/call-to-action-button.test.js +68 -0
- package/lib/components/generic-elements/call-to-action-button/index.js +9 -0
- package/lib/components/generic-elements/chart-icon/index.js +23 -0
- package/lib/components/generic-elements/checkbox/checkbox.js +50 -0
- package/lib/components/generic-elements/checkbox/checkbox.scss +44 -0
- package/lib/components/generic-elements/checkbox/checkbox.test.js +71 -0
- package/lib/components/generic-elements/checkbox/index.js +9 -0
- package/lib/components/generic-elements/error-component/error-component.js +21 -0
- package/lib/components/generic-elements/error-component/error-component.scss +16 -0
- package/lib/components/generic-elements/error-component/error-component.test.js +12 -0
- package/lib/components/generic-elements/error-component/index.js +9 -0
- package/lib/components/generic-elements/folder-icon/index.js +23 -0
- package/lib/components/generic-elements/generated-link/generated-link.js +25 -0
- package/lib/components/generic-elements/generated-link/index.js +13 -0
- package/lib/components/generic-elements/loading-element/index.js +9 -0
- package/lib/components/generic-elements/loading-element/loading-element.js +22 -0
- package/lib/components/generic-elements/loading-element/loading-element.scss +6 -0
- package/lib/components/generic-elements/loading-element/loading-element.test.js +11 -0
- package/lib/components/generic-elements/paginator/index.js +9 -0
- package/lib/components/generic-elements/paginator/paginator.js +84 -0
- package/lib/components/generic-elements/paginator/paginator.scss +38 -0
- package/lib/components/generic-elements/paginator/paginator.test.js +140 -0
- package/lib/components/generic-elements/plus-icon/index.js +21 -0
- package/lib/components/generic-elements/save-indicator/index.js +9 -0
- package/lib/components/generic-elements/save-indicator/save-indicator.js +39 -0
- package/lib/components/generic-elements/save-indicator/save-indicator.scss +31 -0
- package/lib/components/generic-elements/save-indicator/save-indicator.test.js +89 -0
- package/lib/components/generic-elements/search/index.js +9 -0
- package/lib/components/generic-elements/search/search.js +93 -0
- package/lib/components/generic-elements/search/search.scss +90 -0
- package/lib/components/generic-elements/search/search.test.js +41 -0
- package/lib/components/generic-elements/select/index.js +9 -0
- package/lib/components/generic-elements/select/select.js +44 -0
- package/lib/components/generic-elements/select/select.scss +22 -0
- package/lib/components/generic-elements/select/select.test.js +34 -0
- package/lib/components/generic-elements/share-link/index.js +9 -0
- package/lib/components/generic-elements/share-link/share-link.js +23 -0
- package/lib/components/generic-elements/share-link/share-link.scss +17 -0
- package/lib/components/generic-elements/share-link/share-link.test.js +28 -0
- package/lib/components/generic-elements/sql-icon/index.js +20 -0
- package/lib/components/generic-elements/tab-button/index.js +9 -0
- package/lib/components/generic-elements/tab-button/tab-button.js +25 -0
- package/lib/components/generic-elements/tab-button/tab-button.scss +27 -0
- package/lib/components/generic-elements/visualize-button/index.js +9 -0
- package/lib/components/generic-elements/visualize-button/visualize-button.js +37 -0
- package/lib/components/generic-elements/visualize-button/visualize-button.scss +14 -0
- package/lib/components/login-zone/connector.js +25 -0
- package/lib/components/login-zone/index.js +9 -0
- package/lib/components/login-zone/login-svgs-and-text.js +39 -0
- package/lib/components/login-zone/login-zone.js +21 -0
- package/lib/components/login-zone/login-zone.scss +115 -0
- package/lib/components/login-zone/login-zone.test.js +17 -0
- package/lib/components/login-zone/login.js +48 -0
- package/lib/components/login-zone/logout.js +39 -0
- package/lib/components/network-loading-element/connector.js +17 -0
- package/lib/components/network-loading-element/index.js +9 -0
- package/lib/components/network-loading-element/network-loading-element.js +23 -0
- package/lib/components/network-loading-element/network-loading-element.scss +21 -0
- package/lib/components/network-loading-element/network-loading-element.test.js +34 -0
- package/lib/components/organization/index.js +9 -0
- package/lib/components/organization/organization.js +27 -0
- package/lib/components/organization/organization.scss +32 -0
- package/lib/components/protected-route/protected-route.js +101 -0
- package/lib/components/protected-route/protected-route.scss +4 -0
- package/lib/components/protected-route/protected-route.test.js +63 -0
- package/lib/components/query-form/index.js +9 -0
- package/lib/components/query-form/query-form.js +262 -0
- package/lib/components/query-form/query-form.scss +167 -0
- package/lib/components/query-form/query-form.test.js +248 -0
- package/lib/components/recommendation-list/index.js +9 -0
- package/lib/components/recommendation-list/recommendation-list.js +72 -0
- package/lib/components/recommendation-list/recommendation-list.scss +61 -0
- package/lib/components/recommendation-list/recommendation-list.test.js +38 -0
- package/lib/components/remote-toggle/__snapshots__/remote-toggle.test.js.snap +3 -0
- package/lib/components/remote-toggle/index.js +13 -0
- package/lib/components/remote-toggle/remote-toggle.js +35 -0
- package/lib/components/remote-toggle/remote-toggle.scss +0 -0
- package/lib/components/remote-toggle/remote-toggle.test.js +10 -0
- package/lib/components/share/index.js +9 -0
- package/lib/components/share/share.js +109 -0
- package/lib/components/share/share.scss +66 -0
- package/lib/components/streaming-api-doc/index.js +9 -0
- package/lib/components/streaming-api-doc/streaming-api-doc.js +76 -0
- package/lib/components/streaming-api-doc/streaming-api-doc.scss +23 -0
- package/lib/components/streaming-api-doc/streaming-api-doc.test.js +24 -0
- package/lib/components/tooltip/index.js +9 -0
- package/lib/components/tooltip/tooltip.js +17 -0
- package/lib/components/tooltip/tooltip.scss +16 -0
- package/lib/components/tooltip/tooltip.test.js +19 -0
- package/lib/components/visualization-list-menu-item/index.js +9 -0
- package/lib/components/visualization-list-menu-item/visualization-list-menu-item.js +53 -0
- package/lib/components/visualization-list-menu-item/visualization-list-menu-item.scss +21 -0
- package/lib/components/visualization-list-menu-item/visualization-list-menu-item.test.js +42 -0
- package/lib/components/visualization-save-menu-item/index.js +9 -0
- package/lib/components/visualization-save-menu-item/visualization-save-menu-item.js +101 -0
- package/lib/components/visualization-save-menu-item/visualization-save-menu-item.scss +37 -0
- package/lib/components/visualization-save-menu-item/visualization-save-menu-item.test.js +185 -0
- package/lib/components/visualizations/geojson/connector.js +29 -0
- package/lib/components/visualizations/geojson/geojson-visualization.js +151 -0
- package/lib/components/visualizations/geojson/geojson-visualization.scss +24 -0
- package/lib/components/visualizations/geojson/geojson-visualization.test.js +238 -0
- package/lib/components/visualizations/geojson/index.js +9 -0
- package/lib/pages/apikey-view/apiKey-view.test.js +204 -0
- package/lib/pages/apikey-view/apikey-view.js +166 -0
- package/lib/pages/apikey-view/apikey-view.scss +340 -0
- package/lib/pages/apikey-view/connector.js +31 -0
- package/lib/pages/apikey-view/index.js +9 -0
- package/lib/pages/chart-view/chart-view.js +92 -0
- package/lib/pages/chart-view/chart-view.scss +35 -0
- package/lib/pages/chart-view/chart-view.test.js +206 -0
- package/lib/pages/chart-view/connector.js +30 -0
- package/lib/pages/chart-view/index.js +9 -0
- package/lib/pages/dataset-detail-view/connector.js +38 -0
- package/lib/pages/dataset-detail-view/dataset-detail-view-connector.test.js +42 -0
- package/lib/pages/dataset-detail-view/dataset-detail-view.js +99 -0
- package/lib/pages/dataset-detail-view/dataset-detail-view.scss +190 -0
- package/lib/pages/dataset-detail-view/dataset-detail-view.test.js +305 -0
- package/lib/pages/dataset-detail-view/index.js +9 -0
- package/lib/pages/dataset-list-view/connector.js +30 -0
- package/lib/pages/dataset-list-view/dataset-list-view.js +132 -0
- package/lib/pages/dataset-list-view/dataset-list-view.scss +242 -0
- package/lib/pages/dataset-list-view/dataset-list-view.test.js +162 -0
- package/lib/pages/dataset-list-view/index.js +9 -0
- package/lib/pages/dataset-view/connector.js +55 -0
- package/lib/pages/dataset-view/dataset-view-connector.test.js +78 -0
- package/lib/pages/dataset-view/dataset-view.js +175 -0
- package/lib/pages/dataset-view/dataset-view.scss +95 -0
- package/lib/pages/dataset-view/dataset-view.test.js +157 -0
- package/lib/pages/dataset-view/index.js +9 -0
- package/lib/pages/login-view/connector.js +25 -0
- package/lib/pages/login-view/index.js +9 -0
- package/lib/pages/login-view/login-view.js +83 -0
- package/lib/pages/login-view/login-view.scss +62 -0
- package/lib/pages/login-view/login-view.test.js +23 -0
- package/lib/pages/oauth-error-view/index.js +9 -0
- package/lib/pages/oauth-error-view/oauth-error-view.js +25 -0
- package/lib/pages/oauth-error-view/oauth-error-view.scss +13 -0
- package/lib/pages/oauth-error-view/oauth-error-view.test.js +13 -0
- package/lib/pages/oauth-view/connector.js +22 -0
- package/lib/pages/oauth-view/index.js +9 -0
- package/lib/pages/oauth-view/oauth-view.js +124 -0
- package/lib/pages/oauth-view/oauth-view.scss +7 -0
- package/lib/pages/oauth-view/oauth-view.test.js +195 -0
- package/lib/pages/query-view/connector.js +40 -0
- package/lib/pages/query-view/index.js +9 -0
- package/lib/pages/query-view/query-view.js +80 -0
- package/lib/pages/query-view/query-view.scss +39 -0
- package/lib/pages/query-view/query-view.test.js +104 -0
- package/lib/pages/user-profile-view/connector.js +39 -0
- package/lib/pages/user-profile-view/index.js +9 -0
- package/lib/pages/user-profile-view/user-profile-view.js +154 -0
- package/lib/pages/user-profile-view/user-profile-view.scss +81 -0
- package/lib/pages/user-profile-view/user-profile-view.test.js +129 -0
- package/lib/pages/visualization-view/connector.js +52 -0
- package/lib/pages/visualization-view/index.js +9 -0
- package/lib/pages/visualization-view/visualization-view-connector.test.js +62 -0
- package/lib/pages/visualization-view/visualization-view.js +128 -0
- package/lib/pages/visualization-view/visualization-view.scss +115 -0
- package/lib/pages/visualization-view/visualization-view.test.js +188 -0
- package/lib/routes.js +18 -0
- package/lib/search-params/search-params-manager.js +171 -0
- package/lib/search-params/search-params-manager.test.js +490 -0
- package/lib/store/actions.js +428 -0
- package/lib/store/dataset-selectors.js +47 -0
- package/lib/store/dataset-selectors.test.js +154 -0
- package/lib/store/query-selectors.js +53 -0
- package/lib/store/query-selectors.test.js +153 -0
- package/lib/store/reducers/index.js +20 -0
- package/lib/store/reducers/query-reducer.js +52 -0
- package/lib/store/reducers/query-reducer.test.js +89 -0
- package/lib/store/reducers/reducers.js +196 -0
- package/lib/store/reducers/reducers.test.js +309 -0
- package/lib/store/reducers/visualization-reducer.js +167 -0
- package/lib/store/reducers/visualization-reducer.test.js +426 -0
- package/lib/store/sagas/api-invoker.js +79 -0
- package/lib/store/sagas/api-invoker.test.js +139 -0
- package/lib/store/sagas/apiKey-saga.js +81 -0
- package/lib/store/sagas/apiKey-saga.test.js +57 -0
- package/lib/store/sagas/dataset-download-saga.js +43 -0
- package/lib/store/sagas/dataset-list-saga.js +49 -0
- package/lib/store/sagas/dataset-list-saga.test.js +72 -0
- package/lib/store/sagas/dataset-preview-saga.js +44 -0
- package/lib/store/sagas/dataset-query-saga.js +43 -0
- package/lib/store/sagas/dataset-recommendation-saga.js +40 -0
- package/lib/store/sagas/dataset-saga.js +50 -0
- package/lib/store/sagas/freestyle-query-saga.js +127 -0
- package/lib/store/sagas/freestyle-query-saga.test.js +145 -0
- package/lib/store/sagas/index.js +44 -0
- package/lib/store/sagas/login-saga.js +85 -0
- package/lib/store/sagas/login-saga.test.js +84 -0
- package/lib/store/sagas/logout-saga.js +96 -0
- package/lib/store/sagas/oauth-saga.js +78 -0
- package/lib/store/sagas/oauth-saga.test.js +51 -0
- package/lib/store/sagas/process-login-saga.js +62 -0
- package/lib/store/sagas/process-login-saga.test.js +83 -0
- package/lib/store/sagas/visualization-saga.js +371 -0
- package/lib/store/sagas/visualization-saga.test.js +388 -0
- package/lib/store/selectors.js +83 -0
- package/lib/store/visualization-selectors.js +85 -0
- package/lib/store/visualization-selectors.test.js +195 -0
- package/lib/styles/mixins.scss +117 -0
- package/lib/styles/variables.scss +41 -0
- package/lib/utils/file-type-utils.js +18 -0
- package/lib/utils/file-type-utils.test.js +29 -0
- package/lib/utils/geojson-utils.js +70 -0
- package/lib/utils/geojson-utils.test.js +129 -0
- package/lib/utils/http-clients.js +218 -0
- package/lib/utils/http-clients.test.js +88 -0
- package/lib/utils/index.js +34 -0
- package/lib/utils/modified-date-string-builder.js +29 -0
- package/lib/utils/modified-date-string-builder.test.js +93 -0
- package/lib/utils/query-string-builder.js +38 -0
- package/lib/utils/query-string-builder.test.js +33 -0
- package/lib/utils/recommendation-utils.js +12 -0
- package/lib/utils/recommendation-utils.test.js +9 -0
- package/package.json +172 -0
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.default = void 0;
|
|
7
|
+
require("./paginator.scss");
|
|
8
|
+
var _lodash = _interopRequireDefault(require("lodash"));
|
|
9
|
+
var _arrowButton = _interopRequireDefault(require("../arrow-button"));
|
|
10
|
+
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
|
|
11
|
+
var DISPLAY_SIZE = 7;
|
|
12
|
+
// Half the display width minus the first/last element and the elipsis
|
|
13
|
+
var MIDDLE_WIDTH = DISPLAY_SIZE / 2 - 2;
|
|
14
|
+
var _default = exports.default = function _default(_ref) {
|
|
15
|
+
var className = _ref.className,
|
|
16
|
+
numberOfPages = _ref.numberOfPages,
|
|
17
|
+
currentPage = _ref.currentPage,
|
|
18
|
+
pageChangeCallback = _ref.pageChangeCallback;
|
|
19
|
+
var options = calculateOptions(numberOfPages, currentPage);
|
|
20
|
+
return /*#__PURE__*/React.createElement("paginator-element", {
|
|
21
|
+
"data-testid": "paginator",
|
|
22
|
+
class: className
|
|
23
|
+
}, /*#__PURE__*/React.createElement(_arrowButton.default, {
|
|
24
|
+
className: "pagination-box arrow",
|
|
25
|
+
disabled: currentPage === 1,
|
|
26
|
+
onClick: function onClick() {
|
|
27
|
+
return onLeftArrowClick(currentPage, pageChangeCallback);
|
|
28
|
+
},
|
|
29
|
+
innerClass: "left-arrow"
|
|
30
|
+
}), options.map(function (text, index) {
|
|
31
|
+
return createOption(index, text, currentPage, pageChangeCallback);
|
|
32
|
+
}), /*#__PURE__*/React.createElement(_arrowButton.default, {
|
|
33
|
+
className: "pagination-box arrow",
|
|
34
|
+
disabled: currentPage === numberOfPages,
|
|
35
|
+
onClick: function onClick() {
|
|
36
|
+
return onRightArrowClick(currentPage, numberOfPages, pageChangeCallback);
|
|
37
|
+
},
|
|
38
|
+
innerClass: "right-arrow"
|
|
39
|
+
}));
|
|
40
|
+
};
|
|
41
|
+
var createOption = function createOption(index, text, currentPage, pageChangeCallback) {
|
|
42
|
+
var isSelected = text === currentPage;
|
|
43
|
+
var isEllipsis = text === '...';
|
|
44
|
+
var typeClass = isEllipsis ? 'ellipsis' : 'page-number';
|
|
45
|
+
var selectedClass = isSelected ? 'selected' : '';
|
|
46
|
+
var onClick = isSelected || isEllipsis ? function () {} : function () {
|
|
47
|
+
return pageChangeCallback(text);
|
|
48
|
+
};
|
|
49
|
+
return /*#__PURE__*/React.createElement("button", {
|
|
50
|
+
key: "pagination-option-".concat(index),
|
|
51
|
+
disabled: isSelected,
|
|
52
|
+
className: "pagination-box option ".concat(typeClass, " ").concat(selectedClass),
|
|
53
|
+
onClick: onClick
|
|
54
|
+
}, text);
|
|
55
|
+
};
|
|
56
|
+
var onLeftArrowClick = function onLeftArrowClick(currentPage, pageChangeCallback) {
|
|
57
|
+
if (currentPage > 1) {
|
|
58
|
+
pageChangeCallback(currentPage - 1);
|
|
59
|
+
}
|
|
60
|
+
};
|
|
61
|
+
var onRightArrowClick = function onRightArrowClick(currentPage, numberOfPages, pageChangeCallback) {
|
|
62
|
+
if (currentPage < numberOfPages) {
|
|
63
|
+
pageChangeCallback(currentPage + 1);
|
|
64
|
+
}
|
|
65
|
+
};
|
|
66
|
+
var calculateOptions = function calculateOptions(numberOfPages, currentPage) {
|
|
67
|
+
var needsTrailingElipsis = numberOfPages > DISPLAY_SIZE && currentPage < numberOfPages - DISPLAY_SIZE / 2;
|
|
68
|
+
var needsLeadingElipsis = numberOfPages > DISPLAY_SIZE && currentPage > 1 + DISPLAY_SIZE / 2;
|
|
69
|
+
var middleStart, middleEnd;
|
|
70
|
+
if (needsLeadingElipsis && needsTrailingElipsis) {
|
|
71
|
+
middleStart = Math.ceil(currentPage - MIDDLE_WIDTH);
|
|
72
|
+
middleEnd = Math.ceil(currentPage + MIDDLE_WIDTH);
|
|
73
|
+
} else if (needsLeadingElipsis && !needsTrailingElipsis) {
|
|
74
|
+
middleStart = Math.floor(numberOfPages - DISPLAY_SIZE / 2);
|
|
75
|
+
middleEnd = numberOfPages;
|
|
76
|
+
} else if (!needsLeadingElipsis && needsTrailingElipsis) {
|
|
77
|
+
middleStart = 2;
|
|
78
|
+
middleEnd = DISPLAY_SIZE - 1;
|
|
79
|
+
} else {
|
|
80
|
+
middleStart = 2;
|
|
81
|
+
middleEnd = numberOfPages;
|
|
82
|
+
}
|
|
83
|
+
return (0, _lodash.default)([1, needsLeadingElipsis ? '...' : null, numberOfPages > 2 ? _lodash.default.range(middleStart, middleEnd) : null, needsTrailingElipsis ? '...' : null, numberOfPages > 1 ? numberOfPages : null]).flatten().compact().value();
|
|
84
|
+
};
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
@import '../../../styles/mixins.scss';
|
|
2
|
+
@import '../../../styles/variables.scss';
|
|
3
|
+
|
|
4
|
+
paginator-element {
|
|
5
|
+
/*@include flex-row();*/
|
|
6
|
+
|
|
7
|
+
.pagination-box {
|
|
8
|
+
/* @include flex-column();*/
|
|
9
|
+
height: 2.875rem;
|
|
10
|
+
width: 2.875rem;
|
|
11
|
+
border: 1px solid #D2D4D6;
|
|
12
|
+
background-color: white;
|
|
13
|
+
margin: 0px 2px;
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
.page-number,
|
|
17
|
+
.arrow {
|
|
18
|
+
&:hover:not(.selected):not(.disabled) {
|
|
19
|
+
background-color: rgba(235, 237, 240, 0.4);
|
|
20
|
+
color: $light-blue;
|
|
21
|
+
cursor: pointer;
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
.right-arrow svg {
|
|
26
|
+
transform: rotate(180deg);
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
.right-arrow,
|
|
30
|
+
.left-arrow {
|
|
31
|
+
height: .9rem;
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
.selected {
|
|
35
|
+
font-weight: bold;
|
|
36
|
+
background-color: #f7f7f7;
|
|
37
|
+
}
|
|
38
|
+
}
|
|
@@ -0,0 +1,140 @@
|
|
|
1
|
+
import Paginator from './paginator'
|
|
2
|
+
import ArrowButton from '../arrow-button'
|
|
3
|
+
import { shallow } from 'enzyme'
|
|
4
|
+
|
|
5
|
+
describe('Paginator', () => {
|
|
6
|
+
test('sets the text of the option to 1 when number of pages is 1', () => {
|
|
7
|
+
const subject = shallow(<Paginator currentPage={1} numberOfPages={1} />)
|
|
8
|
+
|
|
9
|
+
expect(subject.find('.option').text()).toEqual('1')
|
|
10
|
+
})
|
|
11
|
+
|
|
12
|
+
test('sets the text of the options correctly when number of pages is 7', () => {
|
|
13
|
+
const expected = ['1', '2', '3', '4', '5', '6', '7']
|
|
14
|
+
|
|
15
|
+
const subject = shallow(<Paginator currentPage={1} numberOfPages={7} />)
|
|
16
|
+
|
|
17
|
+
expect(subject.find('.option').map(it => it.text())).toEqual(expected)
|
|
18
|
+
})
|
|
19
|
+
|
|
20
|
+
test('sets the text of the options correctly when current page is 4 with more 8 total pages', () => {
|
|
21
|
+
const expected = ['1', '2', '3', '4', '5', '...', '8']
|
|
22
|
+
|
|
23
|
+
const subject = shallow(<Paginator currentPage={4} numberOfPages={8} />)
|
|
24
|
+
|
|
25
|
+
expect(subject.find('.option').map(it => it.text())).toEqual(expected)
|
|
26
|
+
})
|
|
27
|
+
|
|
28
|
+
test('sets the text of the options correctly when current page is 1 with more 8 total pages', () => {
|
|
29
|
+
const expected = ['1', '2', '3', '4', '5', '...', '8']
|
|
30
|
+
|
|
31
|
+
const subject = shallow(<Paginator currentPage={1} numberOfPages={8} />)
|
|
32
|
+
|
|
33
|
+
expect(subject.find('.option').map(it => it.text())).toEqual(expected)
|
|
34
|
+
})
|
|
35
|
+
|
|
36
|
+
test('sets the text of the options correctly when current page is 11 with 14 total pages', () => {
|
|
37
|
+
const expected = ['1', '...', '10', '11', '12', '13', '14']
|
|
38
|
+
|
|
39
|
+
const subject = shallow(<Paginator currentPage={11} numberOfPages={14} />)
|
|
40
|
+
|
|
41
|
+
expect(subject.find('.option').map(it => it.text())).toEqual(expected)
|
|
42
|
+
})
|
|
43
|
+
|
|
44
|
+
test('sets the text of the options correctly when current page is 14 with 14 total pages', () => {
|
|
45
|
+
const expected = ['1', '...', '10', '11', '12', '13', '14']
|
|
46
|
+
|
|
47
|
+
const subject = shallow(<Paginator currentPage={14} numberOfPages={14} />)
|
|
48
|
+
|
|
49
|
+
expect(subject.find('.option').map(it => it.text())).toEqual(expected)
|
|
50
|
+
})
|
|
51
|
+
|
|
52
|
+
test('sets the text of the options correctly when current page is 6 with 20 total pages', () => {
|
|
53
|
+
const expected = ['1', '...', '5', '6', '7', '...', '20']
|
|
54
|
+
|
|
55
|
+
const subject = shallow(<Paginator currentPage={6} numberOfPages={20} />)
|
|
56
|
+
|
|
57
|
+
expect(subject.find('.option').map(it => it.text())).toEqual(expected)
|
|
58
|
+
})
|
|
59
|
+
|
|
60
|
+
test('sets the text of the options correctly when current page is 1 with 3 total pages', () => {
|
|
61
|
+
const expected = ['1', '2', '3']
|
|
62
|
+
|
|
63
|
+
const subject = shallow(<Paginator currentPage={1} numberOfPages={3} />)
|
|
64
|
+
|
|
65
|
+
expect(subject.find('.option').map(it => it.text())).toEqual(expected)
|
|
66
|
+
})
|
|
67
|
+
|
|
68
|
+
describe('clicking behavior', () => {
|
|
69
|
+
let subject, pageChangeCallback
|
|
70
|
+
|
|
71
|
+
beforeEach(() => {
|
|
72
|
+
pageChangeCallback = jest.fn()
|
|
73
|
+
subject = shallow(<Paginator currentPage={1} numberOfPages={15} pageChangeCallback={pageChangeCallback} />)
|
|
74
|
+
})
|
|
75
|
+
|
|
76
|
+
test('clicking a page number invokes the pageChangeCallback with the page number clicked', () => {
|
|
77
|
+
const thirdPage = subject.find('.page-number').at(2)
|
|
78
|
+
|
|
79
|
+
thirdPage.simulate('click')
|
|
80
|
+
|
|
81
|
+
expect(pageChangeCallback).toHaveBeenCalledWith(3)
|
|
82
|
+
})
|
|
83
|
+
|
|
84
|
+
test('clicking the existing page number does nothing', () => {
|
|
85
|
+
const selectedPage = subject.find('.selected').at(0)
|
|
86
|
+
|
|
87
|
+
selectedPage.simulate('click')
|
|
88
|
+
|
|
89
|
+
expect(pageChangeCallback).not.toHaveBeenCalled()
|
|
90
|
+
})
|
|
91
|
+
|
|
92
|
+
test('clicking an ellipsis does nothing', () => {
|
|
93
|
+
const ellipsisElement = subject.find('.ellipsis').at(0)
|
|
94
|
+
|
|
95
|
+
ellipsisElement.simulate('click')
|
|
96
|
+
|
|
97
|
+
expect(pageChangeCallback).not.toHaveBeenCalled()
|
|
98
|
+
})
|
|
99
|
+
})
|
|
100
|
+
|
|
101
|
+
describe('arrow functionality', () => {
|
|
102
|
+
let pageChangeCallback
|
|
103
|
+
|
|
104
|
+
beforeEach(() => {
|
|
105
|
+
pageChangeCallback = jest.fn()
|
|
106
|
+
})
|
|
107
|
+
|
|
108
|
+
test('clicking the left arrow when on the first page does nothing', () => {
|
|
109
|
+
const subject = shallow(<Paginator currentPage={1} numberOfPages={15} pageChangeCallback={pageChangeCallback} />)
|
|
110
|
+
|
|
111
|
+
subject.find(ArrowButton).at(0).props().onClick()
|
|
112
|
+
|
|
113
|
+
expect(pageChangeCallback).not.toHaveBeenCalled()
|
|
114
|
+
})
|
|
115
|
+
|
|
116
|
+
test('clicking the right arrow when on the last page does nothing', () => {
|
|
117
|
+
const subject = shallow(<Paginator currentPage={15} numberOfPages={15} pageChangeCallback={pageChangeCallback} />)
|
|
118
|
+
|
|
119
|
+
subject.find(ArrowButton).at(1).props().onClick()
|
|
120
|
+
|
|
121
|
+
expect(pageChangeCallback).not.toHaveBeenCalled()
|
|
122
|
+
})
|
|
123
|
+
|
|
124
|
+
test('clicking the left arrow invokes the pageChangeCallback with the previous page', () => {
|
|
125
|
+
const subject = shallow(<Paginator currentPage={4} numberOfPages={15} pageChangeCallback={pageChangeCallback} />)
|
|
126
|
+
|
|
127
|
+
subject.find(ArrowButton).at(0).props().onClick()
|
|
128
|
+
|
|
129
|
+
expect(pageChangeCallback).toHaveBeenCalledWith(3)
|
|
130
|
+
})
|
|
131
|
+
|
|
132
|
+
test('clicking the right arrow invokes the pageChangeCallback with the next page', () => {
|
|
133
|
+
const subject = shallow(<Paginator currentPage={4} numberOfPages={15} pageChangeCallback={pageChangeCallback} />)
|
|
134
|
+
|
|
135
|
+
subject.find(ArrowButton).at(1).props().onClick()
|
|
136
|
+
|
|
137
|
+
expect(pageChangeCallback).toHaveBeenCalledWith(5)
|
|
138
|
+
})
|
|
139
|
+
})
|
|
140
|
+
})
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.default = void 0;
|
|
7
|
+
var _reactSvgInline = _interopRequireDefault(require("react-svg-inline"));
|
|
8
|
+
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
|
|
9
|
+
var folderSVG = "<svg height=\"100\" width=\"100\" fill=\"#999\" xmlns=\"http://www.w3.org/2000/svg\" xmlns:xlink=\"http://www.w3.org/1999/xlink\" preserveAspectRatio=\"none\"><defs><path d=\"M51.95 48V21.85q0-.8-.55-1.45-.6-.55-1.45-.55t-1.4.55q-.65.65-.65 1.45V48H21.75q-.85 0-1.4.6-.6.6-.6 1.45t.6 1.4q.55.6 1.4.6H47.9V78.2q0 .85.65 1.4.55.65 1.4.65.85 0 1.45-.65.55-.55.55-1.4V52.05H78.1q.85 0 1.45-.6.6-.55.6-1.4 0-.85-.6-1.45T78.1 48H51.95z\" id=\"folderSVG-a\"/></defs><use xlink:href=\"#folderSVG-a\"/></svg>";
|
|
10
|
+
var _default = exports.default = function _default(_ref) {
|
|
11
|
+
var className = _ref.className;
|
|
12
|
+
return /*#__PURE__*/React.createElement("span", {
|
|
13
|
+
className: className
|
|
14
|
+
}, /*#__PURE__*/React.createElement(_reactSvgInline.default, {
|
|
15
|
+
className: "plus-icon",
|
|
16
|
+
svg: folderSVG,
|
|
17
|
+
height: "1.6rem",
|
|
18
|
+
width: "1.6rem",
|
|
19
|
+
accessibilityDesc: "Plus Icon"
|
|
20
|
+
}));
|
|
21
|
+
};
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.default = void 0;
|
|
7
|
+
var _saveIndicator = _interopRequireDefault(require("./save-indicator"));
|
|
8
|
+
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
|
|
9
|
+
var _default = exports.default = _saveIndicator.default;
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.default = void 0;
|
|
7
|
+
var _react = _interopRequireDefault(require("react"));
|
|
8
|
+
require("./save-indicator.scss");
|
|
9
|
+
var _CheckCircle = _interopRequireDefault(require("@material-ui/icons/CheckCircle"));
|
|
10
|
+
var _Error = _interopRequireDefault(require("@material-ui/icons/Error"));
|
|
11
|
+
var _loadingElement = _interopRequireDefault(require("../loading-element"));
|
|
12
|
+
var _shareLink = _interopRequireDefault(require("../share-link"));
|
|
13
|
+
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
|
|
14
|
+
var SaveIndicator = function SaveIndicator(_ref) {
|
|
15
|
+
var saving = _ref.saving,
|
|
16
|
+
success = _ref.success,
|
|
17
|
+
failure = _ref.failure,
|
|
18
|
+
linkUrl = _ref.linkUrl;
|
|
19
|
+
if (saving) {
|
|
20
|
+
return /*#__PURE__*/_react.default.createElement("save-indicator", null, /*#__PURE__*/_react.default.createElement(_loadingElement.default, {
|
|
21
|
+
className: "icon"
|
|
22
|
+
}), /*#__PURE__*/_react.default.createElement("p", null, "Your visualization is being saved"));
|
|
23
|
+
}
|
|
24
|
+
if (success) {
|
|
25
|
+
return /*#__PURE__*/_react.default.createElement("save-indicator", null, /*#__PURE__*/_react.default.createElement(_CheckCircle.default, {
|
|
26
|
+
className: "success icon"
|
|
27
|
+
}), /*#__PURE__*/_react.default.createElement("span", null, /*#__PURE__*/_react.default.createElement("p", null, "Your visualization has saved"), linkUrl && /*#__PURE__*/_react.default.createElement(_shareLink.default, {
|
|
28
|
+
linkUrl: linkUrl,
|
|
29
|
+
className: "link-button"
|
|
30
|
+
})));
|
|
31
|
+
}
|
|
32
|
+
if (failure) {
|
|
33
|
+
return /*#__PURE__*/_react.default.createElement("save-indicator", null, /*#__PURE__*/_react.default.createElement(_Error.default, {
|
|
34
|
+
className: "failure icon"
|
|
35
|
+
}), /*#__PURE__*/_react.default.createElement("p", null, "Your visualization failed to save"));
|
|
36
|
+
}
|
|
37
|
+
return /*#__PURE__*/_react.default.createElement("save-indicator", null);
|
|
38
|
+
};
|
|
39
|
+
var _default = exports.default = SaveIndicator;
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
@import "../../../styles/variables.scss";
|
|
2
|
+
@import "../../../styles/mixins.scss";
|
|
3
|
+
|
|
4
|
+
save-indicator {
|
|
5
|
+
@include custom-element();
|
|
6
|
+
|
|
7
|
+
display: flex;
|
|
8
|
+
justify-content: flex-start;
|
|
9
|
+
align-items: center;
|
|
10
|
+
white-space: nowrap;
|
|
11
|
+
margin-top: 10px;
|
|
12
|
+
|
|
13
|
+
.success {
|
|
14
|
+
color: #158655;
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
.failure {
|
|
18
|
+
color: #B80000;
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
.icon {
|
|
22
|
+
width: 1.5rem;
|
|
23
|
+
margin-right: 1rem;
|
|
24
|
+
line-height: 0;
|
|
25
|
+
align-self: start;
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
p {
|
|
29
|
+
margin: 0
|
|
30
|
+
}
|
|
31
|
+
}
|
|
@@ -0,0 +1,89 @@
|
|
|
1
|
+
import { shallow } from 'enzyme'
|
|
2
|
+
import SaveIndicator from './'
|
|
3
|
+
import LoadingElement from '../loading-element'
|
|
4
|
+
import ErrorIcon from '@material-ui/icons/Error'
|
|
5
|
+
import CheckCircleIcon from '@material-ui/icons/CheckCircle'
|
|
6
|
+
import ShareLink from '../share-link'
|
|
7
|
+
|
|
8
|
+
describe('SaveIndicator', () => {
|
|
9
|
+
let subject
|
|
10
|
+
|
|
11
|
+
describe('when no state is indicated', () => {
|
|
12
|
+
it('returns empty', () => {
|
|
13
|
+
subject = shallow(<SaveIndicator />)
|
|
14
|
+
|
|
15
|
+
expect(subject.text()).toEqual('')
|
|
16
|
+
})
|
|
17
|
+
})
|
|
18
|
+
|
|
19
|
+
describe('when saving is in progress', () => {
|
|
20
|
+
beforeEach(() => {
|
|
21
|
+
subject = shallow(<SaveIndicator saving />)
|
|
22
|
+
})
|
|
23
|
+
|
|
24
|
+
it('displays the loading element', () => {
|
|
25
|
+
expect(subject.find(LoadingElement).length).toBe(1)
|
|
26
|
+
})
|
|
27
|
+
|
|
28
|
+
it('displays correct text', () => {
|
|
29
|
+
expect(subject.text()).toContain('Your visualization is being saved')
|
|
30
|
+
})
|
|
31
|
+
})
|
|
32
|
+
|
|
33
|
+
describe('when saving is not in progress', () => {
|
|
34
|
+
describe('and save failed', () => {
|
|
35
|
+
beforeEach(() => {
|
|
36
|
+
subject = shallow(<SaveIndicator failure />)
|
|
37
|
+
})
|
|
38
|
+
|
|
39
|
+
it('does not display the loading element', () => {
|
|
40
|
+
expect(subject.find(LoadingElement).length).toBe(0)
|
|
41
|
+
})
|
|
42
|
+
|
|
43
|
+
it('displays a failure icon', () => {
|
|
44
|
+
expect(subject.find(ErrorIcon).length).toBe(1)
|
|
45
|
+
})
|
|
46
|
+
|
|
47
|
+
it('displays correct text', () => {
|
|
48
|
+
expect(subject.text()).toContain('Your visualization failed to save')
|
|
49
|
+
})
|
|
50
|
+
})
|
|
51
|
+
|
|
52
|
+
describe('and save succeeded with a link url', () => {
|
|
53
|
+
const linkUrl = 'path/to/visualization'
|
|
54
|
+
|
|
55
|
+
beforeEach(() => {
|
|
56
|
+
subject = shallow(<SaveIndicator success linkUrl={linkUrl} />)
|
|
57
|
+
})
|
|
58
|
+
|
|
59
|
+
it('does not display the loading element', () => {
|
|
60
|
+
expect(subject.find(LoadingElement).length).toBe(0)
|
|
61
|
+
})
|
|
62
|
+
|
|
63
|
+
it('displays a success icon', () => {
|
|
64
|
+
expect(subject.find(CheckCircleIcon).length).toBe(1)
|
|
65
|
+
})
|
|
66
|
+
|
|
67
|
+
it('displays correct text', () => {
|
|
68
|
+
expect(subject.text()).toContain('Your visualization has saved')
|
|
69
|
+
})
|
|
70
|
+
|
|
71
|
+
it('displays a shareable link for the saved visualziation', () => {
|
|
72
|
+
const link = subject.find(ShareLink)
|
|
73
|
+
|
|
74
|
+
expect(link.length).toBe(1)
|
|
75
|
+
expect(link.props().linkUrl).toBe(linkUrl)
|
|
76
|
+
})
|
|
77
|
+
})
|
|
78
|
+
|
|
79
|
+
describe('and save succeeded with no link path', () => {
|
|
80
|
+
beforeEach(() => {
|
|
81
|
+
subject = shallow(<SaveIndicator success />)
|
|
82
|
+
})
|
|
83
|
+
|
|
84
|
+
it('does not display a shareable link', () => {
|
|
85
|
+
expect(subject.find(ShareLink).length).toBe(0)
|
|
86
|
+
})
|
|
87
|
+
})
|
|
88
|
+
})
|
|
89
|
+
})
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.default = void 0;
|
|
7
|
+
var _search = _interopRequireDefault(require("./search"));
|
|
8
|
+
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
|
|
9
|
+
var _default = exports.default = _search.default;
|
|
@@ -0,0 +1,93 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
|
|
4
|
+
Object.defineProperty(exports, "__esModule", {
|
|
5
|
+
value: true
|
|
6
|
+
});
|
|
7
|
+
exports.default = void 0;
|
|
8
|
+
require("./search.scss");
|
|
9
|
+
var _react = require("react");
|
|
10
|
+
var _Search = _interopRequireDefault(require("@material-ui/icons/Search"));
|
|
11
|
+
var _Clear = _interopRequireDefault(require("@material-ui/icons/Clear"));
|
|
12
|
+
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
|
|
13
|
+
function _classCallCheck(a, n) { if (!(a instanceof n)) throw new TypeError("Cannot call a class as a function"); }
|
|
14
|
+
function _defineProperties(e, r) { for (var t = 0; t < r.length; t++) { var o = r[t]; o.enumerable = o.enumerable || !1, o.configurable = !0, "value" in o && (o.writable = !0), Object.defineProperty(e, _toPropertyKey(o.key), o); } }
|
|
15
|
+
function _createClass(e, r, t) { return r && _defineProperties(e.prototype, r), t && _defineProperties(e, t), Object.defineProperty(e, "prototype", { writable: !1 }), e; }
|
|
16
|
+
function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : i + ""; }
|
|
17
|
+
function _toPrimitive(t, r) { if ("object" != _typeof(t) || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != _typeof(i)) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
|
|
18
|
+
function _callSuper(t, o, e) { return o = _getPrototypeOf(o), _possibleConstructorReturn(t, _isNativeReflectConstruct() ? Reflect.construct(o, e || [], _getPrototypeOf(t).constructor) : o.apply(t, e)); }
|
|
19
|
+
function _possibleConstructorReturn(t, e) { if (e && ("object" == _typeof(e) || "function" == typeof e)) return e; if (void 0 !== e) throw new TypeError("Derived constructors may only return object or undefined"); return _assertThisInitialized(t); }
|
|
20
|
+
function _assertThisInitialized(e) { if (void 0 === e) throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); return e; }
|
|
21
|
+
function _isNativeReflectConstruct() { try { var t = !Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); } catch (t) {} return (_isNativeReflectConstruct = function _isNativeReflectConstruct() { return !!t; })(); }
|
|
22
|
+
function _getPrototypeOf(t) { return _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf.bind() : function (t) { return t.__proto__ || Object.getPrototypeOf(t); }, _getPrototypeOf(t); }
|
|
23
|
+
function _inherits(t, e) { if ("function" != typeof e && null !== e) throw new TypeError("Super expression must either be null or a function"); t.prototype = Object.create(e && e.prototype, { constructor: { value: t, writable: !0, configurable: !0 } }), Object.defineProperty(t, "prototype", { writable: !1 }), e && _setPrototypeOf(t, e); }
|
|
24
|
+
function _setPrototypeOf(t, e) { return _setPrototypeOf = Object.setPrototypeOf ? Object.setPrototypeOf.bind() : function (t, e) { return t.__proto__ = e, t; }, _setPrototypeOf(t, e); }
|
|
25
|
+
var ENTER = 13;
|
|
26
|
+
var _default = exports.default = /*#__PURE__*/function (_Component) {
|
|
27
|
+
function _default(props) {
|
|
28
|
+
var _this;
|
|
29
|
+
_classCallCheck(this, _default);
|
|
30
|
+
_this = _callSuper(this, _default, [props]);
|
|
31
|
+
_this.state = {
|
|
32
|
+
searchText: props.defaultText || ''
|
|
33
|
+
};
|
|
34
|
+
_this.onChange = _this.onChange.bind(_this);
|
|
35
|
+
_this.onKeyUp = _this.onKeyUp.bind(_this);
|
|
36
|
+
_this.onClearClicked = _this.onClearClicked.bind(_this);
|
|
37
|
+
_this.searchBox = /*#__PURE__*/(0, _react.createRef)();
|
|
38
|
+
return _this;
|
|
39
|
+
}
|
|
40
|
+
_inherits(_default, _Component);
|
|
41
|
+
return _createClass(_default, [{
|
|
42
|
+
key: "render",
|
|
43
|
+
value: function render() {
|
|
44
|
+
var clearButtonDisableClass = this.state.searchText ? '' : 'disabled';
|
|
45
|
+
return /*#__PURE__*/React.createElement("search-box", {
|
|
46
|
+
class: this.props.className
|
|
47
|
+
}, /*#__PURE__*/React.createElement("div", {
|
|
48
|
+
className: "search"
|
|
49
|
+
}, /*#__PURE__*/React.createElement(_Search.default, null)), /*#__PURE__*/React.createElement("input", {
|
|
50
|
+
"data-testid": "search",
|
|
51
|
+
"aria-label": this.props.placeholder,
|
|
52
|
+
ref: this.searchBox,
|
|
53
|
+
type: "text",
|
|
54
|
+
value: this.state.searchText,
|
|
55
|
+
onKeyUp: this.onKeyUp,
|
|
56
|
+
onChange: this.onChange,
|
|
57
|
+
placeholder: this.props.placeholder,
|
|
58
|
+
className: "search-bar"
|
|
59
|
+
}), /*#__PURE__*/React.createElement("div", {
|
|
60
|
+
className: "clear ".concat(clearButtonDisableClass)
|
|
61
|
+
}, /*#__PURE__*/React.createElement(_Clear.default, {
|
|
62
|
+
className: "clear-icon",
|
|
63
|
+
onClick: this.onClearClicked
|
|
64
|
+
})));
|
|
65
|
+
}
|
|
66
|
+
}, {
|
|
67
|
+
key: "onChange",
|
|
68
|
+
value: function onChange(event) {
|
|
69
|
+
this.setState({
|
|
70
|
+
searchText: event.target.value
|
|
71
|
+
});
|
|
72
|
+
}
|
|
73
|
+
}, {
|
|
74
|
+
key: "onKeyUp",
|
|
75
|
+
value: function onKeyUp(event) {
|
|
76
|
+
if (event.keyCode === ENTER) {
|
|
77
|
+
this.props.callback(this.state.searchText);
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
}, {
|
|
81
|
+
key: "onClearClicked",
|
|
82
|
+
value: function onClearClicked() {
|
|
83
|
+
this.setState({
|
|
84
|
+
searchText: ''
|
|
85
|
+
});
|
|
86
|
+
|
|
87
|
+
// Shallow rendering does not play nice with refs
|
|
88
|
+
if (this.searchBox.current) {
|
|
89
|
+
this.searchBox.current.focus();
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
}]);
|
|
93
|
+
}(_react.Component);
|
|
@@ -0,0 +1,90 @@
|
|
|
1
|
+
@import '../../../styles/variables.scss';
|
|
2
|
+
@import '../../../styles/mixins.scss';
|
|
3
|
+
|
|
4
|
+
search-box {
|
|
5
|
+
@include custom-element();
|
|
6
|
+
position: relative;
|
|
7
|
+
|
|
8
|
+
$input-padding: 3.5rem;
|
|
9
|
+
color: $dark-grey;
|
|
10
|
+
|
|
11
|
+
&:hover {
|
|
12
|
+
color: black;
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
.search-bar {
|
|
16
|
+
height: 100%;
|
|
17
|
+
width: calc(100% - (#{$input-padding} * 2));
|
|
18
|
+
padding: 0 $input-padding;
|
|
19
|
+
background-color:#edf1f5;
|
|
20
|
+
box-shadow: 0 1px 4px 0 rgba(0,0,0,0.1);
|
|
21
|
+
border-radius: 20px;
|
|
22
|
+
border: 1px solid $light-grey;
|
|
23
|
+
|
|
24
|
+
&:hover {
|
|
25
|
+
border: 1px solid $medium-grey;
|
|
26
|
+
}
|
|
27
|
+
&:focus {
|
|
28
|
+
outline: none;
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
.search .MuiSvgIcon-root {
|
|
32
|
+
margin: 0 0 0 1rem;
|
|
33
|
+
}
|
|
34
|
+
.clear, .search {
|
|
35
|
+
@include flex-column();
|
|
36
|
+
position: absolute;
|
|
37
|
+
height: 100%;
|
|
38
|
+
width: $input-padding;
|
|
39
|
+
top: 1px;
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
.clear {
|
|
43
|
+
pointer-events: none;
|
|
44
|
+
border: none;
|
|
45
|
+
right: -1px;
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
.search {
|
|
49
|
+
left: 0;
|
|
50
|
+
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
.clear-icon {
|
|
54
|
+
@include flex-column();
|
|
55
|
+
cursor: pointer;
|
|
56
|
+
font-size: 1.25rem;
|
|
57
|
+
height: 1.75rem;
|
|
58
|
+
width: 1.75rem;
|
|
59
|
+
pointer-events: initial;
|
|
60
|
+
|
|
61
|
+
&:hover {
|
|
62
|
+
background-color: $light-grey;
|
|
63
|
+
border-radius: 50%;
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
@media only screen and (max-width: 600px) {
|
|
67
|
+
|
|
68
|
+
.search {
|
|
69
|
+
box-shadow:none;
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
|
|
73
|
+
|
|
74
|
+
search-box.search {
|
|
75
|
+
margin-top:10px;
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
search-box .search-bar {
|
|
79
|
+
box-shadow:none;
|
|
80
|
+
border-radius:6px;
|
|
81
|
+
font-size:13px;
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
.disabled {
|
|
87
|
+
display: none;
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
|