@ndla/ui 22.2.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 (166) hide show
  1. package/es/Animation/DisplayOnPageYOffset.js +1 -1
  2. package/es/Article/Article.js +3 -3
  3. package/es/Article/ArticleAuthorContent.js +2 -4
  4. package/es/Article/ArticleByline.js +5 -6
  5. package/es/AuthorInfo/AuthorInfo.js +29 -16
  6. package/es/Breadcrumb/ActionBreadcrumb.js +3 -3
  7. package/es/ContentCard/ContentCard.js +66 -25
  8. package/es/Figure/FigureOpenDialogButton.js +1 -2
  9. package/es/FileList/File.js +34 -8
  10. package/es/FileList/FileList.js +29 -3
  11. package/es/Filter/FilterListPhone.js +1 -1
  12. package/es/Frontpage/FrontpageProgramMenu.js +10 -11
  13. package/es/InfoBox/InfoBox.js +10 -3
  14. package/es/InfoWidget/InfoWidget.js +67 -22
  15. package/es/NDLAFilm/AllMoviesAlphabetically.js +12 -12
  16. package/es/Portrait/Portrait.js +19 -13
  17. package/es/ResourceBox/ResourceBox.js +7 -35
  18. package/es/ResourceGroup/ResourceItem.js +13 -13
  19. package/es/ResourceGroup/ResourceList.js +3 -3
  20. package/es/Search/ActiveFilterContent.js +4 -14
  21. package/es/Search/ActiveFilters.js +20 -31
  22. package/es/Search/SearchField.js +31 -52
  23. package/es/Search/SearchResult.js +113 -136
  24. package/es/Search/ToggleSearchButton.js +34 -43
  25. package/es/Search/index.js +2 -8
  26. package/es/SearchTypeResult/ActiveFilters.js +18 -18
  27. package/es/SearchTypeResult/SearchFieldHeader.js +5 -6
  28. package/es/TopicMenu/TopicMenu.js +1 -1
  29. package/es/all.css +1 -1
  30. package/es/index-javascript.js +0 -1
  31. package/es/index.js +2 -1
  32. package/es/locale/messages-en.js +2 -0
  33. package/es/locale/messages-nb.js +2 -0
  34. package/es/locale/messages-nn.js +2 -0
  35. package/es/locale/messages-se.js +2 -0
  36. package/es/locale/messages-sma.js +2 -0
  37. package/lib/Animation/DisplayOnPageYOffset.js +2 -2
  38. package/lib/Article/Article.js +4 -4
  39. package/lib/Article/ArticleAuthorContent.js +9 -4
  40. package/lib/Article/ArticleByline.js +4 -4
  41. package/lib/AuthorInfo/AuthorInfo.d.ts +1 -11
  42. package/lib/AuthorInfo/AuthorInfo.js +36 -20
  43. package/lib/Breadcrumb/ActionBreadcrumb.js +3 -3
  44. package/lib/ContentCard/ContentCard.d.ts +1 -15
  45. package/lib/ContentCard/ContentCard.js +60 -28
  46. package/lib/FileList/File.js +36 -12
  47. package/lib/FileList/FileList.js +28 -5
  48. package/lib/Filter/FilterListPhone.js +2 -2
  49. package/lib/Frontpage/FrontpageProgramMenu.js +9 -9
  50. package/lib/InfoBox/InfoBox.js +11 -4
  51. package/lib/InfoWidget/InfoWidget.js +61 -25
  52. package/lib/NDLAFilm/AllMoviesAlphabetically.js +13 -13
  53. package/lib/Portrait/Portrait.js +19 -14
  54. package/lib/ResourceBox/ResourceBox.d.ts +1 -4
  55. package/lib/ResourceBox/ResourceBox.js +15 -35
  56. package/lib/ResourceGroup/ResourceItem.js +12 -14
  57. package/lib/ResourceGroup/ResourceList.js +2 -4
  58. package/lib/Search/ActiveFilterContent.d.ts +13 -0
  59. package/lib/Search/ActiveFilterContent.js +4 -15
  60. package/lib/Search/ActiveFilters.d.ts +13 -0
  61. package/lib/Search/ActiveFilters.js +31 -45
  62. package/lib/Search/SearchField.d.ts +19 -0
  63. package/lib/Search/SearchField.js +32 -56
  64. package/lib/Search/SearchResult.d.ts +36 -0
  65. package/lib/Search/SearchResult.js +116 -159
  66. package/lib/Search/ToggleSearchButton.d.ts +16 -0
  67. package/lib/Search/ToggleSearchButton.js +36 -46
  68. package/lib/Search/index.d.ts +12 -0
  69. package/lib/Search/index.js +0 -54
  70. package/lib/SearchTypeResult/ActiveFilters.js +37 -39
  71. package/lib/SearchTypeResult/SearchFieldHeader.js +6 -6
  72. package/lib/SearchTypeResult/SearchTypeHeader.d.ts +1 -1
  73. package/lib/TopicMenu/TopicMenu.js +2 -2
  74. package/lib/all.css +1 -1
  75. package/lib/index-javascript.js +0 -74
  76. package/lib/index.d.ts +1 -0
  77. package/lib/index.js +38 -1
  78. package/lib/locale/messages-en.d.ts +2 -0
  79. package/lib/locale/messages-en.js +2 -0
  80. package/lib/locale/messages-nb.d.ts +2 -0
  81. package/lib/locale/messages-nb.js +2 -0
  82. package/lib/locale/messages-nn.d.ts +2 -0
  83. package/lib/locale/messages-nn.js +2 -0
  84. package/lib/locale/messages-se.d.ts +2 -0
  85. package/lib/locale/messages-se.js +2 -0
  86. package/lib/locale/messages-sma.d.ts +2 -0
  87. package/lib/locale/messages-sma.js +2 -0
  88. package/package.json +17 -16
  89. package/src/Animation/DisplayOnPageYOffset.tsx +1 -1
  90. package/src/Article/Article.tsx +1 -1
  91. package/src/Article/ArticleAuthorContent.tsx +1 -1
  92. package/src/Article/ArticleByline.tsx +1 -2
  93. package/src/AuthorInfo/AuthorInfo.tsx +53 -19
  94. package/src/Breadcrumb/ActionBreadcrumb.tsx +1 -2
  95. package/src/ContentCard/ContentCard.tsx +127 -35
  96. package/src/Figure/FigureOpenDialogButton.tsx +1 -2
  97. package/src/FileList/File.tsx +47 -17
  98. package/src/FileList/FileList.tsx +37 -8
  99. package/src/Filter/FilterListPhone.jsx +1 -1
  100. package/src/Frontpage/FrontpageProgramMenu.tsx +1 -2
  101. package/src/InfoBox/InfoBox.tsx +24 -4
  102. package/src/InfoWidget/InfoWidget.tsx +83 -34
  103. package/src/NDLAFilm/AllMoviesAlphabetically.tsx +1 -1
  104. package/src/Portrait/Portrait.tsx +25 -10
  105. package/src/ResourceBox/ResourceBox.tsx +1 -20
  106. package/src/ResourceGroup/ResourceItem.tsx +1 -1
  107. package/src/ResourceGroup/ResourceList.tsx +1 -1
  108. package/src/Search/{ActiveFilterContent.jsx → ActiveFilterContent.tsx} +11 -12
  109. package/src/Search/{ActiveFilters.jsx → ActiveFilters.tsx} +21 -18
  110. package/src/Search/{SearchField.jsx → SearchField.tsx} +58 -68
  111. package/src/Search/SearchResult.tsx +360 -0
  112. package/src/Search/ToggleSearchButton.tsx +73 -0
  113. package/src/Search/component.search.scss +0 -4
  114. package/src/Search/index.ts +16 -0
  115. package/src/SearchTypeResult/ActiveFilters.tsx +1 -1
  116. package/src/SearchTypeResult/SearchFieldHeader.tsx +1 -2
  117. package/src/TopicMenu/TopicMenu.jsx +1 -1
  118. package/src/all.scss +0 -1
  119. package/src/index-javascript.js +0 -15
  120. package/src/index.ts +2 -0
  121. package/src/locale/messages-en.ts +2 -0
  122. package/src/locale/messages-nb.ts +2 -0
  123. package/src/locale/messages-nn.ts +2 -0
  124. package/src/locale/messages-se.ts +2 -0
  125. package/src/locale/messages-sma.ts +2 -0
  126. package/src/main.scss +0 -7
  127. package/es/BackgroundImage/BackgroundImage.js +0 -27
  128. package/es/BackgroundImage/index.js +0 -2
  129. package/es/Search/SearchFilter.js +0 -72
  130. package/es/Search/SearchFilterList.js +0 -115
  131. package/es/Search/SearchOverlay.js +0 -39
  132. package/es/Search/SearchPage.js +0 -178
  133. package/es/Search/SearchPopoverFilter.js +0 -152
  134. package/es/Search/SearchResultAuthor.js +0 -51
  135. package/lib/BackgroundImage/BackgroundImage.d.ts +0 -12
  136. package/lib/BackgroundImage/BackgroundImage.js +0 -40
  137. package/lib/BackgroundImage/index.d.ts +0 -2
  138. package/lib/BackgroundImage/index.js +0 -13
  139. package/lib/Search/SearchFilter.js +0 -88
  140. package/lib/Search/SearchFilterList.js +0 -137
  141. package/lib/Search/SearchOverlay.js +0 -62
  142. package/lib/Search/SearchPage.js +0 -207
  143. package/lib/Search/SearchPopoverFilter.js +0 -172
  144. package/lib/Search/SearchResultAuthor.js +0 -60
  145. package/src/AuthorInfo/component.author-info.scss +0 -54
  146. package/src/BackgroundImage/BackgroundImage.tsx +0 -32
  147. package/src/BackgroundImage/component.background-image.scss +0 -52
  148. package/src/BackgroundImage/index.ts +0 -3
  149. package/src/ContentCard/component.content-card.scss +0 -109
  150. package/src/FileList/component.file-list.scss +0 -102
  151. package/src/InfoBox/component.info-box.scss +0 -21
  152. package/src/InfoWidget/component.info-widget.scss +0 -52
  153. package/src/Portrait/component.portrait.scss +0 -29
  154. package/src/Search/SearchFilter.jsx +0 -82
  155. package/src/Search/SearchFilterList.jsx +0 -110
  156. package/src/Search/SearchOverlay.jsx +0 -38
  157. package/src/Search/SearchPage.jsx +0 -178
  158. package/src/Search/SearchPopoverFilter.jsx +0 -109
  159. package/src/Search/SearchResult.jsx +0 -239
  160. package/src/Search/SearchResultAuthor.jsx +0 -54
  161. package/src/Search/ToggleSearchButton.jsx +0 -64
  162. package/src/Search/component.search-filter.scss +0 -67
  163. package/src/Search/component.search-overlay.scss +0 -103
  164. package/src/Search/component.search-page.scss +0 -125
  165. package/src/Search/component.search-result-author.scss +0 -65
  166. package/src/Search/index.js +0 -34
@@ -8,21 +8,6 @@
8
8
 
9
9
  export { FilterList, FilterListPhone, FilterButtons } from './Filter';
10
10
 
11
- export {
12
- SearchOverlay,
13
- SearchField,
14
- SearchPage,
15
- SearchResult,
16
- SearchResultAuthor,
17
- SearchResultList,
18
- SearchResultItem,
19
- SearchFilter,
20
- SearchFilterList,
21
- SearchPopoverFilter,
22
- ActiveFilters,
23
- ToggleSearchButton,
24
- } from './Search';
25
-
26
11
  export { default as TopicIntroductionList } from './TopicIntroductionList';
27
12
  export { default as TopicMenu, TopicMenuButton } from './TopicMenu';
28
13
  export {
package/src/index.ts CHANGED
@@ -245,3 +245,5 @@ export type { Snack, SnackContext } from './SnackBar';
245
245
  export { InfoBlock } from './InfoBlock';
246
246
  export { TreeStructure } from './TreeStructure';
247
247
  export type { FolderType, TreeStructureProps, TreeStructureMenuProps } from './TreeStructure';
248
+
249
+ export { SearchField, SearchResultList, SearchResultItem, ActiveFilters, ToggleSearchButton } from './Search';
@@ -1025,6 +1025,8 @@ const messages = {
1025
1025
  detailView: 'Detailed listview',
1026
1026
  shortView: 'Short view',
1027
1027
  myPage: {
1028
+ confirmDeleteAccount: 'Are you sure you want to delete your account?',
1029
+ confirmDeleteAccountButton: 'Delete account',
1028
1030
  myPage: 'My page',
1029
1031
  logout: 'Log out of My NDLA',
1030
1032
  loginTerms: 'Log in with Feide to receive access. By logging on your accept your terms of service',
@@ -1023,6 +1023,8 @@ const messages = {
1023
1023
  detailView: 'Detaljrik listevisning',
1024
1024
  shortView: 'Kort visning',
1025
1025
  myPage: {
1026
+ confirmDeleteAccount: 'Er du sikker på at du vil slette kontoen?',
1027
+ confirmDeleteAccountButton: 'Slett konto',
1026
1028
  myPage: 'Min side',
1027
1029
  deleteAccount: 'Slett Min NDLA',
1028
1030
  logout: 'Logg ut av Min NDLA',
@@ -1024,6 +1024,8 @@ const messages = {
1024
1024
  detailView: 'Detaljrik listevisning',
1025
1025
  shortView: 'Kort visning',
1026
1026
  myPage: {
1027
+ confirmDeleteAccount: 'Er du sikker på at du vil slette kontoen?',
1028
+ confirmDeleteAccountButton: 'Slett konto',
1027
1029
  myPage: 'Min side',
1028
1030
  deleteAccount: 'Slett Min NDLA',
1029
1031
  logout: 'Logg ut av Min NDLA',
@@ -1023,6 +1023,8 @@ const messages = {
1023
1023
  detailView: 'Detaljrik listevisning',
1024
1024
  shortView: 'Kort visning',
1025
1025
  myPage: {
1026
+ confirmDeleteAccount: 'Er du sikker på at du vil slette kontoen?',
1027
+ confirmDeleteAccountButton: 'Slett konto',
1026
1028
  myPage: 'Min side',
1027
1029
  deleteAccount: 'Slett Min NDLA',
1028
1030
  logout: 'Logg ut av Min NDLA',
@@ -1023,6 +1023,8 @@ const messages = {
1023
1023
  detailView: 'Detaljrik listevisning',
1024
1024
  shortView: 'Kort visning',
1025
1025
  myPage: {
1026
+ confirmDeleteAccount: 'Er du sikker på at du vil slette kontoen?',
1027
+ confirmDeleteAccountButton: 'Slett konto',
1026
1028
  myPage: 'Min side',
1027
1029
  deleteAccount: 'Slett Min NDLA',
1028
1030
  logout: 'Logg ut av Min NDLA',
package/src/main.scss CHANGED
@@ -16,8 +16,6 @@
16
16
  @import 'Aside/component.aside';
17
17
  @import 'Article/component.footnotes';
18
18
  @import 'NoContentBox/component.no-content-box.scss';
19
- @import 'BackgroundImage/component.background-image';
20
- @import 'Portrait/component.portrait.scss';
21
19
  @import 'global/components/component.logo';
22
20
  @import 'MediaList/component.medialist';
23
21
  @import 'RelatedArticleList/component.related-articles';
@@ -32,12 +30,7 @@
32
30
  @import 'Translation/component.translation-box';
33
31
  @import 'Search/component.search';
34
32
  @import 'Subject/component.subject';
35
- @import 'InfoBox/component.info-box';
36
33
  @import 'CompetenceGoals/component.competence-goals';
37
- @import 'ContentCard/component.content-card';
38
- @import 'InfoWidget/component.info-widget';
39
34
  @import 'Carousel/component.carousel';
40
- @import 'FileList/component.file-list';
41
35
  @import 'SectionHeading/component.section-heading';
42
- @import 'AuthorInfo/component.author-info';
43
36
  @import 'NDLAFilm/component.film-movielist';
@@ -1,27 +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 from 'react';
4
- import BEMHelper from 'react-bem-helper';
5
- import { jsx as ___EmotionJSX } from "@emotion/core";
6
- var classes = BEMHelper('c-background-image');
7
-
8
- var BackgroundImage = function BackgroundImage(_ref) {
9
- var images = _ref.images,
10
- _ref$showOverlay = _ref.showOverlay,
11
- showOverlay = _ref$showOverlay === void 0 ? false : _ref$showOverlay;
12
- return ___EmotionJSX("div", classes('', {
13
- showOverlay: showOverlay
14
- }), images && images.map(function (image) {
15
- return image.types.map(function (type) {
16
- return ___EmotionJSX("div", _extends({
17
- key: "".concat(image.url).concat(type)
18
- }, classes('background', type), {
19
- style: {
20
- backgroundImage: "url(".concat(image.url, ")")
21
- }
22
- }));
23
- });
24
- }));
25
- };
26
-
27
- export default BackgroundImage;
@@ -1,2 +0,0 @@
1
- import BackgroundImage from './BackgroundImage';
2
- export default BackgroundImage;
@@ -1,72 +0,0 @@
1
- import React from 'react';
2
- import BEMHelper from 'react-bem-helper';
3
- import PropTypes from 'prop-types';
4
- import { FilterList } from '../Filter';
5
- import { jsx as ___EmotionJSX } from "@emotion/core";
6
- var searchFilterClasses = BEMHelper({
7
- prefix: 'c-',
8
- name: 'search-filter',
9
- outputIsString: true
10
- });
11
- var valueShape = PropTypes.oneOfType([PropTypes.string, PropTypes.number]);
12
-
13
- var SearchFilter = function SearchFilter(_ref) {
14
- var label = _ref.label,
15
- options = _ref.options,
16
- values = _ref.values,
17
- defaultVisibleCount = _ref.defaultVisibleCount,
18
- showLabel = _ref.showLabel,
19
- hideLabel = _ref.hideLabel,
20
- narrowScreenOnly = _ref.narrowScreenOnly,
21
- contextFilter = _ref.contextFilter,
22
- onChange = _ref.onChange,
23
- noFilterSelectedLabel = _ref.noFilterSelectedLabel,
24
- children = _ref.children;
25
- var modifiers = [];
26
-
27
- if (narrowScreenOnly) {
28
- modifiers.push('narrow-screen-only');
29
- }
30
-
31
- if (contextFilter) {
32
- modifiers.push('context-filter');
33
- }
34
-
35
- return ___EmotionJSX("div", {
36
- className: searchFilterClasses('', modifiers)
37
- }, ___EmotionJSX(FilterList, {
38
- options: options,
39
- label: label,
40
- labelNotVisible: contextFilter,
41
- values: values,
42
- defaultVisibleCount: defaultVisibleCount,
43
- modifiers: !contextFilter ? 'search' : null,
44
- showLabel: showLabel,
45
- hideLabel: hideLabel,
46
- onChange: onChange,
47
- alignedGroup: true,
48
- noFilterSelectedLabel: noFilterSelectedLabel
49
- }), children);
50
- };
51
-
52
- SearchFilter.propTypes = {
53
- label: PropTypes.string.isRequired,
54
- options: PropTypes.arrayOf(PropTypes.shape({
55
- value: valueShape.isRequired,
56
- title: PropTypes.string.isRequired,
57
- noResults: PropTypes.bool
58
- })).isRequired,
59
- values: PropTypes.arrayOf(valueShape),
60
- defaultVisibleCount: PropTypes.number,
61
- onChange: PropTypes.func,
62
- showLabel: PropTypes.string,
63
- hideLabel: PropTypes.string,
64
- narrowScreenOnly: PropTypes.bool,
65
- noFilterSelectedLabel: PropTypes.string,
66
- contextFilter: PropTypes.bool,
67
- children: PropTypes.node
68
- };
69
- SearchFilter.defaultProps = {
70
- values: []
71
- };
72
- export default SearchFilter;
@@ -1,115 +0,0 @@
1
- var _this = this;
2
-
3
- function _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread(); }
4
-
5
- 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."); }
6
-
7
- 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); }
8
-
9
- function _iterableToArray(iter) { if (typeof Symbol !== "undefined" && Symbol.iterator in Object(iter)) return Array.from(iter); }
10
-
11
- function _arrayWithoutHoles(arr) { if (Array.isArray(arr)) return _arrayLikeToArray(arr); }
12
-
13
- 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; }
14
-
15
- import React, { Fragment } from 'react';
16
- import BEMHelper from 'react-bem-helper';
17
- import PropTypes from 'prop-types';
18
- import { FilterList, ToggleItem } from '../Filter';
19
- import { jsx as ___EmotionJSX } from "@emotion/core";
20
- var searchFilterClasses = BEMHelper({
21
- prefix: 'c-',
22
- name: 'search-filter',
23
- outputIsString: true
24
- });
25
- var valueShape = PropTypes.oneOfType([PropTypes.string, PropTypes.number]);
26
-
27
- var SearchFilterList = function SearchFilterList(_ref) {
28
- var label = _ref.label,
29
- options = _ref.options,
30
- values = _ref.values,
31
- narrowScreenOnly = _ref.narrowScreenOnly,
32
- _onChange = _ref.onChange,
33
- onSubfilterChange = _ref.onSubfilterChange,
34
- preid = _ref.preid,
35
- noFilterSelectedLabel = _ref.noFilterSelectedLabel,
36
- subjectValues = _ref.subjectValues,
37
- children = _ref.children;
38
- return ___EmotionJSX("div", {
39
- className: searchFilterClasses('')
40
- }, ___EmotionJSX("div", null, options.map(function (option, index) {
41
- var itemModifiers = [];
42
- var checked = values.some(function (value) {
43
- return value === option.value;
44
- });
45
-
46
- if (!checked && index + 1 > _this.state.visibleCount) {
47
- itemModifiers.push('hidden');
48
- }
49
-
50
- var disabled = option.noResults || option.hits === 0;
51
-
52
- if (disabled) {
53
- itemModifiers.push('no-results');
54
- }
55
-
56
- return ___EmotionJSX(Fragment, {
57
- key: option.value
58
- }, ___EmotionJSX(ToggleItem, {
59
- modifiers: itemModifiers,
60
- id: preid + option.value,
61
- value: option.value,
62
- disabled: disabled,
63
- tabIndex: disabled ? -1 : 0,
64
- checked: checked,
65
- icon: option.icon,
66
- label: option.title,
67
- component: "div",
68
- onChange: function onChange(event) {
69
- var newValues = null;
70
-
71
- if (event.currentTarget.checked) {
72
- newValues = [].concat(_toConsumableArray(values), [option.value]);
73
- } else {
74
- newValues = values.filter(function (value) {
75
- return value !== option.value;
76
- });
77
- }
78
-
79
- if (_onChange) {
80
- _onChange(newValues, option.value);
81
- }
82
- }
83
- }), ___EmotionJSX("div", {
84
- className: searchFilterClasses()
85
- }, ___EmotionJSX(FilterList, {
86
- options: option.subjectFilters,
87
- label: label,
88
- labelNotVisible: true,
89
- values: subjectValues[option.value],
90
- onChange: function onChange(subjectFilters, subjectFilter) {
91
- return onSubfilterChange(option.value, subjectFilters, subjectFilter);
92
- },
93
- alignedGroup: true,
94
- noFilterSelectedLabel: noFilterSelectedLabel
95
- })));
96
- })), children);
97
- };
98
-
99
- SearchFilterList.propTypes = {
100
- label: PropTypes.string.isRequired,
101
- options: PropTypes.arrayOf(PropTypes.shape({
102
- value: valueShape.isRequired,
103
- title: PropTypes.string.isRequired,
104
- noResults: PropTypes.bool
105
- })).isRequired,
106
- values: PropTypes.arrayOf(valueShape),
107
- onChange: PropTypes.func,
108
- onSubfilterChange: PropTypes.func,
109
- noFilterSelectedLabel: PropTypes.string,
110
- children: PropTypes.node
111
- };
112
- SearchFilterList.defaultProps = {
113
- values: []
114
- };
115
- export default SearchFilterList;
@@ -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/debounce';
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);