@ndla/ui 23.0.0 → 24.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.
Files changed (95) hide show
  1. package/es/Article/ArticleAuthorContent.js +2 -4
  2. package/es/AuthorInfo/AuthorInfo.js +29 -16
  3. package/es/ContentCard/ContentCard.js +66 -25
  4. package/es/FileList/File.js +34 -8
  5. package/es/FileList/FileList.js +29 -3
  6. package/es/InfoBox/InfoBox.js +10 -3
  7. package/es/InfoWidget/InfoWidget.js +67 -22
  8. package/es/Portrait/Portrait.js +19 -13
  9. package/es/Search/ActiveFilterContent.js +4 -14
  10. package/es/Search/ActiveFilters.js +8 -19
  11. package/es/Search/SearchField.js +31 -52
  12. package/es/Search/SearchResult.js +113 -136
  13. package/es/Search/ToggleSearchButton.js +34 -43
  14. package/es/Search/index.js +2 -8
  15. package/es/all.css +1 -1
  16. package/es/index-javascript.js +0 -1
  17. package/es/index.js +2 -1
  18. package/lib/Article/ArticleAuthorContent.js +9 -4
  19. package/lib/AuthorInfo/AuthorInfo.d.ts +1 -11
  20. package/lib/AuthorInfo/AuthorInfo.js +36 -20
  21. package/lib/ContentCard/ContentCard.d.ts +1 -15
  22. package/lib/ContentCard/ContentCard.js +60 -28
  23. package/lib/FileList/File.js +36 -12
  24. package/lib/FileList/FileList.js +28 -5
  25. package/lib/InfoBox/InfoBox.js +11 -4
  26. package/lib/InfoWidget/InfoWidget.js +61 -25
  27. package/lib/Portrait/Portrait.js +19 -14
  28. package/lib/Search/ActiveFilterContent.d.ts +13 -0
  29. package/lib/Search/ActiveFilterContent.js +4 -15
  30. package/lib/Search/ActiveFilters.d.ts +13 -0
  31. package/lib/Search/ActiveFilters.js +8 -20
  32. package/lib/Search/SearchField.d.ts +19 -0
  33. package/lib/Search/SearchField.js +32 -56
  34. package/lib/Search/SearchResult.d.ts +36 -0
  35. package/lib/Search/SearchResult.js +116 -159
  36. package/lib/Search/ToggleSearchButton.d.ts +16 -0
  37. package/lib/Search/ToggleSearchButton.js +36 -46
  38. package/lib/Search/index.d.ts +12 -0
  39. package/lib/Search/index.js +0 -54
  40. package/lib/SearchTypeResult/SearchTypeHeader.d.ts +1 -1
  41. package/lib/all.css +1 -1
  42. package/lib/index-javascript.js +0 -74
  43. package/lib/index.d.ts +1 -0
  44. package/lib/index.js +38 -1
  45. package/package.json +5 -5
  46. package/src/Article/ArticleAuthorContent.tsx +1 -1
  47. package/src/AuthorInfo/AuthorInfo.tsx +53 -19
  48. package/src/ContentCard/ContentCard.tsx +127 -35
  49. package/src/FileList/File.tsx +47 -17
  50. package/src/FileList/FileList.tsx +37 -8
  51. package/src/InfoBox/InfoBox.tsx +24 -4
  52. package/src/InfoWidget/InfoWidget.tsx +83 -34
  53. package/src/Portrait/Portrait.tsx +25 -10
  54. package/src/Search/{ActiveFilterContent.jsx → ActiveFilterContent.tsx} +11 -12
  55. package/src/Search/{ActiveFilters.jsx → ActiveFilters.tsx} +20 -17
  56. package/src/Search/{SearchField.jsx → SearchField.tsx} +58 -68
  57. package/src/Search/SearchResult.tsx +360 -0
  58. package/src/Search/ToggleSearchButton.tsx +73 -0
  59. package/src/Search/component.search.scss +0 -4
  60. package/src/Search/index.ts +16 -0
  61. package/src/all.scss +0 -1
  62. package/src/index-javascript.js +0 -15
  63. package/src/index.ts +2 -0
  64. package/src/main.scss +0 -6
  65. package/es/Search/SearchFilter.js +0 -72
  66. package/es/Search/SearchFilterList.js +0 -115
  67. package/es/Search/SearchOverlay.js +0 -39
  68. package/es/Search/SearchPage.js +0 -178
  69. package/es/Search/SearchPopoverFilter.js +0 -152
  70. package/es/Search/SearchResultAuthor.js +0 -51
  71. package/lib/Search/SearchFilter.js +0 -88
  72. package/lib/Search/SearchFilterList.js +0 -137
  73. package/lib/Search/SearchOverlay.js +0 -62
  74. package/lib/Search/SearchPage.js +0 -207
  75. package/lib/Search/SearchPopoverFilter.js +0 -172
  76. package/lib/Search/SearchResultAuthor.js +0 -60
  77. package/src/AuthorInfo/component.author-info.scss +0 -54
  78. package/src/ContentCard/component.content-card.scss +0 -109
  79. package/src/FileList/component.file-list.scss +0 -102
  80. package/src/InfoBox/component.info-box.scss +0 -21
  81. package/src/InfoWidget/component.info-widget.scss +0 -52
  82. package/src/Portrait/component.portrait.scss +0 -29
  83. package/src/Search/SearchFilter.jsx +0 -82
  84. package/src/Search/SearchFilterList.jsx +0 -110
  85. package/src/Search/SearchOverlay.jsx +0 -38
  86. package/src/Search/SearchPage.jsx +0 -178
  87. package/src/Search/SearchPopoverFilter.jsx +0 -109
  88. package/src/Search/SearchResult.jsx +0 -239
  89. package/src/Search/SearchResultAuthor.jsx +0 -54
  90. package/src/Search/ToggleSearchButton.jsx +0 -64
  91. package/src/Search/component.search-filter.scss +0 -67
  92. package/src/Search/component.search-overlay.scss +0 -103
  93. package/src/Search/component.search-page.scss +0 -125
  94. package/src/Search/component.search-result-author.scss +0 -65
  95. package/src/Search/index.js +0 -34
@@ -1,39 +0,0 @@
1
- function _extends() { _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }
2
-
3
- import React, { Fragment } from 'react';
4
- import PropTypes from 'prop-types';
5
- import BEMHelper from 'react-bem-helper';
6
- import { Cross } from '@ndla/icons/action';
7
- import { CSSTransition } from 'react-transition-group';
8
- import Fade from '../Animation/Fade';
9
- import { jsx as ___EmotionJSX } from "@emotion/core";
10
- var classes = BEMHelper({
11
- prefix: 'c-',
12
- name: 'search-overlay'
13
- });
14
-
15
- var SearchOverlay = function SearchOverlay(_ref) {
16
- var close = _ref.close,
17
- isOpen = _ref.isOpen,
18
- children = _ref.children;
19
- return ___EmotionJSX(Fragment, null, ___EmotionJSX(Fade, {
20
- "in": isOpen
21
- }, ___EmotionJSX("div", {
22
- className: "o-backdrop"
23
- })), ___EmotionJSX(CSSTransition, {
24
- timeout: 300,
25
- classNames: classes().className,
26
- unmountOnExit: true,
27
- "in": isOpen
28
- }, ___EmotionJSX("div", classes(), ___EmotionJSX("div", classes('container o-wrapper'), children, ___EmotionJSX("button", _extends({}, classes('close-button'), {
29
- type: "button",
30
- onClick: close
31
- }), ___EmotionJSX(Cross, null))))));
32
- };
33
-
34
- SearchOverlay.propTypes = {
35
- isOpen: PropTypes.bool.isRequired,
36
- close: PropTypes.func,
37
- children: PropTypes.node.isRequired
38
- };
39
- export default SearchOverlay;
@@ -1,178 +0,0 @@
1
- function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); }
2
-
3
- function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
4
-
5
- function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }
6
-
7
- function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
8
-
9
- function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); if (superClass) _setPrototypeOf(subClass, superClass); }
10
-
11
- function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
12
-
13
- function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }
14
-
15
- function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } return _assertThisInitialized(self); }
16
-
17
- function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
18
-
19
- function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Date.prototype.toString.call(Reflect.construct(Date, [], function () {})); return true; } catch (e) { return false; } }
20
-
21
- function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }
22
-
23
- import React, { Component, Fragment, createRef } from 'react';
24
- import BEMHelper from 'react-bem-helper';
25
- import PropTypes from 'prop-types';
26
- import { Back } from '@ndla/icons/common';
27
- import { debounce } from 'lodash';
28
- import { getCurrentBreakpoint, breakpoints } from '@ndla/util';
29
- import Modal, { ModalHeader, ModalBody, ModalCloseButton } from '@ndla/modal';
30
- import Button from '@ndla/button';
31
- import { withTranslation } from 'react-i18next';
32
- import SearchField from './SearchField';
33
- import ActiveFilters from './ActiveFilters';
34
- import { SearchFieldForm } from './SearchFieldForm';
35
- import { jsx as ___EmotionJSX } from "@emotion/core";
36
- var classes = BEMHelper('c-search-page');
37
- var filterClasses = BEMHelper('c-filter');
38
-
39
- var SearchPage = /*#__PURE__*/function (_Component) {
40
- _inherits(SearchPage, _Component);
41
-
42
- var _super = _createSuper(SearchPage);
43
-
44
- function SearchPage(props) {
45
- var _this;
46
-
47
- _classCallCheck(this, SearchPage);
48
-
49
- _this = _super.call(this, props);
50
- _this.state = {
51
- isNarrowScreen: false
52
- };
53
- _this.filterCloseButton = null;
54
- _this.inputRef = /*#__PURE__*/createRef();
55
- _this.checkScreenSize = _this.checkScreenSize.bind(_assertThisInitialized(_this));
56
- _this.checkScreenSizeDebounce = debounce(function () {
57
- return _this.checkScreenSize();
58
- }, 100);
59
- return _this;
60
- }
61
-
62
- _createClass(SearchPage, [{
63
- key: "componentDidMount",
64
- value: function componentDidMount() {
65
- window.addEventListener('resize', this.checkScreenSizeDebounce);
66
- this.checkScreenSize();
67
- }
68
- }, {
69
- key: "componentWillUnmount",
70
- value: function componentWillUnmount() {
71
- window.removeEventListener('resize', this.checkScreenSizeDebounce);
72
- }
73
- }, {
74
- key: "checkScreenSize",
75
- value: function checkScreenSize() {
76
- var currentBreakpoint = getCurrentBreakpoint();
77
- var isNarrowScreen = currentBreakpoint === breakpoints.mobile || currentBreakpoint === breakpoints.tablet;
78
- /* eslint react/no-did-mount-set-state: 0 */
79
-
80
- if (isNarrowScreen !== this.state.isNarrowScreen) {
81
- this.setState({
82
- isNarrowScreen: isNarrowScreen
83
- });
84
- }
85
- }
86
- }, {
87
- key: "render",
88
- value: function render() {
89
- var _this$props = this.props,
90
- searchString = _this$props.searchString,
91
- onSearchFieldChange = _this$props.onSearchFieldChange,
92
- onSearchFieldFilterRemove = _this$props.onSearchFieldFilterRemove,
93
- searchFieldFilters = _this$props.searchFieldFilters,
94
- onSearch = _this$props.onSearch,
95
- activeFilters = _this$props.activeFilters,
96
- resourceToLinkProps = _this$props.resourceToLinkProps,
97
- filters = _this$props.filters,
98
- children = _this$props.children,
99
- messages = _this$props.messages,
100
- author = _this$props.author,
101
- t = _this$props.t;
102
- return ___EmotionJSX("main", classes(), ___EmotionJSX("div", classes('search-field-wrapper'), ___EmotionJSX(SearchFieldForm, {
103
- onSubmit: onSearch
104
- }, ___EmotionJSX(SearchField, {
105
- inputRef: this.inputRef,
106
- value: searchString,
107
- onChange: onSearchFieldChange,
108
- placeholder: t('searchPage.searchFieldPlaceholder'),
109
- filters: searchFieldFilters,
110
- onFilterRemove: onSearchFieldFilterRemove,
111
- resourceToLinkProps: resourceToLinkProps,
112
- messages: {
113
- searchFieldTitle: t('searchPage.search')
114
- }
115
- }))), author, ___EmotionJSX("div", classes('filter-result-wrapper'), ___EmotionJSX("aside", classes('filter-wrapper'), ___EmotionJSX("h1", classes('filter-heading'), t('searchPage.searchPageMessages.filterHeading')), ___EmotionJSX("div", classes('filters'), !this.state.isNarrowScreen && filters)), ___EmotionJSX("div", classes('result-wrapper'), ___EmotionJSX("div", classes('active-filters'), ___EmotionJSX(ActiveFilters, {
116
- filters: activeFilters,
117
- showOnSmallScreen: true,
118
- onFilterRemove: function onFilterRemove(value, filterName) {
119
- return onSearchFieldFilterRemove(value, filterName);
120
- }
121
- })), ___EmotionJSX("div", classes('toggle-filter'), ___EmotionJSX(Modal, {
122
- animation: "subtle",
123
- animationDuration: 150,
124
- size: "fullscreen",
125
- backgroundColor: "grey",
126
- activateButton: ___EmotionJSX(Button, {
127
- outline: true
128
- }, t('searchPage.searchPageMessages.filterHeading'))
129
- }, function (onClose) {
130
- return ___EmotionJSX(Fragment, null, ___EmotionJSX(ModalHeader, {
131
- modifier: "white left-align"
132
- }, ___EmotionJSX(ModalCloseButton, {
133
- title: ___EmotionJSX(Fragment, null, ___EmotionJSX(Back, null), " ", messages.narrowScreenFilterHeading),
134
- onClick: onClose
135
- }, "Close")), ___EmotionJSX(ModalBody, {
136
- modifier: "slide-in-left no-side-padding-mobile"
137
- }, filters, ___EmotionJSX("div", filterClasses('usefilter-wrapper'), ___EmotionJSX(Button, {
138
- outline: true,
139
- onClick: onClose
140
- }, t('searchPage.searchFilterMessages.useFilter')))));
141
- })), children)));
142
- }
143
- }]);
144
-
145
- return SearchPage;
146
- }(Component);
147
-
148
- SearchPage.propTypes = {
149
- // should be <Fragment />
150
- filters: PropTypes.node.isRequired,
151
- children: PropTypes.node.isRequired,
152
- searchString: PropTypes.string.isRequired,
153
- onSearchFieldChange: PropTypes.func.isRequired,
154
- onSearch: PropTypes.func.isRequired,
155
- onSearchFieldFilterRemove: PropTypes.func.isRequired,
156
- resourceToLinkProps: PropTypes.func.isRequired,
157
- searchFieldFilters: PropTypes.arrayOf(PropTypes.shape({
158
- value: PropTypes.string.isRequired,
159
- title: PropTypes.string.isRequired,
160
- filterName: PropTypes.string.isRequired
161
- })),
162
- activeFilters: PropTypes.arrayOf(PropTypes.shape({
163
- value: PropTypes.string.isRequired,
164
- title: PropTypes.string.isRequired,
165
- filterName: PropTypes.string.isRequired
166
- })),
167
- messages: PropTypes.shape({
168
- narrowScreenFilterHeading: PropTypes.string.isRequired
169
- }).isRequired,
170
- author: PropTypes.node,
171
- hideResultText: PropTypes.bool,
172
- filterScreenChange: PropTypes.func,
173
- t: PropTypes.func.isRequired
174
- };
175
- SearchPage.defaultProps = {
176
- author: null
177
- };
178
- export default withTranslation()(SearchPage);
@@ -1,152 +0,0 @@
1
- function _extends() { _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }
2
-
3
- function _objectWithoutProperties(source, excluded) { if (source == null) return {}; var target = _objectWithoutPropertiesLoose(source, excluded); var key, i; if (Object.getOwnPropertySymbols) { var sourceSymbolKeys = Object.getOwnPropertySymbols(source); for (i = 0; i < sourceSymbolKeys.length; i++) { key = sourceSymbolKeys[i]; if (excluded.indexOf(key) >= 0) continue; if (!Object.prototype.propertyIsEnumerable.call(source, key)) continue; target[key] = source[key]; } } return target; }
4
-
5
- function _objectWithoutPropertiesLoose(source, excluded) { if (source == null) return {}; var target = {}; var sourceKeys = Object.keys(source); var key, i; for (i = 0; i < sourceKeys.length; i++) { key = sourceKeys[i]; if (excluded.indexOf(key) >= 0) continue; target[key] = source[key]; } return target; }
6
-
7
- function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); }
8
-
9
- function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
10
-
11
- function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }
12
-
13
- function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
14
-
15
- function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); if (superClass) _setPrototypeOf(subClass, superClass); }
16
-
17
- function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
18
-
19
- function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }
20
-
21
- function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } return _assertThisInitialized(self); }
22
-
23
- function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
24
-
25
- function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Date.prototype.toString.call(Reflect.construct(Date, [], function () {})); return true; } catch (e) { return false; } }
26
-
27
- function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }
28
-
29
- /* eslint-disable react/no-multi-comp */
30
- import React, { Fragment, Component } from 'react';
31
- import PropTypes from 'prop-types';
32
- import BEMHelper from 'react-bem-helper';
33
- import { ChevronRight } from '@ndla/icons/common';
34
- import Modal, { ModalCloseButton, ModalHeader, ModalBody } from '@ndla/modal';
35
- import Button from '@ndla/button';
36
- import { FilterList } from '../Filter';
37
- import { jsx as ___EmotionJSX } from "@emotion/core";
38
- var filterClasses = new BEMHelper({
39
- name: 'filter',
40
- prefix: 'c-'
41
- });
42
- var messagesShape = PropTypes.shape({
43
- backButton: PropTypes.string.isRequired,
44
- closeButton: PropTypes.string.isRequired,
45
- confirmButton: PropTypes.string.isRequired,
46
- filterLabel: PropTypes.string.isRequired,
47
- hasValuesButtonText: PropTypes.string.isRequired,
48
- noValuesButtonText: PropTypes.string.isRequired
49
- });
50
-
51
- var Popover = /*#__PURE__*/function (_Component) {
52
- _inherits(Popover, _Component);
53
-
54
- var _super = _createSuper(Popover);
55
-
56
- function Popover(props) {
57
- var _this;
58
-
59
- _classCallCheck(this, Popover);
60
-
61
- _this = _super.call(this, props);
62
- _this.state = {
63
- values: props.values
64
- };
65
- return _this;
66
- }
67
-
68
- _createClass(Popover, [{
69
- key: "render",
70
- value: function render() {
71
- var _this2 = this;
72
-
73
- var _this$props = this.props,
74
- messages = _this$props.messages,
75
- close = _this$props.close,
76
- options = _this$props.options,
77
- onChange = _this$props.onChange;
78
- return ___EmotionJSX(Fragment, null, ___EmotionJSX(FilterList, {
79
- preid: "search-popover",
80
- options: options,
81
- label: messages.filterLabel,
82
- values: this.state.values,
83
- modifiers: "search-popover",
84
- onChange: function onChange(values) {
85
- _this2.setState({
86
- values: values
87
- });
88
- }
89
- }), ___EmotionJSX("div", filterClasses('usefilter-wrapper'), ___EmotionJSX(Button, {
90
- outline: true,
91
- onClick: function onClick() {
92
- close();
93
- onChange(_this2.state.values);
94
- }
95
- }, messages.confirmButton)));
96
- }
97
- }]);
98
-
99
- return Popover;
100
- }(Component);
101
-
102
- Popover.propTypes = {
103
- messages: messagesShape.isRequired,
104
- close: PropTypes.func,
105
- values: PropTypes.arrayOf(PropTypes.string).isRequired,
106
- options: PropTypes.arrayOf(PropTypes.shape({
107
- title: PropTypes.string.isRequired,
108
- value: PropTypes.string.isRequired
109
- })).isRequired,
110
- onChange: PropTypes.func.isRequired
111
- };
112
-
113
- var PopoverFilter = function PopoverFilter(_ref) {
114
- var messages = _ref.messages,
115
- values = _ref.values,
116
- onChange = _ref.onChange,
117
- rest = _objectWithoutProperties(_ref, ["messages", "values", "onChange"]);
118
-
119
- var buttonText = values.length > 0 ? messages.hasValuesButtonText : messages.noValuesButtonText;
120
-
121
- var buttonContent = ___EmotionJSX("button", _extends({
122
- type: "button"
123
- }, filterClasses('expand')), ___EmotionJSX("span", null, buttonText), ___EmotionJSX(ChevronRight, null));
124
-
125
- return ___EmotionJSX(Modal, {
126
- animation: "slide-up",
127
- size: "medium",
128
- activateButton: buttonContent
129
- }, function (onClose) {
130
- return ___EmotionJSX(Fragment, null, ___EmotionJSX(ModalHeader, {
131
- modifiers: "white"
132
- }, ___EmotionJSX(ModalCloseButton, {
133
- title: "Lukk",
134
- onClick: onClose
135
- })), ___EmotionJSX(ModalBody, {
136
- modifier: "no-side-padding-mobile"
137
- }, ___EmotionJSX(Popover, _extends({
138
- close: onClose,
139
- onChange: onChange,
140
- messages: messages
141
- }, rest, {
142
- values: values
143
- }))));
144
- });
145
- };
146
-
147
- PopoverFilter.propTypes = {
148
- values: PropTypes.arrayOf(PropTypes.string).isRequired,
149
- messages: messagesShape.isRequired,
150
- onChange: PropTypes.func.isRequired
151
- };
152
- export default PopoverFilter;
@@ -1,51 +0,0 @@
1
- function _extends() { _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }
2
-
3
- /*
4
- * Copyright (c) 2016-present, NDLA.
5
- *
6
- * This source code is licensed under the GPLv3 license found in the
7
- * LICENSE file in the root directory of this source tree.
8
- *
9
- */
10
- import React from 'react';
11
- import PropTypes from 'prop-types';
12
- import BEMHelper from 'react-bem-helper';
13
- import SafeLink from '@ndla/safelink';
14
- import Portrait from '../Portrait';
15
- import { jsx as ___EmotionJSX } from "@emotion/core";
16
- var classes = new BEMHelper('c-search-result-author');
17
-
18
- var SearchResultAuthor = function SearchResultAuthor(_ref) {
19
- var messages = _ref.messages,
20
- url = _ref.url,
21
- image = _ref.image,
22
- modifier = _ref.modifier;
23
- return ___EmotionJSX("div", classes('', modifier), ___EmotionJSX("div", null, ___EmotionJSX("h1", classes('heading'), messages.authorName), ___EmotionJSX("p", null, messages.role), ___EmotionJSX("p", null, messages.phone), ___EmotionJSX("div", classes('links'), messages.email && ___EmotionJSX(SafeLink, {
24
- to: "mailto:".concat(messages.email)
25
- }, messages.email), url && ___EmotionJSX(SafeLink, _extends({
26
- to: url
27
- }, classes('url')), messages.readmoreLabel))), ___EmotionJSX(Portrait, _extends({
28
- src: image,
29
- alt: messages.authorName
30
- }, classes('portrait-image'))));
31
- };
32
-
33
- SearchResultAuthor.propTypes = {
34
- messages: PropTypes.shape({
35
- authorName: PropTypes.string.isRequired,
36
- role: PropTypes.string.isRequired,
37
- phone: PropTypes.string,
38
- email: PropTypes.string,
39
- readmoreLabel: function readmoreLabel(props, propName, componentName) {
40
- if (typeof props.url === 'string' && typeof props[propName] !== 'string') {
41
- return new Error("".concat(componentName, " messages.readmoreLabel is required when propTypes.url"));
42
- }
43
-
44
- return null;
45
- }
46
- }),
47
- image: PropTypes.string.isRequired,
48
- url: PropTypes.string,
49
- modifier: PropTypes.oneOf(['desktop', 'tablet']).isRequired
50
- };
51
- export default SearchResultAuthor;
@@ -1,88 +0,0 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports["default"] = void 0;
7
-
8
- var _react = _interopRequireDefault(require("react"));
9
-
10
- var _reactBemHelper = _interopRequireDefault(require("react-bem-helper"));
11
-
12
- var _propTypes = _interopRequireDefault(require("prop-types"));
13
-
14
- var _Filter = require("../Filter");
15
-
16
- var _core = require("@emotion/core");
17
-
18
- function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
19
-
20
- var searchFilterClasses = (0, _reactBemHelper["default"])({
21
- prefix: 'c-',
22
- name: 'search-filter',
23
- outputIsString: true
24
- });
25
-
26
- var valueShape = _propTypes["default"].oneOfType([_propTypes["default"].string, _propTypes["default"].number]);
27
-
28
- var SearchFilter = function SearchFilter(_ref) {
29
- var label = _ref.label,
30
- options = _ref.options,
31
- values = _ref.values,
32
- defaultVisibleCount = _ref.defaultVisibleCount,
33
- showLabel = _ref.showLabel,
34
- hideLabel = _ref.hideLabel,
35
- narrowScreenOnly = _ref.narrowScreenOnly,
36
- contextFilter = _ref.contextFilter,
37
- onChange = _ref.onChange,
38
- noFilterSelectedLabel = _ref.noFilterSelectedLabel,
39
- children = _ref.children;
40
- var modifiers = [];
41
-
42
- if (narrowScreenOnly) {
43
- modifiers.push('narrow-screen-only');
44
- }
45
-
46
- if (contextFilter) {
47
- modifiers.push('context-filter');
48
- }
49
-
50
- return (0, _core.jsx)("div", {
51
- className: searchFilterClasses('', modifiers)
52
- }, (0, _core.jsx)(_Filter.FilterList, {
53
- options: options,
54
- label: label,
55
- labelNotVisible: contextFilter,
56
- values: values,
57
- defaultVisibleCount: defaultVisibleCount,
58
- modifiers: !contextFilter ? 'search' : null,
59
- showLabel: showLabel,
60
- hideLabel: hideLabel,
61
- onChange: onChange,
62
- alignedGroup: true,
63
- noFilterSelectedLabel: noFilterSelectedLabel
64
- }), children);
65
- };
66
-
67
- SearchFilter.propTypes = {
68
- label: _propTypes["default"].string.isRequired,
69
- options: _propTypes["default"].arrayOf(_propTypes["default"].shape({
70
- value: valueShape.isRequired,
71
- title: _propTypes["default"].string.isRequired,
72
- noResults: _propTypes["default"].bool
73
- })).isRequired,
74
- values: _propTypes["default"].arrayOf(valueShape),
75
- defaultVisibleCount: _propTypes["default"].number,
76
- onChange: _propTypes["default"].func,
77
- showLabel: _propTypes["default"].string,
78
- hideLabel: _propTypes["default"].string,
79
- narrowScreenOnly: _propTypes["default"].bool,
80
- noFilterSelectedLabel: _propTypes["default"].string,
81
- contextFilter: _propTypes["default"].bool,
82
- children: _propTypes["default"].node
83
- };
84
- SearchFilter.defaultProps = {
85
- values: []
86
- };
87
- var _default = SearchFilter;
88
- exports["default"] = _default;
@@ -1,137 +0,0 @@
1
- "use strict";
2
-
3
- function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); }
4
-
5
- Object.defineProperty(exports, "__esModule", {
6
- value: true
7
- });
8
- exports["default"] = void 0;
9
-
10
- var _react = _interopRequireWildcard(require("react"));
11
-
12
- var _reactBemHelper = _interopRequireDefault(require("react-bem-helper"));
13
-
14
- var _propTypes = _interopRequireDefault(require("prop-types"));
15
-
16
- var _Filter = require("../Filter");
17
-
18
- var _core = require("@emotion/core");
19
-
20
- var _this = void 0;
21
-
22
- function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
23
-
24
- function _getRequireWildcardCache() { if (typeof WeakMap !== "function") return null; var cache = new WeakMap(); _getRequireWildcardCache = function _getRequireWildcardCache() { return cache; }; return cache; }
25
-
26
- function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } if (obj === null || _typeof(obj) !== "object" && typeof obj !== "function") { return { "default": obj }; } var cache = _getRequireWildcardCache(); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj["default"] = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
27
-
28
- function _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread(); }
29
-
30
- function _nonIterableSpread() { throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
31
-
32
- function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
33
-
34
- function _iterableToArray(iter) { if (typeof Symbol !== "undefined" && Symbol.iterator in Object(iter)) return Array.from(iter); }
35
-
36
- function _arrayWithoutHoles(arr) { if (Array.isArray(arr)) return _arrayLikeToArray(arr); }
37
-
38
- function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) { arr2[i] = arr[i]; } return arr2; }
39
-
40
- var searchFilterClasses = (0, _reactBemHelper["default"])({
41
- prefix: 'c-',
42
- name: 'search-filter',
43
- outputIsString: true
44
- });
45
-
46
- var valueShape = _propTypes["default"].oneOfType([_propTypes["default"].string, _propTypes["default"].number]);
47
-
48
- var SearchFilterList = function SearchFilterList(_ref) {
49
- var label = _ref.label,
50
- options = _ref.options,
51
- values = _ref.values,
52
- narrowScreenOnly = _ref.narrowScreenOnly,
53
- _onChange = _ref.onChange,
54
- onSubfilterChange = _ref.onSubfilterChange,
55
- preid = _ref.preid,
56
- noFilterSelectedLabel = _ref.noFilterSelectedLabel,
57
- subjectValues = _ref.subjectValues,
58
- children = _ref.children;
59
- return (0, _core.jsx)("div", {
60
- className: searchFilterClasses('')
61
- }, (0, _core.jsx)("div", null, options.map(function (option, index) {
62
- var itemModifiers = [];
63
- var checked = values.some(function (value) {
64
- return value === option.value;
65
- });
66
-
67
- if (!checked && index + 1 > _this.state.visibleCount) {
68
- itemModifiers.push('hidden');
69
- }
70
-
71
- var disabled = option.noResults || option.hits === 0;
72
-
73
- if (disabled) {
74
- itemModifiers.push('no-results');
75
- }
76
-
77
- return (0, _core.jsx)(_react.Fragment, {
78
- key: option.value
79
- }, (0, _core.jsx)(_Filter.ToggleItem, {
80
- modifiers: itemModifiers,
81
- id: preid + option.value,
82
- value: option.value,
83
- disabled: disabled,
84
- tabIndex: disabled ? -1 : 0,
85
- checked: checked,
86
- icon: option.icon,
87
- label: option.title,
88
- component: "div",
89
- onChange: function onChange(event) {
90
- var newValues = null;
91
-
92
- if (event.currentTarget.checked) {
93
- newValues = [].concat(_toConsumableArray(values), [option.value]);
94
- } else {
95
- newValues = values.filter(function (value) {
96
- return value !== option.value;
97
- });
98
- }
99
-
100
- if (_onChange) {
101
- _onChange(newValues, option.value);
102
- }
103
- }
104
- }), (0, _core.jsx)("div", {
105
- className: searchFilterClasses()
106
- }, (0, _core.jsx)(_Filter.FilterList, {
107
- options: option.subjectFilters,
108
- label: label,
109
- labelNotVisible: true,
110
- values: subjectValues[option.value],
111
- onChange: function onChange(subjectFilters, subjectFilter) {
112
- return onSubfilterChange(option.value, subjectFilters, subjectFilter);
113
- },
114
- alignedGroup: true,
115
- noFilterSelectedLabel: noFilterSelectedLabel
116
- })));
117
- })), children);
118
- };
119
-
120
- SearchFilterList.propTypes = {
121
- label: _propTypes["default"].string.isRequired,
122
- options: _propTypes["default"].arrayOf(_propTypes["default"].shape({
123
- value: valueShape.isRequired,
124
- title: _propTypes["default"].string.isRequired,
125
- noResults: _propTypes["default"].bool
126
- })).isRequired,
127
- values: _propTypes["default"].arrayOf(valueShape),
128
- onChange: _propTypes["default"].func,
129
- onSubfilterChange: _propTypes["default"].func,
130
- noFilterSelectedLabel: _propTypes["default"].string,
131
- children: _propTypes["default"].node
132
- };
133
- SearchFilterList.defaultProps = {
134
- values: []
135
- };
136
- var _default = SearchFilterList;
137
- exports["default"] = _default;