saasufy-components 5.7.0 → 6.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/package.json +1 -1
- package/utils.js +13 -11
package/package.json
CHANGED
package/utils.js
CHANGED
|
@@ -205,6 +205,16 @@ export function computeId(...parts) {
|
|
|
205
205
|
return `${idHex.slice(0, 8)}-${idHex.slice(8, 12)}-${third}-${fourth}-${idHex.slice(20, 32)}`;
|
|
206
206
|
}
|
|
207
207
|
|
|
208
|
+
export function toDate(timestamp) {
|
|
209
|
+
let date = new Date(timestamp);
|
|
210
|
+
let year = date.getFullYear();
|
|
211
|
+
let month = date.toLocaleString('default', { month: 'long' });
|
|
212
|
+
let day = date.getDate();
|
|
213
|
+
let hour = date.getHours();
|
|
214
|
+
let minutes = date.getMinutes();
|
|
215
|
+
return `${month} ${day}, ${year} at ${hour}:${minutes.toString().padStart(2, '0')}`;
|
|
216
|
+
}
|
|
217
|
+
|
|
208
218
|
let templateFormatters = {
|
|
209
219
|
url: (value) => String(value).toLowerCase().replace(/ /g, '-'),
|
|
210
220
|
lowerCase: (value) => String(value).toLowerCase(),
|
|
@@ -217,20 +227,12 @@ let templateFormatters = {
|
|
|
217
227
|
fallback: (...args) => {
|
|
218
228
|
return args.filter(arg => arg)[0];
|
|
219
229
|
},
|
|
220
|
-
date: (timestamp) =>
|
|
221
|
-
let date = new Date(timestamp);
|
|
222
|
-
let year = date.getFullYear();
|
|
223
|
-
let month = date.toLocaleString('default', { month: 'long' });
|
|
224
|
-
let day = date.getDate();
|
|
225
|
-
let hour = date.getHours();
|
|
226
|
-
let minutes = date.getMinutes();
|
|
227
|
-
return `${month} ${day}, ${year} at ${hour}:${minutes.toString().padStart(2, '0')}`;
|
|
228
|
-
},
|
|
230
|
+
date: (timestamp) => toDate(timestamp),
|
|
229
231
|
joinFields: (list, field, sep) => {
|
|
230
232
|
return list.map(item => item[field]).join(sep);
|
|
231
233
|
},
|
|
232
234
|
combineFilters: (filterMap, useOr) => {
|
|
233
|
-
return Object.values(filterMap || {}).join(useOr ? '
|
|
235
|
+
return Object.values(filterMap || {}).join(useOr ? ' ~OR~ ' : ' ~AND~ ');
|
|
234
236
|
},
|
|
235
237
|
computeId,
|
|
236
238
|
safeString: toSafeHTML
|
|
@@ -371,7 +373,7 @@ export function generateRandomHexString(byteLength) {
|
|
|
371
373
|
}).join('');
|
|
372
374
|
}
|
|
373
375
|
|
|
374
|
-
export const fieldPartsRegExp = /("[^"]*"|'[^']*'|\([^)]*\)|[^,()"']+)+/g
|
|
376
|
+
export const fieldPartsRegExp = /((^|(?<=,))((?=,)|$)|"[^"]*"|'[^']*'|\([^)]*\)|[^,()"']+)+/g
|
|
375
377
|
export const quotedContentRegExp = /^\s*["']?(.*?)["']?\s*$/;
|
|
376
378
|
|
|
377
379
|
export function toBoolean(value) {
|