@dataloop-ai/components 0.20.150 → 0.20.152
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
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@dataloop-ai/components",
|
|
3
|
-
"version": "0.20.
|
|
3
|
+
"version": "0.20.152",
|
|
4
4
|
"exports": {
|
|
5
5
|
".": "./index.ts",
|
|
6
6
|
"./models": "./models.ts",
|
|
@@ -23,7 +23,7 @@
|
|
|
23
23
|
"check-only": "if grep -E -H -r --exclude-dir=.git --exclude-dir=node_modules --exclude=*.json --exclude=*.yml '^(describe|it).only' .; then echo 'Found only in test files' && exit 1; fi"
|
|
24
24
|
},
|
|
25
25
|
"dependencies": {
|
|
26
|
-
"@dataloop-ai/icons": "^3.1.
|
|
26
|
+
"@dataloop-ai/icons": "^3.1.29",
|
|
27
27
|
"@types/flat": "^5.0.2",
|
|
28
28
|
"@types/lodash": "^4.14.184",
|
|
29
29
|
"@types/sortablejs": "^1.15.7",
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import Tokenizr from
|
|
1
|
+
import Tokenizr from 'tokenizr/src/tokenizr.js'
|
|
2
2
|
|
|
3
3
|
export enum TokenType {
|
|
4
4
|
NUMBER = 'number',
|
|
@@ -18,35 +18,44 @@ enum Tags {
|
|
|
18
18
|
HAD_VALUE = 'had-value'
|
|
19
19
|
}
|
|
20
20
|
|
|
21
|
-
|
|
21
|
+
const tokenizer = new Tokenizr()
|
|
22
22
|
|
|
23
23
|
tokenizer.rule(/[+-]?[0-9\.]+/, (ctx, match) => {
|
|
24
24
|
ctx.accept(TokenType.NUMBER, parseFloat(match[0])).tag(Tags.HAD_VALUE)
|
|
25
25
|
})
|
|
26
26
|
|
|
27
|
-
tokenizer.rule(
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
27
|
+
tokenizer.rule(
|
|
28
|
+
/\((\d{2}\/\d{2}\/\d{4}[\)']?\s?|\s?DD\/MM\/YYYY)\s?(\d{2}:\d{2}:\d{2}|\s?HH:mm:ss)?\)/,
|
|
29
|
+
(ctx, match) => {
|
|
30
|
+
ctx.accept(TokenType.DATETIME, parseFloat(match[0])).tag(Tags.HAD_VALUE)
|
|
31
|
+
}
|
|
32
|
+
)
|
|
31
33
|
;[
|
|
32
|
-
/<=?/,
|
|
34
|
+
/<=?/,
|
|
35
|
+
/>=?/,
|
|
36
|
+
/!=?/,
|
|
37
|
+
/=/,
|
|
33
38
|
/in?(?![^\s'"])/i,
|
|
34
39
|
/n(o(t(-(in?)?)?)?)?(?![^\s'"])/i,
|
|
35
40
|
/e(x(i(s(ts?)?)?)?)?(?!\S)/i,
|
|
36
41
|
/d(o(e(s(n(t(-(e(x(i(st?)?)?)?)?)?)?)?)?)?)?(?!\S)/i
|
|
37
|
-
].forEach(
|
|
38
|
-
|
|
39
|
-
ctx.
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
}
|
|
42
|
+
].forEach((re) =>
|
|
43
|
+
tokenizer.rule(re, (ctx, match) => {
|
|
44
|
+
if (!ctx.tagged(Tags.HAD_FIELD) && /^[a-z]/i.test(match[0])) {
|
|
45
|
+
ctx.accept(TokenType.FIELD).tag(Tags.HAD_FIELD)
|
|
46
|
+
} else {
|
|
47
|
+
ctx.accept(TokenType.OPERATOR, match[0].toUpperCase())
|
|
48
|
+
}
|
|
49
|
+
})
|
|
50
|
+
)
|
|
44
51
|
|
|
45
52
|
tokenizer.rule(/[a-z][a-z\.\d\-_]*/i, (ctx, match) => {
|
|
46
53
|
const upper = match[0].toUpperCase()
|
|
47
54
|
if (ctx.tagged(Tags.HAD_VALUE)) {
|
|
48
55
|
// we just had a value - it would be followed by AND or OR
|
|
49
|
-
ctx.untag(Tags.HAD_FIELD)
|
|
56
|
+
ctx.untag(Tags.HAD_FIELD)
|
|
57
|
+
.untag(Tags.HAD_VALUE)
|
|
58
|
+
.accept(TokenType.LOGICAL, upper)
|
|
50
59
|
} else if (ctx.tagged(Tags.HAD_FIELD)) {
|
|
51
60
|
// we had a field but no value yet - this must be either a boolean or an unquoted string
|
|
52
61
|
if (['TRUE', 'FALSE'].includes(upper)) {
|
|
@@ -65,16 +74,22 @@ tokenizer.rule(/,/, (ctx) => {
|
|
|
65
74
|
})
|
|
66
75
|
|
|
67
76
|
tokenizer.rule(/(?<!\\)"(.*?)(?<!\\)"/, (ctx, match) => {
|
|
68
|
-
ctx.accept(TokenType.STRING, match[1].replace(/\\"/g, '"')).tag(
|
|
77
|
+
ctx.accept(TokenType.STRING, match[1].replace(/\\"/g, '"')).tag(
|
|
78
|
+
Tags.HAD_VALUE
|
|
79
|
+
)
|
|
69
80
|
})
|
|
70
81
|
|
|
71
82
|
tokenizer.rule(/(?<!\\)'(.*?)(?<!\\)'/, (ctx, match) => {
|
|
72
|
-
ctx.accept(TokenType.STRING, match[1].replace(/\\'/g, "'")).tag(
|
|
83
|
+
ctx.accept(TokenType.STRING, match[1].replace(/\\'/g, "'")).tag(
|
|
84
|
+
Tags.HAD_VALUE
|
|
85
|
+
)
|
|
73
86
|
})
|
|
74
87
|
|
|
75
88
|
tokenizer.rule(/(?<!\\)['"](.*)/, (ctx, match) => {
|
|
76
89
|
// partial string
|
|
77
|
-
ctx.accept(TokenType.PARTIAL_VALUE, match[1].replace(/\\'/g, "'")).tag(
|
|
90
|
+
ctx.accept(TokenType.PARTIAL_VALUE, match[1].replace(/\\'/g, "'")).tag(
|
|
91
|
+
Tags.HAD_VALUE
|
|
92
|
+
)
|
|
78
93
|
})
|
|
79
94
|
|
|
80
95
|
tokenizer.rule(/\s+/, (ctx) => {
|
|
@@ -94,16 +109,16 @@ export function tokenize(input: string) {
|
|
|
94
109
|
|
|
95
110
|
export function splitByQuotes(input: string, ignore?: string) {
|
|
96
111
|
const parts = tokenize(input)
|
|
97
|
-
.filter(token => token.type !== 'whitespace')
|
|
98
|
-
.map(token => token.text)
|
|
112
|
+
.filter((token) => token.type !== 'whitespace')
|
|
113
|
+
.map((token) => token.text)
|
|
99
114
|
.map((text, index, array) => {
|
|
100
|
-
if(array[index + 1] === ',') {
|
|
115
|
+
if (array[index + 1] === ',') {
|
|
101
116
|
return text + ','
|
|
102
117
|
} else {
|
|
103
118
|
return text === ',' ? '' : text
|
|
104
119
|
}
|
|
105
120
|
})
|
|
106
|
-
.filter(text => text !== '')
|
|
121
|
+
.filter((text) => text !== '')
|
|
107
122
|
|
|
108
123
|
if (/\s$/.test(input)) {
|
|
109
124
|
parts.push('')
|