@spothero/ui 15.0.0-beta.2 → 15.0.0-beta.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.
Files changed (60) hide show
  1. package/README.md +2 -2
  2. package/backlog/Chart/Chart.js +2 -2
  3. package/backlog/DateTime/DatePicker.js +4 -4
  4. package/backlog/DateTime/DatePickerCalendar.js +8 -8
  5. package/backlog/DateTime/DatePickerCalendarWithRange.js +6 -6
  6. package/backlog/DateTime/DateTimeRangePicker.js +6 -4
  7. package/backlog/DateTime/TimePicker.js +3 -3
  8. package/backlog/ErrorBoundary/ErrorBoundary.js +7 -9
  9. package/backlog/Flyout/Flyout.js +5 -5
  10. package/backlog/Form/Form.js +5 -3
  11. package/backlog/GooglePlacesSearchInput/GooglePlacesSearchInput.js +1 -4
  12. package/backlog/Notification/Notification.js +4 -4
  13. package/backlog/Portal/Portal.js +3 -3
  14. package/backlog/RenderInBody/RenderInBody.js +2 -2
  15. package/backlog/Select/Select.js +3 -3
  16. package/backlog/SelectControlled/SelectControlled.js +3 -3
  17. package/backlog/Tooltip/Tooltip.js +6 -6
  18. package/backlog/utils/animation.js +84 -0
  19. package/backlog/utils/date.js +233 -0
  20. package/backlog/utils/dom.js +441 -0
  21. package/backlog/utils/environment.js +422 -0
  22. package/backlog/utils/number.js +43 -0
  23. package/backlog/utils/time.js +282 -0
  24. package/backlog/v1/components/Image/Image.js +2 -2
  25. package/backlog/v1/components/Modal/Modal.js +12 -12
  26. package/backlog/v1/components/Modal/ModalContent.js +3 -3
  27. package/package.json +1 -2
  28. package/styles/Chart/Chart.jsx +1 -1
  29. package/styles/DateTime/DatePicker.jsx +1 -1
  30. package/styles/DateTime/DatePickerCalendar.jsx +1 -1
  31. package/styles/DateTime/DatePickerCalendarWithRange.jsx +1 -1
  32. package/styles/DateTime/DateTimeRangePicker.jsx +2 -1
  33. package/styles/DateTime/TimePicker.jsx +1 -1
  34. package/styles/ErrorBoundary/ErrorBoundary.jsx +7 -6
  35. package/styles/Flyout/Flyout.jsx +1 -1
  36. package/styles/Form/Form.jsx +2 -1
  37. package/styles/GooglePlacesSearchInput/GooglePlacesSearchInput.jsx +2 -2
  38. package/styles/Notification/Notification.jsx +1 -1
  39. package/styles/Portal/Portal.jsx +1 -1
  40. package/styles/RenderInBody/RenderInBody.jsx +1 -1
  41. package/styles/Select/Select.jsx +1 -1
  42. package/styles/SelectControlled/SelectControlled.jsx +1 -1
  43. package/styles/Tooltip/Tooltip.jsx +1 -1
  44. package/styles/utils/animation.js +75 -0
  45. package/styles/utils/date.js +226 -0
  46. package/styles/utils/dom.js +428 -0
  47. package/styles/utils/environment.js +425 -0
  48. package/styles/utils/number.js +33 -0
  49. package/styles/utils/time.js +268 -0
  50. package/styles/v1/components/Image/Image.jsx +1 -1
  51. package/styles/v1/components/Modal/Modal.jsx +1 -1
  52. package/styles/v1/components/Modal/ModalContent.jsx +1 -1
  53. package/styles/v1/components/Modal/stories/Content.stories.js +1 -1
  54. package/styles/v2/components/Image/Image.jsx +1 -1
  55. package/v1/index.js +1 -1
  56. package/v1/index.js.LICENSE.txt +0 -29
  57. package/v1/index.js.map +1 -1
  58. package/v2/index.js +1 -1
  59. package/v2/index.js.LICENSE.txt +0 -29
  60. package/v2/index.js.map +1 -1
@@ -0,0 +1,425 @@
1
+ // Most of the methods are pulled from https://is.js.org/. That library has many others that we'll never use so they are added here and made to work with SSR.
2
+ import {window as ssrWindow} from 'ssr-window';
3
+
4
+ // const appVersion = (
5
+ // (ssrWindow.navigator && ssrWindow.navigator.appVersion) ||
6
+ // ''
7
+ // ).toLowerCase();
8
+ // const userAgent = (
9
+ // (ssrWindow.navigator && ssrWindow.navigator.userAgent) ||
10
+ // ''
11
+ // ).toLowerCase();
12
+ // const vendor = (
13
+ // (ssrWindow.navigator && ssrWindow.navigator.vendor) ||
14
+ // ''
15
+ // ).toLowerCase();
16
+ // const comparator = {
17
+ // '<': (a, b) => {
18
+ // return a < b;
19
+ // },
20
+ // '<=': (a, b) => {
21
+ // return a <= b;
22
+ // },
23
+ // '>': (a, b) => {
24
+ // return a > b;
25
+ // },
26
+ // '>=': (a, b) => {
27
+ // return a >= b;
28
+ // },
29
+ // };
30
+ // const compareVersion = (version, range) => {
31
+ // const string = String(range);
32
+ // const n = Number(string.match(/\d+/) || NaN);
33
+ // const op = string.match(/^[<>]=?|/)[0];
34
+ //
35
+ // return comparator[op]
36
+ // ? comparator[op](version, n)
37
+ // : version === n || n !== n; // eslint-disable-line no-self-compare
38
+ // };
39
+
40
+ /**
41
+ * Utilities for working with the execution environment.
42
+ * @module EnvironmentUtils
43
+ */
44
+ const EnvironmentUtils = {
45
+ // /**
46
+ // * Determines whether the code is being executed in the browser.
47
+ // * @static
48
+ // * @function isBrowser
49
+ // * @example
50
+ // * EnvironmentUtils.isBrowser();
51
+ // * @returns {Boolean} - Whether the environment is the browser.
52
+ // */
53
+ // isBrowser() {
54
+ // return typeof window !== 'undefined';
55
+ // },
56
+ //
57
+ // /**
58
+ // * Determines whether the code is being executed in Google Chrome.
59
+ // * @static
60
+ // * @function isChrome
61
+ // * @param {Number|String} [range] - The version range to test against.
62
+ // * @param {String} [ua=navigator.userAgent] - The user agent to test against.
63
+ // * @example
64
+ // * EnvironmentUtils.isChrome();
65
+ // * @returns {Boolean} - Whether the environment is Google Chrome.
66
+ // */
67
+ // isChrome(range, ua = userAgent) {
68
+ // const match = /google inc/.test(vendor)
69
+ // ? ua.match(/(?:chrome|crios)\/(\d+)/)
70
+ // : null;
71
+ //
72
+ // return (
73
+ // match !== null &&
74
+ // !this.isOpera(range, ua) &&
75
+ // compareVersion(match[1], range)
76
+ // );
77
+ // },
78
+ //
79
+ // /**
80
+ // * Determines whether the code is being executed in Mozilla Firefox.
81
+ // * @static
82
+ // * @function isFirefox
83
+ // * @param {Number|String} [range] - The version range to test against.
84
+ // * @param {String} [ua=navigator.userAgent] - The user agent to test against.
85
+ // * @example
86
+ // * EnvironmentUtils.isFirefox();
87
+ // * @returns {Boolean} - Whether the environment is Mozilla Firefox.
88
+ // */
89
+ // isFirefox(range, ua = userAgent) {
90
+ // const match = ua.match(/(?:firefox|fxios)\/(\d+)/);
91
+ //
92
+ // return match !== null && compareVersion(match[1], range);
93
+ // },
94
+ //
95
+ // /**
96
+ // * Determines whether the code is being executed in Apple Safari.
97
+ // * @static
98
+ // * @function isSafari
99
+ // * @param {Number|String} [range] - The version range to test against.
100
+ // * @param {String} [ua=navigator.userAgent] - The user agent to test against.
101
+ // * @example
102
+ // * EnvironmentUtils.isSafari();
103
+ // * @returns {Boolean} - Whether the environment is Apple Safari.
104
+ // */
105
+ // isSafari(range, ua = userAgent) {
106
+ // const match = ua.match(/version\/(\d+).+?safari/);
107
+ //
108
+ // return match !== null && compareVersion(match[1], range);
109
+ // },
110
+ //
111
+ // /**
112
+ // * Determines whether the code is being executed in Microsoft Edge.
113
+ // * @static
114
+ // * @function isEdge
115
+ // * @param {Number|String} [range] - The version range to test against.
116
+ // * @param {String} [ua=navigator.userAgent] - The user agent to test against.
117
+ // * @example
118
+ // * EnvironmentUtils.isEdge();
119
+ // * @returns {Boolean} - Whether the environment is Microsoft Edge.
120
+ // */
121
+ // isEdge(range, ua = userAgent) {
122
+ // const match = ua.match(/edge\/(\d+)/);
123
+ //
124
+ // return match !== null && compareVersion(match[1], range);
125
+ // },
126
+ //
127
+ // /**
128
+ // * Determines whether the code is being executed in Microsoft Internet Explorer.
129
+ // * @static
130
+ // * @function isIE
131
+ // * @param {Number|String} [range] - The version range to test against.
132
+ // * @param {String} [ua=navigator.userAgent] - The user agent to test against.
133
+ // * @example
134
+ // * EnvironmentUtils.isIE();
135
+ // * @returns {Boolean} - Whether the environment is Microsoft Internet Explorer.
136
+ // */
137
+ // isIE(range, ua = userAgent) {
138
+ // const match = ua.match(/(?:msie |trident.+?; rv:)(\d+)/);
139
+ //
140
+ // return match !== null && compareVersion(match[1], range);
141
+ // },
142
+ //
143
+ // /**
144
+ // * Determines whether the code is being executed in Opera.
145
+ // * @static
146
+ // * @function isOpera
147
+ // * @param {Number|String} [range] - The version range to test against.
148
+ // * @param {String} [ua=navigator.userAgent] - The user agent to test against.
149
+ // * @example
150
+ // * EnvironmentUtils.isOpera();
151
+ // * @returns {Boolean} - Whether the environment is Opera.
152
+ // */
153
+ // isOpera(range, ua = userAgent) {
154
+ // const match = ua.match(/(?:^opera.+?version|opr)\/(\d+)/);
155
+ //
156
+ // return match !== null && compareVersion(match[1], range);
157
+ // },
158
+ //
159
+ // /**
160
+ // * Determines whether the code is being executed in iOS.
161
+ // * @static
162
+ // * @function isiOS
163
+ // * @param {String} [ua=navigator.userAgent] - The user agent to test against.
164
+ // * @example
165
+ // * EnvironmentUtils.isiOS();
166
+ // * @returns {Boolean} - Whether the environment is iOS.
167
+ // */
168
+ // isiOS(ua = userAgent) {
169
+ // return (
170
+ // this.isiPhone(null, ua) ||
171
+ // this.isiPad(null, ua) ||
172
+ // this.isiPod(null, ua)
173
+ // );
174
+ // },
175
+ //
176
+ // /**
177
+ // * Determines whether the code is being executed on an iPhone.
178
+ // * @static
179
+ // * @function isiPhone
180
+ // * @param {Number|String} [range] - The version range to test against.
181
+ // * @param {String} [ua=navigator.userAgent] - The user agent to test against.
182
+ // * @example
183
+ // * EnvironmentUtils.isiPhone();
184
+ // * EnvironmentUtils.isiPhone(9);
185
+ // * EnvironmentUtils.isiPhone('>=7');
186
+ // * EnvironmentUtils.isiPhone('<8');
187
+ // * @returns {Boolean} - Whether the environment is iPhone.
188
+ // */
189
+ // isiPhone(range, ua = userAgent) {
190
+ // // avoid false positive for Facebook in-app browser on ipad;
191
+ // // original iphone doesn't have the OS portion of the UA
192
+ // const match = this.isiPad(null, ua)
193
+ // ? null
194
+ // : ua.match(/iphone(?:.+?os (\d+))?/i);
195
+ //
196
+ // return match !== null && compareVersion(match[1] || 1, range);
197
+ // },
198
+ //
199
+ // /**
200
+ // * Determines whether the code is being executed on an iPad.
201
+ // * @static
202
+ // * @function isiPad
203
+ // * @param {Number|String} [range] - The version range to test against.
204
+ // * @param {String} [ua=navigator.userAgent] - The user agent to test against.
205
+ // * @example
206
+ // * EnvironmentUtils.isiPad();
207
+ // * EnvironmentUtils.isiPad(9);
208
+ // * EnvironmentUtils.isiPad('>=7');
209
+ // * EnvironmentUtils.isiPad('<8');
210
+ // * @returns {Boolean} - Whether the environment is iPad.
211
+ // */
212
+ // isiPad(range, ua = userAgent) {
213
+ // const match = ua.match(/ipad.+?os (\d+)/i);
214
+ //
215
+ // return match !== null && compareVersion(match[1], range);
216
+ // },
217
+ //
218
+ // /**
219
+ // * Determines whether the code is being executed on an iPod.
220
+ // * @static
221
+ // * @function isiPod
222
+ // * @param {Number|String} [range] - The version range to test against.
223
+ // * @param {String} [ua=navigator.userAgent] - The user agent to test against.
224
+ // * @example
225
+ // * EnvironmentUtils.isiPod();
226
+ // * EnvironmentUtils.isiPod(9);
227
+ // * EnvironmentUtils.isiPod('>=7');
228
+ // * EnvironmentUtils.isiPod('<8');
229
+ // * @returns {Boolean} - Whether the environment is iPod.
230
+ // */
231
+ // isiPod(range, ua = userAgent) {
232
+ // const match = ua.match(/ipod.+?os (\d+)/i);
233
+ //
234
+ // return match !== null && compareVersion(match[1], range);
235
+ // },
236
+ //
237
+ // /**
238
+ // * Determines whether the code is being executed in Android.
239
+ // * @static
240
+ // * @function isAndroid
241
+ // * @param {String} [ua=navigator.userAgent] - The user agent to test against.
242
+ // * @example
243
+ // * EnvironmentUtils.isAndroid();
244
+ // * @returns {Boolean} - Whether the environment is Android.
245
+ // */
246
+ // isAndroid(ua = userAgent) {
247
+ // return /android/i.test(ua);
248
+ // },
249
+ //
250
+ // /**
251
+ // * Determines whether the code is being executed on an Android phone.
252
+ // * @static
253
+ // * @function isAndroidPhone
254
+ // * @param {String} [ua=navigator.userAgent] - The user agent to test against.
255
+ // * @example
256
+ // * EnvironmentUtils.isAndroidPhone();
257
+ // * @returns {Boolean} - Whether the environment is Android phone.
258
+ // */
259
+ // isAndroidPhone(ua = userAgent) {
260
+ // return /android/i.test(ua) && /mobile/i.test(ua);
261
+ // },
262
+ //
263
+ // /**
264
+ // * Determines whether the code is being executed on an Android tablet.
265
+ // * @static
266
+ // * @function isAndroidTablet
267
+ // * @param {String} [ua=navigator.userAgent] - The user agent to test against.
268
+ // * @example
269
+ // * EnvironmentUtils.isAndroidTablet();
270
+ // * @returns {Boolean} - Whether the environment is Android tablet.
271
+ // */
272
+ // isAndroidTablet(ua = userAgent) {
273
+ // return /android/i.test(ua) && !/mobile/i.test(ua);
274
+ // },
275
+ //
276
+ // /**
277
+ // * Determines whether the code is being executed on a Blackberry.
278
+ // * @static
279
+ // * @function isBlackberry
280
+ // * @param {String} [ua=navigator.userAgent] - The user agent to test against.
281
+ // * @example
282
+ // * EnvironmentUtils.isBlackberry();
283
+ // * @returns {Boolean} - Whether the environment is Blackberry.
284
+ // */
285
+ // isBlackberry(ua = userAgent) {
286
+ // return /blackberry/i.test(ua) || /bb10/i.test(ua);
287
+ // },
288
+ //
289
+ // /**
290
+ // * Determines whether the code is being executed on a Windows phone.
291
+ // * @static
292
+ // * @function isWindowsPhone
293
+ // * @param {String} [ua=navigator.userAgent] - The user agent to test against.
294
+ // * @example
295
+ // * EnvironmentUtils.isWindowsPhone();
296
+ // * @returns {Boolean} - Whether the environment is Windows phone.
297
+ // */
298
+ // isWindowsPhone(ua = userAgent) {
299
+ // return this.isWindows() && /phone/i.test(ua);
300
+ // },
301
+ //
302
+ // /**
303
+ // * Determines whether the code is being executed on a Windows tablet.
304
+ // * @static
305
+ // * @function isWindowsTablet
306
+ // * @param {String} [ua=navigator.userAgent] - The user agent to test against.
307
+ // * @example
308
+ // * EnvironmentUtils.isWindowsTablet();
309
+ // * @returns {Boolean} - Whether the environment is Windows tablet.
310
+ // */
311
+ // isWindowsTablet(ua = userAgent) {
312
+ // return (
313
+ // this.isWindows() && !this.isWindowsPhone(ua) && /touch/i.test(ua)
314
+ // );
315
+ // },
316
+ //
317
+ // /**
318
+ // * Determines whether the code is being executed on Windows.
319
+ // * @static
320
+ // * @function isWindows
321
+ // * @param {String} [ua=navigator.userAgent] - The user agent to test against.
322
+ // * @example
323
+ // * EnvironmentUtils.isWindows();
324
+ // * @returns {Boolean} - Whether the environment is Windows.
325
+ // */
326
+ // isWindows() {
327
+ // return /win/i.test(appVersion);
328
+ // },
329
+ //
330
+ // /**
331
+ // * Determines whether the code is being executed on a tablet.
332
+ // * @static
333
+ // * @function isTablet
334
+ // * @param {String} [ua=navigator.userAgent] - The user agent to test against.
335
+ // * @example
336
+ // * EnvironmentUtils.isTablet();
337
+ // * @returns {Boolean} - Whether the environment is a tablet.
338
+ // */
339
+ // isTablet(ua = userAgent) {
340
+ // return (
341
+ // this.isiPad(null, ua) ||
342
+ // this.isAndroidTablet(ua) ||
343
+ // this.isWindowsTablet(ua)
344
+ // );
345
+ // },
346
+ //
347
+ // /**
348
+ // * Determines whether the code is being executed on a mobile device.
349
+ // * @static
350
+ // * @function isMobileDevice
351
+ // * @param {String} [ua=navigator.userAgent] - The user agent to test against.
352
+ // * @example
353
+ // * EnvironmentUtils.isMobileDevice();
354
+ // * @returns {Boolean} - Whether the environment is a mobile device.
355
+ // */
356
+ // isMobileDevice(ua = userAgent) {
357
+ // return (
358
+ // this.isiPhone(null, ua) ||
359
+ // this.isiPod(null, ua) ||
360
+ // this.isAndroidPhone(ua) ||
361
+ // this.isBlackberry(ua) ||
362
+ // this.isWindowsPhone(ua)
363
+ // );
364
+ // },
365
+ //
366
+ // /**
367
+ // * Determines whether the code is being executed on a touch device.
368
+ // * @static
369
+ // * @function isTouchDevice
370
+ // * @example
371
+ // * EnvironmentUtils.isTouchDevice();
372
+ // * @returns {Boolean} - Whether the environment is a touch device.
373
+ // */
374
+ // isTouchDevice() {
375
+ // return (
376
+ // Boolean(document) &&
377
+ // ('ontouchstart' in document.documentElement ||
378
+ // ('DocumentTouch' in document.documentElement &&
379
+ // document instanceof window.DocumentTouch))
380
+ // );
381
+ // },
382
+
383
+ /**
384
+ * Determines whether the display has a high density.
385
+ * @static
386
+ * @function isHighDensityDisplay
387
+ * @example
388
+ * EnvironmentUtils.isHighDensityDisplay();
389
+ * @returns {Boolean} - Whether the display is high density.
390
+ */
391
+ isHighDensityDisplay() {
392
+ return (
393
+ (ssrWindow.matchMedia &&
394
+ (ssrWindow.matchMedia(
395
+ 'only screen and (min-resolution: 124dpi), only screen and (min-resolution: 1.3dppx), only screen and (min-resolution: 48.8dpcm)'
396
+ ).matches ||
397
+ ssrWindow.matchMedia(
398
+ 'only screen and (-webkit-min-device-pixel-ratio: 1.3), only screen and (-o-min-device-pixel-ratio: 2.6/2), only screen and (min--moz-device-pixel-ratio: 1.3), only screen and (min-device-pixel-ratio: 1.3)'
399
+ ).matches)) ||
400
+ (ssrWindow.devicePixelRatio && ssrWindow.devicePixelRatio > 1.3)
401
+ );
402
+ },
403
+
404
+ // /**
405
+ // * Returns a string based on browser util booleans, consumed by Segment and Optimizely
406
+ // * @static
407
+ // * @function getBrowserCategory
408
+ // * @returns {String} - The browser string
409
+ // */
410
+ // getBrowserCategory() {
411
+ // if (this.isChrome()) {
412
+ // return 'Chrome';
413
+ // } else if (this.isFirefox()) {
414
+ // return 'Firefox';
415
+ // } else if (this.isSafari()) {
416
+ // return 'Safari';
417
+ // } else if (this.isEdge() || this.isIE()) {
418
+ // return 'IE/Edge';
419
+ // }
420
+ //
421
+ // return 'Other';
422
+ // },
423
+ };
424
+
425
+ export default EnvironmentUtils;
@@ -0,0 +1,33 @@
1
+ import isNumber from 'lodash/isNumber';
2
+ import isUndefined from 'lodash/isUndefined';
3
+
4
+ /**
5
+ * Utilities for working with numbers.
6
+ * @module NumberUtils
7
+ */
8
+ const NumberUtils = {
9
+ /**
10
+ * Rounds a given number down to the nearest specified number.
11
+ * @static
12
+ * @function roundDownToNearestStep
13
+ * @param {Number} num - The number to round.
14
+ * @param {Number} step - The step to round down to.
15
+ * @example
16
+ * NumberUtils.roundDownToNearestStep(57, 30); // 30
17
+ * NumberUtils.roundDownToNearestStep(161, 15); // 150
18
+ * @returns {Number} - The rounded number.
19
+ */
20
+ roundDownToNearestStep(num, step) {
21
+ if (!isNumber(num)) {
22
+ throw new Error('You can only round numbers.');
23
+ }
24
+
25
+ if (isUndefined(step)) {
26
+ throw new Error('You must provide a step to round down to.');
27
+ }
28
+
29
+ return step * Math.floor(num / step);
30
+ },
31
+ };
32
+
33
+ export default NumberUtils;