@ndla/ui 22.3.0 → 24.1.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 (148) hide show
  1. package/es/Article/ArticleAuthorContent.js +2 -4
  2. package/es/Article/ArticleFavoritesButton.js +2 -2
  3. package/es/AuthorInfo/AuthorInfo.js +29 -16
  4. package/es/ContentCard/ContentCard.js +66 -25
  5. package/es/FileList/File.js +34 -8
  6. package/es/FileList/FileList.js +29 -3
  7. package/es/InfoBox/InfoBox.js +10 -3
  8. package/es/InfoWidget/InfoWidget.js +67 -22
  9. package/es/MyNdla/Resource/FolderInput.js +19 -6
  10. package/es/NoContentBox/NoContentBox.js +1 -6
  11. package/es/Portrait/Portrait.js +19 -13
  12. package/es/Resource/BlockResource.js +7 -6
  13. package/es/Resource/ListResource.js +8 -7
  14. package/es/ResourceBox/ResourceBox.js +7 -35
  15. package/es/Search/ActiveFilterContent.js +4 -14
  16. package/es/Search/ActiveFilters.js +8 -19
  17. package/es/Search/SearchField.js +31 -52
  18. package/es/Search/SearchResult.js +113 -136
  19. package/es/Search/ToggleSearchButton.js +34 -43
  20. package/es/Search/index.js +2 -8
  21. package/es/TreeStructure/FolderItems.js +3 -3
  22. package/es/TreeStructure/FolderNameInput.js +32 -14
  23. package/es/all.css +1 -1
  24. package/es/index-javascript.js +0 -1
  25. package/es/index.js +2 -1
  26. package/es/locale/messages-en.js +3 -3
  27. package/es/locale/messages-nb.js +3 -3
  28. package/es/locale/messages-nn.js +3 -3
  29. package/es/locale/messages-se.js +3 -3
  30. package/es/locale/messages-sma.js +3 -3
  31. package/lib/Article/ArticleAuthorContent.js +9 -4
  32. package/lib/Article/ArticleFavoritesButton.js +2 -2
  33. package/lib/AuthorInfo/AuthorInfo.d.ts +1 -11
  34. package/lib/AuthorInfo/AuthorInfo.js +36 -20
  35. package/lib/ContentCard/ContentCard.d.ts +1 -15
  36. package/lib/ContentCard/ContentCard.js +60 -28
  37. package/lib/FileList/File.js +36 -12
  38. package/lib/FileList/FileList.js +28 -5
  39. package/lib/InfoBox/InfoBox.js +12 -5
  40. package/lib/InfoWidget/InfoWidget.js +61 -25
  41. package/lib/MyNdla/Resource/FolderInput.js +18 -5
  42. package/lib/NoContentBox/NoContentBox.js +1 -8
  43. package/lib/Portrait/Portrait.js +19 -14
  44. package/lib/Resource/BlockResource.js +7 -6
  45. package/lib/Resource/ListResource.js +8 -7
  46. package/lib/ResourceBox/ResourceBox.d.ts +1 -4
  47. package/lib/ResourceBox/ResourceBox.js +15 -35
  48. package/lib/Search/ActiveFilterContent.d.ts +13 -0
  49. package/lib/Search/ActiveFilterContent.js +4 -15
  50. package/lib/Search/ActiveFilters.d.ts +13 -0
  51. package/lib/Search/ActiveFilters.js +8 -20
  52. package/lib/Search/SearchField.d.ts +19 -0
  53. package/lib/Search/SearchField.js +32 -56
  54. package/lib/Search/SearchResult.d.ts +36 -0
  55. package/lib/Search/SearchResult.js +116 -159
  56. package/lib/Search/ToggleSearchButton.d.ts +16 -0
  57. package/lib/Search/ToggleSearchButton.js +36 -46
  58. package/lib/Search/index.d.ts +12 -0
  59. package/lib/Search/index.js +0 -54
  60. package/lib/SearchTypeResult/SearchTypeHeader.d.ts +1 -1
  61. package/lib/TreeStructure/FolderItems.js +3 -3
  62. package/lib/TreeStructure/FolderNameInput.js +34 -14
  63. package/lib/TreeStructure/types.d.ts +1 -1
  64. package/lib/all.css +1 -1
  65. package/lib/index-javascript.js +0 -74
  66. package/lib/index.d.ts +1 -0
  67. package/lib/index.js +38 -1
  68. package/lib/locale/messages-en.js +3 -3
  69. package/lib/locale/messages-nb.js +3 -3
  70. package/lib/locale/messages-nn.js +3 -3
  71. package/lib/locale/messages-se.js +3 -3
  72. package/lib/locale/messages-sma.js +3 -3
  73. package/package.json +10 -10
  74. package/src/Article/ArticleAuthorContent.tsx +1 -1
  75. package/src/Article/ArticleFavoritesButton.tsx +2 -2
  76. package/src/AuthorInfo/AuthorInfo.tsx +53 -19
  77. package/src/ContentCard/ContentCard.tsx +127 -35
  78. package/src/FileList/File.tsx +47 -17
  79. package/src/FileList/FileList.tsx +37 -8
  80. package/src/InfoBox/InfoBox.tsx +24 -4
  81. package/src/InfoWidget/InfoWidget.tsx +83 -34
  82. package/src/MyNdla/Resource/FolderInput.tsx +18 -3
  83. package/src/NoContentBox/NoContentBox.tsx +2 -7
  84. package/src/Portrait/Portrait.tsx +25 -10
  85. package/src/Resource/BlockResource.tsx +1 -1
  86. package/src/Resource/ListResource.tsx +3 -1
  87. package/src/ResourceBox/ResourceBox.tsx +1 -20
  88. package/src/Search/{ActiveFilterContent.jsx → ActiveFilterContent.tsx} +11 -12
  89. package/src/Search/{ActiveFilters.jsx → ActiveFilters.tsx} +20 -17
  90. package/src/Search/{SearchField.jsx → SearchField.tsx} +58 -68
  91. package/src/Search/SearchResult.tsx +360 -0
  92. package/src/Search/ToggleSearchButton.tsx +73 -0
  93. package/src/Search/component.search.scss +0 -4
  94. package/src/Search/index.ts +16 -0
  95. package/src/SectionHeading/SectionHeading.tsx +1 -0
  96. package/src/TreeStructure/FolderItems.tsx +1 -1
  97. package/src/TreeStructure/FolderNameInput.tsx +33 -9
  98. package/src/TreeStructure/types.ts +1 -1
  99. package/src/all.scss +0 -1
  100. package/src/index-javascript.js +0 -15
  101. package/src/index.ts +2 -0
  102. package/src/locale/messages-en.ts +3 -3
  103. package/src/locale/messages-nb.ts +3 -3
  104. package/src/locale/messages-nn.ts +3 -3
  105. package/src/locale/messages-se.ts +3 -3
  106. package/src/locale/messages-sma.ts +3 -3
  107. package/src/main.scss +0 -8
  108. package/es/BackgroundImage/BackgroundImage.js +0 -27
  109. package/es/BackgroundImage/index.js +0 -2
  110. package/es/Search/SearchFilter.js +0 -72
  111. package/es/Search/SearchFilterList.js +0 -115
  112. package/es/Search/SearchOverlay.js +0 -39
  113. package/es/Search/SearchPage.js +0 -178
  114. package/es/Search/SearchPopoverFilter.js +0 -152
  115. package/es/Search/SearchResultAuthor.js +0 -51
  116. package/lib/BackgroundImage/BackgroundImage.d.ts +0 -12
  117. package/lib/BackgroundImage/BackgroundImage.js +0 -40
  118. package/lib/BackgroundImage/index.d.ts +0 -2
  119. package/lib/BackgroundImage/index.js +0 -13
  120. package/lib/Search/SearchFilter.js +0 -88
  121. package/lib/Search/SearchFilterList.js +0 -137
  122. package/lib/Search/SearchOverlay.js +0 -62
  123. package/lib/Search/SearchPage.js +0 -207
  124. package/lib/Search/SearchPopoverFilter.js +0 -172
  125. package/lib/Search/SearchResultAuthor.js +0 -60
  126. package/src/AuthorInfo/component.author-info.scss +0 -54
  127. package/src/BackgroundImage/BackgroundImage.tsx +0 -32
  128. package/src/BackgroundImage/component.background-image.scss +0 -52
  129. package/src/BackgroundImage/index.ts +0 -3
  130. package/src/ContentCard/component.content-card.scss +0 -109
  131. package/src/FileList/component.file-list.scss +0 -102
  132. package/src/InfoBox/component.info-box.scss +0 -21
  133. package/src/InfoWidget/component.info-widget.scss +0 -52
  134. package/src/NoContentBox/component.no-content-box.scss +0 -17
  135. package/src/Portrait/component.portrait.scss +0 -29
  136. package/src/Search/SearchFilter.jsx +0 -82
  137. package/src/Search/SearchFilterList.jsx +0 -110
  138. package/src/Search/SearchOverlay.jsx +0 -38
  139. package/src/Search/SearchPage.jsx +0 -178
  140. package/src/Search/SearchPopoverFilter.jsx +0 -109
  141. package/src/Search/SearchResult.jsx +0 -239
  142. package/src/Search/SearchResultAuthor.jsx +0 -54
  143. package/src/Search/ToggleSearchButton.jsx +0 -64
  144. package/src/Search/component.search-filter.scss +0 -67
  145. package/src/Search/component.search-overlay.scss +0 -103
  146. package/src/Search/component.search-page.scss +0 -125
  147. package/src/Search/component.search-result-author.scss +0 -65
  148. package/src/Search/index.js +0 -34
@@ -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,12 +0,0 @@
1
- /// <reference types="react" />
2
- declare type ImageType = 'mobile' | 'tablet' | 'desktop' | 'wide';
3
- interface Props {
4
- showOverlay?: boolean;
5
- className?: string;
6
- images: {
7
- url: string;
8
- types: ImageType[];
9
- }[];
10
- }
11
- declare const BackgroundImage: ({ images, showOverlay }: Props) => JSX.Element;
12
- export default BackgroundImage;
@@ -1,40 +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 _core = require("@emotion/core");
13
-
14
- function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
15
-
16
- 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); }
17
-
18
- var classes = (0, _reactBemHelper["default"])('c-background-image');
19
-
20
- var BackgroundImage = function BackgroundImage(_ref) {
21
- var images = _ref.images,
22
- _ref$showOverlay = _ref.showOverlay,
23
- showOverlay = _ref$showOverlay === void 0 ? false : _ref$showOverlay;
24
- return (0, _core.jsx)("div", classes('', {
25
- showOverlay: showOverlay
26
- }), images && images.map(function (image) {
27
- return image.types.map(function (type) {
28
- return (0, _core.jsx)("div", _extends({
29
- key: "".concat(image.url).concat(type)
30
- }, classes('background', type), {
31
- style: {
32
- backgroundImage: "url(".concat(image.url, ")")
33
- }
34
- }));
35
- });
36
- }));
37
- };
38
-
39
- var _default = BackgroundImage;
40
- exports["default"] = _default;
@@ -1,2 +0,0 @@
1
- import BackgroundImage from './BackgroundImage';
2
- export default BackgroundImage;
@@ -1,13 +0,0 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports["default"] = void 0;
7
-
8
- var _BackgroundImage = _interopRequireDefault(require("./BackgroundImage"));
9
-
10
- function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
11
-
12
- var _default = _BackgroundImage["default"];
13
- exports["default"] = _default;
@@ -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;