@spothero/ui 15.0.0-beta.3 → 15.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (60) hide show
  1. package/README.md +2 -2
  2. package/backlog/Chart/Chart.js +1 -1
  3. package/backlog/DateTime/DatePicker.js +1 -1
  4. package/backlog/DateTime/DatePickerCalendar.js +1 -1
  5. package/backlog/DateTime/DatePickerCalendarWithRange.js +1 -1
  6. package/backlog/DateTime/DateTimeRangePicker.js +2 -2
  7. package/backlog/DateTime/TimePicker.js +1 -1
  8. package/backlog/ErrorBoundary/ErrorBoundary.js +9 -7
  9. package/backlog/Flyout/Flyout.js +1 -1
  10. package/backlog/Form/Form.js +2 -2
  11. package/backlog/GooglePlacesSearchInput/GooglePlacesSearchInput.js +4 -1
  12. package/backlog/Notification/Notification.js +1 -1
  13. package/backlog/Portal/Portal.js +1 -1
  14. package/backlog/RenderInBody/RenderInBody.js +1 -1
  15. package/backlog/Select/Select.js +1 -1
  16. package/backlog/SelectControlled/SelectControlled.js +1 -1
  17. package/backlog/Tooltip/Tooltip.js +1 -1
  18. package/backlog/v1/components/Image/Image.js +1 -1
  19. package/backlog/v1/components/Modal/Modal.js +1 -1
  20. package/backlog/v1/components/Modal/ModalContent.js +1 -1
  21. package/package.json +21 -11
  22. package/styles/Chart/Chart.jsx +1 -1
  23. package/styles/DateTime/DatePicker.jsx +1 -1
  24. package/styles/DateTime/DatePickerCalendar.jsx +1 -1
  25. package/styles/DateTime/DatePickerCalendarWithRange.jsx +1 -1
  26. package/styles/DateTime/DateTimeRangePicker.jsx +2 -2
  27. package/styles/DateTime/TimePicker.jsx +1 -1
  28. package/styles/ErrorBoundary/ErrorBoundary.jsx +6 -7
  29. package/styles/Flyout/Flyout.jsx +1 -1
  30. package/styles/Form/Form.jsx +2 -2
  31. package/styles/GooglePlacesSearchInput/GooglePlacesSearchInput.jsx +2 -2
  32. package/styles/Notification/Notification.jsx +1 -1
  33. package/styles/Portal/Portal.jsx +1 -1
  34. package/styles/RenderInBody/RenderInBody.jsx +1 -1
  35. package/styles/Select/Select.jsx +1 -1
  36. package/styles/SelectControlled/SelectControlled.jsx +1 -1
  37. package/styles/Tooltip/Tooltip.jsx +1 -1
  38. package/styles/v1/components/Image/Image.jsx +1 -1
  39. package/styles/v1/components/Modal/Modal.jsx +1 -1
  40. package/styles/v1/components/Modal/ModalContent.jsx +1 -1
  41. package/styles/v1/components/Modal/stories/Content.stories.js +1 -1
  42. package/styles/v2/components/Image/Image.jsx +1 -1
  43. package/styles/v2/components/Modal/Modal.jsx +2 -2
  44. package/styles/v2/components/Modal/Modal.stories.js +4 -7
  45. package/v1/index.js +1 -1
  46. package/v1/index.js.map +1 -1
  47. package/v2/index.js +1 -1
  48. package/v2/index.js.map +1 -1
  49. package/backlog/utils/animation.js +0 -84
  50. package/backlog/utils/date.js +0 -233
  51. package/backlog/utils/dom.js +0 -441
  52. package/backlog/utils/environment.js +0 -422
  53. package/backlog/utils/number.js +0 -43
  54. package/backlog/utils/time.js +0 -282
  55. package/styles/utils/animation.js +0 -75
  56. package/styles/utils/date.js +0 -226
  57. package/styles/utils/dom.js +0 -428
  58. package/styles/utils/environment.js +0 -425
  59. package/styles/utils/number.js +0 -33
  60. package/styles/utils/time.js +0 -268
@@ -1,428 +0,0 @@
1
- // import {document, window} from 'ssr-window';
2
- // import forEach from 'lodash/forEach';
3
- import isArray from 'lodash/isArray';
4
- // import isArrayLikeObject from 'lodash/isArrayLikeObject';
5
- import isString from 'lodash/isString';
6
- import includes from 'lodash/includes';
7
- // import CustomEvent from 'custom-event';
8
- // import EnvironmentUtils from '../environment/environment';
9
-
10
- /**
11
- * Utilities for working with the Document Object Model (DOM).
12
- * @module DOMUtils
13
- */
14
- const DOMUtils = {
15
- // /**
16
- // * Returns the tag name of the specified element.
17
- // * @static
18
- // * @function tag
19
- // * @param {Element} el - The element to check the tag of.
20
- // * @param {Boolean} [lowercase=true] - Whether to normalize the tag name for comparison as lowercase.
21
- // * @example
22
- // * DOMUtils.tag(document.querySelector('.foo'));
23
- // * @returns {String} - The tag of the specified element.
24
- // */
25
- // tag(el, lowercase = true) {
26
- // return lowercase ? el.nodeName.toLowerCase() : el.nodeName;
27
- // },
28
-
29
- /**
30
- * Returns the element(s) matching the specified selector.
31
- * @static
32
- * @function el
33
- * @param {String} selector - The selector of the element to query.
34
- * @example
35
- * DOMUtils.el('.foo');
36
- * @returns {Element|Array} - The element or array of elements matching the selector.
37
- */
38
- el(selector) {
39
- const els = document.querySelectorAll(selector);
40
-
41
- if (els.length > 1) {
42
- return els;
43
- } else {
44
- return els[0];
45
- }
46
- },
47
-
48
- /**
49
- * Returns the element's parent or the closest ancestor matching the specified selector if provided.
50
- * @static
51
- * @function parent
52
- * @param {String|Element} item - The selector or element to find the parent of.
53
- * @param {String} [parentSelector] - The selector of the ancestor to find.
54
- * @example
55
- * DOMUtils.parent('.foo', '.bar');
56
- * @returns {Element} - The parent of the item.
57
- */
58
- parent(item, parentSelector) {
59
- const el = isString(item) ? DOMUtils.el(item) : item;
60
-
61
- if (!el) {
62
- return;
63
- }
64
-
65
- if (parentSelector) {
66
- const allParents = document.querySelectorAll(parentSelector);
67
- let currentParent = el.parentNode;
68
-
69
- while (currentParent && !includes(allParents, currentParent)) {
70
- currentParent = currentParent.parentNode;
71
- }
72
-
73
- return currentParent;
74
- } else {
75
- return el.parentNode;
76
- }
77
- },
78
-
79
- /**
80
- * Returns the attribute of the specified element.
81
- * @static
82
- * @function attr
83
- * @param {String|Element} item - The selector or element to query.
84
- * @param {String} attribute - The attribute to query.
85
- * @example
86
- * DOMUtils.attr('.foo', 'data-baz');
87
- * @returns {String} - The value of the attribute.
88
- */
89
- attr(item, attribute) {
90
- const el = isString(item) ? DOMUtils.el(item) : item;
91
-
92
- if (!el) {
93
- return;
94
- }
95
-
96
- return el.getAttribute(attribute);
97
- },
98
-
99
- /**
100
- * Adds a class to the specified element.
101
- * @static
102
- * @function addClass
103
- * @param {String|Element} item - The selector or element to add the class to.
104
- * @param {String|Array.<String>} className - The class(es) to add.
105
- * @example
106
- * DOMUtils.addClass(evt.currentTarget, 'foo');
107
- * @returns {void}
108
- */
109
- addClass(item, className) {
110
- const el = isString(item) ? DOMUtils.el(item) : item;
111
-
112
- if (!el) {
113
- return;
114
- }
115
-
116
- const classes = isString(className) ? className.split(' ') : className;
117
-
118
- classes.forEach(itemClassName => {
119
- el.classList.add(itemClassName);
120
- });
121
- },
122
-
123
- /**
124
- * Removes a class from the specified element.
125
- * @static
126
- * @function removeClass
127
- * @param {String|Element} item - The selector or element to remove the class from.
128
- * @param {String|Array.<String>} className - The class(es) to remove.
129
- * @example
130
- * DOMUtils.removeClass(evt.currentTarget, 'foo');
131
- * @returns {void}
132
- */
133
- removeClass(item, className) {
134
- const el = isString(item) ? DOMUtils.el(item) : item;
135
-
136
- if (!el) {
137
- return;
138
- }
139
-
140
- const classes = isString(className) ? className.split(' ') : className;
141
-
142
- classes.forEach(itemClassName => {
143
- el.classList.remove(itemClassName);
144
- });
145
- },
146
-
147
- /**
148
- * Checks if an element has a specified class.
149
- * @static
150
- * @function hasClass
151
- * @param {String|Element} item - The selector or element to check.
152
- * @param {String} className - The class to check for.
153
- * @example
154
- * DOMUtils.hasClass(evt.currentTarget, 'foo');
155
- * @returns {Boolean} - Whether the element has the class or not.
156
- */
157
- hasClass(item, className) {
158
- const el = isString(item) ? DOMUtils.el(item) : item;
159
-
160
- if (!el) {
161
- return false;
162
- }
163
-
164
- return el.classList.contains(className) || false;
165
- },
166
-
167
- // /**
168
- // * Toggles a class on or off for the specified element.
169
- // * @static
170
- // * @function toggleClass
171
- // * @param {String|Element} item - The selector or element to toggle the class on.
172
- // * @param {String} className - The class to toggle.
173
- // * @example
174
- // * DOMUtils.toggleClass(evt.currentTarget, 'foo');
175
- // * @returns {void}
176
- // */
177
- // toggleClass(item, className) {
178
- // if (DOMUtils.hasClass(item, className)) {
179
- // DOMUtils.removeClass(item, className);
180
- // } else {
181
- // DOMUtils.addClass(item, className);
182
- // }
183
- // },
184
-
185
- /**
186
- * Get the height of the specified element.
187
- * @static
188
- * @function height
189
- * @param {String|Element} item - The selector or element to find the height of.
190
- * @param {Boolean} [includeMargin=true] - Whether to include the margins in the calculation effectively getting the outerHeight.
191
- * @param {Boolean} [includePadding=true] - Whether to include the padding in the calculation.
192
- * @example
193
- * DOMUtils.height('.foo');
194
- * @returns {Number} - The height of the element.
195
- */
196
- height(item, includeMargin = true, includePadding = true) {
197
- const el = isString(item) ? DOMUtils.el(item) : item;
198
-
199
- if (!el) {
200
- return 0;
201
- }
202
-
203
- const {marginTop, marginBottom, paddingTop, paddingBottom} =
204
- window.getComputedStyle(el);
205
- let height = el.offsetHeight;
206
-
207
- if (includeMargin) {
208
- height += parseInt(marginTop, 10) + parseInt(marginBottom, 10);
209
- }
210
-
211
- if (!includePadding) {
212
- height -= parseInt(paddingTop, 10) + parseInt(paddingBottom, 10);
213
- }
214
-
215
- return height;
216
- },
217
-
218
- // /**
219
- // * Get the width of the specified element.
220
- // * @static
221
- // * @function width
222
- // * @param {String|Element} item - The selector or element to find the width of.
223
- // * @param {Boolean} [includeMargin=true] - Whether to include the margins in the calculation effectively getting the outerWidth.
224
- // * @param {Boolean} [includePadding=true] - Whether to include the padding in the calculation.
225
- // * @example
226
- // * DOMUtils.width('.foo');
227
- // * @returns {Number} - The width of the element.
228
- // */
229
- // width(item, includeMargin = true, includePadding = true) {
230
- // const el = isString(item) ? DOMUtils.el(item) : item;
231
- //
232
- // if (!el) {
233
- // return 0;
234
- // }
235
- //
236
- // const {
237
- // marginLeft,
238
- // marginRight,
239
- // paddingLeft,
240
- // paddingRight,
241
- // } = window.getComputedStyle(el);
242
- // let width = el.offsetWidth;
243
- //
244
- // if (includeMargin) {
245
- // width += parseInt(marginLeft, 10) + parseInt(marginRight, 10);
246
- // }
247
- //
248
- // if (!includePadding) {
249
- // width -= parseInt(paddingLeft, 10) + parseInt(paddingRight, 10);
250
- // }
251
- //
252
- // return width;
253
- // },
254
-
255
- /**
256
- * Removes element(s) from the DOM.
257
- * @static
258
- * @function remove
259
- * @param {String|Element|Array} items - The selector or element(s) to remove from the DOM.
260
- * @example
261
- * DOMUtils.remove('.class-to-remove');
262
- * @returns {void}
263
- */
264
- remove(items) {
265
- const el = isString(items) ? DOMUtils.el(items) : items;
266
-
267
- if (!el) {
268
- return;
269
- }
270
-
271
- if (isArray(el) || el instanceof NodeList) {
272
- const len = el.length;
273
- let i = 0;
274
-
275
- for (i; i < len; ++i) {
276
- el.outerHTML = '';
277
- }
278
- } else {
279
- el.outerHTML = '';
280
- }
281
- },
282
- //
283
- // /**
284
- // * Adds event listener for an element or NodeList.
285
- // * @static
286
- // * @function addEventListener
287
- // * @param {Object} data - The data to pass to the function.
288
- // * @param {String} data.event - The DOM event to take action on.
289
- // * @param {String|Element} [data.target='document'] - The selector or element to attach the event to.
290
- // * @param {Function} data.handler - The function to run when the event triggers.
291
- // * @example
292
- // * DOMUtils.addEventListener({target: '.foo', event: 'click', handler: functionName});
293
- // * @returns {void}
294
- // */
295
- // addEventListener({event, target = 'document', handler}) {
296
- // if (target && target !== 'document') {
297
- // const el = isString(target) ? DOMUtils.el(target) : target;
298
- //
299
- // if (!el) {
300
- // return;
301
- // }
302
- //
303
- // if (isArrayLikeObject(el)) {
304
- // forEach(el, thisEl => {
305
- // thisEl.addEventListener(event, handler);
306
- // });
307
- // } else {
308
- // el.addEventListener(event, handler);
309
- // }
310
- // } else {
311
- // document.addEventListener(event, handler, {capture: true});
312
- // }
313
- // },
314
- //
315
- // /**
316
- // * Removes event listener for an element or NodeList.
317
- // * @static
318
- // * @function removeEventListener
319
- // * @param {Object} data - The data to pass to the function.
320
- // * @param {String} data.event - The DOM event to remove.
321
- // * @param {String|Element} [data.target='document'] - The selector or element to remove the event from.
322
- // * @param {Function} data.handler - The function that is triggered to handle the event.
323
- // * @example
324
- // * DOMUtils.removeEventListener({target: '.foo', event: 'click', handler: functionName});
325
- // * @returns {void}
326
- // */
327
- // removeEventListener({event, target = 'document', handler}) {
328
- // if (target && target !== 'document') {
329
- // const el = isString(target) ? DOMUtils.el(target) : target;
330
- //
331
- // if (!el) {
332
- // return;
333
- // }
334
- //
335
- // if (isArrayLikeObject(el)) {
336
- // forEach(el, thisEl => {
337
- // thisEl.removeEventListener(event, handler);
338
- // });
339
- // } else {
340
- // el.removeEventListener(event, handler);
341
- // }
342
- // } else {
343
- // document.removeEventListener(event, handler);
344
- // }
345
- // },
346
- //
347
- // /**
348
- // * Creates and dispatches a custom event, with or without data.
349
- // * @static
350
- // * @function sendCustomEvent
351
- // * @param {String} eventName - The name for the custom event.
352
- // * @param {Object} [data=null] - The data to send with the custom event.
353
- // * @example
354
- // * DOMUtils.sendCustomEvent('open-my-mind', {mind: 'free'});
355
- // * @returns {void}
356
- // */
357
- // sendCustomEvent(eventName, data = null) {
358
- // if (!eventName) {
359
- // throw new Error(
360
- // `The 'eventName' is required when sending custom events.`
361
- // );
362
- // }
363
- //
364
- // const customEvent = new CustomEvent(eventName, {detail: data});
365
- //
366
- // document.dispatchEvent(customEvent);
367
- // },
368
-
369
- /**
370
- * Gets the offset of an element relative to the document.
371
- * @static
372
- * @function getDocumentOffset
373
- * @param {String|Element} item - The selector or element to get the offset of.
374
- * @example
375
- * DOMUtils.getDocumentOffset('.foo');
376
- * @returns {Object} - The top and left values of the offset.
377
- */
378
- getDocumentOffset(item) {
379
- const el = isString(item) ? DOMUtils.el(item) : item;
380
- const scrollLeft =
381
- window.pageXOffset || document.documentElement.scrollLeft;
382
- const scrollTop =
383
- window.pageYOffset || document.documentElement.scrollTop;
384
-
385
- const rect = el ? el.getBoundingClientRect() : {top: 0, left: 0};
386
-
387
- return {
388
- top: rect.top + scrollTop,
389
- left: rect.left + scrollLeft,
390
- };
391
- },
392
- //
393
- // /**
394
- // * Loads a script into an element in the document. Pass a fully qualified, exact URL to enable proper matching against a pre-existing script of the same path.
395
- // * @static
396
- // * @function loadScript
397
- // * @param {String} src - The exact script path to load.
398
- // * @param {String} [appendTo='head'] - Where to append the script ('head', 'body') in the document.
399
- // * @example
400
- // * DOMUtils.loadScript({src: 'https://js.stripe.com/v3/'});
401
- // * @returns {Promise} - The promise that is either fulfilled or rejected as a result of loading the script.
402
- // */
403
- // loadScript({src, appendTo = 'head'}) {
404
- // if (!EnvironmentUtils.isBrowser()) {
405
- // return;
406
- // }
407
- //
408
- // const isDuplicate = [...document.querySelectorAll('script')].some(
409
- // script => {
410
- // return script.src === src;
411
- // }
412
- // );
413
- //
414
- // return new Promise((resolve, reject) => {
415
- // const s = document.createElement('script');
416
- //
417
- // s.src = src;
418
- // s.onload = resolve;
419
- // s.onerror = reject;
420
- //
421
- // if (!isDuplicate) {
422
- // document[appendTo].appendChild(s);
423
- // }
424
- // });
425
- // },
426
- };
427
-
428
- export default DOMUtils;