cozy-bar 8.4.2 → 8.4.3
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/dist/cozy-bar.min.js +4 -4
- package/dist/cozy-bar.min.js.map +1 -1
- package/package.json +2 -2
- package/CHANGELOG.md +0 -493
- package/transpiled/assets/icons/16/icon-storage-16.svg +0 -3
- package/transpiled/assets/icons/24/icon-arrow-left.svg +0 -3
- package/transpiled/assets/icons/32/icon-claudy.svg +0 -1
- package/transpiled/assets/icons/apps/icon-collect.svg +0 -25
- package/transpiled/assets/icons/apps/icon-drive.svg +0 -17
- package/transpiled/assets/icons/apps/icon-market-soon.svg +0 -25
- package/transpiled/assets/icons/apps/icon-photos.svg +0 -19
- package/transpiled/assets/icons/apps/icon-soon.svg +0 -21
- package/transpiled/assets/icons/apps/icon-store.svg +0 -19
- package/transpiled/assets/icons/claudyActions/icon-bills.svg +0 -6
- package/transpiled/assets/icons/claudyActions/icon-laptop.svg +0 -7
- package/transpiled/assets/icons/claudyActions/icon-phone.svg +0 -8
- package/transpiled/assets/icons/claudyActions/icon-question-mark.svg +0 -6
- package/transpiled/assets/icons/comingsoon/icon-bank.svg +0 -12
- package/transpiled/assets/icons/comingsoon/icon-sante.svg +0 -12
- package/transpiled/assets/icons/comingsoon/icon-store.svg +0 -6
- package/transpiled/assets/icons/icon-cozy.svg +0 -3
- package/transpiled/assets/icons/icon-shield.svg +0 -3
- package/transpiled/assets/icons/spinner.svg +0 -4
- package/transpiled/assets/sprites/icon-apps.svg +0 -1
- package/transpiled/assets/sprites/icon-cozy-home.svg +0 -16
- package/transpiled/components/Apps/AppItem.js +0 -134
- package/transpiled/components/Apps/AppItemPlaceholder.js +0 -14
- package/transpiled/components/Apps/AppNavButtons.js +0 -108
- package/transpiled/components/Apps/AppsContent.js +0 -124
- package/transpiled/components/Apps/ButtonCozyHome.js +0 -25
- package/transpiled/components/Apps/ButtonCozyHome.spec.jsx +0 -53
- package/transpiled/components/Apps/IconCozyHome.js +0 -67
- package/transpiled/components/Apps/index.js +0 -102
- package/transpiled/components/Banner.js +0 -76
- package/transpiled/components/Bar.js +0 -329
- package/transpiled/components/Bar.spec.jsx +0 -133
- package/transpiled/components/Claudy.js +0 -123
- package/transpiled/components/ClaudyIcon.js +0 -16
- package/transpiled/components/Drawer.js +0 -367
- package/transpiled/components/Drawer.spec.jsx +0 -98
- package/transpiled/components/SearchBar.js +0 -407
- package/transpiled/components/Settings/SettingsContent.js +0 -128
- package/transpiled/components/Settings/StorageData.js +0 -24
- package/transpiled/components/Settings/helper.js +0 -9
- package/transpiled/components/Settings/index.js +0 -225
- package/transpiled/components/StorageIcon.js +0 -16
- package/transpiled/components/SupportModal.js +0 -86
- package/transpiled/components/__snapshots__/Bar.spec.jsx.snap +0 -302
- package/transpiled/config/claudyActions.json +0 -20
- package/transpiled/config/persistWhitelist.json +0 -4
- package/transpiled/cozy-bar.css +0 -5905
- package/transpiled/dom.js +0 -84
- package/transpiled/index.js +0 -246
- package/transpiled/index.spec.jsx +0 -34
- package/transpiled/lib/api/helpers.js +0 -12
- package/transpiled/lib/api/index.js +0 -175
- package/transpiled/lib/exceptions.js +0 -156
- package/transpiled/lib/expiringMemoize.js +0 -17
- package/transpiled/lib/icon.js +0 -154
- package/transpiled/lib/intents.js +0 -17
- package/transpiled/lib/logger.js +0 -10
- package/transpiled/lib/middlewares/appsI18n.js +0 -64
- package/transpiled/lib/realtime.js +0 -76
- package/transpiled/lib/reducers/apps.js +0 -291
- package/transpiled/lib/reducers/apps.spec.js +0 -59
- package/transpiled/lib/reducers/content.js +0 -68
- package/transpiled/lib/reducers/context.js +0 -138
- package/transpiled/lib/reducers/index.js +0 -59
- package/transpiled/lib/reducers/locale.js +0 -27
- package/transpiled/lib/reducers/settings.js +0 -253
- package/transpiled/lib/reducers/theme.js +0 -64
- package/transpiled/lib/reducers/unserializable.js +0 -31
- package/transpiled/lib/stack-client.js +0 -442
- package/transpiled/lib/stack.js +0 -122
- package/transpiled/lib/store/index.js +0 -42
- package/transpiled/locales/de.json +0 -57
- package/transpiled/locales/en.json +0 -57
- package/transpiled/locales/es.json +0 -57
- package/transpiled/locales/fr.json +0 -57
- package/transpiled/locales/it.json +0 -57
- package/transpiled/locales/ja.json +0 -57
- package/transpiled/locales/nl_NL.json +0 -57
- package/transpiled/locales/pl.json +0 -57
- package/transpiled/locales/ru.json +0 -57
- package/transpiled/locales/sq.json +0 -57
- package/transpiled/locales/zh_CN.json +0 -57
- package/transpiled/proptypes/index.js +0 -11
- package/transpiled/queries/index.js +0 -19
- package/transpiled/styles/apps.css +0 -248
- package/transpiled/styles/banner.css +0 -64
- package/transpiled/styles/bar.css +0 -106
- package/transpiled/styles/base.css +0 -21
- package/transpiled/styles/claudy.css +0 -98
- package/transpiled/styles/drawer.css +0 -126
- package/transpiled/styles/index.styl +0 -33
- package/transpiled/styles/indicators.css +0 -58
- package/transpiled/styles/nav.css +0 -81
- package/transpiled/styles/navigation_item.css +0 -34
- package/transpiled/styles/searchbar.css +0 -156
- package/transpiled/styles/settings.css +0 -34
- package/transpiled/styles/storage.css +0 -22
- package/transpiled/styles/supportModal.css +0 -20
- package/transpiled/styles/theme.styl +0 -25
|
@@ -1,407 +0,0 @@
|
|
|
1
|
-
import _regeneratorRuntime from "@babel/runtime/regenerator";
|
|
2
|
-
import _toConsumableArray from "@babel/runtime/helpers/toConsumableArray";
|
|
3
|
-
import _asyncToGenerator from "@babel/runtime/helpers/asyncToGenerator";
|
|
4
|
-
import _objectSpread from "@babel/runtime/helpers/objectSpread";
|
|
5
|
-
import _classCallCheck from "@babel/runtime/helpers/classCallCheck";
|
|
6
|
-
import _createClass from "@babel/runtime/helpers/createClass";
|
|
7
|
-
import _assertThisInitialized from "@babel/runtime/helpers/assertThisInitialized";
|
|
8
|
-
import _inherits from "@babel/runtime/helpers/inherits";
|
|
9
|
-
import _possibleConstructorReturn from "@babel/runtime/helpers/possibleConstructorReturn";
|
|
10
|
-
import _getPrototypeOf from "@babel/runtime/helpers/getPrototypeOf";
|
|
11
|
-
import _defineProperty from "@babel/runtime/helpers/defineProperty";
|
|
12
|
-
|
|
13
|
-
function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }
|
|
14
|
-
|
|
15
|
-
function _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; } }
|
|
16
|
-
|
|
17
|
-
import React, { Component } from 'react';
|
|
18
|
-
import { translate } from "cozy-ui/transpiled/react/I18n";
|
|
19
|
-
import Autosuggest from 'react-autosuggest';
|
|
20
|
-
import debounce from 'lodash.debounce';
|
|
21
|
-
import { fetchRawIntent } from "../lib/intents";
|
|
22
|
-
import logger from "../lib/logger";
|
|
23
|
-
var INTENT_VERB = 'OPEN';
|
|
24
|
-
var INTENT_DOCTYPE = 'io.cozy.suggestions';
|
|
25
|
-
var SUGGESTIONS_PER_SOURCE = 10;
|
|
26
|
-
|
|
27
|
-
var normalizeString = function normalizeString(str) {
|
|
28
|
-
return str.toString().toLowerCase().replace(/\//g, ' ').normalize('NFD').replace(/[\u0300-\u036f]/g, '').split(' ');
|
|
29
|
-
};
|
|
30
|
-
|
|
31
|
-
var highlightQueryTerms = function highlightQueryTerms(searchResult, query) {
|
|
32
|
-
var normalizedQueryTerms = normalizeString(query);
|
|
33
|
-
var normalizedResultTerms = normalizeString(searchResult);
|
|
34
|
-
var matchedIntervals = [];
|
|
35
|
-
var spacerLength = 1;
|
|
36
|
-
var currentIndex = 0;
|
|
37
|
-
normalizedResultTerms.forEach(function (resultTerm) {
|
|
38
|
-
normalizedQueryTerms.forEach(function (queryTerm) {
|
|
39
|
-
var index = resultTerm.indexOf(queryTerm);
|
|
40
|
-
|
|
41
|
-
if (index >= 0) {
|
|
42
|
-
matchedIntervals.push({
|
|
43
|
-
from: currentIndex + index,
|
|
44
|
-
to: currentIndex + index + queryTerm.length
|
|
45
|
-
});
|
|
46
|
-
}
|
|
47
|
-
});
|
|
48
|
-
currentIndex += resultTerm.length + spacerLength;
|
|
49
|
-
}); // matchedIntervals can overlap, so we merge them.
|
|
50
|
-
// - sort the intervals by starting index
|
|
51
|
-
// - add the first interval to the stack
|
|
52
|
-
// - for every interval,
|
|
53
|
-
// - - add it to the stack if it doesn't overlap with the stack top
|
|
54
|
-
// - - or extend the stack top if the start overlaps and the new interval's top is bigger
|
|
55
|
-
|
|
56
|
-
var mergedIntervals = matchedIntervals.sort(function (intervalA, intervalB) {
|
|
57
|
-
return intervalA.from > intervalB.from;
|
|
58
|
-
}).reduce(function (computedIntervals, newInterval) {
|
|
59
|
-
if (computedIntervals.length === 0 || computedIntervals[computedIntervals.length - 1].to < newInterval.from) {
|
|
60
|
-
computedIntervals.push(newInterval);
|
|
61
|
-
} else if (computedIntervals[computedIntervals.length - 1].to < newInterval.to) {
|
|
62
|
-
computedIntervals[computedIntervals.length - 1].to = newInterval.to;
|
|
63
|
-
}
|
|
64
|
-
|
|
65
|
-
return computedIntervals;
|
|
66
|
-
}, []); // create an array containing the entire search result, with special characters, and the intervals surrounded y `<b>` tags
|
|
67
|
-
|
|
68
|
-
var slicedOriginalResult = mergedIntervals.length > 0 ? [searchResult.slice(0, mergedIntervals[0].from)] : searchResult;
|
|
69
|
-
|
|
70
|
-
for (var i = 0, l = mergedIntervals.length; i < l; ++i) {
|
|
71
|
-
slicedOriginalResult.push( /*#__PURE__*/React.createElement("b", null, searchResult.slice(mergedIntervals[i].from, mergedIntervals[i].to)));
|
|
72
|
-
if (i + 1 < l) slicedOriginalResult.push(searchResult.slice(mergedIntervals[i].to, mergedIntervals[i + 1].from));
|
|
73
|
-
}
|
|
74
|
-
|
|
75
|
-
if (mergedIntervals.length > 0) slicedOriginalResult.push(searchResult.slice(mergedIntervals[mergedIntervals.length - 1].to, searchResult.length));
|
|
76
|
-
return slicedOriginalResult;
|
|
77
|
-
};
|
|
78
|
-
|
|
79
|
-
var SearchBar = /*#__PURE__*/function (_Component) {
|
|
80
|
-
_inherits(SearchBar, _Component);
|
|
81
|
-
|
|
82
|
-
var _super = _createSuper(SearchBar);
|
|
83
|
-
|
|
84
|
-
function SearchBar() {
|
|
85
|
-
var _this;
|
|
86
|
-
|
|
87
|
-
_classCallCheck(this, SearchBar);
|
|
88
|
-
|
|
89
|
-
for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
|
|
90
|
-
args[_key] = arguments[_key];
|
|
91
|
-
}
|
|
92
|
-
|
|
93
|
-
_this = _super.call.apply(_super, [this].concat(args));
|
|
94
|
-
|
|
95
|
-
_defineProperty(_assertThisInitialized(_this), "state", {
|
|
96
|
-
input: '',
|
|
97
|
-
query: null,
|
|
98
|
-
searching: false,
|
|
99
|
-
focused: false,
|
|
100
|
-
suggestionsBySource: [],
|
|
101
|
-
sourceURLs: []
|
|
102
|
-
});
|
|
103
|
-
|
|
104
|
-
_defineProperty(_assertThisInitialized(_this), "sources", []);
|
|
105
|
-
|
|
106
|
-
_defineProperty(_assertThisInitialized(_this), "onMessageFromSource", function (sources) {
|
|
107
|
-
return function (event) {
|
|
108
|
-
// this re-implements a subset of injectService found in lib/intents, though only the part that are useful for suggestions
|
|
109
|
-
var source = sources.find(function (source) {
|
|
110
|
-
return source.origin === event.origin;
|
|
111
|
-
});
|
|
112
|
-
if (!source) return null;
|
|
113
|
-
|
|
114
|
-
if (event.data.type === "intent-".concat(source.id, ":ready")) {
|
|
115
|
-
source.ready = true;
|
|
116
|
-
source.window = event.source;
|
|
117
|
-
source.window.postMessage({}, event.origin);
|
|
118
|
-
} else if (event.data.type === "intent-".concat(source.id, ":data") && source.resolvers[event.data.id]) {
|
|
119
|
-
source.resolvers[event.data.id]({
|
|
120
|
-
id: source.id,
|
|
121
|
-
suggestions: event.data.suggestions
|
|
122
|
-
});
|
|
123
|
-
delete source.resolvers[event.data.id];
|
|
124
|
-
} else {
|
|
125
|
-
logger.log('unhandled message:', event);
|
|
126
|
-
}
|
|
127
|
-
};
|
|
128
|
-
});
|
|
129
|
-
|
|
130
|
-
_defineProperty(_assertThisInitialized(_this), "onChange", function (event, _ref) {
|
|
131
|
-
var newValue = _ref.newValue;
|
|
132
|
-
|
|
133
|
-
_this.setState({
|
|
134
|
-
input: newValue
|
|
135
|
-
});
|
|
136
|
-
});
|
|
137
|
-
|
|
138
|
-
_defineProperty(_assertThisInitialized(_this), "changeFocusState", function (focused) {
|
|
139
|
-
_this.setState({
|
|
140
|
-
focused: focused
|
|
141
|
-
});
|
|
142
|
-
});
|
|
143
|
-
|
|
144
|
-
_defineProperty(_assertThisInitialized(_this), "clearSuggestions", function () {
|
|
145
|
-
_this.setState({
|
|
146
|
-
suggestionsBySource: []
|
|
147
|
-
});
|
|
148
|
-
});
|
|
149
|
-
|
|
150
|
-
_defineProperty(_assertThisInitialized(_this), "onSuggestionsFetchRequested", function (_ref2) {
|
|
151
|
-
var value = _ref2.value;
|
|
152
|
-
|
|
153
|
-
var availableSources = _this.sources.filter(function (source) {
|
|
154
|
-
return source.ready;
|
|
155
|
-
});
|
|
156
|
-
|
|
157
|
-
if (availableSources.length > 0) {
|
|
158
|
-
// We defer the emptying of `suggestionsBySource` so that we still display
|
|
159
|
-
// the previous suggestion list
|
|
160
|
-
_this.setState(function (state) {
|
|
161
|
-
return _objectSpread({}, state, {
|
|
162
|
-
searching: true
|
|
163
|
-
});
|
|
164
|
-
});
|
|
165
|
-
|
|
166
|
-
availableSources.forEach( /*#__PURE__*/function () {
|
|
167
|
-
var _ref3 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee(source) {
|
|
168
|
-
var _yield$Promise, id, suggestions, title;
|
|
169
|
-
|
|
170
|
-
return _regeneratorRuntime.wrap(function _callee$(_context) {
|
|
171
|
-
while (1) {
|
|
172
|
-
switch (_context.prev = _context.next) {
|
|
173
|
-
case 0:
|
|
174
|
-
_context.next = 2;
|
|
175
|
-
return new Promise(function (resolve) {
|
|
176
|
-
var resolverId = new Date().getTime().toString();
|
|
177
|
-
source.resolvers[resolverId] = resolve;
|
|
178
|
-
source.window.postMessage({
|
|
179
|
-
query: value,
|
|
180
|
-
id: resolverId
|
|
181
|
-
}, source.origin);
|
|
182
|
-
});
|
|
183
|
-
|
|
184
|
-
case 2:
|
|
185
|
-
_yield$Promise = _context.sent;
|
|
186
|
-
id = _yield$Promise.id;
|
|
187
|
-
suggestions = _yield$Promise.suggestions;
|
|
188
|
-
title = _this.sources.find(function (source) {
|
|
189
|
-
return source.id === id;
|
|
190
|
-
}).slug; // This is the first result we get for this new search term,
|
|
191
|
-
// we can now update `query` and replace the previous `suggestionsBySource`
|
|
192
|
-
|
|
193
|
-
if (_this.state.query !== value) {
|
|
194
|
-
_this.setState(function (state) {
|
|
195
|
-
return _objectSpread({}, state, {
|
|
196
|
-
searching: false,
|
|
197
|
-
query: value,
|
|
198
|
-
suggestionsBySource: [{
|
|
199
|
-
title: title,
|
|
200
|
-
suggestions: suggestions
|
|
201
|
-
}]
|
|
202
|
-
});
|
|
203
|
-
});
|
|
204
|
-
} else {
|
|
205
|
-
_this.setState(function (state) {
|
|
206
|
-
return _objectSpread({}, state, {
|
|
207
|
-
suggestionsBySource: [].concat(_toConsumableArray(state.suggestionsBySource), [{
|
|
208
|
-
title: title,
|
|
209
|
-
suggestions: suggestions
|
|
210
|
-
}])
|
|
211
|
-
});
|
|
212
|
-
});
|
|
213
|
-
}
|
|
214
|
-
|
|
215
|
-
case 7:
|
|
216
|
-
case "end":
|
|
217
|
-
return _context.stop();
|
|
218
|
-
}
|
|
219
|
-
}
|
|
220
|
-
}, _callee);
|
|
221
|
-
}));
|
|
222
|
-
|
|
223
|
-
return function (_x) {
|
|
224
|
-
return _ref3.apply(this, arguments);
|
|
225
|
-
};
|
|
226
|
-
}());
|
|
227
|
-
}
|
|
228
|
-
});
|
|
229
|
-
|
|
230
|
-
_defineProperty(_assertThisInitialized(_this), "onSuggestionsClearRequested", function () {
|
|
231
|
-
_this.clearSuggestions();
|
|
232
|
-
|
|
233
|
-
_this.debouncedOnSuggestionsFetchRequested.cancel();
|
|
234
|
-
|
|
235
|
-
_this.setState({
|
|
236
|
-
query: null,
|
|
237
|
-
searching: false
|
|
238
|
-
});
|
|
239
|
-
});
|
|
240
|
-
|
|
241
|
-
_defineProperty(_assertThisInitialized(_this), "onSuggestionSelected", function (event, _ref4) {
|
|
242
|
-
var suggestion = _ref4.suggestion;
|
|
243
|
-
var onSelect = suggestion.onSelect; // `onSelect` is a string that describes what should happen when the suggestion is selected. Currently, the only format we're supporting is `open:http://example.com` to change the url of the current page.
|
|
244
|
-
|
|
245
|
-
if (/^open:/.test(onSelect)) {
|
|
246
|
-
var url = onSelect.substr(5);
|
|
247
|
-
window.location.href = url;
|
|
248
|
-
} else {
|
|
249
|
-
// eslint-disable-next-line no-console
|
|
250
|
-
console.log('suggestion onSelect (' + onSelect + ') could not be executed');
|
|
251
|
-
}
|
|
252
|
-
|
|
253
|
-
_this.setState({
|
|
254
|
-
input: '',
|
|
255
|
-
query: null
|
|
256
|
-
});
|
|
257
|
-
});
|
|
258
|
-
|
|
259
|
-
_defineProperty(_assertThisInitialized(_this), "getSectionSuggestions", function (section) {
|
|
260
|
-
return section.suggestions.slice(0, SUGGESTIONS_PER_SOURCE);
|
|
261
|
-
});
|
|
262
|
-
|
|
263
|
-
_defineProperty(_assertThisInitialized(_this), "getSuggestionValue", function (suggestion) {
|
|
264
|
-
return suggestion.subtitle;
|
|
265
|
-
});
|
|
266
|
-
|
|
267
|
-
_defineProperty(_assertThisInitialized(_this), "renderSectionTitle", function () {
|
|
268
|
-
return null;
|
|
269
|
-
});
|
|
270
|
-
|
|
271
|
-
_defineProperty(_assertThisInitialized(_this), "renderSuggestion", function (suggestion) {
|
|
272
|
-
return /*#__PURE__*/React.createElement("div", {
|
|
273
|
-
className: "coz-searchbar-autosuggest-suggestion-item"
|
|
274
|
-
}, suggestion.icon && /*#__PURE__*/React.createElement("img", {
|
|
275
|
-
className: "coz-searchbar-autosuggest-suggestion-icon",
|
|
276
|
-
src: suggestion.icon,
|
|
277
|
-
alt: "icon"
|
|
278
|
-
}), /*#__PURE__*/React.createElement("div", {
|
|
279
|
-
className: "coz-searchbar-autosuggest-suggestion-content"
|
|
280
|
-
}, /*#__PURE__*/React.createElement("div", {
|
|
281
|
-
className: "coz-searchbar-autosuggest-suggestion-title"
|
|
282
|
-
}, highlightQueryTerms(suggestion.title, _this.state.query)), suggestion.subtitle && /*#__PURE__*/React.createElement("div", {
|
|
283
|
-
className: "coz-searchbar-autosuggest-suggestion-subtitle"
|
|
284
|
-
}, highlightQueryTerms(suggestion.subtitle, _this.state.query))));
|
|
285
|
-
});
|
|
286
|
-
|
|
287
|
-
return _this;
|
|
288
|
-
}
|
|
289
|
-
|
|
290
|
-
_createClass(SearchBar, [{
|
|
291
|
-
key: "componentWillMount",
|
|
292
|
-
value: function componentWillMount() {
|
|
293
|
-
this.debouncedOnSuggestionsFetchRequested = debounce(this.onSuggestionsFetchRequested, 250);
|
|
294
|
-
}
|
|
295
|
-
}, {
|
|
296
|
-
key: "componentDidMount",
|
|
297
|
-
value: function componentDidMount() {
|
|
298
|
-
var _this2 = this;
|
|
299
|
-
|
|
300
|
-
// The searchbar has one or more sources that provide suggestions. These sources are iframes into other apps, provied by thee intent system.
|
|
301
|
-
// Since we need to call the sources whenever the query changes, we are taking manual control over the intent process.
|
|
302
|
-
fetchRawIntent(INTENT_VERB, INTENT_DOCTYPE).then(function (intent) {
|
|
303
|
-
var services = intent.attributes.services;
|
|
304
|
-
if (!services) return null;
|
|
305
|
-
_this2.sources = services.map(function (service) {
|
|
306
|
-
var url = service.href;
|
|
307
|
-
|
|
308
|
-
_this2.setState(function (state) {
|
|
309
|
-
return _objectSpread({}, state, {
|
|
310
|
-
sourceURLs: [].concat(_toConsumableArray(state.sourceURLs), [url])
|
|
311
|
-
});
|
|
312
|
-
});
|
|
313
|
-
|
|
314
|
-
var serviceOrigin = url.split('/', 3).join('/');
|
|
315
|
-
return {
|
|
316
|
-
slug: service.slug,
|
|
317
|
-
// can be used to show where a suggestion comes from
|
|
318
|
-
origin: serviceOrigin,
|
|
319
|
-
id: intent._id,
|
|
320
|
-
ready: false,
|
|
321
|
-
window: null,
|
|
322
|
-
// will hold a reference to the window we're sending messages to
|
|
323
|
-
resolvers: {} // will hold references to a function to call when the source sends suggestions
|
|
324
|
-
|
|
325
|
-
};
|
|
326
|
-
});
|
|
327
|
-
window.addEventListener('message', _this2.onMessageFromSource(_this2.sources));
|
|
328
|
-
});
|
|
329
|
-
}
|
|
330
|
-
}, {
|
|
331
|
-
key: "render",
|
|
332
|
-
value: function render() {
|
|
333
|
-
var _this3 = this;
|
|
334
|
-
|
|
335
|
-
var _this$state = this.state,
|
|
336
|
-
input = _this$state.input,
|
|
337
|
-
query = _this$state.query,
|
|
338
|
-
searching = _this$state.searching,
|
|
339
|
-
focused = _this$state.focused,
|
|
340
|
-
suggestionsBySource = _this$state.suggestionsBySource,
|
|
341
|
-
sourceURLs = _this$state.sourceURLs;
|
|
342
|
-
if (sourceURLs.length === 0) return null;
|
|
343
|
-
var t = this.props.t;
|
|
344
|
-
var isInitialSearch = input !== '' && query === null;
|
|
345
|
-
var hasSuggestions = suggestionsBySource.reduce(function (totalSuggestions, suggestionSection) {
|
|
346
|
-
return totalSuggestions + suggestionSection.suggestions.length;
|
|
347
|
-
}, 0) > 0;
|
|
348
|
-
var inputProps = {
|
|
349
|
-
placeholder: t('searchbar.placeholder'),
|
|
350
|
-
value: input,
|
|
351
|
-
onChange: this.onChange,
|
|
352
|
-
onFocus: function onFocus() {
|
|
353
|
-
return _this3.changeFocusState(true);
|
|
354
|
-
},
|
|
355
|
-
onBlur: function onBlur() {
|
|
356
|
-
return _this3.changeFocusState(false);
|
|
357
|
-
}
|
|
358
|
-
};
|
|
359
|
-
var theme = {
|
|
360
|
-
container: 'coz-searchbar-autosuggest-container' + (searching ? ' --searching' : '') + (focused ? ' --focused' : ''),
|
|
361
|
-
input: 'coz-searchbar-autosuggest-input',
|
|
362
|
-
inputFocused: 'coz-searchbar-autosuggest-input-focused',
|
|
363
|
-
suggestionsContainer: 'coz-searchbar-autosuggest-suggestions-container',
|
|
364
|
-
suggestionsContainerOpen: 'coz-searchbar-autosuggest-suggestions-container--open',
|
|
365
|
-
suggestionsList: 'coz-searchbar-autosuggest-suggestions-list',
|
|
366
|
-
suggestion: 'coz-searchbar-autosuggest-suggestion',
|
|
367
|
-
suggestionHighlighted: 'coz-searchbar-autosuggest-suggestion-highlighted',
|
|
368
|
-
sectionTitle: 'coz-searchbar-autosuggest-section-title'
|
|
369
|
-
};
|
|
370
|
-
return /*#__PURE__*/React.createElement("div", {
|
|
371
|
-
className: "coz-searchbar",
|
|
372
|
-
role: "search"
|
|
373
|
-
}, sourceURLs.map(function (url, i) {
|
|
374
|
-
return /*#__PURE__*/React.createElement("iframe", {
|
|
375
|
-
src: url,
|
|
376
|
-
style: {
|
|
377
|
-
visibility: 'hidden',
|
|
378
|
-
height: '0px',
|
|
379
|
-
width: '0px'
|
|
380
|
-
},
|
|
381
|
-
key: url + i
|
|
382
|
-
});
|
|
383
|
-
}), /*#__PURE__*/React.createElement(Autosuggest, {
|
|
384
|
-
theme: theme,
|
|
385
|
-
suggestions: suggestionsBySource,
|
|
386
|
-
multiSection: true,
|
|
387
|
-
onSuggestionsFetchRequested: this.debouncedOnSuggestionsFetchRequested,
|
|
388
|
-
onSuggestionsClearRequested: this.onSuggestionsClearRequested,
|
|
389
|
-
onSuggestionSelected: this.onSuggestionSelected,
|
|
390
|
-
getSuggestionValue: this.getSuggestionValue,
|
|
391
|
-
getSectionSuggestions: this.getSectionSuggestions,
|
|
392
|
-
renderSectionTitle: this.renderSectionTitle,
|
|
393
|
-
renderSuggestion: this.renderSuggestion,
|
|
394
|
-
inputProps: inputProps,
|
|
395
|
-
focusInputOnSuggestionClick: false
|
|
396
|
-
}), input !== '' && !isInitialSearch && focused && !hasSuggestions && /*#__PURE__*/React.createElement("div", {
|
|
397
|
-
className: 'coz-searchbar-autosuggest-status-container'
|
|
398
|
-
}, t('searchbar.empty', {
|
|
399
|
-
query: input
|
|
400
|
-
})));
|
|
401
|
-
}
|
|
402
|
-
}]);
|
|
403
|
-
|
|
404
|
-
return SearchBar;
|
|
405
|
-
}(Component);
|
|
406
|
-
|
|
407
|
-
export default translate()(SearchBar);
|
|
@@ -1,128 +0,0 @@
|
|
|
1
|
-
import React from 'react';
|
|
2
|
-
import PropTypes from 'prop-types';
|
|
3
|
-
import { isMobileApp } from 'cozy-device-helper';
|
|
4
|
-
import { translate } from "cozy-ui/transpiled/react/I18n";
|
|
5
|
-
import { ButtonLink } from "cozy-ui/transpiled/react/Button";
|
|
6
|
-
import Icon from 'cozy-ui/transpiled/react/Icon';
|
|
7
|
-
import PhoneIcon from 'cozy-ui/transpiled/react/Icons/Phone';
|
|
8
|
-
import CloudIcon from 'cozy-ui/transpiled/react/Icons/Cloud';
|
|
9
|
-
import PeopleIcon from 'cozy-ui/transpiled/react/Icons/People';
|
|
10
|
-
import CloudHappyIcon from 'cozy-ui/transpiled/react/Icons/CloudHappy';
|
|
11
|
-
import LogoutIcon from 'cozy-ui/transpiled/react/Icons/Logout';
|
|
12
|
-
import HelpIcon from 'cozy-ui/transpiled/react/Icons/Help';
|
|
13
|
-
import StorageData from "./StorageData";
|
|
14
|
-
import StorageIcon from "../StorageIcon";
|
|
15
|
-
|
|
16
|
-
var MenuIcon = function MenuIcon(_ref) {
|
|
17
|
-
var icon = _ref.icon;
|
|
18
|
-
return /*#__PURE__*/React.createElement(Icon, {
|
|
19
|
-
className: "u-mr-half",
|
|
20
|
-
color: "var(--slateGrey)",
|
|
21
|
-
icon: icon
|
|
22
|
-
});
|
|
23
|
-
};
|
|
24
|
-
|
|
25
|
-
var NavGroup = function NavGroup(_ref2) {
|
|
26
|
-
var children = _ref2.children;
|
|
27
|
-
return /*#__PURE__*/React.createElement("ul", {
|
|
28
|
-
className: "coz-nav-group"
|
|
29
|
-
}, children);
|
|
30
|
-
};
|
|
31
|
-
|
|
32
|
-
var NavItem = function NavItem(_ref3) {
|
|
33
|
-
var children = _ref3.children;
|
|
34
|
-
return /*#__PURE__*/React.createElement("li", {
|
|
35
|
-
className: "coz-nav-settings-item"
|
|
36
|
-
}, children);
|
|
37
|
-
};
|
|
38
|
-
|
|
39
|
-
var SettingsContent = function SettingsContent(_ref4) {
|
|
40
|
-
var t = _ref4.t,
|
|
41
|
-
onLogOut = _ref4.onLogOut,
|
|
42
|
-
settingsAppURL = _ref4.settingsAppURL,
|
|
43
|
-
storageData = _ref4.storageData,
|
|
44
|
-
onClaudy = _ref4.onClaudy,
|
|
45
|
-
_ref4$isDrawer = _ref4.isDrawer,
|
|
46
|
-
isDrawer = _ref4$isDrawer === void 0 ? false : _ref4$isDrawer,
|
|
47
|
-
isClaudyLoading = _ref4.isClaudyLoading,
|
|
48
|
-
toggleSupport = _ref4.toggleSupport,
|
|
49
|
-
shoulDisplayViewOfferButton = _ref4.shoulDisplayViewOfferButton,
|
|
50
|
-
managerUrlPremiumLink = _ref4.managerUrlPremiumLink,
|
|
51
|
-
viewOfferButtonText = _ref4.viewOfferButtonText;
|
|
52
|
-
return /*#__PURE__*/React.createElement("div", {
|
|
53
|
-
className: "coz-nav-pop-content"
|
|
54
|
-
}, isDrawer && /*#__PURE__*/React.createElement("hr", null), settingsAppURL && /*#__PURE__*/React.createElement(NavGroup, null, /*#__PURE__*/React.createElement(NavItem, null, /*#__PURE__*/React.createElement("a", {
|
|
55
|
-
role: "menuitem",
|
|
56
|
-
href: "".concat(settingsAppURL, "#/profile"),
|
|
57
|
-
target: "_self",
|
|
58
|
-
title: t('profile')
|
|
59
|
-
}, /*#__PURE__*/React.createElement(MenuIcon, {
|
|
60
|
-
className: "u-mr-half",
|
|
61
|
-
icon: PeopleIcon
|
|
62
|
-
}), t('profile'))), /*#__PURE__*/React.createElement(NavItem, null, /*#__PURE__*/React.createElement("a", {
|
|
63
|
-
role: "menuitem",
|
|
64
|
-
href: "".concat(settingsAppURL, "#/connectedDevices"),
|
|
65
|
-
target: "_self",
|
|
66
|
-
title: t('connectedDevices')
|
|
67
|
-
}, /*#__PURE__*/React.createElement(MenuIcon, {
|
|
68
|
-
icon: PhoneIcon
|
|
69
|
-
}), t('connectedDevices')))), isDrawer && onClaudy && !isMobileApp() && /*#__PURE__*/React.createElement(NavGroup, null, /*#__PURE__*/React.createElement(NavItem, null, /*#__PURE__*/React.createElement("button", {
|
|
70
|
-
type: "button",
|
|
71
|
-
role: "menuitem",
|
|
72
|
-
className: "coz-nav-settings-item-btn",
|
|
73
|
-
busy: isClaudyLoading,
|
|
74
|
-
onClick: onClaudy
|
|
75
|
-
}, /*#__PURE__*/React.createElement(MenuIcon, {
|
|
76
|
-
icon: CloudIcon
|
|
77
|
-
}), " ", t('claudy.title')))), !isDrawer && storageData && /*#__PURE__*/React.createElement(NavGroup, null, /*#__PURE__*/React.createElement(NavItem, null, /*#__PURE__*/React.createElement("a", {
|
|
78
|
-
role: "menuitem",
|
|
79
|
-
target: "_self",
|
|
80
|
-
title: t('storage'),
|
|
81
|
-
href: "".concat(settingsAppURL, "#/storage")
|
|
82
|
-
}, /*#__PURE__*/React.createElement(MenuIcon, {
|
|
83
|
-
icon: StorageIcon
|
|
84
|
-
}), " ", t('storage'), /*#__PURE__*/React.createElement(StorageData, {
|
|
85
|
-
data: storageData
|
|
86
|
-
})))), (!isDrawer || !isMobileApp()) && shoulDisplayViewOfferButton && /*#__PURE__*/React.createElement(NavGroup, null, /*#__PURE__*/React.createElement(NavItem, null, /*#__PURE__*/React.createElement(ButtonLink, {
|
|
87
|
-
subtle: true,
|
|
88
|
-
role: "menuitem",
|
|
89
|
-
className: "coz-nav-settings-item-btn",
|
|
90
|
-
icon: /*#__PURE__*/React.createElement(MenuIcon, {
|
|
91
|
-
icon: CloudHappyIcon
|
|
92
|
-
}),
|
|
93
|
-
title: viewOfferButtonText,
|
|
94
|
-
label: viewOfferButtonText,
|
|
95
|
-
href: managerUrlPremiumLink
|
|
96
|
-
}))), !isMobileApp() && /*#__PURE__*/React.createElement(NavGroup, null, /*#__PURE__*/React.createElement(NavItem, null, /*#__PURE__*/React.createElement("button", {
|
|
97
|
-
type: "button",
|
|
98
|
-
role: "menuitem",
|
|
99
|
-
className: "coz-nav-settings-item-btn",
|
|
100
|
-
onClick: toggleSupport
|
|
101
|
-
}, /*#__PURE__*/React.createElement(MenuIcon, {
|
|
102
|
-
icon: HelpIcon
|
|
103
|
-
}), " ", t('help')))), /*#__PURE__*/React.createElement(NavGroup, null, /*#__PURE__*/React.createElement(NavItem, null, /*#__PURE__*/React.createElement("button", {
|
|
104
|
-
type: "button",
|
|
105
|
-
role: "menuitem",
|
|
106
|
-
onClick: onLogOut,
|
|
107
|
-
title: t('logout')
|
|
108
|
-
}, /*#__PURE__*/React.createElement(MenuIcon, {
|
|
109
|
-
icon: LogoutIcon
|
|
110
|
-
}), " ", t('logout')))));
|
|
111
|
-
};
|
|
112
|
-
|
|
113
|
-
SettingsContent.defaultProps = {
|
|
114
|
-
shoulDisplayViewOfferButton: false
|
|
115
|
-
};
|
|
116
|
-
SettingsContent.propTypes = {
|
|
117
|
-
shoulDisplayViewOfferButton: PropTypes.bool,
|
|
118
|
-
t: PropTypes.func.isRequired,
|
|
119
|
-
onLogOut: PropTypes.func.isRequired,
|
|
120
|
-
settingsAppURL: PropTypes.string,
|
|
121
|
-
storageData: PropTypes.object,
|
|
122
|
-
onClaudy: PropTypes.oneOfType([PropTypes.bool, PropTypes.func]),
|
|
123
|
-
isDrawer: PropTypes.bool,
|
|
124
|
-
isClaudyLoading: PropTypes.bool,
|
|
125
|
-
toggleSupport: PropTypes.func.isRequired,
|
|
126
|
-
viewOfferButtonText: PropTypes.string
|
|
127
|
-
};
|
|
128
|
-
export default translate()(SettingsContent);
|
|
@@ -1,24 +0,0 @@
|
|
|
1
|
-
import React from 'react';
|
|
2
|
-
import { translate } from "cozy-ui/transpiled/react/I18n";
|
|
3
|
-
|
|
4
|
-
var StorageData = function StorageData(_ref) {
|
|
5
|
-
var t = _ref.t,
|
|
6
|
-
data = _ref.data;
|
|
7
|
-
var diskQuota = Number.isInteger(data.quota) ? (data.quota / (1000 * 1000 * 1000)).toFixed(2) : data.quota;
|
|
8
|
-
var diskUsage = Number.isInteger(data.usage) ? (data.usage / (1000 * 1000 * 1000)).toFixed(2) : data.usage;
|
|
9
|
-
return /*#__PURE__*/React.createElement("div", {
|
|
10
|
-
className: "coz-nav-storage"
|
|
11
|
-
}, /*#__PURE__*/React.createElement("p", {
|
|
12
|
-
className: "coz-nav-storage-text"
|
|
13
|
-
}, t('storage_phrase', {
|
|
14
|
-
diskUsage: diskUsage,
|
|
15
|
-
diskQuota: diskQuota
|
|
16
|
-
})), /*#__PURE__*/React.createElement("progress", {
|
|
17
|
-
className: "cozy-nav-storage-bar",
|
|
18
|
-
value: diskUsage,
|
|
19
|
-
max: diskQuota,
|
|
20
|
-
min: "0"
|
|
21
|
-
}));
|
|
22
|
-
};
|
|
23
|
-
|
|
24
|
-
export default translate()(StorageData);
|
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
import { compareClientVersion } from "../../lib/stack-client";
|
|
2
|
-
export var isFetchingQueries = function isFetchingQueries(requests) {
|
|
3
|
-
return requests.some(function (request) {
|
|
4
|
-
return request.fetchStatus === 'loading';
|
|
5
|
-
});
|
|
6
|
-
};
|
|
7
|
-
export var cozyClientCanCheckPremium = function cozyClientCanCheckPremium() {
|
|
8
|
-
return compareClientVersion('8.3.0');
|
|
9
|
-
};
|