@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.
- package/README.md +2 -2
- package/backlog/Chart/Chart.js +1 -1
- package/backlog/DateTime/DatePicker.js +1 -1
- package/backlog/DateTime/DatePickerCalendar.js +1 -1
- package/backlog/DateTime/DatePickerCalendarWithRange.js +1 -1
- package/backlog/DateTime/DateTimeRangePicker.js +2 -2
- package/backlog/DateTime/TimePicker.js +1 -1
- package/backlog/ErrorBoundary/ErrorBoundary.js +9 -7
- package/backlog/Flyout/Flyout.js +1 -1
- package/backlog/Form/Form.js +2 -2
- package/backlog/GooglePlacesSearchInput/GooglePlacesSearchInput.js +4 -1
- package/backlog/Notification/Notification.js +1 -1
- package/backlog/Portal/Portal.js +1 -1
- package/backlog/RenderInBody/RenderInBody.js +1 -1
- package/backlog/Select/Select.js +1 -1
- package/backlog/SelectControlled/SelectControlled.js +1 -1
- package/backlog/Tooltip/Tooltip.js +1 -1
- package/backlog/v1/components/Image/Image.js +1 -1
- package/backlog/v1/components/Modal/Modal.js +1 -1
- package/backlog/v1/components/Modal/ModalContent.js +1 -1
- package/package.json +21 -11
- package/styles/Chart/Chart.jsx +1 -1
- package/styles/DateTime/DatePicker.jsx +1 -1
- package/styles/DateTime/DatePickerCalendar.jsx +1 -1
- package/styles/DateTime/DatePickerCalendarWithRange.jsx +1 -1
- package/styles/DateTime/DateTimeRangePicker.jsx +2 -2
- package/styles/DateTime/TimePicker.jsx +1 -1
- package/styles/ErrorBoundary/ErrorBoundary.jsx +6 -7
- package/styles/Flyout/Flyout.jsx +1 -1
- package/styles/Form/Form.jsx +2 -2
- package/styles/GooglePlacesSearchInput/GooglePlacesSearchInput.jsx +2 -2
- package/styles/Notification/Notification.jsx +1 -1
- package/styles/Portal/Portal.jsx +1 -1
- package/styles/RenderInBody/RenderInBody.jsx +1 -1
- package/styles/Select/Select.jsx +1 -1
- package/styles/SelectControlled/SelectControlled.jsx +1 -1
- package/styles/Tooltip/Tooltip.jsx +1 -1
- package/styles/v1/components/Image/Image.jsx +1 -1
- package/styles/v1/components/Modal/Modal.jsx +1 -1
- package/styles/v1/components/Modal/ModalContent.jsx +1 -1
- package/styles/v1/components/Modal/stories/Content.stories.js +1 -1
- package/styles/v2/components/Image/Image.jsx +1 -1
- package/styles/v2/components/Modal/Modal.jsx +2 -2
- package/styles/v2/components/Modal/Modal.stories.js +4 -7
- package/v1/index.js +1 -1
- package/v1/index.js.map +1 -1
- package/v2/index.js +1 -1
- package/v2/index.js.map +1 -1
- package/backlog/utils/animation.js +0 -84
- package/backlog/utils/date.js +0 -233
- package/backlog/utils/dom.js +0 -441
- package/backlog/utils/environment.js +0 -422
- package/backlog/utils/number.js +0 -43
- package/backlog/utils/time.js +0 -282
- package/styles/utils/animation.js +0 -75
- package/styles/utils/date.js +0 -226
- package/styles/utils/dom.js +0 -428
- package/styles/utils/environment.js +0 -425
- package/styles/utils/number.js +0 -33
- package/styles/utils/time.js +0 -268
package/styles/utils/time.js
DELETED
|
@@ -1,268 +0,0 @@
|
|
|
1
|
-
import isEmpty from 'lodash/isEmpty';
|
|
2
|
-
import isNumber from 'lodash/isNumber';
|
|
3
|
-
import isString from 'lodash/isString';
|
|
4
|
-
import moment from 'moment-timezone';
|
|
5
|
-
import NumberUtils from './number';
|
|
6
|
-
// import StringUtils from '../string/string';
|
|
7
|
-
|
|
8
|
-
/**
|
|
9
|
-
* Utilities for working with times.
|
|
10
|
-
* @module TimeUtils
|
|
11
|
-
*/
|
|
12
|
-
const TimeUtils = {
|
|
13
|
-
// /**
|
|
14
|
-
// * Normalizes the provided time down to the provided step.
|
|
15
|
-
// * @static
|
|
16
|
-
// * @function normalizeToStep
|
|
17
|
-
// * @param {String} time - The input value in the format hh:mm A.
|
|
18
|
-
// * @param {Number} [step=1] - The step to round down to.
|
|
19
|
-
// * @example
|
|
20
|
-
// * TimeUtils.normalizeToStep('07:07 PM', 15); // '07:00 PM'
|
|
21
|
-
// * @returns {String} - The normalized time.
|
|
22
|
-
// */
|
|
23
|
-
// normalizeToStep(time, step = 1) {
|
|
24
|
-
// if (isEmpty(time)) {
|
|
25
|
-
// return time;
|
|
26
|
-
// }
|
|
27
|
-
//
|
|
28
|
-
// if (!isString(time)) {
|
|
29
|
-
// throw new Error('The supplied time is not a string.');
|
|
30
|
-
// }
|
|
31
|
-
//
|
|
32
|
-
// const {hours, mins} = TimeUtils.getValuesFromString(time, step);
|
|
33
|
-
//
|
|
34
|
-
// return TimeUtils.getFromValuesAsString(hours, mins);
|
|
35
|
-
// },
|
|
36
|
-
//
|
|
37
|
-
/**
|
|
38
|
-
* Provides the hours, minutes, and meridiem from a time string.
|
|
39
|
-
* @static
|
|
40
|
-
* @function getValuesFromString
|
|
41
|
-
* @param {String} time - The input value in the format hh:mm A.
|
|
42
|
-
* @param {Number} [step=1] - The step to round down to.
|
|
43
|
-
* @example
|
|
44
|
-
* TimeUtils.getValuesFromString('10:19 AM');
|
|
45
|
-
* @returns {Object} - The object containing the hours, minutes, and meridiem.
|
|
46
|
-
*/
|
|
47
|
-
getValuesFromString(time, step = 1) {
|
|
48
|
-
if (isEmpty(time)) {
|
|
49
|
-
return time;
|
|
50
|
-
}
|
|
51
|
-
|
|
52
|
-
if (!isString(time)) {
|
|
53
|
-
throw new Error('The supplied time is not a string.');
|
|
54
|
-
}
|
|
55
|
-
|
|
56
|
-
const firstPartials = time.split(':');
|
|
57
|
-
const secondPartials = firstPartials[1].split(' ');
|
|
58
|
-
const isAM = secondPartials[1] === 'AM';
|
|
59
|
-
const mins = parseInt(secondPartials[0], 10);
|
|
60
|
-
const minsRounded = NumberUtils.roundDownToNearestStep(mins, step);
|
|
61
|
-
let hours = parseInt(firstPartials[0], 10);
|
|
62
|
-
|
|
63
|
-
if (isAM && hours === 12) {
|
|
64
|
-
hours = 0;
|
|
65
|
-
} else if (!isAM && hours !== 12) {
|
|
66
|
-
hours += 12;
|
|
67
|
-
}
|
|
68
|
-
|
|
69
|
-
return {
|
|
70
|
-
hours,
|
|
71
|
-
mins: minsRounded,
|
|
72
|
-
isAM,
|
|
73
|
-
};
|
|
74
|
-
},
|
|
75
|
-
//
|
|
76
|
-
// /**
|
|
77
|
-
// * Provides the formatted time from hours and minutes values.
|
|
78
|
-
// * @static
|
|
79
|
-
// * @function getFromValuesAsString
|
|
80
|
-
// * @param {Number} hours - The hours in a 24 hour format.
|
|
81
|
-
// * @param {Number} minutes - The minutes from 0 - 60.
|
|
82
|
-
// * @param {Boolean} [roundMinutesDown=false] - Whether to round the minutes down to the provided step.
|
|
83
|
-
// * @param {Number} [step=1] - The step to round minutes down to.
|
|
84
|
-
// * @example
|
|
85
|
-
// * TimeUtils.getFromValuesAsString(20, 35); // '08:35 PM'
|
|
86
|
-
// * @returns {String} - The formatted time.
|
|
87
|
-
// */
|
|
88
|
-
// getFromValuesAsString(hours, minutes, roundMinutesDown = false, step = 1) {
|
|
89
|
-
// const meridiem = hours < 12 ? 'AM' : 'PM';
|
|
90
|
-
// let newHours = hours;
|
|
91
|
-
// let newMinutes = minutes;
|
|
92
|
-
//
|
|
93
|
-
// if (newHours > 12) {
|
|
94
|
-
// newHours -= 12;
|
|
95
|
-
// } else if (newHours === 0) {
|
|
96
|
-
// newHours = 12;
|
|
97
|
-
// }
|
|
98
|
-
//
|
|
99
|
-
// if (roundMinutesDown) {
|
|
100
|
-
// newMinutes = NumberUtils.roundDownToNearestStep(newMinutes, step);
|
|
101
|
-
// }
|
|
102
|
-
//
|
|
103
|
-
// return `${StringUtils.padWith(newHours)}:${StringUtils.padWith(
|
|
104
|
-
// newMinutes
|
|
105
|
-
// )} ${meridiem}`;
|
|
106
|
-
// },
|
|
107
|
-
//
|
|
108
|
-
// /**
|
|
109
|
-
// * Converts a mobile input time to a string in the format hh:mm A.
|
|
110
|
-
// * @static
|
|
111
|
-
// * @function getMobileAsString
|
|
112
|
-
// * @param {String} time - The input value in the format HH:mm (24 hour format).
|
|
113
|
-
// * @param {Number} [step=1] - The step to round down to.
|
|
114
|
-
// * @example
|
|
115
|
-
// * TimeUtils.getMobileAsString('22:19'); // 10:19 PM
|
|
116
|
-
// * @returns {String} - The formatted time.
|
|
117
|
-
// */
|
|
118
|
-
// getMobileAsString(time, step = 1) {
|
|
119
|
-
// if (!isString(time)) {
|
|
120
|
-
// throw new Error('The supplied time is not a string.');
|
|
121
|
-
// }
|
|
122
|
-
//
|
|
123
|
-
// const frags = time.split(':');
|
|
124
|
-
// const mins = parseInt(frags[1], 10);
|
|
125
|
-
// const minsRounded = NumberUtils.roundDownToNearestStep(mins, step);
|
|
126
|
-
// const hours = parseInt(frags[0], 10);
|
|
127
|
-
// const meridiem = hours < 12 ? 'AM' : 'PM';
|
|
128
|
-
// let hh = hours;
|
|
129
|
-
//
|
|
130
|
-
// if (hours > 12) {
|
|
131
|
-
// hh -= 12;
|
|
132
|
-
// } else if (hours === 0) {
|
|
133
|
-
// hh = 12;
|
|
134
|
-
// }
|
|
135
|
-
//
|
|
136
|
-
// return `${StringUtils.padWith(hh)}:${StringUtils.padWith(
|
|
137
|
-
// minsRounded
|
|
138
|
-
// )} ${meridiem}`;
|
|
139
|
-
// },
|
|
140
|
-
//
|
|
141
|
-
// /**
|
|
142
|
-
// * Converts a time to a date object.
|
|
143
|
-
// * @static
|
|
144
|
-
// * @function getAsDate
|
|
145
|
-
// * @param {String} time - The input value in the format hh:mm A.
|
|
146
|
-
// * @example
|
|
147
|
-
// * TimeUtils.getAsDate('10:19 PM');
|
|
148
|
-
// * @returns {Date} - The time inside of a date object.
|
|
149
|
-
// */
|
|
150
|
-
// getAsDate(time) {
|
|
151
|
-
// if (isEmpty(time)) {
|
|
152
|
-
// return null;
|
|
153
|
-
// }
|
|
154
|
-
//
|
|
155
|
-
// if (!isString(time)) {
|
|
156
|
-
// throw new Error('The supplied time is not a string.');
|
|
157
|
-
// }
|
|
158
|
-
//
|
|
159
|
-
// const {hours, mins} = TimeUtils.getValuesFromString(time);
|
|
160
|
-
// const d = new Date();
|
|
161
|
-
//
|
|
162
|
-
// d.setHours(hours);
|
|
163
|
-
// d.setMinutes(mins);
|
|
164
|
-
// d.setSeconds(0);
|
|
165
|
-
//
|
|
166
|
-
// return d;
|
|
167
|
-
// },
|
|
168
|
-
|
|
169
|
-
/**
|
|
170
|
-
* Converts a time to a moment instance.
|
|
171
|
-
* @static
|
|
172
|
-
* @function getAsMoment
|
|
173
|
-
* @param {String} time - The input value in the format hh:mm A.
|
|
174
|
-
* @example
|
|
175
|
-
* TimeUtils.getAsMoment('10:19 PM');
|
|
176
|
-
* @returns {Moment} - The time inside of a moment instance.
|
|
177
|
-
*/
|
|
178
|
-
getAsMoment(time) {
|
|
179
|
-
if (isEmpty(time)) {
|
|
180
|
-
return null;
|
|
181
|
-
}
|
|
182
|
-
|
|
183
|
-
if (!isString(time)) {
|
|
184
|
-
throw new Error('The supplied time is not a string.');
|
|
185
|
-
}
|
|
186
|
-
|
|
187
|
-
const {hours, mins} = TimeUtils.getValuesFromString(time);
|
|
188
|
-
|
|
189
|
-
return moment([1, 1])
|
|
190
|
-
.startOf('day')
|
|
191
|
-
.add(hours, 'hours')
|
|
192
|
-
.add(mins, 'minutes');
|
|
193
|
-
},
|
|
194
|
-
|
|
195
|
-
/**
|
|
196
|
-
* Generate an array of times.
|
|
197
|
-
* @static
|
|
198
|
-
* @function getTimes
|
|
199
|
-
* @param {Object} data - The data to pass to the function.
|
|
200
|
-
* @param {Number} [data.step=30] - Increment times by this many minutes.
|
|
201
|
-
* @param {String} [data.format='hh:mm A'] - Moment.js format (http://momentjs.com/docs/#/displaying/format/).
|
|
202
|
-
* @param {String} [data.ignoreBefore] - Number of minutes to ignore times before in the output.
|
|
203
|
-
* @param {String} [data.ignoreAfter] - Number of minutes to ignore times after in the output.
|
|
204
|
-
* @example
|
|
205
|
-
* TimeUtils.getTimes({
|
|
206
|
-
* step: 30,
|
|
207
|
-
* format: 'hh:mm A'
|
|
208
|
-
* });
|
|
209
|
-
* @returns {Array} times - An array of times.
|
|
210
|
-
*/
|
|
211
|
-
getTimes({step = 30, format = 'hh:mm A', ignoreBefore, ignoreAfter} = {}) {
|
|
212
|
-
if (ignoreBefore && !isNumber(ignoreBefore)) {
|
|
213
|
-
throw new Error('The ignoreBefore value passed was not a number.');
|
|
214
|
-
}
|
|
215
|
-
|
|
216
|
-
if (ignoreAfter && !isNumber(ignoreAfter)) {
|
|
217
|
-
throw new Error('The ignoreAfter value passed was not a number.');
|
|
218
|
-
}
|
|
219
|
-
|
|
220
|
-
if (ignoreBefore && ignoreAfter && ignoreBefore > ignoreAfter) {
|
|
221
|
-
throw new Error(
|
|
222
|
-
'The value of ignoreBefore should be less than the value of ignoreAfter.'
|
|
223
|
-
);
|
|
224
|
-
}
|
|
225
|
-
|
|
226
|
-
const dateTime = moment([0, 0]);
|
|
227
|
-
const total = 1440;
|
|
228
|
-
const len = total / step;
|
|
229
|
-
const times = [];
|
|
230
|
-
const beforeMoment = ignoreBefore
|
|
231
|
-
? dateTime.clone().startOf('day').add(ignoreBefore, 'minutes')
|
|
232
|
-
: null;
|
|
233
|
-
const afterMoment = ignoreAfter
|
|
234
|
-
? dateTime.clone().startOf('day').add(ignoreAfter, 'minutes')
|
|
235
|
-
: null;
|
|
236
|
-
let i = 0;
|
|
237
|
-
let id = 0;
|
|
238
|
-
let shouldAdd = true;
|
|
239
|
-
let time;
|
|
240
|
-
|
|
241
|
-
for (i; i < len; i++) {
|
|
242
|
-
id = i * step;
|
|
243
|
-
|
|
244
|
-
time = dateTime.clone().startOf('day').add(id, 'minutes');
|
|
245
|
-
|
|
246
|
-
shouldAdd = beforeMoment
|
|
247
|
-
? time.isSameOrAfter(beforeMoment)
|
|
248
|
-
: shouldAdd;
|
|
249
|
-
|
|
250
|
-
if (shouldAdd) {
|
|
251
|
-
shouldAdd = afterMoment
|
|
252
|
-
? time.isSameOrBefore(afterMoment)
|
|
253
|
-
: shouldAdd;
|
|
254
|
-
}
|
|
255
|
-
|
|
256
|
-
if (shouldAdd) {
|
|
257
|
-
times.push({
|
|
258
|
-
id,
|
|
259
|
-
formatted: time.format(format),
|
|
260
|
-
});
|
|
261
|
-
}
|
|
262
|
-
}
|
|
263
|
-
|
|
264
|
-
return times;
|
|
265
|
-
},
|
|
266
|
-
};
|
|
267
|
-
|
|
268
|
-
export default TimeUtils;
|