@ndla/ui 24.2.1 → 25.0.1

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 (117) hide show
  1. package/es/CompetenceGoals/CompetenceGoalsDialog.js +15 -24
  2. package/es/CompetenceGoals/index.js +1 -4
  3. package/es/Filter/FilterButtons.js +10 -11
  4. package/es/Filter/FilterList.js +82 -152
  5. package/es/Filter/FilterListPhone.js +180 -272
  6. package/es/Filter/ToggleItem.js +6 -25
  7. package/es/Frontpage/FrontpageAllSubjects.js +8 -9
  8. package/es/Frontpage/FrontpageSearch.js +3 -4
  9. package/es/LearningPaths/LearningPathMenuModalWrapper.js +1 -2
  10. package/es/Masthead/Masthead.js +65 -41
  11. package/es/Masthead/MastheadSearchModal.js +4 -5
  12. package/es/Masthead/SkipToMainContent.js +24 -0
  13. package/es/Masthead/index.js +2 -1
  14. package/es/SearchTypeResult/PopupFilter.js +8 -9
  15. package/es/SearchTypeResult/SearchFilterContent.js +3 -4
  16. package/es/SectionHeading/SectionHeading.js +24 -17
  17. package/es/Subject/index.js +0 -1
  18. package/es/User/UserInfo.js +11 -3
  19. package/es/all.css +1 -1
  20. package/es/index-javascript.js +1 -4
  21. package/es/index.js +5 -2
  22. package/es/locale/messages-en.js +1 -0
  23. package/es/locale/messages-nb.js +1 -0
  24. package/es/locale/messages-nn.js +1 -0
  25. package/es/locale/messages-se.js +1 -0
  26. package/es/locale/messages-sma.js +1 -0
  27. package/lib/CompetenceGoals/CompetenceGoalsDialog.d.ts +19 -0
  28. package/lib/CompetenceGoals/CompetenceGoalsDialog.js +13 -25
  29. package/lib/CompetenceGoals/index.d.ts +1 -0
  30. package/lib/CompetenceGoals/index.js +1 -33
  31. package/lib/Filter/FilterButtons.js +9 -9
  32. package/lib/Filter/FilterList.d.ts +25 -0
  33. package/lib/Filter/FilterList.js +85 -155
  34. package/lib/Filter/FilterListPhone.d.ts +32 -0
  35. package/lib/Filter/FilterListPhone.js +176 -270
  36. package/lib/Filter/ToggleItem.d.ts +15 -0
  37. package/lib/Filter/ToggleItem.js +6 -32
  38. package/lib/Filter/filterClasses.d.ts +2 -0
  39. package/lib/Filter/index.d.ts +12 -0
  40. package/lib/Frontpage/FrontpageAllSubjects.js +7 -7
  41. package/lib/Frontpage/FrontpageSearch.js +2 -3
  42. package/lib/LearningPaths/LearningPathMenuModalWrapper.js +1 -2
  43. package/lib/Masthead/Masthead.d.ts +4 -8
  44. package/lib/Masthead/Masthead.js +65 -49
  45. package/lib/Masthead/MastheadSearchModal.js +3 -4
  46. package/lib/Masthead/SkipToMainContent.d.ts +6 -0
  47. package/lib/Masthead/SkipToMainContent.js +38 -0
  48. package/lib/Masthead/index.d.ts +2 -1
  49. package/lib/Masthead/index.js +10 -0
  50. package/lib/SearchTypeResult/PopupFilter.js +7 -7
  51. package/lib/SearchTypeResult/SearchFilterContent.js +2 -2
  52. package/lib/SectionHeading/SectionHeading.d.ts +1 -13
  53. package/lib/SectionHeading/SectionHeading.js +23 -19
  54. package/lib/Subject/index.d.ts +0 -1
  55. package/lib/Subject/index.js +0 -8
  56. package/lib/User/UserInfo.js +11 -3
  57. package/lib/all.css +1 -1
  58. package/lib/index-javascript.js +1 -63
  59. package/lib/index.d.ts +5 -2
  60. package/lib/index.js +48 -7
  61. package/lib/locale/messages-en.d.ts +1 -0
  62. package/lib/locale/messages-en.js +1 -0
  63. package/lib/locale/messages-nb.d.ts +1 -0
  64. package/lib/locale/messages-nb.js +1 -0
  65. package/lib/locale/messages-nn.d.ts +1 -0
  66. package/lib/locale/messages-nn.js +1 -0
  67. package/lib/locale/messages-se.d.ts +1 -0
  68. package/lib/locale/messages-se.js +1 -0
  69. package/lib/locale/messages-sma.d.ts +1 -0
  70. package/lib/locale/messages-sma.js +1 -0
  71. package/package.json +11 -11
  72. package/src/.DS_Store +0 -0
  73. package/src/CompetenceGoals/{CompetenceGoalsDialog.jsx → CompetenceGoalsDialog.tsx} +34 -27
  74. package/src/CompetenceGoals/index.ts +1 -0
  75. package/src/Filter/FilterButtons.tsx +0 -1
  76. package/src/Filter/FilterList.tsx +135 -0
  77. package/src/Filter/FilterListPhone.tsx +275 -0
  78. package/src/Filter/ToggleItem.tsx +58 -0
  79. package/src/Filter/{filterClasses.js → filterClasses.ts} +0 -0
  80. package/src/Filter/{index.js → index.ts} +0 -0
  81. package/src/Frontpage/FrontpageAllSubjects.tsx +0 -1
  82. package/src/Frontpage/FrontpageSearch.tsx +0 -1
  83. package/src/LearningPaths/LearningPathMenuModalWrapper.tsx +0 -1
  84. package/src/Masthead/Masthead.tsx +85 -45
  85. package/src/Masthead/MastheadSearchModal.tsx +0 -1
  86. package/src/Masthead/SkipToMainContent.tsx +48 -0
  87. package/src/Masthead/index.ts +2 -1
  88. package/src/SearchTypeResult/PopupFilter.tsx +0 -1
  89. package/src/SearchTypeResult/SearchFilterContent.tsx +0 -1
  90. package/src/SectionHeading/SectionHeading.tsx +29 -16
  91. package/src/Subject/index.ts +0 -1
  92. package/src/User/UserInfo.tsx +4 -4
  93. package/src/index-javascript.js +0 -10
  94. package/src/index.ts +7 -2
  95. package/src/locale/messages-en.ts +1 -0
  96. package/src/locale/messages-nb.ts +1 -0
  97. package/src/locale/messages-nn.ts +1 -0
  98. package/src/locale/messages-se.ts +1 -0
  99. package/src/locale/messages-sma.ts +1 -0
  100. package/src/main.scss +0 -3
  101. package/es/CompetenceGoals/CompetenceGoalList.js +0 -58
  102. package/es/CompetenceGoals/CompetenceGoals.js +0 -159
  103. package/es/Subject/SubjectFilter.js +0 -42
  104. package/lib/CompetenceGoals/CompetenceGoalList.js +0 -78
  105. package/lib/CompetenceGoals/CompetenceGoals.js +0 -184
  106. package/lib/Subject/SubjectFilter.d.ts +0 -27
  107. package/lib/Subject/SubjectFilter.js +0 -58
  108. package/src/CompetenceGoals/CompetenceGoalList.jsx +0 -51
  109. package/src/CompetenceGoals/CompetenceGoals.jsx +0 -152
  110. package/src/CompetenceGoals/component.competence-goals.scss +0 -161
  111. package/src/CompetenceGoals/index.js +0 -6
  112. package/src/Filter/FilterList.jsx +0 -167
  113. package/src/Filter/FilterListPhone.jsx +0 -329
  114. package/src/Filter/ToggleItem.jsx +0 -71
  115. package/src/Masthead/component.masthead.scss +0 -146
  116. package/src/SectionHeading/component.section-heading.scss +0 -17
  117. package/src/Subject/SubjectFilter.tsx +0 -48
@@ -1,38 +1,24 @@
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
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); }
4
2
 
5
3
  function _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread(); }
6
4
 
7
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."); }
8
6
 
9
- 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); }
10
-
11
7
  function _iterableToArray(iter) { if (typeof Symbol !== "undefined" && Symbol.iterator in Object(iter)) return Array.from(iter); }
12
8
 
13
9
  function _arrayWithoutHoles(arr) { if (Array.isArray(arr)) return _arrayLikeToArray(arr); }
14
10
 
15
- 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; }
16
-
17
- function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
18
-
19
- 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); } }
20
-
21
- function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
11
+ function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
22
12
 
23
- 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); }
13
+ function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
24
14
 
25
- function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
26
-
27
- 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); }; }
28
-
29
- function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } return _assertThisInitialized(self); }
15
+ 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); }
30
16
 
31
- function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
17
+ 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; }
32
18
 
33
- 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; } }
19
+ function _iterableToArrayLimit(arr, i) { if (typeof Symbol === "undefined" || !(Symbol.iterator in Object(arr))) return; var _arr = []; var _n = true; var _d = false; var _e = undefined; try { for (var _i = arr[Symbol.iterator](), _s; !(_n = (_s = _i.next()).done); _n = true) { _arr.push(_s.value); if (i && _arr.length === i) break; } } catch (err) { _d = true; _e = err; } finally { try { if (!_n && _i["return"] != null) _i["return"](); } finally { if (_d) throw _e; } } return _arr; }
34
20
 
35
- function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }
21
+ function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
36
22
 
37
23
  /*
38
24
  * Copyright (c) 2016-present, NDLA.
@@ -41,10 +27,8 @@ function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.g
41
27
  * LICENSE file in the root directory of this source tree.
42
28
  * FRI OG BEGRENSET
43
29
  */
44
- import React, { Component, Fragment } from 'react';
45
- import PropTypes from 'prop-types';
30
+ import React, { useEffect, useState } from 'react';
46
31
  import { ChevronDown, ChevronUp } from '@ndla/icons/common';
47
- import { Cross } from '@ndla/icons/action';
48
32
  import Modal, { ModalHeader, ModalBody, ModalCloseButton } from '@ndla/modal';
49
33
  import Button from '@ndla/button';
50
34
  import { debounce } from 'lodash';
@@ -53,205 +37,144 @@ import ToggleItem from './ToggleItem';
53
37
  import ActiveFilters from '../Search/ActiveFilters';
54
38
  import { jsx as ___EmotionJSX } from "@emotion/core";
55
39
 
56
- var FilterListPhone = /*#__PURE__*/function (_Component) {
57
- _inherits(FilterListPhone, _Component);
40
+ var is2DArray = function is2DArray(options) {
41
+ return Array.isArray(options[0]);
42
+ };
58
43
 
59
- var _super = _createSuper(FilterListPhone);
44
+ var FilterListPhone = function FilterListPhone(_ref) {
45
+ var preid = _ref.preid,
46
+ label = _ref.label,
47
+ labelNotVisible = _ref.labelNotVisible,
48
+ _ref$modifiers = _ref.modifiers,
49
+ modifiers = _ref$modifiers === void 0 ? '' : _ref$modifiers,
50
+ onChange = _ref.onChange,
51
+ options = _ref.options,
52
+ _ref$values = _ref.values,
53
+ values = _ref$values === void 0 ? [] : _ref$values,
54
+ defaultVisibleCount = _ref.defaultVisibleCount,
55
+ showLabel = _ref.showLabel,
56
+ hideLabel = _ref.hideLabel,
57
+ _ref$alignedGroup = _ref.alignedGroup,
58
+ alignedGroup = _ref$alignedGroup === void 0 ? false : _ref$alignedGroup,
59
+ _ref$collapseMobile = _ref.collapseMobile,
60
+ collapseMobile = _ref$collapseMobile === void 0 ? true : _ref$collapseMobile,
61
+ activeFiltersNarrow = _ref.activeFiltersNarrow,
62
+ messages = _ref.messages,
63
+ _ref$viewMode = _ref.viewMode,
64
+ viewMode = _ref$viewMode === void 0 ? 'inlineDesktop' : _ref$viewMode,
65
+ isGroupedOptions = _ref.isGroupedOptions,
66
+ showActiveFiltersOnSmallScreen = _ref.showActiveFiltersOnSmallScreen;
67
+
68
+ var _useState = useState(false),
69
+ _useState2 = _slicedToArray(_useState, 2),
70
+ isNarrowScreen = _useState2[0],
71
+ setIsNarrowScreen = _useState2[1];
72
+
73
+ var _useState3 = useState(defaultVisibleCount),
74
+ _useState4 = _slicedToArray(_useState3, 2),
75
+ visibleCount = _useState4[0],
76
+ setVisibleCount = _useState4[1];
77
+
78
+ useEffect(function () {
79
+ setScreenSize(true);
80
+ var debounced = debounce(function () {
81
+ return setScreenSize(false);
82
+ }, 50);
83
+ window.addEventListener('resize', debounced);
84
+ return function () {
85
+ debounced.cancel();
86
+ window.removeEventListener('resize', debounced);
87
+ };
88
+ }, []);
60
89
 
61
- function FilterListPhone(props) {
62
- var _this;
90
+ var setScreenSize = function setScreenSize() {
91
+ var initial = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : false;
92
+ var newIsNarrowScreen = (window.innerWidth || document.documentElement.clientWidth) < 768;
93
+ /* eslint react/no-did-mount-set-state: 0 */
63
94
 
64
- _classCallCheck(this, FilterListPhone);
95
+ if (initial && newIsNarrowScreen || !initial) {
96
+ setIsNarrowScreen(newIsNarrowScreen);
97
+ }
98
+ /* eslint react/no-did-mount-set-state: 1 */
65
99
 
66
- _this = _super.call(this, props);
67
- _this.state = {
68
- isNarrowScreen: false,
69
- visibleCount: props.defaultVisibleCount
70
- };
71
- _this.setScreenSizeDebounced = debounce(function () {
72
- return _this.setScreenSize(false);
73
- }, 50);
74
- _this.handleChange = _this.handleChange.bind(_assertThisInitialized(_this));
75
- return _this;
76
- }
100
+ };
77
101
 
78
- _createClass(FilterListPhone, [{
79
- key: "componentDidMount",
80
- value: function componentDidMount() {
81
- this.setScreenSize(true);
82
- window.addEventListener('resize', this.setScreenSizeDebounced);
83
- }
84
- }, {
85
- key: "componentWillUnmount",
86
- value: function componentWillUnmount() {
87
- this.setScreenSizeDebounced.cancel();
88
- window.removeEventListener('resize', this.setScreenSizeDebounced);
89
- }
90
- }, {
91
- key: "setScreenSize",
92
- value: function setScreenSize() {
93
- var initial = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : false;
94
- var isNarrowScreen = (window.innerWidth || document.documentElement.clientWidth) < 768;
95
- /* eslint react/no-did-mount-set-state: 0 */
96
-
97
- if (initial && isNarrowScreen || !initial) {
98
- this.setState({
99
- isNarrowScreen: isNarrowScreen
100
- });
101
- }
102
- /* eslint react/no-did-mount-set-state: 1 */
102
+ var handleChange = function handleChange(event, option) {
103
+ var newValues = null;
103
104
 
105
+ if (event.currentTarget.checked) {
106
+ newValues = [].concat(_toConsumableArray(values), [option.value]);
107
+ } else {
108
+ newValues = values.filter(function (value) {
109
+ return value !== option.value;
110
+ });
104
111
  }
105
- }, {
106
- key: "handleChange",
107
- value: function handleChange(event, option) {
108
- var _this$props = this.props,
109
- onChange = _this$props.onChange,
110
- values = _this$props.values;
111
- var newValues = null;
112
-
113
- if (event.currentTarget.checked) {
114
- newValues = [].concat(_toConsumableArray(values), [option.value]);
115
- } else {
116
- newValues = values.filter(function (value) {
117
- return value !== option.value;
118
- });
119
- }
120
112
 
121
- if (onChange) {
122
- onChange(newValues, option.value);
123
- }
113
+ if (onChange) {
114
+ onChange(newValues, option.value);
124
115
  }
125
- }, {
126
- key: "render",
127
- value: function render() {
128
- var _this2 = this;
129
-
130
- var _this$props2 = this.props,
131
- preid = _this$props2.preid,
132
- modifiers = _this$props2.modifiers,
133
- label = _this$props2.label,
134
- labelNotVisible = _this$props2.labelNotVisible,
135
- options = _this$props2.options,
136
- values = _this$props2.values,
137
- onChange = _this$props2.onChange,
138
- defaultVisibleCount = _this$props2.defaultVisibleCount,
139
- showLabel = _this$props2.showLabel,
140
- hideLabel = _this$props2.hideLabel,
141
- messages = _this$props2.messages,
142
- alignedGroup = _this$props2.alignedGroup,
143
- collapseMobile = _this$props2.collapseMobile,
144
- activeFiltersNarrow = _this$props2.activeFiltersNarrow,
145
- viewMode = _this$props2.viewMode,
146
- isGroupedOptions = _this$props2.isGroupedOptions,
147
- showActiveFiltersOnSmallScreen = _this$props2.showActiveFiltersOnSmallScreen;
148
- var showAll = defaultVisibleCount === null || options.length <= defaultVisibleCount;
149
- var labelModifiers = [];
150
-
151
- if (labelNotVisible) {
152
- labelModifiers.push('hidden');
153
- }
116
+ };
154
117
 
155
- var groupedOptions = options;
118
+ var showAll = defaultVisibleCount === undefined || options.length <= defaultVisibleCount;
119
+ var labelModifiers = [];
156
120
 
157
- if (!isGroupedOptions) {
158
- groupedOptions = [options];
159
- }
121
+ if (labelNotVisible) {
122
+ labelModifiers.push('hidden');
123
+ }
160
124
 
161
- if (this.state.isNarrowScreen || viewMode === 'allModal') {
162
- var currentlyActiveFilters = [];
163
- groupedOptions.forEach(function (options) {
164
- var activeFilters = options.filter(function (option) {
165
- return values.some(function (value) {
166
- return value === option.value;
167
- });
168
- });
169
- currentlyActiveFilters = [].concat(_toConsumableArray(currentlyActiveFilters), _toConsumableArray(activeFilters));
125
+ var groupedOptions = is2DArray(options) ? options : [options];
126
+
127
+ if (isNarrowScreen || viewMode === 'allModal') {
128
+ var currentlyActiveFilters = [];
129
+ groupedOptions.forEach(function (options) {
130
+ var activeFilters = options.filter(function (option) {
131
+ return values.some(function (value) {
132
+ return value === option.value;
170
133
  });
171
- var wrapperClassName = activeFiltersNarrow || viewMode === 'allModal' ? classes('narrow-active-filters').className : '';
172
- return ___EmotionJSX("div", {
173
- className: wrapperClassName
174
- }, currentlyActiveFilters.length > 0 && ___EmotionJSX(ActiveFilters, {
175
- filters: currentlyActiveFilters,
176
- showOnSmallScreen: showActiveFiltersOnSmallScreen,
177
- onFilterRemove: function onFilterRemove(value) {
178
- onChange(values.filter(function (option) {
179
- return option !== value;
180
- }), value);
181
- }
182
- }), ___EmotionJSX(Modal, {
183
- size: "fullscreen",
184
- animation: "slide-up",
185
- backgroundColor: "grey",
186
- activateButton: ___EmotionJSX(Button, _extends({
187
- outline: true
188
- }, classes('modal-button')), messages.openFilter)
189
- }, function (onClose) {
190
- return ___EmotionJSX(Fragment, null, ___EmotionJSX(ModalHeader, {
191
- modifier: ['left-align']
192
- }, ___EmotionJSX("div", classes('modal-header'), ___EmotionJSX("div", classes('modal-heading'), !_this2.state.isNarrowScreen && label && ___EmotionJSX("h1", classes('label'), label), ___EmotionJSX(Button, {
193
- outline: true,
194
- onClick: onClose
195
- }, messages.useFilter)), ___EmotionJSX(ModalCloseButton, {
196
- title: ___EmotionJSX(Fragment, null, ___EmotionJSX(Cross, null), " ", messages.closeFilter),
197
- onClick: onClose
198
- }))), ___EmotionJSX(ModalBody, {
199
- modifier: "no-side-padding-mobile"
200
- }, _this2.state.isNarrowScreen && label && ___EmotionJSX("h1", classes('label'), label), groupedOptions.map(function (options, index) {
201
- return ___EmotionJSX("ul", _extends({
202
- key: index
203
- }, classes('item-wrapper', {
204
- 'aligned-grouping': alignedGroup,
205
- 'collapse-mobile': collapseMobile,
206
- 'grouped-options': isGroupedOptions
207
- })), options.map(function (option) {
208
- var itemModifiers = [];
209
- var checked = values.some(function (value) {
210
- return value === option.value;
211
- });
212
-
213
- if (option.noResults) {
214
- itemModifiers.push('no-results');
215
- }
216
-
217
- if (option.disabled) {
218
- itemModifiers.push('disabled');
219
- }
220
-
221
- return ___EmotionJSX(ToggleItem, {
222
- key: option.value,
223
- id: preid + option.value,
224
- value: option.value,
225
- checked: checked,
226
- onChange: function onChange(event) {
227
- _this2.handleChange(event, option);
228
- },
229
- icon: option.icon,
230
- label: option.title,
231
- disabled: option.disabled,
232
- modifiers: itemModifiers
233
- });
234
- }));
235
- }), ___EmotionJSX("div", classes('usefilter-wrapper'), ___EmotionJSX(Button, {
236
- outline: true,
237
- onClick: onClose
238
- }, messages.useFilter))));
239
- }));
134
+ });
135
+ currentlyActiveFilters = [].concat(_toConsumableArray(currentlyActiveFilters), _toConsumableArray(activeFilters));
136
+ });
137
+ var wrapperClassName = activeFiltersNarrow || viewMode === 'allModal' ? classes('narrow-active-filters').className : '';
138
+ return ___EmotionJSX("div", {
139
+ className: wrapperClassName
140
+ }, currentlyActiveFilters.length > 0 && ___EmotionJSX(ActiveFilters, {
141
+ filters: currentlyActiveFilters,
142
+ showOnSmallScreen: showActiveFiltersOnSmallScreen,
143
+ onFilterRemove: function onFilterRemove(value) {
144
+ onChange(values.filter(function (option) {
145
+ return option !== value;
146
+ }), value);
240
147
  }
241
-
242
- return ___EmotionJSX(React.Fragment, null, isGroupedOptions && label && ___EmotionJSX("h2", classes('label', labelModifiers), label), groupedOptions.map(function (options, index) {
243
- return ___EmotionJSX("section", _extends({
148
+ }), ___EmotionJSX(Modal, {
149
+ size: "fullscreen",
150
+ backgroundColor: "grey",
151
+ activateButton: ___EmotionJSX(Button, _extends({
152
+ outline: true
153
+ }, classes('modal-button')), messages.openFilter)
154
+ }, function (onClose) {
155
+ return ___EmotionJSX(React.Fragment, null, ___EmotionJSX(ModalHeader, {
156
+ modifier: ['left-align']
157
+ }, ___EmotionJSX("div", classes('modal-header'), ___EmotionJSX("div", classes('modal-heading'), !isNarrowScreen && label && ___EmotionJSX("h1", classes('label'), label), ___EmotionJSX(Button, {
158
+ outline: true,
159
+ onClick: onClose
160
+ }, messages.useFilter)), ___EmotionJSX(ModalCloseButton, {
161
+ title: messages.closeFilter,
162
+ onClick: onClose
163
+ }))), ___EmotionJSX(ModalBody, {
164
+ modifier: "no-side-padding-mobile"
165
+ }, isNarrowScreen && label && ___EmotionJSX("h1", classes('label'), label), groupedOptions.map(function (options, index) {
166
+ return ___EmotionJSX("ul", _extends({
244
167
  key: index
245
- }, classes('list', modifiers)), !isGroupedOptions && label && ___EmotionJSX("h1", classes('label', labelModifiers), label), ___EmotionJSX("ul", classes('item-wrapper'), options.map(function (option, index) {
168
+ }, classes('item-wrapper', {
169
+ 'aligned-grouping': !!alignedGroup,
170
+ 'collapse-mobile': !!collapseMobile,
171
+ 'grouped-options': !!isGroupedOptions
172
+ })), options.map(function (option) {
246
173
  var itemModifiers = [];
247
174
  var checked = values.some(function (value) {
248
175
  return value === option.value;
249
176
  });
250
177
 
251
- if (!showAll && !checked && index + 1 > _this2.state.visibleCount) {
252
- itemModifiers.push('hidden');
253
- }
254
-
255
178
  if (option.noResults) {
256
179
  itemModifiers.push('no-results');
257
180
  }
@@ -264,80 +187,65 @@ var FilterListPhone = /*#__PURE__*/function (_Component) {
264
187
  key: option.value,
265
188
  id: preid + option.value,
266
189
  value: option.value,
267
- tabIndex: option.noResults ? -1 : 0,
268
190
  checked: checked,
269
191
  onChange: function onChange(event) {
270
- _this2.handleChange(event, option);
192
+ return handleChange(event, option);
271
193
  },
272
- icon: option.icon,
273
194
  label: option.title,
274
- modifiers: itemModifiers,
275
- disabled: option.disabled
195
+ disabled: option.disabled,
196
+ modifiers: itemModifiers
276
197
  });
277
- })), !showAll && ___EmotionJSX("button", _extends({}, classes('expand'), {
278
- type: "button",
279
- onClick: function onClick() {
280
- _this2.setState(function (prevState) {
281
- if (prevState.visibleCount === defaultVisibleCount) {
282
- return {
283
- visibleCount: options.length
284
- };
285
- }
286
-
287
- return {
288
- visibleCount: defaultVisibleCount
289
- };
290
- });
291
- }
292
- }), _this2.state.visibleCount === defaultVisibleCount ? ___EmotionJSX(Fragment, null, ___EmotionJSX("span", null, showLabel), " ", ___EmotionJSX(ChevronDown, null)) : ___EmotionJSX(Fragment, null, ___EmotionJSX("span", null, hideLabel), " ", ___EmotionJSX(ChevronUp, null))));
293
- }));
294
- }
295
- }]);
296
-
297
- return FilterListPhone;
298
- }(Component);
299
-
300
- var valueShape = PropTypes.oneOfType([PropTypes.string, PropTypes.number]);
301
- var optionsShape = PropTypes.shape({
302
- title: PropTypes.string.isRequired,
303
- value: valueShape.isRequired,
304
- icon: PropTypes.func,
305
- noResults: PropTypes.bool,
306
- disabled: PropTypes.bool
307
- });
308
- FilterListPhone.propTypes = {
309
- preid: PropTypes.string.isRequired,
310
- children: PropTypes.node,
311
- label: PropTypes.string,
312
- labelNotVisible: PropTypes.bool,
313
- modifiers: PropTypes.string,
314
- onChange: PropTypes.func,
315
- // isRequired
316
- options: PropTypes.oneOfType([PropTypes.arrayOf(optionsShape), PropTypes.arrayOf(PropTypes.arrayOf(optionsShape))]).isRequired,
317
- values: PropTypes.arrayOf(valueShape),
318
- defaultVisibleCount: PropTypes.number,
319
- showLabel: PropTypes.string,
320
- hideLabel: PropTypes.string,
321
- onToggle: PropTypes.func,
322
- alignedGroup: PropTypes.bool,
323
- collapseMobile: PropTypes.bool,
324
- activeFiltersNarrow: PropTypes.bool,
325
- messages: PropTypes.shape({
326
- useFilter: PropTypes.string.isRequired,
327
- openFilter: PropTypes.string.isRequired,
328
- closeFilter: PropTypes.string.isRequired
329
- }).isRequired,
330
- viewMode: PropTypes.oneOf(['inlineDesktop', 'allModal']),
331
- isGroupedOptions: PropTypes.bool,
332
- showActiveFiltersOnSmallScreen: PropTypes.bool
333
- };
334
- FilterListPhone.defaultProps = {
335
- modifiers: '',
336
- values: [],
337
- defaultVisibleCount: null,
338
- onToggle: null,
339
- alignedGroup: false,
340
- collapseMobile: true,
341
- viewMode: 'inlineDesktop'
198
+ }));
199
+ }), ___EmotionJSX("div", classes('usefilter-wrapper'), ___EmotionJSX(Button, {
200
+ outline: true,
201
+ onClick: onClose
202
+ }, messages.useFilter))));
203
+ }));
204
+ }
205
+
206
+ return ___EmotionJSX(React.Fragment, null, isGroupedOptions && label && ___EmotionJSX("h2", classes('label', labelModifiers), label), groupedOptions.map(function (options, index) {
207
+ return ___EmotionJSX("section", _extends({
208
+ key: index
209
+ }, classes('list', modifiers)), !isGroupedOptions && label && ___EmotionJSX("h1", classes('label', labelModifiers), label), ___EmotionJSX("ul", classes('item-wrapper'), options.map(function (option, index) {
210
+ var itemModifiers = [];
211
+ var checked = values.some(function (value) {
212
+ return value === option.value;
213
+ });
214
+
215
+ if (!showAll && !checked && !!visibleCount && index + 1 > visibleCount) {
216
+ itemModifiers.push('hidden');
217
+ }
218
+
219
+ if (option.noResults) {
220
+ itemModifiers.push('no-results');
221
+ }
222
+
223
+ if (option.disabled) {
224
+ itemModifiers.push('disabled');
225
+ }
226
+
227
+ return ___EmotionJSX(ToggleItem, {
228
+ key: option.value,
229
+ id: preid + option.value,
230
+ value: option.value,
231
+ tabIndex: option.noResults ? -1 : 0,
232
+ checked: checked,
233
+ onChange: function onChange(event) {
234
+ return handleChange(event, option);
235
+ },
236
+ label: option.title,
237
+ modifiers: itemModifiers,
238
+ disabled: option.disabled
239
+ });
240
+ })), !showAll && ___EmotionJSX("button", _extends({}, classes('expand'), {
241
+ type: "button",
242
+ onClick: function onClick() {
243
+ setVisibleCount(function (prev) {
244
+ return prev === defaultVisibleCount ? options.length : defaultVisibleCount;
245
+ });
246
+ }
247
+ }), visibleCount === defaultVisibleCount ? ___EmotionJSX(React.Fragment, null, ___EmotionJSX("span", null, showLabel), " ", ___EmotionJSX(ChevronDown, null)) : ___EmotionJSX(React.Fragment, null, ___EmotionJSX("span", null, hideLabel), " ", ___EmotionJSX(ChevronUp, null))));
248
+ }));
342
249
  };
250
+
343
251
  export default FilterListPhone;
@@ -7,18 +7,18 @@ function _extends() { _extends = Object.assign || function (target) { for (var i
7
7
  * LICENSE file in the root directory of this source tree.
8
8
  *
9
9
  */
10
- import React, { createElement } from 'react';
11
- import PropTypes from 'prop-types';
10
+ import React from 'react';
12
11
  import { classes } from './filterClasses';
13
12
  import { jsx as ___EmotionJSX } from "@emotion/core";
14
13
 
15
14
  var ToggleItem = function ToggleItem(_ref) {
16
15
  var id = _ref.id,
17
- checked = _ref.checked,
16
+ _ref$checked = _ref.checked,
17
+ checked = _ref$checked === void 0 ? false : _ref$checked,
18
18
  modifiers = _ref.modifiers,
19
19
  label = _ref.label,
20
- Component = _ref.component,
21
- icon = _ref.icon,
20
+ _ref$component = _ref.component,
21
+ Component = _ref$component === void 0 ? 'li' : _ref$component,
22
22
  onChange = _ref.onChange,
23
23
  tabIndex = _ref.tabIndex,
24
24
  value = _ref.value,
@@ -34,26 +34,7 @@ var ToggleItem = function ToggleItem(_ref) {
34
34
  onChange: onChange
35
35
  })), ___EmotionJSX("label", {
36
36
  htmlFor: id
37
- }, ___EmotionJSX("span", classes('item-checkbox')), ___EmotionJSX("span", classes('text'), label, hits !== undefined && " (".concat(hits, ")")), icon ? /*#__PURE__*/createElement(icon, {
38
- className: "c-icon--22 ".concat(classes('icon').className)
39
- }) : null));
37
+ }, ___EmotionJSX("span", classes('item-checkbox')), ___EmotionJSX("span", classes('text'), label, hits !== undefined && " (".concat(hits, ")"))));
40
38
  };
41
39
 
42
- ToggleItem.propTypes = {
43
- id: PropTypes.string.isRequired,
44
- label: PropTypes.string.isRequired,
45
- onChange: PropTypes.func.isRequired,
46
- checked: PropTypes.bool,
47
- disabled: PropTypes.bool,
48
- tabIndex: PropTypes.number,
49
- modifiers: PropTypes.oneOfType([PropTypes.string, PropTypes.arrayOf(PropTypes.string)]),
50
- value: PropTypes.oneOfType([PropTypes.string, PropTypes.number]),
51
- component: PropTypes.oneOfType([PropTypes.string, PropTypes.func, PropTypes.object]),
52
- hits: PropTypes.number,
53
- icon: PropTypes.func
54
- };
55
- ToggleItem.defaultProps = {
56
- component: 'li',
57
- checked: false
58
- };
59
40
  export default ToggleItem;