@ndla/ui 24.2.2 → 25.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 (91) hide show
  1. package/es/CompetenceGoals/CompetenceGoalsDialog.js +15 -23
  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 -271
  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/Masthead/Masthead.js +65 -41
  10. package/es/Masthead/MastheadSearchModal.js +4 -5
  11. package/es/Masthead/SkipToMainContent.js +24 -0
  12. package/es/Masthead/index.js +2 -1
  13. package/es/SearchTypeResult/PopupFilter.js +8 -9
  14. package/es/SearchTypeResult/SearchFilterContent.js +3 -4
  15. package/es/SectionHeading/SectionHeading.js +24 -17
  16. package/es/Subject/index.js +0 -1
  17. package/es/all.css +1 -1
  18. package/es/index-javascript.js +1 -4
  19. package/es/index.js +5 -2
  20. package/lib/CompetenceGoals/CompetenceGoalsDialog.d.ts +19 -0
  21. package/lib/CompetenceGoals/CompetenceGoalsDialog.js +13 -24
  22. package/lib/CompetenceGoals/index.d.ts +1 -0
  23. package/lib/CompetenceGoals/index.js +1 -33
  24. package/lib/Filter/FilterButtons.js +9 -9
  25. package/lib/Filter/FilterList.d.ts +25 -0
  26. package/lib/Filter/FilterList.js +85 -155
  27. package/lib/Filter/FilterListPhone.d.ts +32 -0
  28. package/lib/Filter/FilterListPhone.js +176 -269
  29. package/lib/Filter/ToggleItem.d.ts +15 -0
  30. package/lib/Filter/ToggleItem.js +6 -32
  31. package/lib/Filter/filterClasses.d.ts +2 -0
  32. package/lib/Filter/index.d.ts +12 -0
  33. package/lib/Frontpage/FrontpageAllSubjects.js +7 -7
  34. package/lib/Frontpage/FrontpageSearch.js +2 -3
  35. package/lib/Masthead/Masthead.d.ts +4 -8
  36. package/lib/Masthead/Masthead.js +65 -49
  37. package/lib/Masthead/MastheadSearchModal.js +3 -4
  38. package/lib/Masthead/SkipToMainContent.d.ts +6 -0
  39. package/lib/Masthead/SkipToMainContent.js +38 -0
  40. package/lib/Masthead/index.d.ts +2 -1
  41. package/lib/Masthead/index.js +10 -0
  42. package/lib/SearchTypeResult/PopupFilter.js +7 -7
  43. package/lib/SearchTypeResult/SearchFilterContent.js +2 -2
  44. package/lib/SectionHeading/SectionHeading.d.ts +1 -13
  45. package/lib/SectionHeading/SectionHeading.js +23 -19
  46. package/lib/Subject/index.d.ts +0 -1
  47. package/lib/Subject/index.js +0 -8
  48. package/lib/all.css +1 -1
  49. package/lib/index-javascript.js +1 -63
  50. package/lib/index.d.ts +5 -2
  51. package/lib/index.js +48 -7
  52. package/package.json +11 -11
  53. package/src/CompetenceGoals/{CompetenceGoalsDialog.jsx → CompetenceGoalsDialog.tsx} +34 -26
  54. package/src/CompetenceGoals/index.ts +1 -0
  55. package/src/Filter/FilterButtons.tsx +0 -1
  56. package/src/Filter/FilterList.tsx +135 -0
  57. package/src/Filter/FilterListPhone.tsx +275 -0
  58. package/src/Filter/ToggleItem.tsx +58 -0
  59. package/src/Filter/{filterClasses.js → filterClasses.ts} +0 -0
  60. package/src/Filter/{index.js → index.ts} +0 -0
  61. package/src/Frontpage/FrontpageAllSubjects.tsx +0 -1
  62. package/src/Frontpage/FrontpageSearch.tsx +0 -1
  63. package/src/Masthead/Masthead.tsx +85 -45
  64. package/src/Masthead/MastheadSearchModal.tsx +0 -1
  65. package/src/Masthead/SkipToMainContent.tsx +48 -0
  66. package/src/Masthead/index.ts +2 -1
  67. package/src/SearchTypeResult/PopupFilter.tsx +0 -1
  68. package/src/SearchTypeResult/SearchFilterContent.tsx +0 -1
  69. package/src/SectionHeading/SectionHeading.tsx +29 -16
  70. package/src/Subject/index.ts +0 -1
  71. package/src/index-javascript.js +0 -10
  72. package/src/index.ts +7 -2
  73. package/src/main.scss +0 -3
  74. package/es/CompetenceGoals/CompetenceGoalList.js +0 -58
  75. package/es/CompetenceGoals/CompetenceGoals.js +0 -159
  76. package/es/Subject/SubjectFilter.js +0 -42
  77. package/lib/CompetenceGoals/CompetenceGoalList.js +0 -78
  78. package/lib/CompetenceGoals/CompetenceGoals.js +0 -184
  79. package/lib/Subject/SubjectFilter.d.ts +0 -27
  80. package/lib/Subject/SubjectFilter.js +0 -58
  81. package/src/.DS_Store +0 -0
  82. package/src/CompetenceGoals/CompetenceGoalList.jsx +0 -51
  83. package/src/CompetenceGoals/CompetenceGoals.jsx +0 -152
  84. package/src/CompetenceGoals/component.competence-goals.scss +0 -161
  85. package/src/CompetenceGoals/index.js +0 -6
  86. package/src/Filter/FilterList.jsx +0 -167
  87. package/src/Filter/FilterListPhone.jsx +0 -328
  88. package/src/Filter/ToggleItem.jsx +0 -71
  89. package/src/Masthead/component.masthead.scss +0 -146
  90. package/src/SectionHeading/component.section-heading.scss +0 -17
  91. 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,204 +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
- backgroundColor: "grey",
185
- activateButton: ___EmotionJSX(Button, _extends({
186
- outline: true
187
- }, classes('modal-button')), messages.openFilter)
188
- }, function (onClose) {
189
- return ___EmotionJSX(Fragment, null, ___EmotionJSX(ModalHeader, {
190
- modifier: ['left-align']
191
- }, ___EmotionJSX("div", classes('modal-header'), ___EmotionJSX("div", classes('modal-heading'), !_this2.state.isNarrowScreen && label && ___EmotionJSX("h1", classes('label'), label), ___EmotionJSX(Button, {
192
- outline: true,
193
- onClick: onClose
194
- }, messages.useFilter)), ___EmotionJSX(ModalCloseButton, {
195
- title: ___EmotionJSX(Fragment, null, ___EmotionJSX(Cross, null), " ", messages.closeFilter),
196
- onClick: onClose
197
- }))), ___EmotionJSX(ModalBody, {
198
- modifier: "no-side-padding-mobile"
199
- }, _this2.state.isNarrowScreen && label && ___EmotionJSX("h1", classes('label'), label), groupedOptions.map(function (options, index) {
200
- return ___EmotionJSX("ul", _extends({
201
- key: index
202
- }, classes('item-wrapper', {
203
- 'aligned-grouping': alignedGroup,
204
- 'collapse-mobile': collapseMobile,
205
- 'grouped-options': isGroupedOptions
206
- })), options.map(function (option) {
207
- var itemModifiers = [];
208
- var checked = values.some(function (value) {
209
- return value === option.value;
210
- });
211
-
212
- if (option.noResults) {
213
- itemModifiers.push('no-results');
214
- }
215
-
216
- if (option.disabled) {
217
- itemModifiers.push('disabled');
218
- }
219
-
220
- return ___EmotionJSX(ToggleItem, {
221
- key: option.value,
222
- id: preid + option.value,
223
- value: option.value,
224
- checked: checked,
225
- onChange: function onChange(event) {
226
- _this2.handleChange(event, option);
227
- },
228
- icon: option.icon,
229
- label: option.title,
230
- disabled: option.disabled,
231
- modifiers: itemModifiers
232
- });
233
- }));
234
- }), ___EmotionJSX("div", classes('usefilter-wrapper'), ___EmotionJSX(Button, {
235
- outline: true,
236
- onClick: onClose
237
- }, messages.useFilter))));
238
- }));
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);
239
147
  }
240
-
241
- return ___EmotionJSX(React.Fragment, null, isGroupedOptions && label && ___EmotionJSX("h2", classes('label', labelModifiers), label), groupedOptions.map(function (options, index) {
242
- 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({
243
167
  key: index
244
- }, 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) {
245
173
  var itemModifiers = [];
246
174
  var checked = values.some(function (value) {
247
175
  return value === option.value;
248
176
  });
249
177
 
250
- if (!showAll && !checked && index + 1 > _this2.state.visibleCount) {
251
- itemModifiers.push('hidden');
252
- }
253
-
254
178
  if (option.noResults) {
255
179
  itemModifiers.push('no-results');
256
180
  }
@@ -263,80 +187,65 @@ var FilterListPhone = /*#__PURE__*/function (_Component) {
263
187
  key: option.value,
264
188
  id: preid + option.value,
265
189
  value: option.value,
266
- tabIndex: option.noResults ? -1 : 0,
267
190
  checked: checked,
268
191
  onChange: function onChange(event) {
269
- _this2.handleChange(event, option);
192
+ return handleChange(event, option);
270
193
  },
271
- icon: option.icon,
272
194
  label: option.title,
273
- modifiers: itemModifiers,
274
- disabled: option.disabled
195
+ disabled: option.disabled,
196
+ modifiers: itemModifiers
275
197
  });
276
- })), !showAll && ___EmotionJSX("button", _extends({}, classes('expand'), {
277
- type: "button",
278
- onClick: function onClick() {
279
- _this2.setState(function (prevState) {
280
- if (prevState.visibleCount === defaultVisibleCount) {
281
- return {
282
- visibleCount: options.length
283
- };
284
- }
285
-
286
- return {
287
- visibleCount: defaultVisibleCount
288
- };
289
- });
290
- }
291
- }), _this2.state.visibleCount === defaultVisibleCount ? ___EmotionJSX(Fragment, null, ___EmotionJSX("span", null, showLabel), " ", ___EmotionJSX(ChevronDown, null)) : ___EmotionJSX(Fragment, null, ___EmotionJSX("span", null, hideLabel), " ", ___EmotionJSX(ChevronUp, null))));
292
- }));
293
- }
294
- }]);
295
-
296
- return FilterListPhone;
297
- }(Component);
298
-
299
- var valueShape = PropTypes.oneOfType([PropTypes.string, PropTypes.number]);
300
- var optionsShape = PropTypes.shape({
301
- title: PropTypes.string.isRequired,
302
- value: valueShape.isRequired,
303
- icon: PropTypes.func,
304
- noResults: PropTypes.bool,
305
- disabled: PropTypes.bool
306
- });
307
- FilterListPhone.propTypes = {
308
- preid: PropTypes.string.isRequired,
309
- children: PropTypes.node,
310
- label: PropTypes.string,
311
- labelNotVisible: PropTypes.bool,
312
- modifiers: PropTypes.string,
313
- onChange: PropTypes.func,
314
- // isRequired
315
- options: PropTypes.oneOfType([PropTypes.arrayOf(optionsShape), PropTypes.arrayOf(PropTypes.arrayOf(optionsShape))]).isRequired,
316
- values: PropTypes.arrayOf(valueShape),
317
- defaultVisibleCount: PropTypes.number,
318
- showLabel: PropTypes.string,
319
- hideLabel: PropTypes.string,
320
- onToggle: PropTypes.func,
321
- alignedGroup: PropTypes.bool,
322
- collapseMobile: PropTypes.bool,
323
- activeFiltersNarrow: PropTypes.bool,
324
- messages: PropTypes.shape({
325
- useFilter: PropTypes.string.isRequired,
326
- openFilter: PropTypes.string.isRequired,
327
- closeFilter: PropTypes.string.isRequired
328
- }).isRequired,
329
- viewMode: PropTypes.oneOf(['inlineDesktop', 'allModal']),
330
- isGroupedOptions: PropTypes.bool,
331
- showActiveFiltersOnSmallScreen: PropTypes.bool
332
- };
333
- FilterListPhone.defaultProps = {
334
- modifiers: '',
335
- values: [],
336
- defaultVisibleCount: null,
337
- onToggle: null,
338
- alignedGroup: false,
339
- collapseMobile: true,
340
- 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
+ }));
341
249
  };
250
+
342
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;