@01-edu/shared 1.2.17 → 2.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 -2
- package/toolbox.js +10 -6
- package/lodash.deburr.js +0 -255
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@01-edu/shared",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "2.0.0",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"description": "",
|
|
6
6
|
"scripts": {
|
|
@@ -9,7 +9,6 @@
|
|
|
9
9
|
"files": [
|
|
10
10
|
"./bin/check-definitions.js",
|
|
11
11
|
"./event-utils.js",
|
|
12
|
-
"./lodash.deburr.js",
|
|
13
12
|
"./onboarding.js",
|
|
14
13
|
"./attrs.js",
|
|
15
14
|
"./attrs-defs.js",
|
package/toolbox.js
CHANGED
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import { isFinished } from './event-utils.js'
|
|
2
|
-
import { deburr } from './lodash.deburr.js'
|
|
3
2
|
import { onboardingTypes } from './onboarding.js'
|
|
4
3
|
|
|
5
4
|
const keyCodes = {
|
|
@@ -339,11 +338,14 @@ export const defer = () => {
|
|
|
339
338
|
|
|
340
339
|
// slugify('A Test') => a-test
|
|
341
340
|
export const slugify = str =>
|
|
342
|
-
|
|
343
|
-
.
|
|
341
|
+
str
|
|
342
|
+
.normalize('NFKD')
|
|
343
|
+
.replace(/\p{M}+/gu, '')
|
|
344
344
|
.toLowerCase()
|
|
345
|
-
.replace(
|
|
346
|
-
.replace(/
|
|
345
|
+
.replace(/\s+/g, ' ')
|
|
346
|
+
.replace(/[^a-z0-9._ ]+/g, '')
|
|
347
|
+
.trim()
|
|
348
|
+
.replaceAll(' ', '-')
|
|
347
349
|
|
|
348
350
|
export const fullName = ({ firstName, lastName }) =>
|
|
349
351
|
`${firstName || ''} ${lastName || ''}`
|
|
@@ -468,6 +470,9 @@ export const getUserName = user => {
|
|
|
468
470
|
return `${firstName} ${lastName}`
|
|
469
471
|
}
|
|
470
472
|
|
|
473
|
+
// This only works for JSON like value
|
|
474
|
+
// no support for Dates, Regexp, Set, Map etc...
|
|
475
|
+
// this is 100% fine for anything from the database
|
|
471
476
|
export const eq = (a, b) => {
|
|
472
477
|
if (a === b) return true
|
|
473
478
|
if (typeof a !== typeof b) return false
|
|
@@ -475,7 +480,6 @@ export const eq = (a, b) => {
|
|
|
475
480
|
if (typeof a === 'object') {
|
|
476
481
|
if (!a || !b) return false
|
|
477
482
|
if (a.constructor !== b.constructor) return false
|
|
478
|
-
// todo: handle regexp
|
|
479
483
|
const entries = Object.entries(a)
|
|
480
484
|
if (entries.length !== Object.values(b).length) return false
|
|
481
485
|
for (const [k, v] of entries) {
|
package/lodash.deburr.js
DELETED
|
@@ -1,255 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* lodash (Custom Build) <https://lodash.com/>
|
|
3
|
-
* Build: `lodash modularize exports="npm" -o ./`
|
|
4
|
-
* Copyright jQuery Foundation and other contributors <https://jquery.org/>
|
|
5
|
-
* Released under MIT license <https://lodash.com/license>
|
|
6
|
-
* Based on Underscore.js 1.8.3 <http://underscorejs.org/LICENSE>
|
|
7
|
-
* Copyright Jeremy Ashkenas, DocumentCloud and Investigative Reporters & Editors
|
|
8
|
-
*/
|
|
9
|
-
|
|
10
|
-
/** Used as references for various `Number` constants. */
|
|
11
|
-
var INFINITY = 1 / 0;
|
|
12
|
-
|
|
13
|
-
/** `Object#toString` result references. */
|
|
14
|
-
var symbolTag = '[object Symbol]';
|
|
15
|
-
|
|
16
|
-
/** Used to match Latin Unicode letters (excluding mathematical operators). */
|
|
17
|
-
var reLatin = /[\xc0-\xd6\xd8-\xf6\xf8-\xff\u0100-\u017f]/g;
|
|
18
|
-
|
|
19
|
-
/** Used to compose unicode character classes. */
|
|
20
|
-
var rsComboMarksRange = '\\u0300-\\u036f\\ufe20-\\ufe23',
|
|
21
|
-
rsComboSymbolsRange = '\\u20d0-\\u20f0';
|
|
22
|
-
|
|
23
|
-
/** Used to compose unicode capture groups. */
|
|
24
|
-
var rsCombo = '[' + rsComboMarksRange + rsComboSymbolsRange + ']';
|
|
25
|
-
|
|
26
|
-
/**
|
|
27
|
-
* Used to match [combining diacritical marks](https://en.wikipedia.org/wiki/Combining_Diacritical_Marks) and
|
|
28
|
-
* [combining diacritical marks for symbols](https://en.wikipedia.org/wiki/Combining_Diacritical_Marks_for_Symbols).
|
|
29
|
-
*/
|
|
30
|
-
var reComboMark = RegExp(rsCombo, 'g');
|
|
31
|
-
|
|
32
|
-
/** Used to map Latin Unicode letters to basic Latin letters. */
|
|
33
|
-
var deburredLetters = {
|
|
34
|
-
// Latin-1 Supplement block.
|
|
35
|
-
'\xc0': 'A', '\xc1': 'A', '\xc2': 'A', '\xc3': 'A', '\xc4': 'A', '\xc5': 'A',
|
|
36
|
-
'\xe0': 'a', '\xe1': 'a', '\xe2': 'a', '\xe3': 'a', '\xe4': 'a', '\xe5': 'a',
|
|
37
|
-
'\xc7': 'C', '\xe7': 'c',
|
|
38
|
-
'\xd0': 'D', '\xf0': 'd',
|
|
39
|
-
'\xc8': 'E', '\xc9': 'E', '\xca': 'E', '\xcb': 'E',
|
|
40
|
-
'\xe8': 'e', '\xe9': 'e', '\xea': 'e', '\xeb': 'e',
|
|
41
|
-
'\xcc': 'I', '\xcd': 'I', '\xce': 'I', '\xcf': 'I',
|
|
42
|
-
'\xec': 'i', '\xed': 'i', '\xee': 'i', '\xef': 'i',
|
|
43
|
-
'\xd1': 'N', '\xf1': 'n',
|
|
44
|
-
'\xd2': 'O', '\xd3': 'O', '\xd4': 'O', '\xd5': 'O', '\xd6': 'O', '\xd8': 'O',
|
|
45
|
-
'\xf2': 'o', '\xf3': 'o', '\xf4': 'o', '\xf5': 'o', '\xf6': 'o', '\xf8': 'o',
|
|
46
|
-
'\xd9': 'U', '\xda': 'U', '\xdb': 'U', '\xdc': 'U',
|
|
47
|
-
'\xf9': 'u', '\xfa': 'u', '\xfb': 'u', '\xfc': 'u',
|
|
48
|
-
'\xdd': 'Y', '\xfd': 'y', '\xff': 'y',
|
|
49
|
-
'\xc6': 'Ae', '\xe6': 'ae',
|
|
50
|
-
'\xde': 'Th', '\xfe': 'th',
|
|
51
|
-
'\xdf': 'ss',
|
|
52
|
-
// Latin Extended-A block.
|
|
53
|
-
'\u0100': 'A', '\u0102': 'A', '\u0104': 'A',
|
|
54
|
-
'\u0101': 'a', '\u0103': 'a', '\u0105': 'a',
|
|
55
|
-
'\u0106': 'C', '\u0108': 'C', '\u010a': 'C', '\u010c': 'C',
|
|
56
|
-
'\u0107': 'c', '\u0109': 'c', '\u010b': 'c', '\u010d': 'c',
|
|
57
|
-
'\u010e': 'D', '\u0110': 'D', '\u010f': 'd', '\u0111': 'd',
|
|
58
|
-
'\u0112': 'E', '\u0114': 'E', '\u0116': 'E', '\u0118': 'E', '\u011a': 'E',
|
|
59
|
-
'\u0113': 'e', '\u0115': 'e', '\u0117': 'e', '\u0119': 'e', '\u011b': 'e',
|
|
60
|
-
'\u011c': 'G', '\u011e': 'G', '\u0120': 'G', '\u0122': 'G',
|
|
61
|
-
'\u011d': 'g', '\u011f': 'g', '\u0121': 'g', '\u0123': 'g',
|
|
62
|
-
'\u0124': 'H', '\u0126': 'H', '\u0125': 'h', '\u0127': 'h',
|
|
63
|
-
'\u0128': 'I', '\u012a': 'I', '\u012c': 'I', '\u012e': 'I', '\u0130': 'I',
|
|
64
|
-
'\u0129': 'i', '\u012b': 'i', '\u012d': 'i', '\u012f': 'i', '\u0131': 'i',
|
|
65
|
-
'\u0134': 'J', '\u0135': 'j',
|
|
66
|
-
'\u0136': 'K', '\u0137': 'k', '\u0138': 'k',
|
|
67
|
-
'\u0139': 'L', '\u013b': 'L', '\u013d': 'L', '\u013f': 'L', '\u0141': 'L',
|
|
68
|
-
'\u013a': 'l', '\u013c': 'l', '\u013e': 'l', '\u0140': 'l', '\u0142': 'l',
|
|
69
|
-
'\u0143': 'N', '\u0145': 'N', '\u0147': 'N', '\u014a': 'N',
|
|
70
|
-
'\u0144': 'n', '\u0146': 'n', '\u0148': 'n', '\u014b': 'n',
|
|
71
|
-
'\u014c': 'O', '\u014e': 'O', '\u0150': 'O',
|
|
72
|
-
'\u014d': 'o', '\u014f': 'o', '\u0151': 'o',
|
|
73
|
-
'\u0154': 'R', '\u0156': 'R', '\u0158': 'R',
|
|
74
|
-
'\u0155': 'r', '\u0157': 'r', '\u0159': 'r',
|
|
75
|
-
'\u015a': 'S', '\u015c': 'S', '\u015e': 'S', '\u0160': 'S',
|
|
76
|
-
'\u015b': 's', '\u015d': 's', '\u015f': 's', '\u0161': 's',
|
|
77
|
-
'\u0162': 'T', '\u0164': 'T', '\u0166': 'T',
|
|
78
|
-
'\u0163': 't', '\u0165': 't', '\u0167': 't',
|
|
79
|
-
'\u0168': 'U', '\u016a': 'U', '\u016c': 'U', '\u016e': 'U', '\u0170': 'U', '\u0172': 'U',
|
|
80
|
-
'\u0169': 'u', '\u016b': 'u', '\u016d': 'u', '\u016f': 'u', '\u0171': 'u', '\u0173': 'u',
|
|
81
|
-
'\u0174': 'W', '\u0175': 'w',
|
|
82
|
-
'\u0176': 'Y', '\u0177': 'y', '\u0178': 'Y',
|
|
83
|
-
'\u0179': 'Z', '\u017b': 'Z', '\u017d': 'Z',
|
|
84
|
-
'\u017a': 'z', '\u017c': 'z', '\u017e': 'z',
|
|
85
|
-
'\u0132': 'IJ', '\u0133': 'ij',
|
|
86
|
-
'\u0152': 'Oe', '\u0153': 'oe',
|
|
87
|
-
'\u0149': "'n", '\u017f': 'ss'
|
|
88
|
-
};
|
|
89
|
-
|
|
90
|
-
/** Detect free variable `global` from Node.js. */
|
|
91
|
-
var freeGlobal = typeof global == 'object' && global && global.Object === Object && global;
|
|
92
|
-
|
|
93
|
-
/** Detect free variable `self`. */
|
|
94
|
-
var freeSelf = typeof self == 'object' && self && self.Object === Object && self;
|
|
95
|
-
|
|
96
|
-
/** Used as a reference to the global object. */
|
|
97
|
-
var root = freeGlobal || freeSelf || Function('return this')();
|
|
98
|
-
|
|
99
|
-
/**
|
|
100
|
-
* The base implementation of `_.propertyOf` without support for deep paths.
|
|
101
|
-
*
|
|
102
|
-
* @private
|
|
103
|
-
* @param {Object} object The object to query.
|
|
104
|
-
* @returns {Function} Returns the new accessor function.
|
|
105
|
-
*/
|
|
106
|
-
function basePropertyOf(object) {
|
|
107
|
-
return function(key) {
|
|
108
|
-
return object == null ? undefined : object[key];
|
|
109
|
-
};
|
|
110
|
-
}
|
|
111
|
-
|
|
112
|
-
/**
|
|
113
|
-
* Used by `_.deburr` to convert Latin-1 Supplement and Latin Extended-A
|
|
114
|
-
* letters to basic Latin letters.
|
|
115
|
-
*
|
|
116
|
-
* @private
|
|
117
|
-
* @param {string} letter The matched letter to deburr.
|
|
118
|
-
* @returns {string} Returns the deburred letter.
|
|
119
|
-
*/
|
|
120
|
-
var deburrLetter = basePropertyOf(deburredLetters);
|
|
121
|
-
|
|
122
|
-
/** Used for built-in method references. */
|
|
123
|
-
var objectProto = Object.prototype;
|
|
124
|
-
|
|
125
|
-
/**
|
|
126
|
-
* Used to resolve the
|
|
127
|
-
* [`toStringTag`](http://ecma-international.org/ecma-262/7.0/#sec-object.prototype.tostring)
|
|
128
|
-
* of values.
|
|
129
|
-
*/
|
|
130
|
-
var objectToString = objectProto.toString;
|
|
131
|
-
|
|
132
|
-
/** Built-in value references. */
|
|
133
|
-
var Symbol = root.Symbol;
|
|
134
|
-
|
|
135
|
-
/** Used to convert symbols to primitives and strings. */
|
|
136
|
-
var symbolProto = Symbol ? Symbol.prototype : undefined,
|
|
137
|
-
symbolToString = symbolProto ? symbolProto.toString : undefined;
|
|
138
|
-
|
|
139
|
-
/**
|
|
140
|
-
* The base implementation of `_.toString` which doesn't convert nullish
|
|
141
|
-
* values to empty strings.
|
|
142
|
-
*
|
|
143
|
-
* @private
|
|
144
|
-
* @param {*} value The value to process.
|
|
145
|
-
* @returns {string} Returns the string.
|
|
146
|
-
*/
|
|
147
|
-
function baseToString(value) {
|
|
148
|
-
// Exit early for strings to avoid a performance hit in some environments.
|
|
149
|
-
if (typeof value == 'string') {
|
|
150
|
-
return value;
|
|
151
|
-
}
|
|
152
|
-
if (isSymbol(value)) {
|
|
153
|
-
return symbolToString ? symbolToString.call(value) : '';
|
|
154
|
-
}
|
|
155
|
-
var result = (value + '');
|
|
156
|
-
return (result == '0' && (1 / value) == -INFINITY) ? '-0' : result;
|
|
157
|
-
}
|
|
158
|
-
|
|
159
|
-
/**
|
|
160
|
-
* Checks if `value` is object-like. A value is object-like if it's not `null`
|
|
161
|
-
* and has a `typeof` result of "object".
|
|
162
|
-
*
|
|
163
|
-
* @static
|
|
164
|
-
* @memberOf _
|
|
165
|
-
* @since 4.0.0
|
|
166
|
-
* @category Lang
|
|
167
|
-
* @param {*} value The value to check.
|
|
168
|
-
* @returns {boolean} Returns `true` if `value` is object-like, else `false`.
|
|
169
|
-
* @example
|
|
170
|
-
*
|
|
171
|
-
* _.isObjectLike({});
|
|
172
|
-
* // => true
|
|
173
|
-
*
|
|
174
|
-
* _.isObjectLike([1, 2, 3]);
|
|
175
|
-
* // => true
|
|
176
|
-
*
|
|
177
|
-
* _.isObjectLike(_.noop);
|
|
178
|
-
* // => false
|
|
179
|
-
*
|
|
180
|
-
* _.isObjectLike(null);
|
|
181
|
-
* // => false
|
|
182
|
-
*/
|
|
183
|
-
function isObjectLike(value) {
|
|
184
|
-
return !!value && typeof value == 'object';
|
|
185
|
-
}
|
|
186
|
-
|
|
187
|
-
/**
|
|
188
|
-
* Checks if `value` is classified as a `Symbol` primitive or object.
|
|
189
|
-
*
|
|
190
|
-
* @static
|
|
191
|
-
* @memberOf _
|
|
192
|
-
* @since 4.0.0
|
|
193
|
-
* @category Lang
|
|
194
|
-
* @param {*} value The value to check.
|
|
195
|
-
* @returns {boolean} Returns `true` if `value` is a symbol, else `false`.
|
|
196
|
-
* @example
|
|
197
|
-
*
|
|
198
|
-
* _.isSymbol(Symbol.iterator);
|
|
199
|
-
* // => true
|
|
200
|
-
*
|
|
201
|
-
* _.isSymbol('abc');
|
|
202
|
-
* // => false
|
|
203
|
-
*/
|
|
204
|
-
function isSymbol(value) {
|
|
205
|
-
return typeof value == 'symbol' ||
|
|
206
|
-
(isObjectLike(value) && objectToString.call(value) == symbolTag);
|
|
207
|
-
}
|
|
208
|
-
|
|
209
|
-
/**
|
|
210
|
-
* Converts `value` to a string. An empty string is returned for `null`
|
|
211
|
-
* and `undefined` values. The sign of `-0` is preserved.
|
|
212
|
-
*
|
|
213
|
-
* @static
|
|
214
|
-
* @memberOf _
|
|
215
|
-
* @since 4.0.0
|
|
216
|
-
* @category Lang
|
|
217
|
-
* @param {*} value The value to process.
|
|
218
|
-
* @returns {string} Returns the string.
|
|
219
|
-
* @example
|
|
220
|
-
*
|
|
221
|
-
* _.toString(null);
|
|
222
|
-
* // => ''
|
|
223
|
-
*
|
|
224
|
-
* _.toString(-0);
|
|
225
|
-
* // => '-0'
|
|
226
|
-
*
|
|
227
|
-
* _.toString([1, 2, 3]);
|
|
228
|
-
* // => '1,2,3'
|
|
229
|
-
*/
|
|
230
|
-
function toString(value) {
|
|
231
|
-
return value == null ? '' : baseToString(value);
|
|
232
|
-
}
|
|
233
|
-
|
|
234
|
-
/**
|
|
235
|
-
* Deburrs `string` by converting
|
|
236
|
-
* [Latin-1 Supplement](https://en.wikipedia.org/wiki/Latin-1_Supplement_(Unicode_block)#Character_table)
|
|
237
|
-
* and [Latin Extended-A](https://en.wikipedia.org/wiki/Latin_Extended-A)
|
|
238
|
-
* letters to basic Latin letters and removing
|
|
239
|
-
* [combining diacritical marks](https://en.wikipedia.org/wiki/Combining_Diacritical_Marks).
|
|
240
|
-
*
|
|
241
|
-
* @static
|
|
242
|
-
* @memberOf _
|
|
243
|
-
* @since 3.0.0
|
|
244
|
-
* @category String
|
|
245
|
-
* @param {string} [string=''] The string to deburr.
|
|
246
|
-
* @returns {string} Returns the deburred string.
|
|
247
|
-
* @example
|
|
248
|
-
*
|
|
249
|
-
* _.deburr('déjà vu');
|
|
250
|
-
* // => 'deja vu'
|
|
251
|
-
*/
|
|
252
|
-
export function deburr(string) {
|
|
253
|
-
string = toString(string);
|
|
254
|
-
return string && string.replace(reLatin, deburrLetter).replace(reComboMark, '');
|
|
255
|
-
}
|