@questwork/q-utilities 0.1.16 → 0.1.17
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/dist/index.min.cjs +34 -18
- package/dist/q-utilities.esm.js +34 -18
- package/dist/q-utilities.min.js +34 -18
- package/package.json +8 -8
package/dist/index.min.cjs
CHANGED
|
@@ -379,6 +379,9 @@ function getValueByKeys_getValueByKeys(keys, data) {
|
|
|
379
379
|
return getValueByKeys_getValueByKeys(_keys, _data[firstKey])
|
|
380
380
|
}
|
|
381
381
|
if (_data && firstKey) {
|
|
382
|
+
if (_keys.length > 0) {
|
|
383
|
+
return getValueByKeys_getValueByKeys(_keys, _data[firstKey])
|
|
384
|
+
}
|
|
382
385
|
return _data[firstKey]
|
|
383
386
|
}
|
|
384
387
|
return _data
|
|
@@ -1432,19 +1435,6 @@ function concatStringByArray(arrTemplate, data) {
|
|
|
1432
1435
|
return arrTemplate.reduce((acc, item) => {
|
|
1433
1436
|
const { type, value = '', restriction, template, format, showMinutes } = item
|
|
1434
1437
|
switch (type) {
|
|
1435
|
-
case('label'): {
|
|
1436
|
-
if (getValidation(restriction, data, getValueByKeys_getValueByKeys)) {
|
|
1437
|
-
acc += (value.toString())
|
|
1438
|
-
}
|
|
1439
|
-
break
|
|
1440
|
-
}
|
|
1441
|
-
case('value'): {
|
|
1442
|
-
if (getValidation(restriction, data, getValueByKeys_getValueByKeys)) {
|
|
1443
|
-
const _value = getValueByKeys_getValueByKeys(value.split('.'), data) || ''
|
|
1444
|
-
acc += (_value.toString())
|
|
1445
|
-
}
|
|
1446
|
-
break
|
|
1447
|
-
}
|
|
1448
1438
|
case('array'): {
|
|
1449
1439
|
if (getValidation(restriction, data, getValueByKeys_getValueByKeys)) {
|
|
1450
1440
|
const _value = getValueByKeys_getValueByKeys(value.split('.'), data) || []
|
|
@@ -1454,6 +1444,13 @@ function concatStringByArray(arrTemplate, data) {
|
|
|
1454
1444
|
}
|
|
1455
1445
|
break
|
|
1456
1446
|
}
|
|
1447
|
+
case ('date'): {
|
|
1448
|
+
if (getValidation(restriction, data, getValueByKeys_getValueByKeys)) {
|
|
1449
|
+
const _value = getValueByKeys_getValueByKeys(value.split('.'), data) || ''
|
|
1450
|
+
acc += (formatDate(_value, format).toString())
|
|
1451
|
+
}
|
|
1452
|
+
break
|
|
1453
|
+
}
|
|
1457
1454
|
case('ellipsis'): {
|
|
1458
1455
|
if (getValidation(restriction, data, getValueByKeys_getValueByKeys)) {
|
|
1459
1456
|
const { maxLength } = item
|
|
@@ -1466,10 +1463,15 @@ function concatStringByArray(arrTemplate, data) {
|
|
|
1466
1463
|
}
|
|
1467
1464
|
break
|
|
1468
1465
|
}
|
|
1469
|
-
case
|
|
1466
|
+
case('group'): {
|
|
1470
1467
|
if (getValidation(restriction, data, getValueByKeys_getValueByKeys)) {
|
|
1471
|
-
|
|
1472
|
-
|
|
1468
|
+
return concatStringByArray(value, data)
|
|
1469
|
+
}
|
|
1470
|
+
break
|
|
1471
|
+
}
|
|
1472
|
+
case('label'): {
|
|
1473
|
+
if (getValidation(restriction, data, getValueByKeys_getValueByKeys)) {
|
|
1474
|
+
acc += (value.toString())
|
|
1473
1475
|
}
|
|
1474
1476
|
break
|
|
1475
1477
|
}
|
|
@@ -1480,6 +1482,13 @@ function concatStringByArray(arrTemplate, data) {
|
|
|
1480
1482
|
}
|
|
1481
1483
|
break
|
|
1482
1484
|
}
|
|
1485
|
+
case('value'): {
|
|
1486
|
+
if (getValidation(restriction, data, getValueByKeys_getValueByKeys)) {
|
|
1487
|
+
const _value = getValueByKeys_getValueByKeys(value.split('.'), data) || ''
|
|
1488
|
+
acc += (_value.toString())
|
|
1489
|
+
}
|
|
1490
|
+
break
|
|
1491
|
+
}
|
|
1483
1492
|
}
|
|
1484
1493
|
return acc
|
|
1485
1494
|
}, '')
|
|
@@ -2433,6 +2442,7 @@ function sanitizeText(input, options = {}) {
|
|
|
2433
2442
|
normalizeWhitespace = true,
|
|
2434
2443
|
removeNewlines = false,
|
|
2435
2444
|
trim = true,
|
|
2445
|
+
preserveBasicWhitespace = true, // new option to keep tabs, newlines if removeNewlines=false
|
|
2436
2446
|
} = options
|
|
2437
2447
|
|
|
2438
2448
|
if (typeof input !== 'string') {
|
|
@@ -2441,8 +2451,14 @@ function sanitizeText(input, options = {}) {
|
|
|
2441
2451
|
|
|
2442
2452
|
let result = input
|
|
2443
2453
|
|
|
2444
|
-
// Phase 1: Remove
|
|
2445
|
-
|
|
2454
|
+
// Phase 1: Remove all control characters except basic whitespace if requested
|
|
2455
|
+
if (preserveBasicWhitespace && !removeNewlines) {
|
|
2456
|
+
// Keep tab (\t), newline (\n), carriage return (\r)
|
|
2457
|
+
result = result.replace(/[\x00-\x08\x0B\x0C\x0E-\x1F\x7F-\x9F\u200B-\u200D\uFEFF\u202A-\u202E]/g, '')
|
|
2458
|
+
} else {
|
|
2459
|
+
// Remove all control characters including basic whitespace
|
|
2460
|
+
result = result.replace(/[\x00-\x1F\x7F-\x9F\u200B-\u200D\uFEFF\u202A-\u202E]/g, '')
|
|
2461
|
+
}
|
|
2446
2462
|
|
|
2447
2463
|
// Phase 2: Handle whitespace transformations
|
|
2448
2464
|
if (removeNewlines) {
|
package/dist/q-utilities.esm.js
CHANGED
|
@@ -290,6 +290,9 @@ function getValueByKeys_getValueByKeys(keys, data) {
|
|
|
290
290
|
return getValueByKeys_getValueByKeys(_keys, _data[firstKey])
|
|
291
291
|
}
|
|
292
292
|
if (_data && firstKey) {
|
|
293
|
+
if (_keys.length > 0) {
|
|
294
|
+
return getValueByKeys_getValueByKeys(_keys, _data[firstKey])
|
|
295
|
+
}
|
|
293
296
|
return _data[firstKey]
|
|
294
297
|
}
|
|
295
298
|
return _data
|
|
@@ -1343,19 +1346,6 @@ function concatStringByArray(arrTemplate, data) {
|
|
|
1343
1346
|
return arrTemplate.reduce((acc, item) => {
|
|
1344
1347
|
const { type, value = '', restriction, template, format, showMinutes } = item
|
|
1345
1348
|
switch (type) {
|
|
1346
|
-
case('label'): {
|
|
1347
|
-
if (getValidation(restriction, data, getValueByKeys_getValueByKeys)) {
|
|
1348
|
-
acc += (value.toString())
|
|
1349
|
-
}
|
|
1350
|
-
break
|
|
1351
|
-
}
|
|
1352
|
-
case('value'): {
|
|
1353
|
-
if (getValidation(restriction, data, getValueByKeys_getValueByKeys)) {
|
|
1354
|
-
const _value = getValueByKeys_getValueByKeys(value.split('.'), data) || ''
|
|
1355
|
-
acc += (_value.toString())
|
|
1356
|
-
}
|
|
1357
|
-
break
|
|
1358
|
-
}
|
|
1359
1349
|
case('array'): {
|
|
1360
1350
|
if (getValidation(restriction, data, getValueByKeys_getValueByKeys)) {
|
|
1361
1351
|
const _value = getValueByKeys_getValueByKeys(value.split('.'), data) || []
|
|
@@ -1365,6 +1355,13 @@ function concatStringByArray(arrTemplate, data) {
|
|
|
1365
1355
|
}
|
|
1366
1356
|
break
|
|
1367
1357
|
}
|
|
1358
|
+
case ('date'): {
|
|
1359
|
+
if (getValidation(restriction, data, getValueByKeys_getValueByKeys)) {
|
|
1360
|
+
const _value = getValueByKeys_getValueByKeys(value.split('.'), data) || ''
|
|
1361
|
+
acc += (formatDate(_value, format).toString())
|
|
1362
|
+
}
|
|
1363
|
+
break
|
|
1364
|
+
}
|
|
1368
1365
|
case('ellipsis'): {
|
|
1369
1366
|
if (getValidation(restriction, data, getValueByKeys_getValueByKeys)) {
|
|
1370
1367
|
const { maxLength } = item
|
|
@@ -1377,10 +1374,15 @@ function concatStringByArray(arrTemplate, data) {
|
|
|
1377
1374
|
}
|
|
1378
1375
|
break
|
|
1379
1376
|
}
|
|
1380
|
-
case
|
|
1377
|
+
case('group'): {
|
|
1381
1378
|
if (getValidation(restriction, data, getValueByKeys_getValueByKeys)) {
|
|
1382
|
-
|
|
1383
|
-
|
|
1379
|
+
return concatStringByArray(value, data)
|
|
1380
|
+
}
|
|
1381
|
+
break
|
|
1382
|
+
}
|
|
1383
|
+
case('label'): {
|
|
1384
|
+
if (getValidation(restriction, data, getValueByKeys_getValueByKeys)) {
|
|
1385
|
+
acc += (value.toString())
|
|
1384
1386
|
}
|
|
1385
1387
|
break
|
|
1386
1388
|
}
|
|
@@ -1391,6 +1393,13 @@ function concatStringByArray(arrTemplate, data) {
|
|
|
1391
1393
|
}
|
|
1392
1394
|
break
|
|
1393
1395
|
}
|
|
1396
|
+
case('value'): {
|
|
1397
|
+
if (getValidation(restriction, data, getValueByKeys_getValueByKeys)) {
|
|
1398
|
+
const _value = getValueByKeys_getValueByKeys(value.split('.'), data) || ''
|
|
1399
|
+
acc += (_value.toString())
|
|
1400
|
+
}
|
|
1401
|
+
break
|
|
1402
|
+
}
|
|
1394
1403
|
}
|
|
1395
1404
|
return acc
|
|
1396
1405
|
}, '')
|
|
@@ -2344,6 +2353,7 @@ function sanitizeText(input, options = {}) {
|
|
|
2344
2353
|
normalizeWhitespace = true,
|
|
2345
2354
|
removeNewlines = false,
|
|
2346
2355
|
trim = true,
|
|
2356
|
+
preserveBasicWhitespace = true, // new option to keep tabs, newlines if removeNewlines=false
|
|
2347
2357
|
} = options
|
|
2348
2358
|
|
|
2349
2359
|
if (typeof input !== 'string') {
|
|
@@ -2352,8 +2362,14 @@ function sanitizeText(input, options = {}) {
|
|
|
2352
2362
|
|
|
2353
2363
|
let result = input
|
|
2354
2364
|
|
|
2355
|
-
// Phase 1: Remove
|
|
2356
|
-
|
|
2365
|
+
// Phase 1: Remove all control characters except basic whitespace if requested
|
|
2366
|
+
if (preserveBasicWhitespace && !removeNewlines) {
|
|
2367
|
+
// Keep tab (\t), newline (\n), carriage return (\r)
|
|
2368
|
+
result = result.replace(/[\x00-\x08\x0B\x0C\x0E-\x1F\x7F-\x9F\u200B-\u200D\uFEFF\u202A-\u202E]/g, '')
|
|
2369
|
+
} else {
|
|
2370
|
+
// Remove all control characters including basic whitespace
|
|
2371
|
+
result = result.replace(/[\x00-\x1F\x7F-\x9F\u200B-\u200D\uFEFF\u202A-\u202E]/g, '')
|
|
2372
|
+
}
|
|
2357
2373
|
|
|
2358
2374
|
// Phase 2: Handle whitespace transformations
|
|
2359
2375
|
if (removeNewlines) {
|
package/dist/q-utilities.min.js
CHANGED
|
@@ -378,6 +378,9 @@ function getValueByKeys_getValueByKeys(keys, data) {
|
|
|
378
378
|
return getValueByKeys_getValueByKeys(_keys, _data[firstKey])
|
|
379
379
|
}
|
|
380
380
|
if (_data && firstKey) {
|
|
381
|
+
if (_keys.length > 0) {
|
|
382
|
+
return getValueByKeys_getValueByKeys(_keys, _data[firstKey])
|
|
383
|
+
}
|
|
381
384
|
return _data[firstKey]
|
|
382
385
|
}
|
|
383
386
|
return _data
|
|
@@ -1431,19 +1434,6 @@ function concatStringByArray(arrTemplate, data) {
|
|
|
1431
1434
|
return arrTemplate.reduce((acc, item) => {
|
|
1432
1435
|
const { type, value = '', restriction, template, format, showMinutes } = item
|
|
1433
1436
|
switch (type) {
|
|
1434
|
-
case('label'): {
|
|
1435
|
-
if (getValidation(restriction, data, getValueByKeys_getValueByKeys)) {
|
|
1436
|
-
acc += (value.toString())
|
|
1437
|
-
}
|
|
1438
|
-
break
|
|
1439
|
-
}
|
|
1440
|
-
case('value'): {
|
|
1441
|
-
if (getValidation(restriction, data, getValueByKeys_getValueByKeys)) {
|
|
1442
|
-
const _value = getValueByKeys_getValueByKeys(value.split('.'), data) || ''
|
|
1443
|
-
acc += (_value.toString())
|
|
1444
|
-
}
|
|
1445
|
-
break
|
|
1446
|
-
}
|
|
1447
1437
|
case('array'): {
|
|
1448
1438
|
if (getValidation(restriction, data, getValueByKeys_getValueByKeys)) {
|
|
1449
1439
|
const _value = getValueByKeys_getValueByKeys(value.split('.'), data) || []
|
|
@@ -1453,6 +1443,13 @@ function concatStringByArray(arrTemplate, data) {
|
|
|
1453
1443
|
}
|
|
1454
1444
|
break
|
|
1455
1445
|
}
|
|
1446
|
+
case ('date'): {
|
|
1447
|
+
if (getValidation(restriction, data, getValueByKeys_getValueByKeys)) {
|
|
1448
|
+
const _value = getValueByKeys_getValueByKeys(value.split('.'), data) || ''
|
|
1449
|
+
acc += (formatDate(_value, format).toString())
|
|
1450
|
+
}
|
|
1451
|
+
break
|
|
1452
|
+
}
|
|
1456
1453
|
case('ellipsis'): {
|
|
1457
1454
|
if (getValidation(restriction, data, getValueByKeys_getValueByKeys)) {
|
|
1458
1455
|
const { maxLength } = item
|
|
@@ -1465,10 +1462,15 @@ function concatStringByArray(arrTemplate, data) {
|
|
|
1465
1462
|
}
|
|
1466
1463
|
break
|
|
1467
1464
|
}
|
|
1468
|
-
case
|
|
1465
|
+
case('group'): {
|
|
1469
1466
|
if (getValidation(restriction, data, getValueByKeys_getValueByKeys)) {
|
|
1470
|
-
|
|
1471
|
-
|
|
1467
|
+
return concatStringByArray(value, data)
|
|
1468
|
+
}
|
|
1469
|
+
break
|
|
1470
|
+
}
|
|
1471
|
+
case('label'): {
|
|
1472
|
+
if (getValidation(restriction, data, getValueByKeys_getValueByKeys)) {
|
|
1473
|
+
acc += (value.toString())
|
|
1472
1474
|
}
|
|
1473
1475
|
break
|
|
1474
1476
|
}
|
|
@@ -1479,6 +1481,13 @@ function concatStringByArray(arrTemplate, data) {
|
|
|
1479
1481
|
}
|
|
1480
1482
|
break
|
|
1481
1483
|
}
|
|
1484
|
+
case('value'): {
|
|
1485
|
+
if (getValidation(restriction, data, getValueByKeys_getValueByKeys)) {
|
|
1486
|
+
const _value = getValueByKeys_getValueByKeys(value.split('.'), data) || ''
|
|
1487
|
+
acc += (_value.toString())
|
|
1488
|
+
}
|
|
1489
|
+
break
|
|
1490
|
+
}
|
|
1482
1491
|
}
|
|
1483
1492
|
return acc
|
|
1484
1493
|
}, '')
|
|
@@ -2432,6 +2441,7 @@ function sanitizeText(input, options = {}) {
|
|
|
2432
2441
|
normalizeWhitespace = true,
|
|
2433
2442
|
removeNewlines = false,
|
|
2434
2443
|
trim = true,
|
|
2444
|
+
preserveBasicWhitespace = true, // new option to keep tabs, newlines if removeNewlines=false
|
|
2435
2445
|
} = options
|
|
2436
2446
|
|
|
2437
2447
|
if (typeof input !== 'string') {
|
|
@@ -2440,8 +2450,14 @@ function sanitizeText(input, options = {}) {
|
|
|
2440
2450
|
|
|
2441
2451
|
let result = input
|
|
2442
2452
|
|
|
2443
|
-
// Phase 1: Remove
|
|
2444
|
-
|
|
2453
|
+
// Phase 1: Remove all control characters except basic whitespace if requested
|
|
2454
|
+
if (preserveBasicWhitespace && !removeNewlines) {
|
|
2455
|
+
// Keep tab (\t), newline (\n), carriage return (\r)
|
|
2456
|
+
result = result.replace(/[\x00-\x08\x0B\x0C\x0E-\x1F\x7F-\x9F\u200B-\u200D\uFEFF\u202A-\u202E]/g, '')
|
|
2457
|
+
} else {
|
|
2458
|
+
// Remove all control characters including basic whitespace
|
|
2459
|
+
result = result.replace(/[\x00-\x1F\x7F-\x9F\u200B-\u200D\uFEFF\u202A-\u202E]/g, '')
|
|
2460
|
+
}
|
|
2445
2461
|
|
|
2446
2462
|
// Phase 2: Handle whitespace transformations
|
|
2447
2463
|
if (removeNewlines) {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@questwork/q-utilities",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.17",
|
|
4
4
|
"description": "Questwork QUtilities",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"exports": {
|
|
@@ -10,12 +10,6 @@
|
|
|
10
10
|
"default": "./dist/q-utilities.min.js"
|
|
11
11
|
}
|
|
12
12
|
},
|
|
13
|
-
"scripts": {
|
|
14
|
-
"build": "cross-env NODE_ENV=production minimize=false gulp",
|
|
15
|
-
"build:wp": "cross-env NODE_ENV=production minimize=false gulp wp",
|
|
16
|
-
"lint": "eslint .",
|
|
17
|
-
"test:models": "NODE_ENV=test mocha --exit 'lib/models/test.setup.js' 'lib/models/**/*.spec.js'"
|
|
18
|
-
},
|
|
19
13
|
"author": {
|
|
20
14
|
"name": "Questwork Consulting Limited",
|
|
21
15
|
"email": "info@questwork.com",
|
|
@@ -45,5 +39,11 @@
|
|
|
45
39
|
},
|
|
46
40
|
"engines": {
|
|
47
41
|
"node": ">=10.0.0"
|
|
42
|
+
},
|
|
43
|
+
"scripts": {
|
|
44
|
+
"build": "cross-env NODE_ENV=production minimize=false gulp",
|
|
45
|
+
"build:wp": "cross-env NODE_ENV=production minimize=false gulp wp",
|
|
46
|
+
"lint": "eslint .",
|
|
47
|
+
"test:models": "NODE_ENV=test mocha --exit 'lib/models/test.setup.js' 'lib/models/**/*.spec.js'"
|
|
48
48
|
}
|
|
49
|
-
}
|
|
49
|
+
}
|