cozy-ui 117.2.2 → 118.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.
@@ -0,0 +1,21 @@
1
+ import _extends from "@babel/runtime/helpers/extends";
2
+ // Automatically created, please run `scripts/generate-svgr-icon.sh assets/icons/illus/file-type-server.svg` to regenerate;
3
+ import React from 'react';
4
+
5
+ function SvgFileTypeServer(props) {
6
+ return /*#__PURE__*/React.createElement("svg", _extends({
7
+ viewBox: "0 0 32 32",
8
+ fill: "none"
9
+ }, props), /*#__PURE__*/React.createElement("path", {
10
+ d: "M2.799 16.501A4 4 0 015.923 15h20.155a4 4 0 013.123 1.501l2.142 2.677A3 3 0 0132 21.052V24H0v-2.948a3 3 0 01.657-1.874L2.8 16.501zm0-14A4 4 0 015.923 1h20.155A4 4 0 0129.2 2.501l2.142 2.677A3 3 0 0132 7.052V10H0V7.052a3 3 0 01.657-1.874L2.8 2.501z",
11
+ fill: "#197BFF"
12
+ }), /*#__PURE__*/React.createElement("path", {
13
+ d: "M0 21a2 2 0 012-2h28a2 2 0 012 2v8a2 2 0 01-2 2H2a2 2 0 01-2-2v-8zM0 7a2 2 0 012-2h28a2 2 0 012 2v8a2 2 0 01-2 2H2a2 2 0 01-2-2V7z",
14
+ fill: "#B2D3FF"
15
+ }), /*#__PURE__*/React.createElement("path", {
16
+ d: "M8 25a2 2 0 11-4 0 2 2 0 014 0zm0-14a2 2 0 11-4 0 2 2 0 014 0z",
17
+ fill: "#297EF2"
18
+ }));
19
+ }
20
+
21
+ export default SvgFileTypeServer;
@@ -1,2 +1,2 @@
1
- declare function _exports(): boolean | "";
2
- export = _exports;
1
+ declare function _default(): boolean | "";
2
+ export default _default;
@@ -1,3 +1,3 @@
1
- module.exports = function () {
1
+ export default (function () {
2
2
  return navigator && navigator.userAgent && navigator.userAgent.includes('Argos');
3
- };
3
+ });
@@ -1,46 +1,49 @@
1
- export const black: string;
2
- export const white: string;
3
- export const paleGrey: string;
4
- export const silver: string;
5
- export const coolGrey: string;
6
- export const slateGrey: string;
7
- export const charcoalGrey: string;
8
- export const overlay: string;
9
- export const primaryColor: string;
10
- export const primaryColorLight: string;
11
- export const primaryContrastTextColor: string;
12
- export const success: string;
13
- export const warning: string;
14
- export const error: string;
15
- export const info: string;
16
- export const errorBackground: string;
17
- export const primaryBackgroundLight: string;
18
- export const neutralBackground: string;
19
- export const zircon: string;
20
- export const frenchPass: string;
21
- export const dodgerBlue: string;
22
- export const scienceBlue: string;
23
- export const puertoRico: string;
24
- export const grannyApple: string;
25
- export const emerald: string;
26
- export const malachite: string;
27
- export const seafoamGreen: string;
28
- export const brightSun: string;
29
- export const texasRose: string;
30
- export const chablis: string;
31
- export const yourPink: string;
32
- export const fuchsia: string;
33
- export const pomegranate: string;
34
- export const monza: string;
35
- export const portage: string;
36
- export const azure: string;
37
- export const melon: string;
38
- export const blazeOrange: string;
39
- export const mango: string;
40
- export const pumpkinOrange: string;
41
- export const lavender: string;
42
- export const darkPeriwinkle: string;
43
- export const purpley: string;
44
- export const lightishPurple: string;
45
- export const barney: string;
46
- export const weirdGreen: string;
1
+ declare namespace _default {
2
+ const black: string;
3
+ const white: string;
4
+ const paleGrey: string;
5
+ const silver: string;
6
+ const coolGrey: string;
7
+ const slateGrey: string;
8
+ const charcoalGrey: string;
9
+ const overlay: string;
10
+ const primaryColor: string;
11
+ const primaryColorLight: string;
12
+ const primaryContrastTextColor: string;
13
+ const success: string;
14
+ const warning: string;
15
+ const error: string;
16
+ const info: string;
17
+ const errorBackground: string;
18
+ const primaryBackgroundLight: string;
19
+ const neutralBackground: string;
20
+ const zircon: string;
21
+ const frenchPass: string;
22
+ const dodgerBlue: string;
23
+ const scienceBlue: string;
24
+ const puertoRico: string;
25
+ const grannyApple: string;
26
+ const emerald: string;
27
+ const malachite: string;
28
+ const seafoamGreen: string;
29
+ const brightSun: string;
30
+ const texasRose: string;
31
+ const chablis: string;
32
+ const yourPink: string;
33
+ const fuchsia: string;
34
+ const pomegranate: string;
35
+ const monza: string;
36
+ const portage: string;
37
+ const azure: string;
38
+ const melon: string;
39
+ const blazeOrange: string;
40
+ const mango: string;
41
+ const pumpkinOrange: string;
42
+ const lavender: string;
43
+ const darkPeriwinkle: string;
44
+ const purpley: string;
45
+ const lightishPurple: string;
46
+ const barney: string;
47
+ const weirdGreen: string;
48
+ }
49
+ export default _default;
@@ -1,5 +1,5 @@
1
1
  // GENERATED AUTOMATICALLY FROM stylus/settings/palette.json
2
- module.exports = {
2
+ export default {
3
3
  black: 'var(--black)',
4
4
  white: 'var(--white)',
5
5
  paleGrey: 'var(--paleGrey)',
@@ -6,54 +6,48 @@ function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { va
6
6
 
7
7
  import format from 'date-fns/format';
8
8
  import formatDistanceToNow from 'date-fns/formatDistanceToNow';
9
+ import { enGB as enLocale, fr as frLocale, es as esLocale } from 'date-fns/locale';
9
10
  import { DEFAULT_LANG } from "cozy-ui/transpiled/react/providers/I18n";
10
- var locales = {};
11
- var lang = DEFAULT_LANG;
12
- /**
13
- * Ensure that the locale is in the correct format for date-fns (see 2.0.0 BC https://github.com/date-fns/date-fns/blob/main/CHANGELOG.md#200---2019-08-20)
14
- * @param {string} lang
15
- */
11
+ var currentLocale;
16
12
 
17
- var ensureLocaleFormat = function ensureLocaleFormat(lang) {
13
+ var getDateFnsLocale = function getDateFnsLocale(lang) {
18
14
  switch (lang) {
19
15
  case 'en':
20
- return 'en-US';
16
+ return enLocale;
21
17
 
22
- case 'zh_cn':
23
- return 'zh-CN';
18
+ case 'fr':
19
+ return frLocale;
24
20
 
25
- case 'zh_tw':
26
- return 'zh-TW';
21
+ case 'es':
22
+ return esLocale;
27
23
 
28
24
  default:
29
- return lang;
25
+ throw new Error('Locale not found');
30
26
  }
31
27
  };
32
28
 
33
29
  var getWarningMessage = function getWarningMessage(lang) {
34
- return "The \"".concat(lang, "\" locale isn't supported by date-fns. or has not been included in the build. Check if you have configured a ContextReplacementPlugin that is too restrictive.");
30
+ return "The \"".concat(lang, "\" locale isn't supported by date-fns or has not been included in the build. Check if you have configured a ContextReplacementPlugin that is too restrictive.");
35
31
  };
36
32
 
37
33
  export var provideDateFnsLocale = function provideDateFnsLocale(userLang) {
38
34
  var defaultLang = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : DEFAULT_LANG;
39
- lang = ensureLocaleFormat(userLang);
40
- var ensureDefaultLang = ensureLocaleFormat(defaultLang);
41
35
 
42
36
  try {
43
- locales[ensureDefaultLang] = require("date-fns/locale/".concat(ensureDefaultLang, "/index.js"));
44
- } catch (err) {
45
- console.warn(getWarningMessage(ensureDefaultLang));
37
+ var userLocale = getDateFnsLocale(userLang);
38
+ currentLocale = userLocale;
39
+ return userLocale;
40
+ } catch (e) {
41
+ console.warn(getWarningMessage(userLang));
46
42
  }
47
43
 
48
- if (lang && lang !== ensureDefaultLang) {
49
- try {
50
- locales[lang] = require("date-fns/locale/".concat(lang, "/index.js"));
51
- } catch (e) {
52
- console.warn(getWarningMessage(lang));
53
- }
44
+ try {
45
+ var defaultLocale = getDateFnsLocale(defaultLang);
46
+ currentLocale = defaultLocale;
47
+ return defaultLocale;
48
+ } catch (err) {
49
+ console.warn(getWarningMessage(defaultLang));
54
50
  }
55
-
56
- return locales[lang];
57
51
  };
58
52
  export var initFormat = function initFormat(userLang) {
59
53
  var defaultLang = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : DEFAULT_LANG;
@@ -73,6 +67,6 @@ export var initFormat = function initFormat(userLang) {
73
67
  };
74
68
  export var formatLocallyDistanceToNow = function formatLocallyDistanceToNow(date) {
75
69
  return formatDistanceToNow(date, {
76
- locale: locales[lang]
70
+ locale: currentLocale
77
71
  });
78
72
  };
@@ -1,173 +0,0 @@
1
- /* global __PIWIK_TRACKER_URL__ __PIWIK_SITEID__ __PIWIK_DIMENSION_ID_APP__ */
2
- /* global Piwik */
3
- import memoize from 'lodash/memoize'
4
-
5
- import { readCozyDataFromDOM } from './appDataset'
6
-
7
- // Think of these functions as a singleton class with only static methods.
8
- let trackerInstance = null
9
-
10
- /**
11
- * Returns whether tracking should be enabled
12
- *
13
- * @returns {boolean|unefined} True if tracking should be enabled
14
- */
15
- export const shouldEnableTracking = memoize(() =>
16
- readCozyDataFromDOM('tracking')
17
- )
18
-
19
- /**
20
- * @private
21
- *
22
- * Returns the instance of the piwik tracker, creating it on thee fly if required. All parameters are optionnal.
23
- * You should not use this method directly but rather `trackEvent`
24
- * @param {string} trackerUrl The URL of the piwik instance, without the php file name
25
- * @param {number} siteId The siteId to use for piwik
26
- * @param {boolean} automaticallyConfigure = true Pass false to skip the automatic configuration
27
- * @param {boolean} injectScript = false Whether or not the Piwik tracking script should be injected
28
- * @returns {object | null } An instance of `PiwikReactRouter` on success,
29
- * `null` if the creation fails (usually because of adblockers)
30
- * `null` if the user doesn't accept the tracking
31
- */
32
- export const getTracker = (
33
- trackerUrl,
34
- siteId,
35
- automaticallyConfigure = true,
36
- injectScript = false
37
- ) => {
38
- if (!shouldEnableTracking()) return null
39
- if (trackerInstance !== null) return trackerInstance
40
-
41
- try {
42
- // If `injectScript` is falsy, we rely on having the Piwik tracking script already on the page, otherwise the tracking will fail.
43
- // the next line is just there to throw in case the script is missing
44
- if (injectScript === false) Piwik.getTracker()
45
-
46
- var PiwikReactRouter = require('piwik-react-router')
47
-
48
- trackerInstance = PiwikReactRouter({
49
- url: trackerUrl || __PIWIK_TRACKER_URL__,
50
- siteId: siteId || __PIWIK_SITEID__, // site id is required here
51
- injectScript: injectScript
52
- })
53
-
54
- // apply the default configuration
55
- if (automaticallyConfigure) configureTracker()
56
-
57
- return trackerInstance
58
- } catch (err) {
59
- // this usually happens when there's an ad blocker
60
- console.warn(err)
61
- trackerInstance = null
62
- return null
63
- }
64
- }
65
-
66
- export const setTracker = tracker => (trackerInstance = tracker)
67
-
68
- /**
69
- * Configures the base options for the tracker which will persist during the session.
70
- *
71
- * @param {object} options A map of options that can be configured.
72
- * @param {string} options.userId
73
- * @param {number} options.appDimensionId
74
- * @param {string} options.app
75
- * @param {number} options.heartbeat
76
- */
77
- export const configureTracker = (options = {}) => {
78
- // early out in case the tracker is not available
79
- if (trackerInstance === null) {
80
- // maybe we should throw an error here?
81
- return
82
- }
83
-
84
- let appName
85
-
86
- const root = document.querySelector('[role=application]')
87
-
88
- if (root && root.dataset) {
89
- appName = readCozyDataFromDOM('appName') || readCozyDataFromDOM('app').name
90
- }
91
- // merge default options with what has been provided
92
- const { app, appDimensionId } = Object.assign(
93
- {
94
- appDimensionId: __PIWIK_DIMENSION_ID_APP__,
95
- app: appName
96
- },
97
- options
98
- )
99
-
100
- trackerInstance.push(['setCustomDimension', appDimensionId, app])
101
- trackerInstance.push([
102
- 'setCustomUrl',
103
- window.location.pathname.substr(1) + location.search
104
- ])
105
- }
106
-
107
- /**
108
- * Returns a redux middleware which tracks events if the action
109
- * has a `trackEvent` field containing at least `category` and `action`
110
- * fields.
111
- *
112
- * @returns {function}
113
- */
114
- export const createTrackerMiddleware = () => {
115
- return () => next => action => {
116
- if (
117
- trackerInstance &&
118
- action.trackEvent &&
119
- action.trackEvent.category &&
120
- action.trackEvent.action
121
- ) {
122
- trackerInstance.push([
123
- 'trackEvent',
124
- action.trackEvent.category,
125
- action.trackEvent.action,
126
- action.trackEvent.name,
127
- action.trackEvent.value
128
- ])
129
- }
130
-
131
- return next(action)
132
- }
133
- }
134
-
135
- /**
136
- * Resets the tracker; disconnecting it from history and the middleware, if
137
- * it was attached.
138
- *
139
- * *Please be aware*: if the tracker instance had been used outside of this
140
- * library (in another middleware for example), further calls to the tracking
141
- * server may still work.
142
- */
143
- export const resetTracker = () => {
144
- if (trackerInstance) {
145
- // stop tracking the history, if we were doing that
146
- trackerInstance.disconnectFromHistory()
147
- // we can't remove middlewares on the fly, but resetting the instance object will actually achieve that
148
- trackerInstance = null
149
- }
150
- }
151
-
152
- /**
153
- * Sends an event to matomo
154
- *
155
- * @param {array} event Event to track ['Drive', 'action', 'label']
156
- * @param {object} trackerForTest Mocked Tracker for test purpose
157
- */
158
- export const trackEvent = (event, trackerForTest) => {
159
- const tracker = trackerForTest || getTracker()
160
- if (tracker) {
161
- let trackEventArray = []
162
- if (event && event[0]) {
163
- // Like that, we can do trackEvent(['Drive', 'option1']) without thinking of adding this `trackEvent` attr
164
- if (event[0] !== 'trackEvent') {
165
- trackEventArray = event.unshift('trackEvent')
166
- }
167
-
168
- trackEventArray = event
169
- }
170
-
171
- tracker.push(trackEventArray)
172
- }
173
- }
@@ -1,66 +0,0 @@
1
- import { resetCache } from './appDataset'
2
- import * as trackerFile from './tracker'
3
-
4
- window.__PIWIK_DIMENSION_ID_APP__ = 1234
5
-
6
- jest.mock('./tracker', () => ({
7
- ...jest.requireActual('./tracker'),
8
- getTracker: jest.fn()
9
- }))
10
-
11
- describe('tracker / piwik action', () => {
12
- beforeEach(() => {
13
- trackerFile.getTracker.mockImplementation(() => ({ push: jest.fn() }))
14
- })
15
-
16
- afterEach(() => {
17
- jest.resetAllMocks()
18
- jest.restoreAllMocks()
19
- })
20
-
21
- it('should track event', () => {
22
- const tracker = trackerFile.getTracker()
23
- trackerFile.trackEvent(['trackEvent', 'toto'], tracker)
24
- expect(tracker.push).toHaveBeenCalledWith(['trackEvent', 'toto'])
25
- })
26
- it('should add or not the trackEvent item in the array', () => {
27
- const tracker = trackerFile.getTracker()
28
- trackerFile.trackEvent(['toto'], tracker)
29
- expect(tracker.push).toHaveBeenCalledWith(['trackEvent', 'toto'])
30
- trackerFile.trackEvent(['trackEvent', 'foo'], tracker)
31
- expect(tracker.push).toHaveBeenCalledWith(['trackEvent', 'foo'])
32
- })
33
-
34
- it('should memoize shouldEnableTracking', () => {
35
- const querySelectorSpy = jest.fn()
36
- jest
37
- .spyOn(global.document, 'querySelector')
38
- .mockImplementation(querySelectorSpy)
39
- trackerFile.shouldEnableTracking()
40
- trackerFile.shouldEnableTracking()
41
- expect(querySelectorSpy).toHaveBeenCalledTimes(1)
42
- })
43
- })
44
-
45
- describe('configureTracker', () => {
46
- beforeEach(() => {
47
- resetCache()
48
- trackerFile.getTracker.mockImplementation(() => ({ push: jest.fn() }))
49
- })
50
-
51
- it('should read the correct values from DOM', () => {
52
- const tracker = trackerFile.getTracker()
53
- trackerFile.setTracker(tracker)
54
- const data = { cozyDomain: 'cozy.tools:8080', appName: 'banks' }
55
- document.body.innerHTML = `<div role="application" data-cozy='${JSON.stringify(
56
- data
57
- )}' />`
58
-
59
- trackerFile.configureTracker({ app: 'banks2' })
60
- expect(tracker.push).toHaveBeenCalledWith([
61
- 'setCustomDimension',
62
- 1234,
63
- 'banks2'
64
- ])
65
- })
66
- })
@@ -1,162 +0,0 @@
1
- /* global __PIWIK_TRACKER_URL__ __PIWIK_SITEID__ __PIWIK_DIMENSION_ID_APP__ */
2
-
3
- /* global Piwik */
4
- import memoize from 'lodash/memoize';
5
- import { readCozyDataFromDOM } from "cozy-ui/transpiled/react/helpers/appDataset"; // Think of these functions as a singleton class with only static methods.
6
-
7
- var trackerInstance = null;
8
- /**
9
- * Returns whether tracking should be enabled
10
- *
11
- * @returns {boolean|unefined} True if tracking should be enabled
12
- */
13
-
14
- export var shouldEnableTracking = memoize(function () {
15
- return readCozyDataFromDOM('tracking');
16
- });
17
- /**
18
- * @private
19
- *
20
- * Returns the instance of the piwik tracker, creating it on thee fly if required. All parameters are optionnal.
21
- * You should not use this method directly but rather `trackEvent`
22
- * @param {string} trackerUrl The URL of the piwik instance, without the php file name
23
- * @param {number} siteId The siteId to use for piwik
24
- * @param {boolean} automaticallyConfigure = true Pass false to skip the automatic configuration
25
- * @param {boolean} injectScript = false Whether or not the Piwik tracking script should be injected
26
- * @returns {object | null } An instance of `PiwikReactRouter` on success,
27
- * `null` if the creation fails (usually because of adblockers)
28
- * `null` if the user doesn't accept the tracking
29
- */
30
-
31
- export var getTracker = function getTracker(trackerUrl, siteId) {
32
- var automaticallyConfigure = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : true;
33
- var injectScript = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : false;
34
- if (!shouldEnableTracking()) return null;
35
- if (trackerInstance !== null) return trackerInstance;
36
-
37
- try {
38
- // If `injectScript` is falsy, we rely on having the Piwik tracking script already on the page, otherwise the tracking will fail.
39
- // the next line is just there to throw in case the script is missing
40
- if (injectScript === false) Piwik.getTracker();
41
-
42
- var PiwikReactRouter = require('piwik-react-router');
43
-
44
- trackerInstance = PiwikReactRouter({
45
- url: trackerUrl || __PIWIK_TRACKER_URL__,
46
- siteId: siteId || __PIWIK_SITEID__,
47
- // site id is required here
48
- injectScript: injectScript
49
- }); // apply the default configuration
50
-
51
- if (automaticallyConfigure) configureTracker();
52
- return trackerInstance;
53
- } catch (err) {
54
- // this usually happens when there's an ad blocker
55
- console.warn(err);
56
- trackerInstance = null;
57
- return null;
58
- }
59
- };
60
- export var setTracker = function setTracker(tracker) {
61
- return trackerInstance = tracker;
62
- };
63
- /**
64
- * Configures the base options for the tracker which will persist during the session.
65
- *
66
- * @param {object} options A map of options that can be configured.
67
- * @param {string} options.userId
68
- * @param {number} options.appDimensionId
69
- * @param {string} options.app
70
- * @param {number} options.heartbeat
71
- */
72
-
73
- export var configureTracker = function configureTracker() {
74
- var options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
75
-
76
- // early out in case the tracker is not available
77
- if (trackerInstance === null) {
78
- // maybe we should throw an error here?
79
- return;
80
- }
81
-
82
- var appName;
83
- var root = document.querySelector('[role=application]');
84
-
85
- if (root && root.dataset) {
86
- appName = readCozyDataFromDOM('appName') || readCozyDataFromDOM('app').name;
87
- } // merge default options with what has been provided
88
-
89
-
90
- var _Object$assign = Object.assign({
91
- appDimensionId: __PIWIK_DIMENSION_ID_APP__,
92
- app: appName
93
- }, options),
94
- app = _Object$assign.app,
95
- appDimensionId = _Object$assign.appDimensionId;
96
-
97
- trackerInstance.push(['setCustomDimension', appDimensionId, app]);
98
- trackerInstance.push(['setCustomUrl', window.location.pathname.substr(1) + location.search]);
99
- };
100
- /**
101
- * Returns a redux middleware which tracks events if the action
102
- * has a `trackEvent` field containing at least `category` and `action`
103
- * fields.
104
- *
105
- * @returns {function}
106
- */
107
-
108
- export var createTrackerMiddleware = function createTrackerMiddleware() {
109
- return function () {
110
- return function (next) {
111
- return function (action) {
112
- if (trackerInstance && action.trackEvent && action.trackEvent.category && action.trackEvent.action) {
113
- trackerInstance.push(['trackEvent', action.trackEvent.category, action.trackEvent.action, action.trackEvent.name, action.trackEvent.value]);
114
- }
115
-
116
- return next(action);
117
- };
118
- };
119
- };
120
- };
121
- /**
122
- * Resets the tracker; disconnecting it from history and the middleware, if
123
- * it was attached.
124
- *
125
- * *Please be aware*: if the tracker instance had been used outside of this
126
- * library (in another middleware for example), further calls to the tracking
127
- * server may still work.
128
- */
129
-
130
- export var resetTracker = function resetTracker() {
131
- if (trackerInstance) {
132
- // stop tracking the history, if we were doing that
133
- trackerInstance.disconnectFromHistory(); // we can't remove middlewares on the fly, but resetting the instance object will actually achieve that
134
-
135
- trackerInstance = null;
136
- }
137
- };
138
- /**
139
- * Sends an event to matomo
140
- *
141
- * @param {array} event Event to track ['Drive', 'action', 'label']
142
- * @param {object} trackerForTest Mocked Tracker for test purpose
143
- */
144
-
145
- export var trackEvent = function trackEvent(event, trackerForTest) {
146
- var tracker = trackerForTest || getTracker();
147
-
148
- if (tracker) {
149
- var trackEventArray = [];
150
-
151
- if (event && event[0]) {
152
- // Like that, we can do trackEvent(['Drive', 'option1']) without thinking of adding this `trackEvent` attr
153
- if (event[0] !== 'trackEvent') {
154
- trackEventArray = event.unshift('trackEvent');
155
- }
156
-
157
- trackEventArray = event;
158
- }
159
-
160
- tracker.push(trackEventArray);
161
- }
162
- };