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