@vuu-ui/vuu-table-extras 0.7.2-debug → 0.7.2
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/cjs/index.js +1 -2861
- package/cjs/index.js.map +2 -2
- package/esm/index.js +1 -2896
- package/esm/index.js.map +2 -2
- package/index.css +1 -537
- package/index.css.map +1 -1
- package/package.json +8 -8
package/esm/index.js
CHANGED
|
@@ -1,2897 +1,2 @@
|
|
|
1
|
-
var __accessCheck = (obj, member, msg) => {
|
|
2
|
-
if (!member.has(obj))
|
|
3
|
-
throw TypeError("Cannot " + msg);
|
|
4
|
-
};
|
|
5
|
-
var __privateGet = (obj, member, getter) => {
|
|
6
|
-
__accessCheck(obj, member, "read from private field");
|
|
7
|
-
return getter ? getter.call(obj) : member.get(obj);
|
|
8
|
-
};
|
|
9
|
-
var __privateAdd = (obj, member, value) => {
|
|
10
|
-
if (member.has(obj))
|
|
11
|
-
throw TypeError("Cannot add the same private member more than once");
|
|
12
|
-
member instanceof WeakSet ? member.add(obj) : member.set(obj, value);
|
|
13
|
-
};
|
|
14
|
-
var __privateSet = (obj, member, value, setter) => {
|
|
15
|
-
__accessCheck(obj, member, "write to private field");
|
|
16
|
-
setter ? setter.call(obj, value) : member.set(obj, value);
|
|
17
|
-
return value;
|
|
18
|
-
};
|
|
19
|
-
|
|
20
|
-
// src/cell-renderers/background-cell/BackgroundCell.tsx
|
|
21
|
-
import {
|
|
22
|
-
DOWN1,
|
|
23
|
-
DOWN2,
|
|
24
|
-
isTypeDescriptor as isTypeDescriptor2,
|
|
25
|
-
metadataKeys,
|
|
26
|
-
registerComponent,
|
|
27
|
-
UP1,
|
|
28
|
-
UP2
|
|
29
|
-
} from "@vuu-ui/vuu-utils";
|
|
30
|
-
import cx from "classnames";
|
|
31
|
-
|
|
32
|
-
// src/cell-renderers/background-cell/useDirection.ts
|
|
33
|
-
import { useEffect, useRef } from "react";
|
|
34
|
-
import { isTypeDescriptor } from "@vuu-ui/vuu-utils";
|
|
35
|
-
import {
|
|
36
|
-
getMovingValueDirection,
|
|
37
|
-
isValidNumber
|
|
38
|
-
} from "@vuu-ui/vuu-utils";
|
|
39
|
-
var INITIAL_VALUE = [void 0, void 0, void 0, void 0];
|
|
40
|
-
function useDirection(key, value, column) {
|
|
41
|
-
var _a;
|
|
42
|
-
const ref = useRef();
|
|
43
|
-
const [prevKey, prevValue, prevColumn, prevDirection] = ref.current || INITIAL_VALUE;
|
|
44
|
-
const { type: dataType } = column;
|
|
45
|
-
const decimals = isTypeDescriptor(dataType) ? (_a = dataType.formatting) == null ? void 0 : _a.decimals : void 0;
|
|
46
|
-
const direction = key === prevKey && isValidNumber(value) && isValidNumber(prevValue) && column === prevColumn ? getMovingValueDirection(value, prevDirection, prevValue, decimals) : "";
|
|
47
|
-
useEffect(() => {
|
|
48
|
-
ref.current = [key, value, column, direction];
|
|
49
|
-
});
|
|
50
|
-
return direction;
|
|
51
|
-
}
|
|
52
|
-
|
|
53
|
-
// src/cell-renderers/background-cell/BackgroundCell.tsx
|
|
54
|
-
import { jsx, jsxs } from "react/jsx-runtime";
|
|
55
|
-
var CHAR_ARROW_UP = String.fromCharCode(11014);
|
|
56
|
-
var CHAR_ARROW_DOWN = String.fromCharCode(11015);
|
|
57
|
-
var { KEY } = metadataKeys;
|
|
58
|
-
var classBase = "vuuBackgroundCell";
|
|
59
|
-
var FlashStyle = {
|
|
60
|
-
ArrowOnly: "arrow",
|
|
61
|
-
BackgroundOnly: "bg-only",
|
|
62
|
-
ArrowBackground: "arrow-bg"
|
|
63
|
-
};
|
|
64
|
-
var getFlashStyle = (colType) => {
|
|
65
|
-
if (isTypeDescriptor2(colType) && colType.renderer) {
|
|
66
|
-
if ("flashStyle" in colType.renderer) {
|
|
67
|
-
return colType.renderer["flashStyle"];
|
|
68
|
-
}
|
|
69
|
-
}
|
|
70
|
-
return FlashStyle.BackgroundOnly;
|
|
71
|
-
};
|
|
72
|
-
var BackgroundCell = ({ column, row }) => {
|
|
73
|
-
const { key, type, valueFormatter } = column;
|
|
74
|
-
const value = row[key];
|
|
75
|
-
const flashStyle = getFlashStyle(type);
|
|
76
|
-
const direction = useDirection(row[KEY], value, column);
|
|
77
|
-
const arrow = flashStyle === FlashStyle.ArrowOnly || flashStyle === FlashStyle.ArrowBackground ? direction === UP1 || direction === UP2 ? CHAR_ARROW_UP : direction === DOWN1 || direction === DOWN2 ? CHAR_ARROW_DOWN : null : null;
|
|
78
|
-
const dirClass = direction ? ` ` + direction : "";
|
|
79
|
-
const className = cx(classBase, dirClass, {
|
|
80
|
-
[`${classBase}-arrowOnly`]: flashStyle === FlashStyle.ArrowOnly,
|
|
81
|
-
[`${classBase}-arrowBackground`]: flashStyle === FlashStyle.ArrowBackground
|
|
82
|
-
});
|
|
83
|
-
return /* @__PURE__ */ jsxs("div", { className, tabIndex: -1, children: [
|
|
84
|
-
/* @__PURE__ */ jsx("div", { className: `${classBase}-flasher`, children: arrow }),
|
|
85
|
-
valueFormatter(row[column.key])
|
|
86
|
-
] });
|
|
87
|
-
};
|
|
88
|
-
registerComponent("background", BackgroundCell, "cell-renderer", {
|
|
89
|
-
serverDataType: ["long", "int", "double"]
|
|
90
|
-
});
|
|
91
|
-
|
|
92
|
-
// src/cell-renderers/progress-cell/ProgressCell.tsx
|
|
93
|
-
import {
|
|
94
|
-
isColumnTypeRenderer,
|
|
95
|
-
isTypeDescriptor as isTypeDescriptor3,
|
|
96
|
-
registerComponent as registerComponent2
|
|
97
|
-
} from "@vuu-ui/vuu-utils";
|
|
98
|
-
import cx2 from "classnames";
|
|
99
|
-
import { jsx as jsx2, jsxs as jsxs2 } from "react/jsx-runtime";
|
|
100
|
-
var classBase2 = "vuuProgressCell";
|
|
101
|
-
var ProgressCell = ({ column, columnMap, row }) => {
|
|
102
|
-
const { type } = column;
|
|
103
|
-
const value = row[column.key];
|
|
104
|
-
let showProgress = false;
|
|
105
|
-
let percentage = 0;
|
|
106
|
-
if (isTypeDescriptor3(type) && isColumnTypeRenderer(type.renderer)) {
|
|
107
|
-
const { associatedField } = type.renderer;
|
|
108
|
-
const associatedValue = row[columnMap[associatedField]];
|
|
109
|
-
if (typeof value === "number" && typeof associatedValue === "number") {
|
|
110
|
-
percentage = Math.min(Math.round(value / associatedValue * 100), 100);
|
|
111
|
-
showProgress = isFinite(percentage);
|
|
112
|
-
} else {
|
|
113
|
-
const floatValue = parseFloat(value);
|
|
114
|
-
if (Number.isFinite(floatValue)) {
|
|
115
|
-
const floatOtherValue = parseFloat(associatedValue);
|
|
116
|
-
if (Number.isFinite(floatOtherValue)) {
|
|
117
|
-
percentage = Math.min(
|
|
118
|
-
Math.round(floatValue / floatOtherValue * 100),
|
|
119
|
-
100
|
|
120
|
-
);
|
|
121
|
-
showProgress = isFinite(percentage);
|
|
122
|
-
}
|
|
123
|
-
}
|
|
124
|
-
}
|
|
125
|
-
}
|
|
126
|
-
const className = cx2(classBase2, {});
|
|
127
|
-
return /* @__PURE__ */ jsxs2("div", { className, tabIndex: -1, children: [
|
|
128
|
-
showProgress ? /* @__PURE__ */ jsxs2("span", { className: `${classBase2}-track`, children: [
|
|
129
|
-
/* @__PURE__ */ jsx2("span", { className: `${classBase2}-bg` }),
|
|
130
|
-
/* @__PURE__ */ jsx2(
|
|
131
|
-
"span",
|
|
132
|
-
{
|
|
133
|
-
className: `${classBase2}-bar`,
|
|
134
|
-
style: { "--progress-bar-pct": `-${100 - percentage}%` }
|
|
135
|
-
}
|
|
136
|
-
)
|
|
137
|
-
] }) : null,
|
|
138
|
-
/* @__PURE__ */ jsx2("span", { className: `${classBase2}-text`, children: `${percentage} %` })
|
|
139
|
-
] });
|
|
140
|
-
};
|
|
141
|
-
registerComponent2("vuu.progress", ProgressCell, "cell-renderer", {
|
|
142
|
-
serverDataType: ["long", "int", "double"]
|
|
143
|
-
});
|
|
144
|
-
|
|
145
|
-
// src/column-expression-input/useColumnExpressionEditor.ts
|
|
146
|
-
import {
|
|
147
|
-
autocompletion,
|
|
148
|
-
defaultKeymap,
|
|
149
|
-
EditorState as EditorState2,
|
|
150
|
-
EditorView as EditorView2,
|
|
151
|
-
ensureSyntaxTree,
|
|
152
|
-
keymap,
|
|
153
|
-
minimalSetup,
|
|
154
|
-
startCompletion
|
|
155
|
-
} from "@vuu-ui/vuu-codemirror";
|
|
156
|
-
import { createEl } from "@vuu-ui/vuu-utils";
|
|
157
|
-
import { useEffect as useEffect2, useMemo, useRef as useRef2 } from "react";
|
|
158
|
-
|
|
159
|
-
// src/column-expression-input/column-language-parser/ColumnExpressionLanguage.ts
|
|
160
|
-
import {
|
|
161
|
-
LanguageSupport,
|
|
162
|
-
LRLanguage,
|
|
163
|
-
styleTags,
|
|
164
|
-
tags as tag
|
|
165
|
-
} from "@vuu-ui/vuu-codemirror";
|
|
166
|
-
|
|
167
|
-
// src/column-expression-input/column-language-parser/generated/column-parser.js
|
|
168
|
-
import { LRParser } from "@lezer/lr";
|
|
169
|
-
var parser = LRParser.deserialize({
|
|
170
|
-
version: 14,
|
|
171
|
-
states: "&fOVQPOOO!SQPO'#C^OVQPO'#CcQ!pQPOOO#OQPO'#CkO#TQPO'#CrOOQO'#Cy'#CyO#YQPO,58}OVQPO,59QOVQPO,59QOVQPO,59VOVQPO'#CtOOQO,59^,59^OOQO1G.i1G.iOOQO1G.l1G.lO#kQPO1G.lO$fQPO'#CmO%WQQO1G.qOOQO'#C{'#C{O%cQPO,59`OOQO'#Cn'#CnO%wQPO,59XOVQPO,59ZOVQPO,59[OVQPO7+$]OVQPO'#CuO&`QPO1G.zOOQO1G.z1G.zO&hQQO'#C^O&rQQO1G.sO'ZQQO1G.uOOQO1G.v1G.vO'fQPO<<GwO'wQPO,59aOOQO-E6s-E6sOOQO7+$f7+$fOVQPOAN=cO(]QQO1G.lO(tQPOG22}OOQOLD(iLD(iO%wQPO,59QO%wQPO,59Q",
|
|
172
|
-
stateData: ")[~OlOS~ORUOSUOTUOUUOWQO`SOnPO~OWgXZQX[QX]QX^QXeQX~OjQXXQXpQXqQXrQXsQXtQXuQX~PnOZWO[WO]XO^XO~OWYO~OWZO~OX]OZWO[WO]XO^XO~OZWO[WO]Yi^YijYiXYipYiqYirYisYitYiuYieYi~OZWO[WO]XO^XOpdOqdOrdOsdOtdOudO~OehOvfOwgO~OXkOZWO[WO]XO^XOeiO~ORUOSUOTUOUUOWQO`SOnlO~OXsOeiO~OvQXwQX~PnOZxO[xO]yO^yOeaivaiwai~OwgOecivci~OZWO[WO]XO^XOetO~OZWO[WO]XO^XOXiaeia~OZxO[xO]Yi^YieYivYiwYi~OXwOZWO[WO]XO^XO~O`UTn~",
|
|
173
|
-
goto: "#spPPqPPPPqPPqPPPPqP!R!W!R!RPq!Z!k!nPPP!tP#jmUOQWXYZefghitxyVbYfgRe`mTOQWXYZefghitxyR[TQjcRrjQROQVQS^WxQ_XU`YfgQcZQmeQphQqiQuyRvtQaYQnfRog",
|
|
174
|
-
nodeNames: "\u26A0 ColumnDefinitionExpression Column Number String True False ParenthesizedExpression OpenBrace CloseBrace ArithmeticExpression Divide Times Plus Minus ConditionalExpression If RelationalExpression RelationalOperator AndCondition OrCondition Comma CallExpression Function ArgList",
|
|
175
|
-
maxTerm: 39,
|
|
176
|
-
skippedNodes: [0],
|
|
177
|
-
repeatNodeCount: 1,
|
|
178
|
-
tokenData: ".^~RnXY#PYZ#P]^#Ppq#Pqr#brs#mxy$eyz$jz{$o{|$t|}$y}!O%O!O!P%T!P!Q%c!Q![%h!^!_%s!_!`&Q!`!a&V!c!}&d#R#S&d#T#U&u#U#Y&d#Y#Z(Y#Z#]&d#]#^*j#^#c&d#c#d+f#d#h&d#h#i,b#i#o&d~#USl~XY#PYZ#P]^#Ppq#P~#eP!_!`#h~#mOu~~#pWOX#mZ]#m^r#mrs$Ys#O#m#P;'S#m;'S;=`$_<%lO#m~$_OS~~$bP;=`<%l#m~$jOW~~$oOX~~$tO[~~$yO]~~%OOe~~%TO^~~%WP!Q![%Z~%`PR~!Q![%Z~%hOZ~~%mQR~!O!P%Z!Q![%h~%xPr~!_!`%{~&QOt~~&VOp~~&[Pq~!_!`&_~&dOs~P&iSnP!Q![&d!c!}&d#R#S&d#T#o&dR&zUnP!Q![&d!c!}&d#R#S&d#T#b&d#b#c'^#c#o&dR'cUnP!Q![&d!c!}&d#R#S&d#T#W&d#W#X'u#X#o&dR'|SvQnP!Q![&d!c!}&d#R#S&d#T#o&d~(_TnP!Q![&d!c!}&d#R#S&d#T#U(n#U#o&d~(sUnP!Q![&d!c!}&d#R#S&d#T#`&d#`#a)V#a#o&d~)[UnP!Q![&d!c!}&d#R#S&d#T#g&d#g#h)n#h#o&d~)sUnP!Q![&d!c!}&d#R#S&d#T#X&d#X#Y*V#Y#o&d~*^SU~nP!Q![&d!c!}&d#R#S&d#T#o&d~*oUnP!Q![&d!c!}&d#R#S&d#T#Y&d#Y#Z+R#Z#o&d~+YS`~nP!Q![&d!c!}&d#R#S&d#T#o&dR+kUnP!Q![&d!c!}&d#R#S&d#T#f&d#f#g+}#g#o&dR,USwQnP!Q![&d!c!}&d#R#S&d#T#o&d~,gUnP!Q![&d!c!}&d#R#S&d#T#f&d#f#g,y#g#o&d~-OUnP!Q![&d!c!}&d#R#S&d#T#i&d#i#j-b#j#o&d~-gUnP!Q![&d!c!}&d#R#S&d#T#X&d#X#Y-y#Y#o&d~.QST~nP!Q![&d!c!}&d#R#S&d#T#o&d",
|
|
179
|
-
tokenizers: [0, 1],
|
|
180
|
-
topRules: { "ColumnDefinitionExpression": [0, 1] },
|
|
181
|
-
tokenPrec: 375
|
|
182
|
-
});
|
|
183
|
-
|
|
184
|
-
// src/column-expression-input/column-language-parser/ColumnExpressionLanguage.ts
|
|
185
|
-
var columnExpressionLanguage = LRLanguage.define({
|
|
186
|
-
name: "VuuColumnExpression",
|
|
187
|
-
parser: parser.configure({
|
|
188
|
-
props: [
|
|
189
|
-
styleTags({
|
|
190
|
-
Function: tag.variableName,
|
|
191
|
-
String: tag.string,
|
|
192
|
-
Or: tag.emphasis,
|
|
193
|
-
Operator: tag.operator
|
|
194
|
-
})
|
|
195
|
-
]
|
|
196
|
-
})
|
|
197
|
-
});
|
|
198
|
-
var columnExpressionLanguageSupport = () => {
|
|
199
|
-
return new LanguageSupport(
|
|
200
|
-
columnExpressionLanguage
|
|
201
|
-
/*, [exampleCompletion]*/
|
|
202
|
-
);
|
|
203
|
-
};
|
|
204
|
-
|
|
205
|
-
// src/column-expression-input/column-language-parser/ColumnExpressionTreeWalker.ts
|
|
206
|
-
var LiteralExpressionImpl = class {
|
|
207
|
-
constructor(value) {
|
|
208
|
-
this.value = value;
|
|
209
|
-
switch (typeof value) {
|
|
210
|
-
case "boolean":
|
|
211
|
-
this.type = "booleanLiteralExpression";
|
|
212
|
-
break;
|
|
213
|
-
case "number":
|
|
214
|
-
this.type = "numericLiteralExpression";
|
|
215
|
-
break;
|
|
216
|
-
default:
|
|
217
|
-
this.type = "stringLiteralExpression";
|
|
218
|
-
}
|
|
219
|
-
}
|
|
220
|
-
toJSON() {
|
|
221
|
-
return {
|
|
222
|
-
type: this.type,
|
|
223
|
-
value: this.value
|
|
224
|
-
};
|
|
225
|
-
}
|
|
226
|
-
};
|
|
227
|
-
var ColumnExpressionImpl = class {
|
|
228
|
-
constructor(columnName) {
|
|
229
|
-
this.type = "colExpression";
|
|
230
|
-
this.column = columnName;
|
|
231
|
-
}
|
|
232
|
-
toJSON() {
|
|
233
|
-
return {
|
|
234
|
-
type: this.type,
|
|
235
|
-
column: this.column
|
|
236
|
-
};
|
|
237
|
-
}
|
|
238
|
-
};
|
|
239
|
-
var _expressions, _op;
|
|
240
|
-
var ArithmeticExpressionImpl = class {
|
|
241
|
-
constructor(op = "unknown") {
|
|
242
|
-
__privateAdd(this, _expressions, [
|
|
243
|
-
{ type: "unknown" },
|
|
244
|
-
{ type: "unknown" }
|
|
245
|
-
]);
|
|
246
|
-
__privateAdd(this, _op, void 0);
|
|
247
|
-
this.type = "arithmeticExpression";
|
|
248
|
-
__privateSet(this, _op, op);
|
|
249
|
-
}
|
|
250
|
-
get op() {
|
|
251
|
-
return __privateGet(this, _op);
|
|
252
|
-
}
|
|
253
|
-
set op(op) {
|
|
254
|
-
__privateSet(this, _op, op);
|
|
255
|
-
}
|
|
256
|
-
get expressions() {
|
|
257
|
-
return __privateGet(this, _expressions);
|
|
258
|
-
}
|
|
259
|
-
toJSON() {
|
|
260
|
-
return {
|
|
261
|
-
type: this.type,
|
|
262
|
-
op: __privateGet(this, _op),
|
|
263
|
-
expressions: __privateGet(this, _expressions)
|
|
264
|
-
};
|
|
265
|
-
}
|
|
266
|
-
};
|
|
267
|
-
_expressions = new WeakMap();
|
|
268
|
-
_op = new WeakMap();
|
|
269
|
-
var _expressions2;
|
|
270
|
-
var CallExpressionImpl = class {
|
|
271
|
-
constructor(functionName) {
|
|
272
|
-
__privateAdd(this, _expressions2, []);
|
|
273
|
-
this.type = "callExpression";
|
|
274
|
-
this.functionName = functionName;
|
|
275
|
-
}
|
|
276
|
-
get expressions() {
|
|
277
|
-
return __privateGet(this, _expressions2);
|
|
278
|
-
}
|
|
279
|
-
get arguments() {
|
|
280
|
-
return __privateGet(this, _expressions2);
|
|
281
|
-
}
|
|
282
|
-
toJSON() {
|
|
283
|
-
return {
|
|
284
|
-
type: this.type,
|
|
285
|
-
functionName: this.functionName,
|
|
286
|
-
arguments: __privateGet(this, _expressions2).map((e) => {
|
|
287
|
-
var _a;
|
|
288
|
-
return (_a = e.toJSON) == null ? void 0 : _a.call(e);
|
|
289
|
-
})
|
|
290
|
-
};
|
|
291
|
-
}
|
|
292
|
-
};
|
|
293
|
-
_expressions2 = new WeakMap();
|
|
294
|
-
var _expressions3, _op2;
|
|
295
|
-
var RelationalExpressionImpl = class {
|
|
296
|
-
constructor() {
|
|
297
|
-
__privateAdd(this, _expressions3, [
|
|
298
|
-
{ type: "unknown" },
|
|
299
|
-
{ type: "unknown" }
|
|
300
|
-
]);
|
|
301
|
-
__privateAdd(this, _op2, "unknown");
|
|
302
|
-
this.type = "relationalExpression";
|
|
303
|
-
}
|
|
304
|
-
get op() {
|
|
305
|
-
return __privateGet(this, _op2);
|
|
306
|
-
}
|
|
307
|
-
set op(op) {
|
|
308
|
-
__privateSet(this, _op2, op);
|
|
309
|
-
}
|
|
310
|
-
get expressions() {
|
|
311
|
-
return __privateGet(this, _expressions3);
|
|
312
|
-
}
|
|
313
|
-
toJSON() {
|
|
314
|
-
return {
|
|
315
|
-
type: this.type,
|
|
316
|
-
op: __privateGet(this, _op2),
|
|
317
|
-
expressions: __privateGet(this, _expressions3)
|
|
318
|
-
};
|
|
319
|
-
}
|
|
320
|
-
};
|
|
321
|
-
_expressions3 = new WeakMap();
|
|
322
|
-
_op2 = new WeakMap();
|
|
323
|
-
var _expressions4, _op3;
|
|
324
|
-
var BooleanConditionImp = class {
|
|
325
|
-
constructor(booleanOperator) {
|
|
326
|
-
__privateAdd(this, _expressions4, [
|
|
327
|
-
{ type: "unknown" },
|
|
328
|
-
{ type: "unknown" }
|
|
329
|
-
]);
|
|
330
|
-
__privateAdd(this, _op3, void 0);
|
|
331
|
-
this.type = "booleanCondition";
|
|
332
|
-
__privateSet(this, _op3, booleanOperator);
|
|
333
|
-
}
|
|
334
|
-
get op() {
|
|
335
|
-
return __privateGet(this, _op3);
|
|
336
|
-
}
|
|
337
|
-
get expressions() {
|
|
338
|
-
return __privateGet(this, _expressions4);
|
|
339
|
-
}
|
|
340
|
-
toJSON() {
|
|
341
|
-
return {
|
|
342
|
-
type: this.type,
|
|
343
|
-
op: __privateGet(this, _op3),
|
|
344
|
-
expressions: __privateGet(this, _expressions4).map((e) => {
|
|
345
|
-
var _a;
|
|
346
|
-
return (_a = e.toJSON) == null ? void 0 : _a.call(e);
|
|
347
|
-
})
|
|
348
|
-
};
|
|
349
|
-
}
|
|
350
|
-
};
|
|
351
|
-
_expressions4 = new WeakMap();
|
|
352
|
-
_op3 = new WeakMap();
|
|
353
|
-
var _expressions5;
|
|
354
|
-
var ConditionalExpressionImpl = class {
|
|
355
|
-
constructor(booleanOperator) {
|
|
356
|
-
__privateAdd(this, _expressions5, void 0);
|
|
357
|
-
this.type = "conditionalExpression";
|
|
358
|
-
__privateSet(this, _expressions5, [
|
|
359
|
-
booleanOperator ? new BooleanConditionImp(booleanOperator) : new RelationalExpressionImpl(),
|
|
360
|
-
{ type: "unknown" },
|
|
361
|
-
{ type: "unknown" }
|
|
362
|
-
]);
|
|
363
|
-
}
|
|
364
|
-
get expressions() {
|
|
365
|
-
return __privateGet(this, _expressions5);
|
|
366
|
-
}
|
|
367
|
-
get condition() {
|
|
368
|
-
return __privateGet(this, _expressions5)[0];
|
|
369
|
-
}
|
|
370
|
-
get truthyExpression() {
|
|
371
|
-
return __privateGet(this, _expressions5)[1];
|
|
372
|
-
}
|
|
373
|
-
set truthyExpression(expression) {
|
|
374
|
-
__privateGet(this, _expressions5)[1] = expression;
|
|
375
|
-
}
|
|
376
|
-
get falsyExpression() {
|
|
377
|
-
return __privateGet(this, _expressions5)[2];
|
|
378
|
-
}
|
|
379
|
-
set falsyExpression(expression) {
|
|
380
|
-
__privateGet(this, _expressions5)[2] = expression;
|
|
381
|
-
}
|
|
382
|
-
toJSON() {
|
|
383
|
-
var _a, _b, _c, _d, _e;
|
|
384
|
-
return {
|
|
385
|
-
type: this.type,
|
|
386
|
-
condition: (_b = (_a = this.condition).toJSON) == null ? void 0 : _b.call(_a),
|
|
387
|
-
truthyExpression: this.truthyExpression,
|
|
388
|
-
falsyExpression: (_e = (_d = (_c = this.falsyExpression) == null ? void 0 : _c.toJSON) == null ? void 0 : _d.call(_c)) != null ? _e : this.falsyExpression
|
|
389
|
-
};
|
|
390
|
-
}
|
|
391
|
-
};
|
|
392
|
-
_expressions5 = new WeakMap();
|
|
393
|
-
var isUnknown = (e) => e.type === "unknown";
|
|
394
|
-
var isArithmeticExpression = (expression) => expression.type === "arithmeticExpression";
|
|
395
|
-
var isCallExpression = (expression) => expression.type === "callExpression";
|
|
396
|
-
var isConditionalExpression = (expression) => expression.type === "conditionalExpression";
|
|
397
|
-
var isCondition = (expression) => expression.type === "relationalExpression" || expression.type === "booleanCondition";
|
|
398
|
-
var isBooleanCondition = (expression) => expression.type === "booleanCondition";
|
|
399
|
-
var isRelationalExpression = (expression) => (expression == null ? void 0 : expression.type) === "relationalExpression";
|
|
400
|
-
var firstIncompleteExpression = (expression) => {
|
|
401
|
-
if (isUnknown(expression)) {
|
|
402
|
-
return expression;
|
|
403
|
-
} else if (isRelationalExpression(expression)) {
|
|
404
|
-
const [operand1, operand2] = expression.expressions;
|
|
405
|
-
if (expressionIsIncomplete(operand1)) {
|
|
406
|
-
return firstIncompleteExpression(operand1);
|
|
407
|
-
} else if (expression.op === "unknown") {
|
|
408
|
-
return expression;
|
|
409
|
-
} else if (expressionIsIncomplete(operand2)) {
|
|
410
|
-
return firstIncompleteExpression(operand2);
|
|
411
|
-
}
|
|
412
|
-
} else if (isCondition(expression)) {
|
|
413
|
-
const { expressions = [] } = expression;
|
|
414
|
-
for (const e of expressions) {
|
|
415
|
-
if (expressionIsIncomplete(e)) {
|
|
416
|
-
return firstIncompleteExpression(e);
|
|
417
|
-
}
|
|
418
|
-
}
|
|
419
|
-
} else if (isConditionalExpression(expression)) {
|
|
420
|
-
const { condition, truthyExpression, falsyExpression } = expression;
|
|
421
|
-
if (expressionIsIncomplete(condition)) {
|
|
422
|
-
return firstIncompleteExpression(condition);
|
|
423
|
-
} else if (expressionIsIncomplete(truthyExpression)) {
|
|
424
|
-
return firstIncompleteExpression(truthyExpression);
|
|
425
|
-
} else if (expressionIsIncomplete(falsyExpression)) {
|
|
426
|
-
return firstIncompleteExpression(falsyExpression);
|
|
427
|
-
}
|
|
428
|
-
} else if (isArithmeticExpression(expression)) {
|
|
429
|
-
const { expressions = [] } = expression;
|
|
430
|
-
for (const e of expressions) {
|
|
431
|
-
if (expressionIsIncomplete(e)) {
|
|
432
|
-
return firstIncompleteExpression(e);
|
|
433
|
-
}
|
|
434
|
-
}
|
|
435
|
-
}
|
|
436
|
-
};
|
|
437
|
-
var replaceUnknownExpression = (incompleteExpression, unknownExpression, expression) => {
|
|
438
|
-
const { expressions = [] } = incompleteExpression;
|
|
439
|
-
if (expressions.includes(unknownExpression)) {
|
|
440
|
-
const pos = expressions.indexOf(unknownExpression);
|
|
441
|
-
expressions.splice(pos, 1, expression);
|
|
442
|
-
return true;
|
|
443
|
-
} else {
|
|
444
|
-
for (const e of expressions) {
|
|
445
|
-
if (replaceUnknownExpression(e, unknownExpression, expression)) {
|
|
446
|
-
return true;
|
|
447
|
-
}
|
|
448
|
-
}
|
|
449
|
-
}
|
|
450
|
-
return false;
|
|
451
|
-
};
|
|
452
|
-
var expressionIsIncomplete = (expression) => {
|
|
453
|
-
if (isUnknown(expression)) {
|
|
454
|
-
return true;
|
|
455
|
-
} else if (isConditionalExpression(expression)) {
|
|
456
|
-
return expressionIsIncomplete(expression.condition) || expressionIsIncomplete(expression.truthyExpression) || expressionIsIncomplete(expression.falsyExpression);
|
|
457
|
-
} else if (isRelationalExpression(expression) || isBooleanCondition(expression)) {
|
|
458
|
-
return expression.op === void 0 || expression.expressions.some((e) => expressionIsIncomplete(e));
|
|
459
|
-
}
|
|
460
|
-
return false;
|
|
461
|
-
};
|
|
462
|
-
var addExpression = (expression, subExpression) => {
|
|
463
|
-
const targetExpression = firstIncompleteExpression(expression);
|
|
464
|
-
if (targetExpression) {
|
|
465
|
-
if (targetExpression.expressions) {
|
|
466
|
-
targetExpression.expressions.push(subExpression);
|
|
467
|
-
} else {
|
|
468
|
-
console.warn("don't know how to treat targetExpression");
|
|
469
|
-
}
|
|
470
|
-
} else {
|
|
471
|
-
console.error("no target expression found");
|
|
472
|
-
}
|
|
473
|
-
};
|
|
474
|
-
var _expression, _callStack;
|
|
475
|
-
var ColumnExpression = class {
|
|
476
|
-
constructor() {
|
|
477
|
-
__privateAdd(this, _expression, void 0);
|
|
478
|
-
__privateAdd(this, _callStack, []);
|
|
479
|
-
}
|
|
480
|
-
setCondition(booleanOperator) {
|
|
481
|
-
if (__privateGet(this, _expression) === void 0) {
|
|
482
|
-
this.addExpression(new ConditionalExpressionImpl(booleanOperator));
|
|
483
|
-
} else if (isConditionalExpression(__privateGet(this, _expression))) {
|
|
484
|
-
if (expressionIsIncomplete(__privateGet(this, _expression).condition)) {
|
|
485
|
-
const condition = booleanOperator ? new BooleanConditionImp(booleanOperator) : new RelationalExpressionImpl();
|
|
486
|
-
this.addExpression(condition);
|
|
487
|
-
} else if (isUnknown(__privateGet(this, _expression).truthyExpression)) {
|
|
488
|
-
__privateGet(this, _expression).truthyExpression = new ConditionalExpressionImpl(
|
|
489
|
-
booleanOperator
|
|
490
|
-
);
|
|
491
|
-
} else if (expressionIsIncomplete(__privateGet(this, _expression).truthyExpression)) {
|
|
492
|
-
const condition = booleanOperator ? new BooleanConditionImp(booleanOperator) : new RelationalExpressionImpl();
|
|
493
|
-
this.addExpression(condition);
|
|
494
|
-
} else if (isUnknown(__privateGet(this, _expression).falsyExpression)) {
|
|
495
|
-
__privateGet(this, _expression).falsyExpression = new ConditionalExpressionImpl(
|
|
496
|
-
booleanOperator
|
|
497
|
-
);
|
|
498
|
-
} else if (expressionIsIncomplete(__privateGet(this, _expression).falsyExpression)) {
|
|
499
|
-
const condition = booleanOperator ? new BooleanConditionImp(booleanOperator) : new RelationalExpressionImpl();
|
|
500
|
-
this.addExpression(condition);
|
|
501
|
-
}
|
|
502
|
-
} else {
|
|
503
|
-
console.error("setCondition called unexpectedly");
|
|
504
|
-
}
|
|
505
|
-
}
|
|
506
|
-
addExpression(expression) {
|
|
507
|
-
if (__privateGet(this, _callStack).length > 0) {
|
|
508
|
-
const currentCallExpression = __privateGet(this, _callStack).at(-1);
|
|
509
|
-
currentCallExpression == null ? void 0 : currentCallExpression.arguments.push(expression);
|
|
510
|
-
} else if (__privateGet(this, _expression) === void 0) {
|
|
511
|
-
__privateSet(this, _expression, expression);
|
|
512
|
-
} else if (isArithmeticExpression(__privateGet(this, _expression))) {
|
|
513
|
-
const targetExpression = firstIncompleteExpression(__privateGet(this, _expression));
|
|
514
|
-
if (targetExpression && isUnknown(targetExpression)) {
|
|
515
|
-
replaceUnknownExpression(
|
|
516
|
-
__privateGet(this, _expression),
|
|
517
|
-
targetExpression,
|
|
518
|
-
expression
|
|
519
|
-
);
|
|
520
|
-
}
|
|
521
|
-
} else if (isConditionalExpression(__privateGet(this, _expression))) {
|
|
522
|
-
if (expressionIsIncomplete(__privateGet(this, _expression))) {
|
|
523
|
-
const targetExpression = firstIncompleteExpression(__privateGet(this, _expression));
|
|
524
|
-
if (targetExpression && isUnknown(targetExpression)) {
|
|
525
|
-
replaceUnknownExpression(
|
|
526
|
-
__privateGet(this, _expression),
|
|
527
|
-
targetExpression,
|
|
528
|
-
expression
|
|
529
|
-
);
|
|
530
|
-
} else if (targetExpression) {
|
|
531
|
-
addExpression(targetExpression, expression);
|
|
532
|
-
}
|
|
533
|
-
}
|
|
534
|
-
}
|
|
535
|
-
}
|
|
536
|
-
setFunction(functionName) {
|
|
537
|
-
const callExpression = new CallExpressionImpl(functionName);
|
|
538
|
-
this.addExpression(callExpression);
|
|
539
|
-
__privateGet(this, _callStack).push(callExpression);
|
|
540
|
-
}
|
|
541
|
-
setColumn(columnName) {
|
|
542
|
-
this.addExpression(new ColumnExpressionImpl(columnName));
|
|
543
|
-
}
|
|
544
|
-
setArithmeticOp(value) {
|
|
545
|
-
const op = value;
|
|
546
|
-
const expression = __privateGet(this, _expression);
|
|
547
|
-
if (isArithmeticExpression(expression)) {
|
|
548
|
-
expression.op = op;
|
|
549
|
-
}
|
|
550
|
-
}
|
|
551
|
-
setRelationalOperator(value) {
|
|
552
|
-
const op = value;
|
|
553
|
-
if (__privateGet(this, _expression) && isConditionalExpression(__privateGet(this, _expression))) {
|
|
554
|
-
const targetExpression = firstIncompleteExpression(__privateGet(this, _expression));
|
|
555
|
-
if (isRelationalExpression(targetExpression)) {
|
|
556
|
-
targetExpression.op = op;
|
|
557
|
-
} else {
|
|
558
|
-
console.error(`no target expression found (op = ${value})`);
|
|
559
|
-
}
|
|
560
|
-
}
|
|
561
|
-
}
|
|
562
|
-
setValue(value) {
|
|
563
|
-
const literalExpression = new LiteralExpressionImpl(value);
|
|
564
|
-
if (__privateGet(this, _expression) === void 0) {
|
|
565
|
-
__privateSet(this, _expression, literalExpression);
|
|
566
|
-
} else if (isArithmeticExpression(__privateGet(this, _expression))) {
|
|
567
|
-
this.addExpression(literalExpression);
|
|
568
|
-
} else if (isCallExpression(__privateGet(this, _expression))) {
|
|
569
|
-
__privateGet(this, _expression).arguments.push(literalExpression);
|
|
570
|
-
} else if (isConditionalExpression(__privateGet(this, _expression))) {
|
|
571
|
-
if (expressionIsIncomplete(__privateGet(this, _expression))) {
|
|
572
|
-
const targetExpression = firstIncompleteExpression(__privateGet(this, _expression));
|
|
573
|
-
if (targetExpression && isUnknown(targetExpression)) {
|
|
574
|
-
replaceUnknownExpression(
|
|
575
|
-
__privateGet(this, _expression),
|
|
576
|
-
targetExpression,
|
|
577
|
-
literalExpression
|
|
578
|
-
);
|
|
579
|
-
} else if (targetExpression) {
|
|
580
|
-
addExpression(targetExpression, literalExpression);
|
|
581
|
-
}
|
|
582
|
-
} else {
|
|
583
|
-
console.log("what do we do with value, in a complete expression");
|
|
584
|
-
}
|
|
585
|
-
}
|
|
586
|
-
}
|
|
587
|
-
closeBrace() {
|
|
588
|
-
__privateGet(this, _callStack).pop();
|
|
589
|
-
}
|
|
590
|
-
get expression() {
|
|
591
|
-
return __privateGet(this, _expression);
|
|
592
|
-
}
|
|
593
|
-
toJSON() {
|
|
594
|
-
var _a;
|
|
595
|
-
return (_a = __privateGet(this, _expression)) == null ? void 0 : _a.toJSON();
|
|
596
|
-
}
|
|
597
|
-
};
|
|
598
|
-
_expression = new WeakMap();
|
|
599
|
-
_callStack = new WeakMap();
|
|
600
|
-
var walkTree = (tree, source) => {
|
|
601
|
-
const columnExpression = new ColumnExpression();
|
|
602
|
-
const cursor = tree.cursor();
|
|
603
|
-
do {
|
|
604
|
-
const { name, from, to } = cursor;
|
|
605
|
-
switch (name) {
|
|
606
|
-
case "AndCondition":
|
|
607
|
-
columnExpression.setCondition("and");
|
|
608
|
-
break;
|
|
609
|
-
case "OrCondition":
|
|
610
|
-
columnExpression.setCondition("or");
|
|
611
|
-
break;
|
|
612
|
-
case "RelationalExpression":
|
|
613
|
-
columnExpression.setCondition();
|
|
614
|
-
break;
|
|
615
|
-
case "ArithmeticExpression":
|
|
616
|
-
columnExpression.addExpression(new ArithmeticExpressionImpl());
|
|
617
|
-
break;
|
|
618
|
-
case "Column":
|
|
619
|
-
{
|
|
620
|
-
const columnName = source.substring(from, to);
|
|
621
|
-
columnExpression.setColumn(columnName);
|
|
622
|
-
}
|
|
623
|
-
break;
|
|
624
|
-
case "Function":
|
|
625
|
-
{
|
|
626
|
-
const functionName = source.substring(from, to);
|
|
627
|
-
columnExpression.setFunction(functionName);
|
|
628
|
-
}
|
|
629
|
-
break;
|
|
630
|
-
case "Times":
|
|
631
|
-
case "Divide":
|
|
632
|
-
case "Plus":
|
|
633
|
-
case "Minus":
|
|
634
|
-
{
|
|
635
|
-
const op = source.substring(from, to);
|
|
636
|
-
columnExpression.setArithmeticOp(op);
|
|
637
|
-
}
|
|
638
|
-
break;
|
|
639
|
-
case "RelationalOperator":
|
|
640
|
-
{
|
|
641
|
-
const op = source.substring(from, to);
|
|
642
|
-
columnExpression.setRelationalOperator(op);
|
|
643
|
-
}
|
|
644
|
-
break;
|
|
645
|
-
case "False":
|
|
646
|
-
case "True":
|
|
647
|
-
{
|
|
648
|
-
const value = source.substring(from, to);
|
|
649
|
-
columnExpression.setValue(value === "true" ? true : false);
|
|
650
|
-
}
|
|
651
|
-
break;
|
|
652
|
-
case "String":
|
|
653
|
-
columnExpression.setValue(source.substring(from + 1, to - 1));
|
|
654
|
-
break;
|
|
655
|
-
case "Number":
|
|
656
|
-
columnExpression.setValue(parseFloat(source.substring(from, to)));
|
|
657
|
-
break;
|
|
658
|
-
case "CloseBrace":
|
|
659
|
-
columnExpression.closeBrace();
|
|
660
|
-
break;
|
|
661
|
-
default:
|
|
662
|
-
}
|
|
663
|
-
} while (cursor.next());
|
|
664
|
-
return columnExpression.toJSON();
|
|
665
|
-
};
|
|
666
|
-
|
|
667
|
-
// src/column-expression-input/column-language-parser/column-expression-parse-utils.ts
|
|
668
|
-
var strictParser = parser.configure({ strict: true });
|
|
669
|
-
var RelationalOperands = ["Number", "String"];
|
|
670
|
-
var ColumnNamedTerms = [
|
|
671
|
-
...RelationalOperands,
|
|
672
|
-
"AndCondition",
|
|
673
|
-
"ArithmeticExpression",
|
|
674
|
-
"BooleanOperator",
|
|
675
|
-
"RelationalOperatorOperator",
|
|
676
|
-
"CallExpression",
|
|
677
|
-
"CloseBrace",
|
|
678
|
-
"Column",
|
|
679
|
-
"Comma",
|
|
680
|
-
"ConditionalExpression",
|
|
681
|
-
"Divide",
|
|
682
|
-
"Equal",
|
|
683
|
-
"If",
|
|
684
|
-
"Minus",
|
|
685
|
-
"OpenBrace",
|
|
686
|
-
"OrCondition",
|
|
687
|
-
"ParenthesizedExpression",
|
|
688
|
-
"Plus",
|
|
689
|
-
"RelationalExpression",
|
|
690
|
-
"RelationalOperator",
|
|
691
|
-
"Times"
|
|
692
|
-
];
|
|
693
|
-
var isCompleteExpression = (src) => {
|
|
694
|
-
try {
|
|
695
|
-
strictParser.parse(src);
|
|
696
|
-
return true;
|
|
697
|
-
} catch (err) {
|
|
698
|
-
return false;
|
|
699
|
-
}
|
|
700
|
-
};
|
|
701
|
-
var lastNamedChild = (node) => {
|
|
702
|
-
let { lastChild } = node;
|
|
703
|
-
while (lastChild && !ColumnNamedTerms.includes(lastChild.name)) {
|
|
704
|
-
lastChild = lastChild.prevSibling;
|
|
705
|
-
console.log(lastChild == null ? void 0 : lastChild.name);
|
|
706
|
-
}
|
|
707
|
-
return lastChild;
|
|
708
|
-
};
|
|
709
|
-
var isCompleteRelationalExpression = (node) => {
|
|
710
|
-
if ((node == null ? void 0 : node.name) === "RelationalExpression") {
|
|
711
|
-
const { firstChild } = node;
|
|
712
|
-
const lastChild = lastNamedChild(node);
|
|
713
|
-
if ((firstChild == null ? void 0 : firstChild.name) === "Column" && typeof (lastChild == null ? void 0 : lastChild.name) === "string" && RelationalOperands.includes(lastChild.name)) {
|
|
714
|
-
return true;
|
|
715
|
-
}
|
|
716
|
-
}
|
|
717
|
-
return false;
|
|
718
|
-
};
|
|
719
|
-
|
|
720
|
-
// src/column-expression-input/highlighting.ts
|
|
721
|
-
import {
|
|
722
|
-
HighlightStyle,
|
|
723
|
-
syntaxHighlighting,
|
|
724
|
-
tags
|
|
725
|
-
} from "@vuu-ui/vuu-codemirror";
|
|
726
|
-
var myHighlightStyle = HighlightStyle.define([
|
|
727
|
-
{ tag: tags.variableName, color: "var(--vuuFilterEditor-variableColor)" },
|
|
728
|
-
{ tag: tags.comment, color: "green", fontStyle: "italic" }
|
|
729
|
-
]);
|
|
730
|
-
var vuuHighlighting = syntaxHighlighting(myHighlightStyle);
|
|
731
|
-
|
|
732
|
-
// src/column-expression-input/theme.ts
|
|
733
|
-
import { EditorView } from "@vuu-ui/vuu-codemirror";
|
|
734
|
-
var vuuTheme = EditorView.theme(
|
|
735
|
-
{
|
|
736
|
-
"&": {
|
|
737
|
-
border: "solid 1px var(--salt-container-primary-borderColor)",
|
|
738
|
-
color: "var(--vuuFilterEditor-color)",
|
|
739
|
-
backgroundColor: "var(--vuuFilterEditor-background)"
|
|
740
|
-
},
|
|
741
|
-
".cm-content": {
|
|
742
|
-
caretColor: "var(--vuuFilterEditor-cursorColor)"
|
|
743
|
-
},
|
|
744
|
-
"&.cm-focused .cm-cursor": {
|
|
745
|
-
borderLeftColor: "var(--vuuFilterEditor-cursorColor)"
|
|
746
|
-
},
|
|
747
|
-
"&.cm-focused .cm-selectionBackground, ::selection": {
|
|
748
|
-
backgroundColor: "var(--vuuFilterEditor-selectionBackground)"
|
|
749
|
-
},
|
|
750
|
-
".cm-selectionBackground, ::selection": {
|
|
751
|
-
backgroundColor: "var(--vuuFilterEditor-selectionBackground)"
|
|
752
|
-
},
|
|
753
|
-
".cm-scroller": {
|
|
754
|
-
fontFamily: "var(--vuuFilterEditor-fontFamily)"
|
|
755
|
-
},
|
|
756
|
-
".cm-tooltip": {
|
|
757
|
-
background: "var(--vuuFilterEditor-tooltipBackground)",
|
|
758
|
-
border: "var(--vuuFilterEditor-tooltipBorder)",
|
|
759
|
-
boxShadow: "var(--vuuFilterEditor-tooltipElevation)",
|
|
760
|
-
"&.cm-tooltip-autocomplete > ul": {
|
|
761
|
-
fontFamily: "var(--vuuFilterEditor-fontFamily)",
|
|
762
|
-
fontSize: "var(--vuuFilterEditor-fontSize)",
|
|
763
|
-
maxHeight: "240px"
|
|
764
|
-
},
|
|
765
|
-
"&.cm-tooltip-autocomplete > ul > li": {
|
|
766
|
-
height: "var(--vuuFilterEditor-suggestion-height)",
|
|
767
|
-
padding: "0 3px",
|
|
768
|
-
lineHeight: "var(--vuuFilterEditor-suggestion-height)"
|
|
769
|
-
},
|
|
770
|
-
"&.cm-tooltip-autocomplete li[aria-selected]": {
|
|
771
|
-
background: "var(--vuuFilterEditor-suggestion-selectedBackground)",
|
|
772
|
-
color: "var(--vuuFilterEditor-suggestion-selectedColor)"
|
|
773
|
-
},
|
|
774
|
-
"&.cm-tooltip-autocomplete li .cm-completionDetail": {
|
|
775
|
-
color: "var(--vuuFilterEditor-suggestion-detailColor)"
|
|
776
|
-
}
|
|
777
|
-
}
|
|
778
|
-
},
|
|
779
|
-
{ dark: false }
|
|
780
|
-
);
|
|
781
|
-
|
|
782
|
-
// src/column-expression-input/useColumnAutoComplete.ts
|
|
783
|
-
import {
|
|
784
|
-
booleanJoinSuggestions,
|
|
785
|
-
getNamedParentNode,
|
|
786
|
-
getPreviousNode,
|
|
787
|
-
getValue,
|
|
788
|
-
syntaxTree
|
|
789
|
-
} from "@vuu-ui/vuu-codemirror";
|
|
790
|
-
import { useCallback } from "react";
|
|
791
|
-
var applyPrefix = (completions, prefix) => prefix ? completions.map((completion) => {
|
|
792
|
-
var _a;
|
|
793
|
-
return {
|
|
794
|
-
...completion,
|
|
795
|
-
apply: typeof completion.apply === "function" ? completion.apply : `${prefix}${(_a = completion.apply) != null ? _a : completion.label}`
|
|
796
|
-
};
|
|
797
|
-
}) : completions;
|
|
798
|
-
var isOperator = (node) => node === void 0 ? false : ["Times", "Divide", "Plus", "Minus"].includes(node.name);
|
|
799
|
-
var getLastChild = (node, context) => {
|
|
800
|
-
var _a;
|
|
801
|
-
let { lastChild: childNode } = node;
|
|
802
|
-
const { pos } = context;
|
|
803
|
-
while (childNode) {
|
|
804
|
-
const isBeforeCursor = childNode.from < pos;
|
|
805
|
-
if (isBeforeCursor && ColumnNamedTerms.includes(childNode.name)) {
|
|
806
|
-
if (childNode.name === "ParenthesizedExpression") {
|
|
807
|
-
const expression = (_a = childNode.firstChild) == null ? void 0 : _a.nextSibling;
|
|
808
|
-
if (expression) {
|
|
809
|
-
childNode = expression;
|
|
810
|
-
}
|
|
811
|
-
}
|
|
812
|
-
return childNode;
|
|
813
|
-
} else {
|
|
814
|
-
childNode = childNode.prevSibling;
|
|
815
|
-
}
|
|
816
|
-
}
|
|
817
|
-
};
|
|
818
|
-
var getFunctionName = (node, state) => {
|
|
819
|
-
var _a;
|
|
820
|
-
if (node.name === "ArgList") {
|
|
821
|
-
const functionNode = node.prevSibling;
|
|
822
|
-
if (functionNode) {
|
|
823
|
-
return getValue(functionNode, state);
|
|
824
|
-
}
|
|
825
|
-
} else if (node.name === "OpenBrace") {
|
|
826
|
-
const maybeFunction = (_a = node.parent) == null ? void 0 : _a.prevSibling;
|
|
827
|
-
if ((maybeFunction == null ? void 0 : maybeFunction.name) === "Function") {
|
|
828
|
-
return getValue(maybeFunction, state);
|
|
829
|
-
}
|
|
830
|
-
}
|
|
831
|
-
};
|
|
832
|
-
var getRelationalOperator = (node, state) => {
|
|
833
|
-
if (node.name === "RelationalExpression") {
|
|
834
|
-
const lastNode = lastNamedChild(node);
|
|
835
|
-
if ((lastNode == null ? void 0 : lastNode.name) === "RelationalOperator") {
|
|
836
|
-
return getValue(lastNode, state);
|
|
837
|
-
}
|
|
838
|
-
} else {
|
|
839
|
-
const prevNode = node.prevSibling;
|
|
840
|
-
if ((prevNode == null ? void 0 : prevNode.name) === "RelationalOperator") {
|
|
841
|
-
return getValue(prevNode, state);
|
|
842
|
-
}
|
|
843
|
-
}
|
|
844
|
-
};
|
|
845
|
-
var getColumnName = (node, state) => {
|
|
846
|
-
var _a;
|
|
847
|
-
if (node.name === "RelationalExpression") {
|
|
848
|
-
if (((_a = node.firstChild) == null ? void 0 : _a.name) === "Column") {
|
|
849
|
-
return getValue(node.firstChild, state);
|
|
850
|
-
}
|
|
851
|
-
} else {
|
|
852
|
-
const prevNode = node.prevSibling;
|
|
853
|
-
if ((prevNode == null ? void 0 : prevNode.name) === "Column") {
|
|
854
|
-
return getValue(prevNode, state);
|
|
855
|
-
} else if ((prevNode == null ? void 0 : prevNode.name) === "RelationalOperator") {
|
|
856
|
-
return getColumnName(prevNode, state);
|
|
857
|
-
}
|
|
858
|
-
}
|
|
859
|
-
};
|
|
860
|
-
var makeSuggestions = async (context, suggestionProvider, suggestionType, optionalArgs = {}) => {
|
|
861
|
-
const options = await suggestionProvider.getSuggestions(
|
|
862
|
-
suggestionType,
|
|
863
|
-
optionalArgs
|
|
864
|
-
);
|
|
865
|
-
const { startsWith = "" } = optionalArgs;
|
|
866
|
-
return { from: context.pos - startsWith.length, options };
|
|
867
|
-
};
|
|
868
|
-
var handleConditionalExpression = (node, context, suggestionProvider, maybeComplete, onSubmit) => {
|
|
869
|
-
const lastChild = getLastChild(node, context);
|
|
870
|
-
console.log(`conditional expression last child ${lastChild == null ? void 0 : lastChild.name}`);
|
|
871
|
-
switch (lastChild == null ? void 0 : lastChild.name) {
|
|
872
|
-
case "If":
|
|
873
|
-
return makeSuggestions(context, suggestionProvider, "expression", {
|
|
874
|
-
prefix: "( "
|
|
875
|
-
});
|
|
876
|
-
case "OpenBrace":
|
|
877
|
-
return makeSuggestions(context, suggestionProvider, "expression");
|
|
878
|
-
case "Condition":
|
|
879
|
-
return makeSuggestions(context, suggestionProvider, "expression", {
|
|
880
|
-
prefix: ", "
|
|
881
|
-
});
|
|
882
|
-
case "CloseBrace":
|
|
883
|
-
if (maybeComplete) {
|
|
884
|
-
const options = [
|
|
885
|
-
{
|
|
886
|
-
apply: () => {
|
|
887
|
-
onSubmit == null ? void 0 : onSubmit();
|
|
888
|
-
},
|
|
889
|
-
label: "Save Expression",
|
|
890
|
-
boost: 10
|
|
891
|
-
}
|
|
892
|
-
];
|
|
893
|
-
return { from: context.pos, options };
|
|
894
|
-
}
|
|
895
|
-
}
|
|
896
|
-
};
|
|
897
|
-
var promptToSave = (context, onSubmit) => {
|
|
898
|
-
const options = [
|
|
899
|
-
{
|
|
900
|
-
apply: () => {
|
|
901
|
-
onSubmit == null ? void 0 : onSubmit();
|
|
902
|
-
},
|
|
903
|
-
label: "Save Expression",
|
|
904
|
-
boost: 10
|
|
905
|
-
}
|
|
906
|
-
];
|
|
907
|
-
return { from: context.pos, options };
|
|
908
|
-
};
|
|
909
|
-
var useColumnAutoComplete = (suggestionProvider, onSubmit) => {
|
|
910
|
-
const makeSuggestions2 = useCallback(
|
|
911
|
-
async (context, suggestionType, optionalArgs = {}) => {
|
|
912
|
-
const options = await suggestionProvider.getSuggestions(
|
|
913
|
-
suggestionType,
|
|
914
|
-
optionalArgs
|
|
915
|
-
);
|
|
916
|
-
const { startsWith = "" } = optionalArgs;
|
|
917
|
-
return { from: context.pos - startsWith.length, options };
|
|
918
|
-
},
|
|
919
|
-
[suggestionProvider]
|
|
920
|
-
);
|
|
921
|
-
return useCallback(
|
|
922
|
-
async (context) => {
|
|
923
|
-
var _a, _b;
|
|
924
|
-
const { state, pos } = context;
|
|
925
|
-
const word = (_a = context.matchBefore(/\w*/)) != null ? _a : {
|
|
926
|
-
from: 0,
|
|
927
|
-
to: 0,
|
|
928
|
-
text: void 0
|
|
929
|
-
};
|
|
930
|
-
const tree = syntaxTree(state);
|
|
931
|
-
const nodeBefore = tree.resolveInner(pos, -1);
|
|
932
|
-
const text = state.doc.toString();
|
|
933
|
-
const maybeComplete = isCompleteExpression(text);
|
|
934
|
-
console.log({ nodeBeforeName: nodeBefore.name });
|
|
935
|
-
switch (nodeBefore.name) {
|
|
936
|
-
case "If": {
|
|
937
|
-
console.log(`conditional expression If`);
|
|
938
|
-
return makeSuggestions2(context, "expression", { prefix: "( " });
|
|
939
|
-
}
|
|
940
|
-
case "Condition":
|
|
941
|
-
{
|
|
942
|
-
const lastChild = getLastChild(nodeBefore, context);
|
|
943
|
-
if ((lastChild == null ? void 0 : lastChild.name) === "Column") {
|
|
944
|
-
const prevChild = getPreviousNode(lastChild);
|
|
945
|
-
if ((prevChild == null ? void 0 : prevChild.name) !== "RelationalOperator") {
|
|
946
|
-
return makeSuggestions2(context, "condition-operator", {
|
|
947
|
-
columnName: getValue(lastChild, state)
|
|
948
|
-
});
|
|
949
|
-
}
|
|
950
|
-
console.log(
|
|
951
|
-
`Condition last child Column, prev child ${prevChild == null ? void 0 : prevChild.name}`
|
|
952
|
-
);
|
|
953
|
-
} else if ((lastChild == null ? void 0 : lastChild.name) === "RelationalOperator") {
|
|
954
|
-
return makeSuggestions2(context, "expression");
|
|
955
|
-
}
|
|
956
|
-
console.log(`condition last child ${lastChild == null ? void 0 : lastChild.name}`);
|
|
957
|
-
}
|
|
958
|
-
break;
|
|
959
|
-
case "ConditionalExpression":
|
|
960
|
-
return handleConditionalExpression(
|
|
961
|
-
nodeBefore,
|
|
962
|
-
context,
|
|
963
|
-
suggestionProvider
|
|
964
|
-
);
|
|
965
|
-
case "RelationalExpression":
|
|
966
|
-
{
|
|
967
|
-
if (isCompleteRelationalExpression(nodeBefore)) {
|
|
968
|
-
return {
|
|
969
|
-
from: context.pos,
|
|
970
|
-
options: booleanJoinSuggestions.concat({
|
|
971
|
-
label: ", <truthy expression>, <falsy expression>",
|
|
972
|
-
apply: ", "
|
|
973
|
-
})
|
|
974
|
-
};
|
|
975
|
-
} else {
|
|
976
|
-
const operator = getRelationalOperator(nodeBefore, state);
|
|
977
|
-
const columnName = getColumnName(nodeBefore, state);
|
|
978
|
-
if (!operator) {
|
|
979
|
-
const options = await suggestionProvider.getSuggestions(
|
|
980
|
-
"condition-operator",
|
|
981
|
-
{
|
|
982
|
-
columnName
|
|
983
|
-
}
|
|
984
|
-
);
|
|
985
|
-
return { from: context.pos, options };
|
|
986
|
-
} else {
|
|
987
|
-
return makeSuggestions2(context, "expression");
|
|
988
|
-
}
|
|
989
|
-
}
|
|
990
|
-
}
|
|
991
|
-
break;
|
|
992
|
-
case "RelationalOperator":
|
|
993
|
-
return makeSuggestions2(context, "expression");
|
|
994
|
-
case "String":
|
|
995
|
-
{
|
|
996
|
-
const operator = getRelationalOperator(
|
|
997
|
-
nodeBefore,
|
|
998
|
-
state
|
|
999
|
-
);
|
|
1000
|
-
const columnName = getColumnName(nodeBefore, state);
|
|
1001
|
-
const { from, to } = nodeBefore;
|
|
1002
|
-
if (to - from === 2 && context.pos === from + 1) {
|
|
1003
|
-
if (columnName && operator) {
|
|
1004
|
-
return makeSuggestions2(context, "columnValue", {
|
|
1005
|
-
columnName,
|
|
1006
|
-
operator,
|
|
1007
|
-
startsWith: word.text
|
|
1008
|
-
});
|
|
1009
|
-
}
|
|
1010
|
-
} else if (to - from > 2 && context.pos === to) {
|
|
1011
|
-
return makeSuggestions2(context, "expression", {
|
|
1012
|
-
prefix: ", "
|
|
1013
|
-
});
|
|
1014
|
-
}
|
|
1015
|
-
console.log(
|
|
1016
|
-
`we have a string, column is ${columnName} ${from} ${to}`
|
|
1017
|
-
);
|
|
1018
|
-
}
|
|
1019
|
-
break;
|
|
1020
|
-
case "ArithmeticExpression":
|
|
1021
|
-
{
|
|
1022
|
-
const lastChild = getLastChild(nodeBefore, context);
|
|
1023
|
-
if ((lastChild == null ? void 0 : lastChild.name) === "Column") {
|
|
1024
|
-
return makeSuggestions2(context, "expression");
|
|
1025
|
-
} else if (isOperator(lastChild)) {
|
|
1026
|
-
const operator = lastChild.name;
|
|
1027
|
-
return makeSuggestions2(context, "column", { operator });
|
|
1028
|
-
}
|
|
1029
|
-
}
|
|
1030
|
-
break;
|
|
1031
|
-
case "OpenBrace":
|
|
1032
|
-
{
|
|
1033
|
-
const functionName = getFunctionName(nodeBefore, state);
|
|
1034
|
-
return makeSuggestions2(context, "expression", { functionName });
|
|
1035
|
-
}
|
|
1036
|
-
break;
|
|
1037
|
-
case "ArgList": {
|
|
1038
|
-
const functionName = getFunctionName(nodeBefore, state);
|
|
1039
|
-
const lastArgument = getLastChild(nodeBefore, context);
|
|
1040
|
-
const prefix = (lastArgument == null ? void 0 : lastArgument.name) === "OpenBrace" ? void 0 : ",";
|
|
1041
|
-
let options = await suggestionProvider.getSuggestions("expression", {
|
|
1042
|
-
functionName
|
|
1043
|
-
});
|
|
1044
|
-
options = prefix ? applyPrefix(options, ", ") : options;
|
|
1045
|
-
if ((lastArgument == null ? void 0 : lastArgument.name) !== "OpenBrace" && (lastArgument == null ? void 0 : lastArgument.name) !== "Comma") {
|
|
1046
|
-
options = [
|
|
1047
|
-
{
|
|
1048
|
-
apply: ") ",
|
|
1049
|
-
boost: 10,
|
|
1050
|
-
label: "Done - no more arguments"
|
|
1051
|
-
}
|
|
1052
|
-
].concat(options);
|
|
1053
|
-
}
|
|
1054
|
-
return { from: context.pos, options };
|
|
1055
|
-
}
|
|
1056
|
-
case "Equal":
|
|
1057
|
-
if (text.trim() === "=") {
|
|
1058
|
-
return makeSuggestions2(context, "expression");
|
|
1059
|
-
}
|
|
1060
|
-
break;
|
|
1061
|
-
case "ParenthesizedExpression":
|
|
1062
|
-
case "ColumnDefinitionExpression":
|
|
1063
|
-
if (context.pos === 0) {
|
|
1064
|
-
return makeSuggestions2(context, "expression");
|
|
1065
|
-
} else {
|
|
1066
|
-
const lastChild = getLastChild(nodeBefore, context);
|
|
1067
|
-
if ((lastChild == null ? void 0 : lastChild.name) === "Column") {
|
|
1068
|
-
if (maybeComplete) {
|
|
1069
|
-
const options = [
|
|
1070
|
-
{
|
|
1071
|
-
apply: () => {
|
|
1072
|
-
onSubmit.current();
|
|
1073
|
-
},
|
|
1074
|
-
label: "Save Expression",
|
|
1075
|
-
boost: 10
|
|
1076
|
-
}
|
|
1077
|
-
];
|
|
1078
|
-
const columnName = getValue(lastChild, state);
|
|
1079
|
-
const columnOptions = await suggestionProvider.getSuggestions("operator", {
|
|
1080
|
-
columnName
|
|
1081
|
-
});
|
|
1082
|
-
return {
|
|
1083
|
-
from: context.pos,
|
|
1084
|
-
options: options.concat(columnOptions)
|
|
1085
|
-
};
|
|
1086
|
-
}
|
|
1087
|
-
} else if ((lastChild == null ? void 0 : lastChild.name) === "CallExpression") {
|
|
1088
|
-
if (maybeComplete) {
|
|
1089
|
-
const options = [
|
|
1090
|
-
{
|
|
1091
|
-
apply: () => {
|
|
1092
|
-
onSubmit.current();
|
|
1093
|
-
},
|
|
1094
|
-
label: "Save Expression",
|
|
1095
|
-
boost: 10
|
|
1096
|
-
}
|
|
1097
|
-
];
|
|
1098
|
-
return {
|
|
1099
|
-
from: context.pos,
|
|
1100
|
-
options
|
|
1101
|
-
};
|
|
1102
|
-
}
|
|
1103
|
-
} else if ((lastChild == null ? void 0 : lastChild.name) === "ArithmeticExpression") {
|
|
1104
|
-
if (maybeComplete) {
|
|
1105
|
-
let options = [
|
|
1106
|
-
{
|
|
1107
|
-
apply: () => {
|
|
1108
|
-
onSubmit.current();
|
|
1109
|
-
},
|
|
1110
|
-
label: "Save Expression",
|
|
1111
|
-
boost: 10
|
|
1112
|
-
}
|
|
1113
|
-
];
|
|
1114
|
-
const lastExpressionChild = getLastChild(lastChild, context);
|
|
1115
|
-
if ((lastExpressionChild == null ? void 0 : lastExpressionChild.name) === "Column") {
|
|
1116
|
-
const columnName = getValue(lastExpressionChild, state);
|
|
1117
|
-
const suggestions = await suggestionProvider.getSuggestions(
|
|
1118
|
-
"operator",
|
|
1119
|
-
{ columnName }
|
|
1120
|
-
);
|
|
1121
|
-
options = options.concat(suggestions);
|
|
1122
|
-
}
|
|
1123
|
-
return {
|
|
1124
|
-
from: context.pos,
|
|
1125
|
-
options
|
|
1126
|
-
};
|
|
1127
|
-
}
|
|
1128
|
-
} else if ((lastChild == null ? void 0 : lastChild.name) === "ConditionalExpression") {
|
|
1129
|
-
return handleConditionalExpression(
|
|
1130
|
-
lastChild,
|
|
1131
|
-
context,
|
|
1132
|
-
suggestionProvider,
|
|
1133
|
-
maybeComplete,
|
|
1134
|
-
onSubmit.current
|
|
1135
|
-
);
|
|
1136
|
-
}
|
|
1137
|
-
break;
|
|
1138
|
-
}
|
|
1139
|
-
case "Column":
|
|
1140
|
-
{
|
|
1141
|
-
const isPartialMatch = await suggestionProvider.isPartialMatch(
|
|
1142
|
-
"expression",
|
|
1143
|
-
void 0,
|
|
1144
|
-
word.text
|
|
1145
|
-
);
|
|
1146
|
-
if (isPartialMatch) {
|
|
1147
|
-
return makeSuggestions2(context, "expression", {
|
|
1148
|
-
startsWith: word.text
|
|
1149
|
-
});
|
|
1150
|
-
}
|
|
1151
|
-
}
|
|
1152
|
-
break;
|
|
1153
|
-
case "Comma":
|
|
1154
|
-
{
|
|
1155
|
-
const parentNode = getNamedParentNode(nodeBefore);
|
|
1156
|
-
if ((parentNode == null ? void 0 : parentNode.name) === "ConditionalExpression") {
|
|
1157
|
-
return makeSuggestions2(context, "expression");
|
|
1158
|
-
}
|
|
1159
|
-
}
|
|
1160
|
-
break;
|
|
1161
|
-
case "CloseBrace":
|
|
1162
|
-
{
|
|
1163
|
-
const parentNode = getNamedParentNode(nodeBefore);
|
|
1164
|
-
if ((parentNode == null ? void 0 : parentNode.name) === "ConditionalExpression") {
|
|
1165
|
-
return handleConditionalExpression(
|
|
1166
|
-
parentNode,
|
|
1167
|
-
context,
|
|
1168
|
-
suggestionProvider,
|
|
1169
|
-
maybeComplete,
|
|
1170
|
-
onSubmit.current
|
|
1171
|
-
);
|
|
1172
|
-
} else if ((parentNode == null ? void 0 : parentNode.name) === "ArgList") {
|
|
1173
|
-
if (maybeComplete) {
|
|
1174
|
-
return promptToSave(context, onSubmit.current);
|
|
1175
|
-
}
|
|
1176
|
-
}
|
|
1177
|
-
console.log(
|
|
1178
|
-
`does closebrace denote an ARgList or a parenthetised expression ? ${parentNode}`
|
|
1179
|
-
);
|
|
1180
|
-
}
|
|
1181
|
-
break;
|
|
1182
|
-
default: {
|
|
1183
|
-
if (((_b = nodeBefore == null ? void 0 : nodeBefore.prevSibling) == null ? void 0 : _b.name) === "FilterClause") {
|
|
1184
|
-
console.log("looks like we ight be a or|and operator");
|
|
1185
|
-
}
|
|
1186
|
-
}
|
|
1187
|
-
}
|
|
1188
|
-
},
|
|
1189
|
-
[makeSuggestions2, onSubmit, suggestionProvider]
|
|
1190
|
-
);
|
|
1191
|
-
};
|
|
1192
|
-
|
|
1193
|
-
// src/column-expression-input/useColumnExpressionEditor.ts
|
|
1194
|
-
var getView = (ref) => {
|
|
1195
|
-
if (ref.current == void 0) {
|
|
1196
|
-
throw Error("EditorView not defined");
|
|
1197
|
-
}
|
|
1198
|
-
return ref.current;
|
|
1199
|
-
};
|
|
1200
|
-
var getOptionClass = () => {
|
|
1201
|
-
return "vuuSuggestion";
|
|
1202
|
-
};
|
|
1203
|
-
var noop = () => console.log("noooop");
|
|
1204
|
-
var hasExpressionType = (completion) => "expressionType" in completion;
|
|
1205
|
-
var injectOptionContent = (completion) => {
|
|
1206
|
-
if (hasExpressionType(completion)) {
|
|
1207
|
-
const div = createEl("div", "expression-type-container");
|
|
1208
|
-
const span = createEl("span", "expression-type", completion.expressionType);
|
|
1209
|
-
div.appendChild(span);
|
|
1210
|
-
return div;
|
|
1211
|
-
} else {
|
|
1212
|
-
return null;
|
|
1213
|
-
}
|
|
1214
|
-
};
|
|
1215
|
-
var useColumnExpressionEditor = ({
|
|
1216
|
-
onChange,
|
|
1217
|
-
onSubmitExpression,
|
|
1218
|
-
suggestionProvider
|
|
1219
|
-
}) => {
|
|
1220
|
-
const editorRef = useRef2(null);
|
|
1221
|
-
const onSubmit = useRef2(noop);
|
|
1222
|
-
const viewRef = useRef2();
|
|
1223
|
-
const completionFn = useColumnAutoComplete(suggestionProvider, onSubmit);
|
|
1224
|
-
const [createState, clearInput] = useMemo(() => {
|
|
1225
|
-
const parseExpression = () => {
|
|
1226
|
-
const view = getView(viewRef);
|
|
1227
|
-
const source = view.state.doc.toString();
|
|
1228
|
-
const tree = ensureSyntaxTree(view.state, view.state.doc.length, 5e3);
|
|
1229
|
-
if (tree) {
|
|
1230
|
-
const expression = walkTree(tree, source);
|
|
1231
|
-
return [source, expression];
|
|
1232
|
-
} else {
|
|
1233
|
-
return ["", void 0];
|
|
1234
|
-
}
|
|
1235
|
-
};
|
|
1236
|
-
const clearInput2 = () => {
|
|
1237
|
-
getView(viewRef).setState(createState2());
|
|
1238
|
-
};
|
|
1239
|
-
const submitExpressionAndClearInput = () => {
|
|
1240
|
-
const [source, expression] = parseExpression();
|
|
1241
|
-
onSubmitExpression == null ? void 0 : onSubmitExpression(source, expression);
|
|
1242
|
-
clearInput2();
|
|
1243
|
-
};
|
|
1244
|
-
const submitFilter = (key) => {
|
|
1245
|
-
return keymap.of([
|
|
1246
|
-
{
|
|
1247
|
-
key,
|
|
1248
|
-
run() {
|
|
1249
|
-
submitExpressionAndClearInput();
|
|
1250
|
-
return true;
|
|
1251
|
-
}
|
|
1252
|
-
}
|
|
1253
|
-
]);
|
|
1254
|
-
};
|
|
1255
|
-
const showSuggestions = (key) => {
|
|
1256
|
-
return keymap.of([
|
|
1257
|
-
{
|
|
1258
|
-
key,
|
|
1259
|
-
run() {
|
|
1260
|
-
startCompletion(getView(viewRef));
|
|
1261
|
-
return true;
|
|
1262
|
-
}
|
|
1263
|
-
}
|
|
1264
|
-
]);
|
|
1265
|
-
};
|
|
1266
|
-
const createState2 = () => EditorState2.create({
|
|
1267
|
-
doc: "",
|
|
1268
|
-
extensions: [
|
|
1269
|
-
minimalSetup,
|
|
1270
|
-
autocompletion({
|
|
1271
|
-
addToOptions: [
|
|
1272
|
-
{
|
|
1273
|
-
render: injectOptionContent,
|
|
1274
|
-
position: 70
|
|
1275
|
-
}
|
|
1276
|
-
],
|
|
1277
|
-
override: [completionFn],
|
|
1278
|
-
optionClass: getOptionClass
|
|
1279
|
-
}),
|
|
1280
|
-
columnExpressionLanguageSupport(),
|
|
1281
|
-
keymap.of(defaultKeymap),
|
|
1282
|
-
submitFilter("Ctrl-Enter"),
|
|
1283
|
-
showSuggestions("ArrowDown"),
|
|
1284
|
-
EditorView2.updateListener.of((v) => {
|
|
1285
|
-
const view = getView(viewRef);
|
|
1286
|
-
if (v.docChanged) {
|
|
1287
|
-
startCompletion(view);
|
|
1288
|
-
const source = view.state.doc.toString();
|
|
1289
|
-
onChange == null ? void 0 : onChange(source, void 0);
|
|
1290
|
-
}
|
|
1291
|
-
}),
|
|
1292
|
-
// Enforces single line view
|
|
1293
|
-
// EditorState.transactionFilter.of((tr) =>
|
|
1294
|
-
// tr.newDoc.lines > 1 ? [] : tr
|
|
1295
|
-
// ),
|
|
1296
|
-
vuuTheme,
|
|
1297
|
-
vuuHighlighting
|
|
1298
|
-
]
|
|
1299
|
-
});
|
|
1300
|
-
onSubmit.current = () => {
|
|
1301
|
-
submitExpressionAndClearInput();
|
|
1302
|
-
setTimeout(() => {
|
|
1303
|
-
getView(viewRef).focus();
|
|
1304
|
-
}, 100);
|
|
1305
|
-
};
|
|
1306
|
-
return [createState2, clearInput2];
|
|
1307
|
-
}, [completionFn, onChange, onSubmitExpression]);
|
|
1308
|
-
useEffect2(() => {
|
|
1309
|
-
if (!editorRef.current) {
|
|
1310
|
-
throw Error("editor not in dom");
|
|
1311
|
-
}
|
|
1312
|
-
viewRef.current = new EditorView2({
|
|
1313
|
-
state: createState(),
|
|
1314
|
-
parent: editorRef.current
|
|
1315
|
-
});
|
|
1316
|
-
return () => {
|
|
1317
|
-
var _a;
|
|
1318
|
-
(_a = viewRef.current) == null ? void 0 : _a.destroy();
|
|
1319
|
-
};
|
|
1320
|
-
}, [completionFn, createState]);
|
|
1321
|
-
return { editorRef, clearInput };
|
|
1322
|
-
};
|
|
1323
|
-
|
|
1324
|
-
// src/column-expression-input/ColumnExpressionInput.tsx
|
|
1325
|
-
import { jsx as jsx3 } from "react/jsx-runtime";
|
|
1326
|
-
var classBase3 = "vuuColumnExpressionInput";
|
|
1327
|
-
var ColumnExpressionInput = ({
|
|
1328
|
-
onChange,
|
|
1329
|
-
onSubmitExpression,
|
|
1330
|
-
suggestionProvider
|
|
1331
|
-
}) => {
|
|
1332
|
-
const { editorRef } = useColumnExpressionEditor({
|
|
1333
|
-
onChange,
|
|
1334
|
-
onSubmitExpression,
|
|
1335
|
-
suggestionProvider
|
|
1336
|
-
});
|
|
1337
|
-
return /* @__PURE__ */ jsx3("div", { className: `${classBase3}`, ref: editorRef });
|
|
1338
|
-
};
|
|
1339
|
-
|
|
1340
|
-
// src/column-expression-input/useColumnExpressionSuggestionProvider.ts
|
|
1341
|
-
import {
|
|
1342
|
-
AnnotationType,
|
|
1343
|
-
getRelationalOperators,
|
|
1344
|
-
numericOperators,
|
|
1345
|
-
stringOperators,
|
|
1346
|
-
toSuggestions
|
|
1347
|
-
} from "@vuu-ui/vuu-codemirror";
|
|
1348
|
-
import { getTypeaheadParams, useTypeaheadSuggestions } from "@vuu-ui/vuu-data";
|
|
1349
|
-
import { isNumericColumn, isTextColumn } from "@vuu-ui/vuu-utils";
|
|
1350
|
-
import { useCallback as useCallback2, useRef as useRef3 } from "react";
|
|
1351
|
-
|
|
1352
|
-
// src/column-expression-input/column-function-descriptors.ts
|
|
1353
|
-
var columnFunctionDescriptors = [
|
|
1354
|
-
/**
|
|
1355
|
-
* concatenate()
|
|
1356
|
-
*/
|
|
1357
|
-
{
|
|
1358
|
-
accepts: "string",
|
|
1359
|
-
description: "Returns multiple string values as a single joined string. Arguments may be string literal values, string columns or other string expressions. Non string arguments may also be included, these will be converted to strings.",
|
|
1360
|
-
example: {
|
|
1361
|
-
expression: 'concatenate("example", "-test")',
|
|
1362
|
-
result: '"example-test"'
|
|
1363
|
-
},
|
|
1364
|
-
name: "concatenate",
|
|
1365
|
-
params: {
|
|
1366
|
-
description: "( string, string, [ string* ] )"
|
|
1367
|
-
},
|
|
1368
|
-
type: "string"
|
|
1369
|
-
},
|
|
1370
|
-
/**
|
|
1371
|
-
* contains()
|
|
1372
|
-
*/
|
|
1373
|
-
{
|
|
1374
|
-
accepts: ["string", "string"],
|
|
1375
|
-
description: "Tests a string value to determine whether it contains a given substring. Accepts two arguments: source text and target substring. Returns true if <source text> contains one or more occurrences of <target subscring>",
|
|
1376
|
-
example: {
|
|
1377
|
-
expression: 'contains("Royal Bank of Scotland", "bank")',
|
|
1378
|
-
result: "true"
|
|
1379
|
-
},
|
|
1380
|
-
name: "contains",
|
|
1381
|
-
params: {
|
|
1382
|
-
description: "( string )"
|
|
1383
|
-
},
|
|
1384
|
-
type: "boolean"
|
|
1385
|
-
},
|
|
1386
|
-
/**
|
|
1387
|
-
* left()
|
|
1388
|
-
*/
|
|
1389
|
-
{
|
|
1390
|
-
accepts: ["string", "number"],
|
|
1391
|
-
description: "Returns the leftmost <number> characters from <string>. First argument may be a string literal, string column or other string expression.",
|
|
1392
|
-
example: {
|
|
1393
|
-
expression: 'left("USD Benchmark Report", 3)',
|
|
1394
|
-
result: '"USD"'
|
|
1395
|
-
},
|
|
1396
|
-
name: "left",
|
|
1397
|
-
params: {
|
|
1398
|
-
count: 2,
|
|
1399
|
-
description: "( string, number )"
|
|
1400
|
-
},
|
|
1401
|
-
type: "string"
|
|
1402
|
-
},
|
|
1403
|
-
/**
|
|
1404
|
-
* len()
|
|
1405
|
-
*/
|
|
1406
|
-
{
|
|
1407
|
-
accepts: "string",
|
|
1408
|
-
description: "Returns the number of characters in <string>. Argument may be a string literal, string column or other string expression.",
|
|
1409
|
-
example: {
|
|
1410
|
-
expression: 'len("example")',
|
|
1411
|
-
result: "7"
|
|
1412
|
-
},
|
|
1413
|
-
name: "len",
|
|
1414
|
-
params: {
|
|
1415
|
-
description: "(string)"
|
|
1416
|
-
},
|
|
1417
|
-
type: "number"
|
|
1418
|
-
},
|
|
1419
|
-
/**
|
|
1420
|
-
* lower()
|
|
1421
|
-
*/
|
|
1422
|
-
{
|
|
1423
|
-
accepts: "string",
|
|
1424
|
-
description: "Convert a string value to lowercase. Argument may be a string column or other string expression.",
|
|
1425
|
-
example: {
|
|
1426
|
-
expression: 'lower("examPLE")',
|
|
1427
|
-
result: '"example"'
|
|
1428
|
-
},
|
|
1429
|
-
name: "lower",
|
|
1430
|
-
params: {
|
|
1431
|
-
description: "( string )"
|
|
1432
|
-
},
|
|
1433
|
-
type: "string"
|
|
1434
|
-
},
|
|
1435
|
-
/**
|
|
1436
|
-
* upper()
|
|
1437
|
-
*/
|
|
1438
|
-
{
|
|
1439
|
-
accepts: "string",
|
|
1440
|
-
description: "Convert a string value to uppercase. Argument may be a string column or other string expression.",
|
|
1441
|
-
example: {
|
|
1442
|
-
expression: 'upper("example")',
|
|
1443
|
-
result: '"EXAMPLE"'
|
|
1444
|
-
},
|
|
1445
|
-
name: "upper",
|
|
1446
|
-
params: {
|
|
1447
|
-
description: "( string )"
|
|
1448
|
-
},
|
|
1449
|
-
type: "string"
|
|
1450
|
-
},
|
|
1451
|
-
/**
|
|
1452
|
-
* right()
|
|
1453
|
-
*/
|
|
1454
|
-
{
|
|
1455
|
-
accepts: ["string", "number"],
|
|
1456
|
-
description: "Returns the rightmost <number> characters from <string>. First argument may be a string literal, string column or other string expression.",
|
|
1457
|
-
example: {
|
|
1458
|
-
expression: "blah",
|
|
1459
|
-
result: "blah"
|
|
1460
|
-
},
|
|
1461
|
-
name: "right",
|
|
1462
|
-
params: {
|
|
1463
|
-
description: "( string )"
|
|
1464
|
-
},
|
|
1465
|
-
type: "string"
|
|
1466
|
-
},
|
|
1467
|
-
/**
|
|
1468
|
-
* replace()
|
|
1469
|
-
*/
|
|
1470
|
-
{
|
|
1471
|
-
accepts: ["string", "string", "string"],
|
|
1472
|
-
description: "Replace characters within a string. Accepts three arguments: source text, text to replace and replacement text. Returns a copy of <source text> with any occurrences of <text to replace> replaced by <replacement text>",
|
|
1473
|
-
example: {
|
|
1474
|
-
expression: "blah",
|
|
1475
|
-
result: "blah"
|
|
1476
|
-
},
|
|
1477
|
-
name: "replace",
|
|
1478
|
-
params: {
|
|
1479
|
-
description: "( string )"
|
|
1480
|
-
},
|
|
1481
|
-
type: "string"
|
|
1482
|
-
},
|
|
1483
|
-
/**
|
|
1484
|
-
* text()
|
|
1485
|
-
*/
|
|
1486
|
-
{
|
|
1487
|
-
accepts: "number",
|
|
1488
|
-
description: "Converts a number to a string.",
|
|
1489
|
-
example: {
|
|
1490
|
-
expression: "blah",
|
|
1491
|
-
result: "blah"
|
|
1492
|
-
},
|
|
1493
|
-
name: "text",
|
|
1494
|
-
params: {
|
|
1495
|
-
description: "( string )"
|
|
1496
|
-
},
|
|
1497
|
-
type: "string"
|
|
1498
|
-
},
|
|
1499
|
-
/**
|
|
1500
|
-
* starts()
|
|
1501
|
-
*/
|
|
1502
|
-
{
|
|
1503
|
-
accepts: "string",
|
|
1504
|
-
description: "Tests a string value to determine whether it starts with a given substring. Accepts two arguments: source text and target substring. Returns true if <source text> starts with <target subscring>.",
|
|
1505
|
-
example: {
|
|
1506
|
-
expression: "blah",
|
|
1507
|
-
result: "blah"
|
|
1508
|
-
},
|
|
1509
|
-
name: "starts",
|
|
1510
|
-
params: {
|
|
1511
|
-
description: "( string )"
|
|
1512
|
-
},
|
|
1513
|
-
type: "boolean"
|
|
1514
|
-
},
|
|
1515
|
-
/**
|
|
1516
|
-
* starts()
|
|
1517
|
-
*/
|
|
1518
|
-
{
|
|
1519
|
-
accepts: "string",
|
|
1520
|
-
description: "Tests a string value to determine whether it ends with a given substring. Accepts two arguments: source text and target substring. Returns true if <source text> ends with <target subscring>.",
|
|
1521
|
-
example: {
|
|
1522
|
-
expression: "blah",
|
|
1523
|
-
result: "blah"
|
|
1524
|
-
},
|
|
1525
|
-
name: "ends",
|
|
1526
|
-
params: {
|
|
1527
|
-
description: "( string )"
|
|
1528
|
-
},
|
|
1529
|
-
type: "boolean"
|
|
1530
|
-
},
|
|
1531
|
-
{
|
|
1532
|
-
accepts: "number",
|
|
1533
|
-
description: "blah",
|
|
1534
|
-
example: {
|
|
1535
|
-
expression: "blah",
|
|
1536
|
-
result: "blah"
|
|
1537
|
-
},
|
|
1538
|
-
name: "min",
|
|
1539
|
-
params: {
|
|
1540
|
-
description: "( string )"
|
|
1541
|
-
},
|
|
1542
|
-
type: "number"
|
|
1543
|
-
},
|
|
1544
|
-
{
|
|
1545
|
-
accepts: "number",
|
|
1546
|
-
description: "blah",
|
|
1547
|
-
example: {
|
|
1548
|
-
expression: "blah",
|
|
1549
|
-
result: "blah"
|
|
1550
|
-
},
|
|
1551
|
-
name: "max",
|
|
1552
|
-
params: {
|
|
1553
|
-
description: "( string )"
|
|
1554
|
-
},
|
|
1555
|
-
type: "number"
|
|
1556
|
-
},
|
|
1557
|
-
{
|
|
1558
|
-
accepts: "number",
|
|
1559
|
-
description: "blah",
|
|
1560
|
-
example: {
|
|
1561
|
-
expression: "blah",
|
|
1562
|
-
result: "blah"
|
|
1563
|
-
},
|
|
1564
|
-
name: "sum",
|
|
1565
|
-
params: {
|
|
1566
|
-
description: "( string )"
|
|
1567
|
-
},
|
|
1568
|
-
type: "number"
|
|
1569
|
-
},
|
|
1570
|
-
{
|
|
1571
|
-
accepts: "number",
|
|
1572
|
-
description: "blah",
|
|
1573
|
-
example: {
|
|
1574
|
-
expression: "blah",
|
|
1575
|
-
result: "blah"
|
|
1576
|
-
},
|
|
1577
|
-
name: "round",
|
|
1578
|
-
params: {
|
|
1579
|
-
description: "( string )"
|
|
1580
|
-
},
|
|
1581
|
-
type: "number"
|
|
1582
|
-
},
|
|
1583
|
-
{
|
|
1584
|
-
accepts: "any",
|
|
1585
|
-
description: "blah",
|
|
1586
|
-
example: {
|
|
1587
|
-
expression: "blah",
|
|
1588
|
-
result: "blah"
|
|
1589
|
-
},
|
|
1590
|
-
name: "or",
|
|
1591
|
-
params: {
|
|
1592
|
-
description: "( string )"
|
|
1593
|
-
},
|
|
1594
|
-
type: "boolean"
|
|
1595
|
-
},
|
|
1596
|
-
{
|
|
1597
|
-
accepts: "any",
|
|
1598
|
-
description: "blah",
|
|
1599
|
-
example: {
|
|
1600
|
-
expression: "blah",
|
|
1601
|
-
result: "blah"
|
|
1602
|
-
},
|
|
1603
|
-
name: "and",
|
|
1604
|
-
params: {
|
|
1605
|
-
description: "( string )"
|
|
1606
|
-
},
|
|
1607
|
-
type: "boolean"
|
|
1608
|
-
},
|
|
1609
|
-
{
|
|
1610
|
-
accepts: "any",
|
|
1611
|
-
description: "Return one of two possible result values, depending on the evaluation of a filter expression. If <filterExpression> resolves to true, result is <expression1>, otherwise <expression2>. ",
|
|
1612
|
-
example: {
|
|
1613
|
-
expression: "blah",
|
|
1614
|
-
result: "blah"
|
|
1615
|
-
},
|
|
1616
|
-
name: "if",
|
|
1617
|
-
params: {
|
|
1618
|
-
description: "( filterExpression, expression1, expression 2)"
|
|
1619
|
-
},
|
|
1620
|
-
type: "variable"
|
|
1621
|
-
}
|
|
1622
|
-
];
|
|
1623
|
-
|
|
1624
|
-
// src/column-expression-input/functionDocInfo.ts
|
|
1625
|
-
import { createEl as createEl2 } from "@vuu-ui/vuu-utils";
|
|
1626
|
-
var functionDocInfo = ({
|
|
1627
|
-
name,
|
|
1628
|
-
description,
|
|
1629
|
-
example,
|
|
1630
|
-
params,
|
|
1631
|
-
type
|
|
1632
|
-
}) => {
|
|
1633
|
-
const rootElement = createEl2("div", "vuuFunctionDoc");
|
|
1634
|
-
const headingElement = createEl2("div", "function-heading");
|
|
1635
|
-
const nameElement = createEl2("span", "function-name", name);
|
|
1636
|
-
const paramElement = createEl2("span", "param-list", params.description);
|
|
1637
|
-
const typeElement = createEl2("span", "function-type", type);
|
|
1638
|
-
headingElement.appendChild(nameElement);
|
|
1639
|
-
headingElement.appendChild(paramElement);
|
|
1640
|
-
headingElement.appendChild(typeElement);
|
|
1641
|
-
const child2 = createEl2("p", void 0, description);
|
|
1642
|
-
rootElement.appendChild(headingElement);
|
|
1643
|
-
rootElement.appendChild(child2);
|
|
1644
|
-
if (example) {
|
|
1645
|
-
const exampleElement = createEl2("div", "example-container", "Example:");
|
|
1646
|
-
const expressionElement = createEl2(
|
|
1647
|
-
"div",
|
|
1648
|
-
"example-expression",
|
|
1649
|
-
example.expression
|
|
1650
|
-
);
|
|
1651
|
-
const resultElement = createEl2("div", "example-result", example.result);
|
|
1652
|
-
exampleElement.appendChild(expressionElement);
|
|
1653
|
-
exampleElement.appendChild(resultElement);
|
|
1654
|
-
rootElement.appendChild(exampleElement);
|
|
1655
|
-
}
|
|
1656
|
-
return rootElement;
|
|
1657
|
-
};
|
|
1658
|
-
|
|
1659
|
-
// src/column-expression-input/useColumnExpressionSuggestionProvider.ts
|
|
1660
|
-
var NO_OPERATORS = [];
|
|
1661
|
-
var withApplySpace = (suggestions) => suggestions.map((suggestion) => {
|
|
1662
|
-
var _a;
|
|
1663
|
-
return {
|
|
1664
|
-
...suggestion,
|
|
1665
|
-
apply: ((_a = suggestion.apply) != null ? _a : suggestion.label) + " "
|
|
1666
|
-
};
|
|
1667
|
-
});
|
|
1668
|
-
var getValidColumns = (columns, { functionName, operator }) => {
|
|
1669
|
-
if (operator) {
|
|
1670
|
-
return columns.filter(isNumericColumn);
|
|
1671
|
-
} else if (functionName) {
|
|
1672
|
-
const fn = columnFunctionDescriptors.find((f) => f.name === functionName);
|
|
1673
|
-
if (fn) {
|
|
1674
|
-
switch (fn.accepts) {
|
|
1675
|
-
case "string":
|
|
1676
|
-
return columns.filter(isTextColumn);
|
|
1677
|
-
case "number":
|
|
1678
|
-
return columns.filter(isNumericColumn);
|
|
1679
|
-
default:
|
|
1680
|
-
return columns;
|
|
1681
|
-
}
|
|
1682
|
-
}
|
|
1683
|
-
}
|
|
1684
|
-
return columns;
|
|
1685
|
-
};
|
|
1686
|
-
var getColumns = (columns, options) => {
|
|
1687
|
-
const validColumns = getValidColumns(columns, options);
|
|
1688
|
-
return validColumns.map((column) => {
|
|
1689
|
-
var _a;
|
|
1690
|
-
const label = (_a = column.label) != null ? _a : column.name;
|
|
1691
|
-
return {
|
|
1692
|
-
apply: options.prefix ? `${options.prefix}${label}` : label,
|
|
1693
|
-
label,
|
|
1694
|
-
boost: 5,
|
|
1695
|
-
type: "column",
|
|
1696
|
-
expressionType: column.serverDataType
|
|
1697
|
-
};
|
|
1698
|
-
});
|
|
1699
|
-
};
|
|
1700
|
-
var arithmeticOperators = [
|
|
1701
|
-
{ apply: "* ", boost: 2, label: "*", type: "operator" },
|
|
1702
|
-
{ apply: "/ ", boost: 2, label: "/", type: "operator" },
|
|
1703
|
-
{ apply: "+ ", boost: 2, label: "+", type: "operator" },
|
|
1704
|
-
{ apply: "- ", boost: 2, label: "-", type: "operator" }
|
|
1705
|
-
];
|
|
1706
|
-
var getOperators = (column) => {
|
|
1707
|
-
if (column === void 0 || isNumericColumn(column)) {
|
|
1708
|
-
return arithmeticOperators;
|
|
1709
|
-
} else {
|
|
1710
|
-
return NO_OPERATORS;
|
|
1711
|
-
}
|
|
1712
|
-
};
|
|
1713
|
-
var getConditionOperators = (column) => {
|
|
1714
|
-
switch (column.serverDataType) {
|
|
1715
|
-
case "string":
|
|
1716
|
-
case "char":
|
|
1717
|
-
return withApplySpace(
|
|
1718
|
-
stringOperators
|
|
1719
|
-
/*, startsWith*/
|
|
1720
|
-
);
|
|
1721
|
-
case "int":
|
|
1722
|
-
case "long":
|
|
1723
|
-
case "double":
|
|
1724
|
-
return withApplySpace(numericOperators);
|
|
1725
|
-
}
|
|
1726
|
-
};
|
|
1727
|
-
var toFunctionCompletion = (functionDescriptor) => ({
|
|
1728
|
-
apply: `${functionDescriptor.name}( `,
|
|
1729
|
-
boost: 2,
|
|
1730
|
-
expressionType: functionDescriptor.type,
|
|
1731
|
-
info: () => functionDocInfo(functionDescriptor),
|
|
1732
|
-
label: functionDescriptor.name,
|
|
1733
|
-
type: "function"
|
|
1734
|
-
});
|
|
1735
|
-
var getAcceptedTypes = (fn) => {
|
|
1736
|
-
if (fn) {
|
|
1737
|
-
if (typeof fn.accepts === "string") {
|
|
1738
|
-
return fn.accepts;
|
|
1739
|
-
} else if (Array.isArray(fn.accepts)) {
|
|
1740
|
-
if (fn.accepts.every((s) => s === "string")) {
|
|
1741
|
-
return "string";
|
|
1742
|
-
} else {
|
|
1743
|
-
return "any";
|
|
1744
|
-
}
|
|
1745
|
-
}
|
|
1746
|
-
}
|
|
1747
|
-
return "any";
|
|
1748
|
-
};
|
|
1749
|
-
var functions = columnFunctionDescriptors.map(toFunctionCompletion);
|
|
1750
|
-
var getFunctions = ({ functionName }) => {
|
|
1751
|
-
if (functionName) {
|
|
1752
|
-
const fn = columnFunctionDescriptors.find((f) => f.name === functionName);
|
|
1753
|
-
const acceptedTypes = getAcceptedTypes(fn);
|
|
1754
|
-
if (fn) {
|
|
1755
|
-
switch (acceptedTypes) {
|
|
1756
|
-
case "string":
|
|
1757
|
-
return columnFunctionDescriptors.filter((f) => f.type === "string" || f.type === "variable").map(toFunctionCompletion);
|
|
1758
|
-
case "number":
|
|
1759
|
-
return columnFunctionDescriptors.filter((f) => f.type === "number" || f.type === "variable").map(toFunctionCompletion);
|
|
1760
|
-
default:
|
|
1761
|
-
}
|
|
1762
|
-
}
|
|
1763
|
-
}
|
|
1764
|
-
return functions;
|
|
1765
|
-
};
|
|
1766
|
-
var NONE = {};
|
|
1767
|
-
var useColumnExpressionSuggestionProvider = ({
|
|
1768
|
-
columns,
|
|
1769
|
-
table
|
|
1770
|
-
}) => {
|
|
1771
|
-
const findColumn = useCallback2(
|
|
1772
|
-
(name) => name ? columns.find((col) => col.name === name) : void 0,
|
|
1773
|
-
[columns]
|
|
1774
|
-
);
|
|
1775
|
-
const latestSuggestionsRef = useRef3();
|
|
1776
|
-
const getTypeaheadSuggestions = useTypeaheadSuggestions();
|
|
1777
|
-
const getSuggestions = useCallback2(
|
|
1778
|
-
async (suggestionType, options = NONE) => {
|
|
1779
|
-
const { columnName, functionName, operator, prefix } = options;
|
|
1780
|
-
switch (suggestionType) {
|
|
1781
|
-
case "expression": {
|
|
1782
|
-
const suggestions = await withApplySpace(
|
|
1783
|
-
getColumns(columns, { functionName, prefix })
|
|
1784
|
-
).concat(getFunctions(options));
|
|
1785
|
-
return latestSuggestionsRef.current = suggestions;
|
|
1786
|
-
}
|
|
1787
|
-
case "column": {
|
|
1788
|
-
const suggestions = await getColumns(columns, options);
|
|
1789
|
-
return latestSuggestionsRef.current = withApplySpace(suggestions);
|
|
1790
|
-
}
|
|
1791
|
-
case "operator": {
|
|
1792
|
-
const suggestions = await getOperators(findColumn(columnName));
|
|
1793
|
-
return latestSuggestionsRef.current = withApplySpace(suggestions);
|
|
1794
|
-
}
|
|
1795
|
-
case "relational-operator": {
|
|
1796
|
-
const suggestions = await getRelationalOperators(
|
|
1797
|
-
findColumn(columnName)
|
|
1798
|
-
);
|
|
1799
|
-
return latestSuggestionsRef.current = withApplySpace(suggestions);
|
|
1800
|
-
}
|
|
1801
|
-
case "condition-operator":
|
|
1802
|
-
{
|
|
1803
|
-
const column = findColumn(columnName);
|
|
1804
|
-
if (column) {
|
|
1805
|
-
const suggestions = await getConditionOperators(column);
|
|
1806
|
-
if (suggestions) {
|
|
1807
|
-
return latestSuggestionsRef.current = withApplySpace(suggestions);
|
|
1808
|
-
}
|
|
1809
|
-
}
|
|
1810
|
-
}
|
|
1811
|
-
break;
|
|
1812
|
-
case "columnValue":
|
|
1813
|
-
if (columnName && operator) {
|
|
1814
|
-
const params = getTypeaheadParams(
|
|
1815
|
-
table,
|
|
1816
|
-
columnName
|
|
1817
|
-
/*, startsWith*/
|
|
1818
|
-
);
|
|
1819
|
-
const suggestions = await getTypeaheadSuggestions(params);
|
|
1820
|
-
latestSuggestionsRef.current = toSuggestions(suggestions, {
|
|
1821
|
-
suffix: ""
|
|
1822
|
-
});
|
|
1823
|
-
latestSuggestionsRef.current.forEach((suggestion) => {
|
|
1824
|
-
suggestion.apply = (view, completion, from) => {
|
|
1825
|
-
const annotation = new AnnotationType();
|
|
1826
|
-
const cursorPos = from + completion.label.length + 1;
|
|
1827
|
-
view.dispatch({
|
|
1828
|
-
changes: { from, insert: completion.label },
|
|
1829
|
-
selection: { anchor: cursorPos, head: cursorPos },
|
|
1830
|
-
annotations: annotation.of(completion)
|
|
1831
|
-
});
|
|
1832
|
-
};
|
|
1833
|
-
});
|
|
1834
|
-
return latestSuggestionsRef.current;
|
|
1835
|
-
}
|
|
1836
|
-
break;
|
|
1837
|
-
}
|
|
1838
|
-
return [];
|
|
1839
|
-
},
|
|
1840
|
-
[columns, findColumn, getTypeaheadSuggestions, table]
|
|
1841
|
-
);
|
|
1842
|
-
const isPartialMatch = useCallback2(
|
|
1843
|
-
async (valueType, columnName, pattern) => {
|
|
1844
|
-
const { current: latestSuggestions } = latestSuggestionsRef;
|
|
1845
|
-
let maybe = false;
|
|
1846
|
-
const suggestions = latestSuggestions || await getSuggestions(valueType, { columnName });
|
|
1847
|
-
if (pattern && suggestions) {
|
|
1848
|
-
for (const option of suggestions) {
|
|
1849
|
-
if (option.label === pattern) {
|
|
1850
|
-
return false;
|
|
1851
|
-
} else if (option.label.startsWith(pattern)) {
|
|
1852
|
-
maybe = true;
|
|
1853
|
-
}
|
|
1854
|
-
}
|
|
1855
|
-
}
|
|
1856
|
-
return maybe;
|
|
1857
|
-
},
|
|
1858
|
-
[getSuggestions]
|
|
1859
|
-
);
|
|
1860
|
-
return {
|
|
1861
|
-
getSuggestions,
|
|
1862
|
-
isPartialMatch
|
|
1863
|
-
};
|
|
1864
|
-
};
|
|
1865
|
-
|
|
1866
|
-
// src/datagrid-configuration-ui/settings-panel/DatagridSettingsPanel.tsx
|
|
1867
|
-
import { Button as Button3, Panel as Panel5 } from "@salt-ds/core";
|
|
1868
|
-
import cx6 from "classnames";
|
|
1869
|
-
import {
|
|
1870
|
-
useCallback as useCallback8,
|
|
1871
|
-
useState as useState4
|
|
1872
|
-
} from "react";
|
|
1873
|
-
|
|
1874
|
-
// src/datagrid-configuration-ui/column-picker/ColumnPicker.tsx
|
|
1875
|
-
import { List } from "@heswell/salt-lab";
|
|
1876
|
-
import { Button, Text, useIdMemo as useId } from "@salt-ds/core";
|
|
1877
|
-
import { useCallback as useCallback3, useState } from "react";
|
|
1878
|
-
|
|
1879
|
-
// src/datagrid-configuration-ui/column-picker/ColumnListItem.tsx
|
|
1880
|
-
import { ListItem } from "@heswell/salt-lab";
|
|
1881
|
-
import cx3 from "classnames";
|
|
1882
|
-
import { jsx as jsx4, jsxs as jsxs3 } from "react/jsx-runtime";
|
|
1883
|
-
var classBase4 = "vuuColumnListItem";
|
|
1884
|
-
var ColumnListItem = ({
|
|
1885
|
-
className: classNameProp,
|
|
1886
|
-
item,
|
|
1887
|
-
label,
|
|
1888
|
-
style: styleProp,
|
|
1889
|
-
...restProps
|
|
1890
|
-
}) => {
|
|
1891
|
-
const className = cx3(classBase4, classNameProp, {
|
|
1892
|
-
[`${classBase4}-calculated`]: item == null ? void 0 : item.expression,
|
|
1893
|
-
[`${classBase4}-hidden`]: item == null ? void 0 : item.hidden
|
|
1894
|
-
});
|
|
1895
|
-
return /* @__PURE__ */ jsxs3(ListItem, { className, ...restProps, children: [
|
|
1896
|
-
/* @__PURE__ */ jsx4("span", { className: `${classBase4}-iconType` }),
|
|
1897
|
-
/* @__PURE__ */ jsx4("label", { className: `${classBase4}-label`, children: label }),
|
|
1898
|
-
/* @__PURE__ */ jsx4("span", { className: `${classBase4}-iconHidden` })
|
|
1899
|
-
] });
|
|
1900
|
-
};
|
|
1901
|
-
|
|
1902
|
-
// src/datagrid-configuration-ui/column-picker/ColumnPicker.tsx
|
|
1903
|
-
import { jsx as jsx5, jsxs as jsxs4 } from "react/jsx-runtime";
|
|
1904
|
-
var classBase5 = "vuuColumnPicker";
|
|
1905
|
-
var removeSelectedColumns = (availableColumns, selectedColumns) => {
|
|
1906
|
-
return availableColumns.filter(
|
|
1907
|
-
(column) => selectedColumns.find((col) => col.name === column.name) == null
|
|
1908
|
-
);
|
|
1909
|
-
};
|
|
1910
|
-
var ColumnPicker = ({
|
|
1911
|
-
availableColumns,
|
|
1912
|
-
id: idProp,
|
|
1913
|
-
dispatchColumnAction: dispatch,
|
|
1914
|
-
onAddCalculatedColumnClick,
|
|
1915
|
-
onSelectionChange,
|
|
1916
|
-
chosenColumns,
|
|
1917
|
-
selectedColumn
|
|
1918
|
-
}) => {
|
|
1919
|
-
const [selected1, setSelected1] = useState([]);
|
|
1920
|
-
const id = useId(idProp);
|
|
1921
|
-
const unusedColumns = removeSelectedColumns(availableColumns, chosenColumns);
|
|
1922
|
-
const addColumn2 = useCallback3(() => {
|
|
1923
|
-
if (selected1.length > 0) {
|
|
1924
|
-
setSelected1([]);
|
|
1925
|
-
dispatch({ type: "addColumn", columns: selected1 });
|
|
1926
|
-
}
|
|
1927
|
-
}, [dispatch, selected1]);
|
|
1928
|
-
const removeColumn2 = useCallback3(
|
|
1929
|
-
() => selectedColumn && dispatch({ type: "removeColumn", column: selectedColumn }),
|
|
1930
|
-
[selectedColumn, dispatch]
|
|
1931
|
-
);
|
|
1932
|
-
const moveColumnUp = useCallback3(
|
|
1933
|
-
() => selectedColumn && dispatch({ type: "moveColumn", column: selectedColumn, moveBy: -1 }),
|
|
1934
|
-
[dispatch, selectedColumn]
|
|
1935
|
-
);
|
|
1936
|
-
const moveColumnDown = useCallback3(
|
|
1937
|
-
() => selectedColumn && dispatch({ type: "moveColumn", column: selectedColumn, moveBy: 1 }),
|
|
1938
|
-
[dispatch, selectedColumn]
|
|
1939
|
-
);
|
|
1940
|
-
const handleSelectionChange1 = useCallback3(
|
|
1941
|
-
(evt, selected) => setSelected1(selected),
|
|
1942
|
-
[]
|
|
1943
|
-
);
|
|
1944
|
-
const handleSelectionChange2 = useCallback3(
|
|
1945
|
-
(evt, selected) => onSelectionChange == null ? void 0 : onSelectionChange(selected),
|
|
1946
|
-
[onSelectionChange]
|
|
1947
|
-
);
|
|
1948
|
-
const handleDrop = useCallback3(
|
|
1949
|
-
(moveFrom, moveTo) => {
|
|
1950
|
-
dispatch({ type: "moveColumn", moveFrom, moveTo });
|
|
1951
|
-
},
|
|
1952
|
-
[dispatch]
|
|
1953
|
-
);
|
|
1954
|
-
return /* @__PURE__ */ jsxs4("div", { className: classBase5, id, children: [
|
|
1955
|
-
/* @__PURE__ */ jsxs4("div", { className: `${classBase5}-listColumn`, children: [
|
|
1956
|
-
/* @__PURE__ */ jsx5("label", { htmlFor: `available-${id}`, children: /* @__PURE__ */ jsx5(Text, { as: "h4", children: "Available Columns" }) }),
|
|
1957
|
-
/* @__PURE__ */ jsx5(
|
|
1958
|
-
"div",
|
|
1959
|
-
{
|
|
1960
|
-
className: `${classBase5}-listContainer`,
|
|
1961
|
-
style: { flex: 1, overflow: "hidden" },
|
|
1962
|
-
children: /* @__PURE__ */ jsx5(
|
|
1963
|
-
List,
|
|
1964
|
-
{
|
|
1965
|
-
borderless: true,
|
|
1966
|
-
checkable: false,
|
|
1967
|
-
height: "100%",
|
|
1968
|
-
id: `available-${id}`,
|
|
1969
|
-
itemHeight: 24,
|
|
1970
|
-
itemToString: (item) => item.name,
|
|
1971
|
-
onSelectionChange: handleSelectionChange1,
|
|
1972
|
-
selected: selected1,
|
|
1973
|
-
selectionStrategy: "extended",
|
|
1974
|
-
source: unusedColumns
|
|
1975
|
-
}
|
|
1976
|
-
)
|
|
1977
|
-
}
|
|
1978
|
-
),
|
|
1979
|
-
/* @__PURE__ */ jsx5(
|
|
1980
|
-
"div",
|
|
1981
|
-
{
|
|
1982
|
-
style: {
|
|
1983
|
-
display: "flex",
|
|
1984
|
-
alignItems: "center",
|
|
1985
|
-
flex: "0 0 32px",
|
|
1986
|
-
marginTop: "var(--salt-size-basis-unit)"
|
|
1987
|
-
},
|
|
1988
|
-
children: /* @__PURE__ */ jsxs4(Button, { onClick: addColumn2, disabled: selected1.length === 0, children: [
|
|
1989
|
-
"Show",
|
|
1990
|
-
/* @__PURE__ */ jsx5("span", { "data-icon": "arrow-thin-right", style: { marginLeft: 8 } })
|
|
1991
|
-
] })
|
|
1992
|
-
}
|
|
1993
|
-
)
|
|
1994
|
-
] }),
|
|
1995
|
-
/* @__PURE__ */ jsxs4("div", { className: `${classBase5}-listColumn`, children: [
|
|
1996
|
-
/* @__PURE__ */ jsx5("label", { htmlFor: `selected-${id}`, children: /* @__PURE__ */ jsx5(Text, { as: "h4", children: "Included Columns" }) }),
|
|
1997
|
-
/* @__PURE__ */ jsx5(
|
|
1998
|
-
"div",
|
|
1999
|
-
{
|
|
2000
|
-
className: `${classBase5}-listContainer`,
|
|
2001
|
-
style: { flex: 1, overflow: "hidden" },
|
|
2002
|
-
children: /* @__PURE__ */ jsx5(
|
|
2003
|
-
List,
|
|
2004
|
-
{
|
|
2005
|
-
ListItem: ColumnListItem,
|
|
2006
|
-
allowDragDrop: true,
|
|
2007
|
-
borderless: true,
|
|
2008
|
-
height: "100%",
|
|
2009
|
-
id: `selected-${id}`,
|
|
2010
|
-
itemHeight: 24,
|
|
2011
|
-
itemToString: (item) => item.name,
|
|
2012
|
-
onMoveListItem: handleDrop,
|
|
2013
|
-
onSelectionChange: handleSelectionChange2,
|
|
2014
|
-
selected: selectedColumn,
|
|
2015
|
-
style: { flex: 1 },
|
|
2016
|
-
source: chosenColumns
|
|
2017
|
-
}
|
|
2018
|
-
)
|
|
2019
|
-
}
|
|
2020
|
-
),
|
|
2021
|
-
/* @__PURE__ */ jsxs4(
|
|
2022
|
-
"div",
|
|
2023
|
-
{
|
|
2024
|
-
style: {
|
|
2025
|
-
alignItems: "center",
|
|
2026
|
-
flex: "0 0 32px",
|
|
2027
|
-
display: "flex",
|
|
2028
|
-
gap: 6,
|
|
2029
|
-
marginTop: "var(--salt-size-basis-unit)"
|
|
2030
|
-
},
|
|
2031
|
-
children: [
|
|
2032
|
-
/* @__PURE__ */ jsxs4(Button, { onClick: removeColumn2, disabled: selectedColumn === null, children: [
|
|
2033
|
-
/* @__PURE__ */ jsx5("span", { "data-icon": "arrow-thin-left", style: { marginRight: 8 } }),
|
|
2034
|
-
"Hide"
|
|
2035
|
-
] }),
|
|
2036
|
-
/* @__PURE__ */ jsx5(
|
|
2037
|
-
Button,
|
|
2038
|
-
{
|
|
2039
|
-
"aria-label": "Move column up",
|
|
2040
|
-
onClick: moveColumnUp,
|
|
2041
|
-
disabled: selectedColumn === null || (chosenColumns == null ? void 0 : chosenColumns.indexOf(selectedColumn)) === 0,
|
|
2042
|
-
style: { width: 28 },
|
|
2043
|
-
children: /* @__PURE__ */ jsx5("span", { "data-icon": "arrow-thin-up" })
|
|
2044
|
-
}
|
|
2045
|
-
),
|
|
2046
|
-
/* @__PURE__ */ jsx5(
|
|
2047
|
-
Button,
|
|
2048
|
-
{
|
|
2049
|
-
"aria-label": "Move column down",
|
|
2050
|
-
onClick: moveColumnDown,
|
|
2051
|
-
disabled: selectedColumn === null || chosenColumns.indexOf(selectedColumn) === chosenColumns.length - 1,
|
|
2052
|
-
style: { width: 28 },
|
|
2053
|
-
children: /* @__PURE__ */ jsx5("span", { "data-icon": "arrow-thin-down" })
|
|
2054
|
-
}
|
|
2055
|
-
),
|
|
2056
|
-
/* @__PURE__ */ jsx5(
|
|
2057
|
-
Button,
|
|
2058
|
-
{
|
|
2059
|
-
"aria-label": "Add calculated column",
|
|
2060
|
-
className: `${classBase5}-addCalculatedColumn`,
|
|
2061
|
-
onClick: onAddCalculatedColumnClick,
|
|
2062
|
-
variant: "primary",
|
|
2063
|
-
children: /* @__PURE__ */ jsx5("span", { "data-icon": "add" })
|
|
2064
|
-
}
|
|
2065
|
-
)
|
|
2066
|
-
]
|
|
2067
|
-
}
|
|
2068
|
-
)
|
|
2069
|
-
] })
|
|
2070
|
-
] });
|
|
2071
|
-
};
|
|
2072
|
-
|
|
2073
|
-
// src/datagrid-configuration-ui/column-settings-panel/ColumnSettingsPanel.tsx
|
|
2074
|
-
import { Stack } from "@vuu-ui/vuu-layout";
|
|
2075
|
-
import {
|
|
2076
|
-
Checkbox,
|
|
2077
|
-
FormField as FormField2,
|
|
2078
|
-
Input,
|
|
2079
|
-
RadioButton,
|
|
2080
|
-
RadioButtonGroup,
|
|
2081
|
-
StepperInput as StepperInput2
|
|
2082
|
-
} from "@heswell/salt-lab";
|
|
2083
|
-
import { Panel as Panel2, Text as Text3 } from "@salt-ds/core";
|
|
2084
|
-
import cx5 from "classnames";
|
|
2085
|
-
import {
|
|
2086
|
-
useCallback as useCallback5,
|
|
2087
|
-
useState as useState2
|
|
2088
|
-
} from "react";
|
|
2089
|
-
|
|
2090
|
-
// src/datagrid-configuration-ui/column-type-panel/ColumnTypePanel.tsx
|
|
2091
|
-
import { getRegisteredCellRenderers } from "@vuu-ui/vuu-utils";
|
|
2092
|
-
import { Dropdown } from "@heswell/salt-lab";
|
|
2093
|
-
import { Panel } from "@salt-ds/core";
|
|
2094
|
-
import cx4 from "classnames";
|
|
2095
|
-
import { useMemo as useMemo2 } from "react";
|
|
2096
|
-
|
|
2097
|
-
// src/datagrid-configuration-ui/column-type-panel/NumericColumnPanel.tsx
|
|
2098
|
-
import { FormField, StepperInput, Switch } from "@heswell/salt-lab";
|
|
2099
|
-
import { Text as Text2 } from "@salt-ds/core";
|
|
2100
|
-
import { useCallback as useCallback4 } from "react";
|
|
2101
|
-
import { Fragment, jsx as jsx6, jsxs as jsxs5 } from "react/jsx-runtime";
|
|
2102
|
-
var defaultValues = {
|
|
2103
|
-
alignOnDecimals: false,
|
|
2104
|
-
decimals: 4,
|
|
2105
|
-
zeroPad: false
|
|
2106
|
-
};
|
|
2107
|
-
var getColumnValues = (columnType, gridDefaultValues) => {
|
|
2108
|
-
const columnValue = typeof columnType === "object" && columnType.formatting ? columnType.formatting : {};
|
|
2109
|
-
const properties = ["alignOnDecimals", "decimals", "zeroPad"];
|
|
2110
|
-
return properties.reduce((configValues, property) => {
|
|
2111
|
-
if (columnValue[property] !== void 0) {
|
|
2112
|
-
return {
|
|
2113
|
-
...configValues,
|
|
2114
|
-
[property]: columnValue[property]
|
|
2115
|
-
};
|
|
2116
|
-
} else if ((gridDefaultValues == null ? void 0 : gridDefaultValues[property]) !== void 0) {
|
|
2117
|
-
return {
|
|
2118
|
-
...configValues,
|
|
2119
|
-
[property]: gridDefaultValues[property]
|
|
2120
|
-
};
|
|
2121
|
-
}
|
|
2122
|
-
return configValues;
|
|
2123
|
-
}, defaultValues);
|
|
2124
|
-
};
|
|
2125
|
-
var NumericColumnPanel = ({
|
|
2126
|
-
column,
|
|
2127
|
-
dispatchColumnAction
|
|
2128
|
-
}) => {
|
|
2129
|
-
const { decimals, alignOnDecimals, zeroPad } = getColumnValues(column == null ? void 0 : column.type);
|
|
2130
|
-
const dispatchUpdate = useCallback4(
|
|
2131
|
-
(values) => dispatchColumnAction({
|
|
2132
|
-
type: "updateColumnTypeFormatting",
|
|
2133
|
-
column,
|
|
2134
|
-
...values
|
|
2135
|
-
}),
|
|
2136
|
-
[column, dispatchColumnAction]
|
|
2137
|
-
);
|
|
2138
|
-
const handleChangeDecimals = useCallback4(
|
|
2139
|
-
(value) => dispatchUpdate({ decimals: parseInt(value.toString(), 10) }),
|
|
2140
|
-
[dispatchUpdate]
|
|
2141
|
-
);
|
|
2142
|
-
const handleChangeAlignOnDecimals = useCallback4(
|
|
2143
|
-
(evt, value) => dispatchUpdate({ alignOnDecimals: value }),
|
|
2144
|
-
[dispatchUpdate]
|
|
2145
|
-
);
|
|
2146
|
-
const handleChangeZeroPad = useCallback4(
|
|
2147
|
-
(evt, value) => dispatchUpdate({ zeroPad: value }),
|
|
2148
|
-
[dispatchUpdate]
|
|
2149
|
-
);
|
|
2150
|
-
switch (column.serverDataType) {
|
|
2151
|
-
case "double":
|
|
2152
|
-
return /* @__PURE__ */ jsxs5(Fragment, { children: [
|
|
2153
|
-
/* @__PURE__ */ jsx6(FormField, { label: "No of Decimals", labelPlacement: "top", children: /* @__PURE__ */ jsx6(StepperInput, { value: decimals, onChange: handleChangeDecimals }) }),
|
|
2154
|
-
/* @__PURE__ */ jsx6(
|
|
2155
|
-
Switch,
|
|
2156
|
-
{
|
|
2157
|
-
checked: alignOnDecimals,
|
|
2158
|
-
label: "Align on decimals",
|
|
2159
|
-
LabelProps: { className: "vuuColumnPanelSwitch" },
|
|
2160
|
-
onChange: handleChangeAlignOnDecimals
|
|
2161
|
-
}
|
|
2162
|
-
),
|
|
2163
|
-
/* @__PURE__ */ jsx6(
|
|
2164
|
-
Switch,
|
|
2165
|
-
{
|
|
2166
|
-
checked: zeroPad,
|
|
2167
|
-
label: "Zero pad",
|
|
2168
|
-
LabelProps: { className: "vuuColumnPanelSwitch" },
|
|
2169
|
-
onChange: handleChangeZeroPad
|
|
2170
|
-
}
|
|
2171
|
-
)
|
|
2172
|
-
] });
|
|
2173
|
-
case "long":
|
|
2174
|
-
case "int":
|
|
2175
|
-
return /* @__PURE__ */ jsx6(Fragment, { children: /* @__PURE__ */ jsx6(Text2, { children: "Work in progress" }) });
|
|
2176
|
-
default:
|
|
2177
|
-
return null;
|
|
2178
|
-
}
|
|
2179
|
-
};
|
|
2180
|
-
|
|
2181
|
-
// src/datagrid-configuration-ui/column-type-panel/StringColumnPanel.tsx
|
|
2182
|
-
import { Fragment as Fragment2, jsx as jsx7 } from "react/jsx-runtime";
|
|
2183
|
-
var StringColumnPanel = ({
|
|
2184
|
-
column,
|
|
2185
|
-
dispatchColumnAction
|
|
2186
|
-
}) => {
|
|
2187
|
-
return /* @__PURE__ */ jsx7(Fragment2, { children: "String" });
|
|
2188
|
-
};
|
|
2189
|
-
|
|
2190
|
-
// src/datagrid-configuration-ui/column-type-panel/ColumnTypePanel.tsx
|
|
2191
|
-
import { Fragment as Fragment3, jsx as jsx8, jsxs as jsxs6 } from "react/jsx-runtime";
|
|
2192
|
-
var classBase6 = "vuuColumnTypePanel";
|
|
2193
|
-
var integerCellRenderers = ["Default Renderer (int, long)"];
|
|
2194
|
-
var doubleCellRenderers = ["Default Renderer (double)"];
|
|
2195
|
-
var stringCellRenderers = ["Default Renderer (string)"];
|
|
2196
|
-
var getAvailableCellRenderers = (column) => {
|
|
2197
|
-
const customCellRenderers = getRegisteredCellRenderers(column.serverDataType);
|
|
2198
|
-
const customRendererNames = customCellRenderers.map((r) => r.name);
|
|
2199
|
-
console.log({ customRendererNames });
|
|
2200
|
-
switch (column.serverDataType) {
|
|
2201
|
-
case "char":
|
|
2202
|
-
case "string":
|
|
2203
|
-
return stringCellRenderers;
|
|
2204
|
-
case "int":
|
|
2205
|
-
case "long":
|
|
2206
|
-
return integerCellRenderers;
|
|
2207
|
-
case "double":
|
|
2208
|
-
return doubleCellRenderers.concat(customRendererNames);
|
|
2209
|
-
default:
|
|
2210
|
-
return stringCellRenderers;
|
|
2211
|
-
}
|
|
2212
|
-
};
|
|
2213
|
-
var ColumnTypePanel = ({
|
|
2214
|
-
className,
|
|
2215
|
-
column,
|
|
2216
|
-
dispatchColumnAction,
|
|
2217
|
-
...props
|
|
2218
|
-
}) => {
|
|
2219
|
-
const content = useMemo2(() => {
|
|
2220
|
-
switch (column.serverDataType) {
|
|
2221
|
-
case "double":
|
|
2222
|
-
case "int":
|
|
2223
|
-
case "long":
|
|
2224
|
-
return /* @__PURE__ */ jsx8(
|
|
2225
|
-
NumericColumnPanel,
|
|
2226
|
-
{
|
|
2227
|
-
column,
|
|
2228
|
-
dispatchColumnAction
|
|
2229
|
-
}
|
|
2230
|
-
);
|
|
2231
|
-
default:
|
|
2232
|
-
return /* @__PURE__ */ jsx8(
|
|
2233
|
-
StringColumnPanel,
|
|
2234
|
-
{
|
|
2235
|
-
column,
|
|
2236
|
-
dispatchColumnAction
|
|
2237
|
-
}
|
|
2238
|
-
);
|
|
2239
|
-
}
|
|
2240
|
-
}, [column, dispatchColumnAction]);
|
|
2241
|
-
const { serverDataType = "string" } = column;
|
|
2242
|
-
const availableRenderers = getAvailableCellRenderers(column);
|
|
2243
|
-
return /* @__PURE__ */ jsxs6(Fragment3, { children: [
|
|
2244
|
-
/* @__PURE__ */ jsx8(
|
|
2245
|
-
Dropdown,
|
|
2246
|
-
{
|
|
2247
|
-
className: cx4(`${classBase6}-renderer`),
|
|
2248
|
-
fullWidth: true,
|
|
2249
|
-
selected: availableRenderers[0],
|
|
2250
|
-
source: availableRenderers
|
|
2251
|
-
}
|
|
2252
|
-
),
|
|
2253
|
-
/* @__PURE__ */ jsx8(
|
|
2254
|
-
Panel,
|
|
2255
|
-
{
|
|
2256
|
-
...props,
|
|
2257
|
-
className: cx4(classBase6, className, `${classBase6}-${serverDataType}`),
|
|
2258
|
-
children: content
|
|
2259
|
-
}
|
|
2260
|
-
)
|
|
2261
|
-
] });
|
|
2262
|
-
};
|
|
2263
|
-
|
|
2264
|
-
// src/datagrid-configuration-ui/column-settings-panel/ColumnSettingsPanel.tsx
|
|
2265
|
-
import { jsx as jsx9, jsxs as jsxs7 } from "react/jsx-runtime";
|
|
2266
|
-
var classBase7 = "vuuColumnSettingsPanel";
|
|
2267
|
-
var tabstripProps = {
|
|
2268
|
-
className: "salt-density-high"
|
|
2269
|
-
};
|
|
2270
|
-
var NullActivationIndicator = () => null;
|
|
2271
|
-
var ColumnSettingsPanel = ({
|
|
2272
|
-
column,
|
|
2273
|
-
dispatchColumnAction,
|
|
2274
|
-
style: styleProp,
|
|
2275
|
-
...props
|
|
2276
|
-
}) => {
|
|
2277
|
-
var _a, _b, _c, _d;
|
|
2278
|
-
const [activeTab, setActiveTab] = useState2(0);
|
|
2279
|
-
const dispatchUpdate = useCallback5(
|
|
2280
|
-
(values) => dispatchColumnAction({
|
|
2281
|
-
type: "updateColumnProp",
|
|
2282
|
-
column,
|
|
2283
|
-
...values
|
|
2284
|
-
}),
|
|
2285
|
-
[column, dispatchColumnAction]
|
|
2286
|
-
);
|
|
2287
|
-
const handleChangeAlign = useCallback5(
|
|
2288
|
-
(evt) => dispatchUpdate({ align: evt.target.value }),
|
|
2289
|
-
[dispatchUpdate]
|
|
2290
|
-
);
|
|
2291
|
-
const handleChangePin = useCallback5(
|
|
2292
|
-
(evt) => dispatchUpdate({ pin: evt.target.value }),
|
|
2293
|
-
[dispatchUpdate]
|
|
2294
|
-
);
|
|
2295
|
-
const handleChangeHidden = useCallback5(
|
|
2296
|
-
(evt, value) => dispatchUpdate({ hidden: value }),
|
|
2297
|
-
[dispatchUpdate]
|
|
2298
|
-
);
|
|
2299
|
-
const handleChangeLabel = useCallback5(
|
|
2300
|
-
(evt, value) => dispatchUpdate({ label: value }),
|
|
2301
|
-
[dispatchUpdate]
|
|
2302
|
-
);
|
|
2303
|
-
const handleChangeWidth = useCallback5(
|
|
2304
|
-
(value) => dispatchUpdate({ width: parseInt(value.toString(), 10) }),
|
|
2305
|
-
[dispatchUpdate]
|
|
2306
|
-
);
|
|
2307
|
-
return /* @__PURE__ */ jsxs7(
|
|
2308
|
-
"div",
|
|
2309
|
-
{
|
|
2310
|
-
className: classBase7,
|
|
2311
|
-
...props,
|
|
2312
|
-
style: {
|
|
2313
|
-
...styleProp
|
|
2314
|
-
},
|
|
2315
|
-
children: [
|
|
2316
|
-
/* @__PURE__ */ jsx9(Text3, { as: "h4", children: "Column Settings" }),
|
|
2317
|
-
/* @__PURE__ */ jsxs7(
|
|
2318
|
-
Stack,
|
|
2319
|
-
{
|
|
2320
|
-
active: activeTab,
|
|
2321
|
-
showTabs: true,
|
|
2322
|
-
className: cx5(`${classBase7}-columnTabs`),
|
|
2323
|
-
onTabSelectionChanged: setActiveTab,
|
|
2324
|
-
TabstripProps: tabstripProps,
|
|
2325
|
-
children: [
|
|
2326
|
-
/* @__PURE__ */ jsxs7(Panel2, { title: "Column", children: [
|
|
2327
|
-
/* @__PURE__ */ jsx9(FormField2, { label: "Hidden", labelPlacement: "left", children: /* @__PURE__ */ jsx9(
|
|
2328
|
-
Checkbox,
|
|
2329
|
-
{
|
|
2330
|
-
checked: column.hidden === true,
|
|
2331
|
-
onChange: handleChangeHidden
|
|
2332
|
-
}
|
|
2333
|
-
) }),
|
|
2334
|
-
/* @__PURE__ */ jsx9(FormField2, { label: "Label", labelPlacement: "left", children: /* @__PURE__ */ jsx9(
|
|
2335
|
-
Input,
|
|
2336
|
-
{
|
|
2337
|
-
value: (_a = column.label) != null ? _a : column.name,
|
|
2338
|
-
onChange: handleChangeLabel
|
|
2339
|
-
}
|
|
2340
|
-
) }),
|
|
2341
|
-
/* @__PURE__ */ jsx9(FormField2, { label: "Width", labelPlacement: "left", children: /* @__PURE__ */ jsx9(
|
|
2342
|
-
StepperInput2,
|
|
2343
|
-
{
|
|
2344
|
-
value: (_b = column.width) != null ? _b : 100,
|
|
2345
|
-
onChange: handleChangeWidth
|
|
2346
|
-
}
|
|
2347
|
-
) }),
|
|
2348
|
-
/* @__PURE__ */ jsx9(
|
|
2349
|
-
FormField2,
|
|
2350
|
-
{
|
|
2351
|
-
label: "Align",
|
|
2352
|
-
labelPlacement: "left",
|
|
2353
|
-
ActivationIndicatorComponent: NullActivationIndicator,
|
|
2354
|
-
children: /* @__PURE__ */ jsxs7(
|
|
2355
|
-
RadioButtonGroup,
|
|
2356
|
-
{
|
|
2357
|
-
"aria-label": "Column Align",
|
|
2358
|
-
value: (_c = column.align) != null ? _c : "left",
|
|
2359
|
-
legend: "Align",
|
|
2360
|
-
onChange: handleChangeAlign,
|
|
2361
|
-
children: [
|
|
2362
|
-
/* @__PURE__ */ jsx9(RadioButton, { label: "Left", value: "left" }),
|
|
2363
|
-
/* @__PURE__ */ jsx9(RadioButton, { label: "Right", value: "right" })
|
|
2364
|
-
]
|
|
2365
|
-
}
|
|
2366
|
-
)
|
|
2367
|
-
}
|
|
2368
|
-
),
|
|
2369
|
-
/* @__PURE__ */ jsx9(
|
|
2370
|
-
FormField2,
|
|
2371
|
-
{
|
|
2372
|
-
label: "Pin Column",
|
|
2373
|
-
labelPlacement: "left",
|
|
2374
|
-
ActivationIndicatorComponent: NullActivationIndicator,
|
|
2375
|
-
children: /* @__PURE__ */ jsxs7(
|
|
2376
|
-
RadioButtonGroup,
|
|
2377
|
-
{
|
|
2378
|
-
"aria-label": "Pin Column",
|
|
2379
|
-
value: (_d = column.pin) != null ? _d : "",
|
|
2380
|
-
legend: "Pin Column",
|
|
2381
|
-
onChange: handleChangePin,
|
|
2382
|
-
children: [
|
|
2383
|
-
/* @__PURE__ */ jsx9(RadioButton, { label: "Do not pin", value: "" }),
|
|
2384
|
-
/* @__PURE__ */ jsx9(RadioButton, { label: "Left", value: "left" }),
|
|
2385
|
-
/* @__PURE__ */ jsx9(RadioButton, { label: "Right", value: "right" })
|
|
2386
|
-
]
|
|
2387
|
-
}
|
|
2388
|
-
)
|
|
2389
|
-
}
|
|
2390
|
-
)
|
|
2391
|
-
] }),
|
|
2392
|
-
/* @__PURE__ */ jsx9(
|
|
2393
|
-
ColumnTypePanel,
|
|
2394
|
-
{
|
|
2395
|
-
column,
|
|
2396
|
-
dispatchColumnAction,
|
|
2397
|
-
title: "Data Cell"
|
|
2398
|
-
}
|
|
2399
|
-
),
|
|
2400
|
-
/* @__PURE__ */ jsxs7(Panel2, { title: "Vuu", variant: "secondary", children: [
|
|
2401
|
-
/* @__PURE__ */ jsx9(
|
|
2402
|
-
FormField2,
|
|
2403
|
-
{
|
|
2404
|
-
label: "Name",
|
|
2405
|
-
labelPlacement: "top",
|
|
2406
|
-
readOnly: true,
|
|
2407
|
-
variant: "secondary",
|
|
2408
|
-
children: /* @__PURE__ */ jsx9(Input, { value: column.name })
|
|
2409
|
-
}
|
|
2410
|
-
),
|
|
2411
|
-
/* @__PURE__ */ jsx9(
|
|
2412
|
-
FormField2,
|
|
2413
|
-
{
|
|
2414
|
-
label: "Vuu type",
|
|
2415
|
-
labelPlacement: "top",
|
|
2416
|
-
readOnly: true,
|
|
2417
|
-
variant: "secondary",
|
|
2418
|
-
children: /* @__PURE__ */ jsx9(Input, { value: column.serverDataType })
|
|
2419
|
-
}
|
|
2420
|
-
)
|
|
2421
|
-
] })
|
|
2422
|
-
]
|
|
2423
|
-
}
|
|
2424
|
-
)
|
|
2425
|
-
]
|
|
2426
|
-
}
|
|
2427
|
-
);
|
|
2428
|
-
};
|
|
2429
|
-
|
|
2430
|
-
// src/datagrid-configuration-ui/settings-panel/GridSettingsPanel.tsx
|
|
2431
|
-
import {
|
|
2432
|
-
FormField as FormField3,
|
|
2433
|
-
RadioButton as RadioButton2,
|
|
2434
|
-
RadioButtonGroup as RadioButtonGroup2,
|
|
2435
|
-
StepperInput as StepperInput3
|
|
2436
|
-
} from "@heswell/salt-lab";
|
|
2437
|
-
import { Panel as Panel3, Text as Text4 } from "@salt-ds/core";
|
|
2438
|
-
import { useCallback as useCallback6 } from "react";
|
|
2439
|
-
import { jsx as jsx10, jsxs as jsxs8 } from "react/jsx-runtime";
|
|
2440
|
-
var classBase8 = "vuuGridSettingsPanel";
|
|
2441
|
-
var NullActivationIndicator2 = () => null;
|
|
2442
|
-
var GridSettingsPanel = ({
|
|
2443
|
-
config,
|
|
2444
|
-
dispatchColumnAction,
|
|
2445
|
-
style: styleProp,
|
|
2446
|
-
...props
|
|
2447
|
-
}) => {
|
|
2448
|
-
var _a;
|
|
2449
|
-
const dispatchUpdate = useCallback6(
|
|
2450
|
-
(values) => dispatchColumnAction({
|
|
2451
|
-
type: "updateGridSettings",
|
|
2452
|
-
...values
|
|
2453
|
-
}),
|
|
2454
|
-
[dispatchColumnAction]
|
|
2455
|
-
);
|
|
2456
|
-
const handleChangeLabelFormatting = useCallback6(
|
|
2457
|
-
(evt) => dispatchUpdate({
|
|
2458
|
-
columnFormatHeader: evt.target.value
|
|
2459
|
-
}),
|
|
2460
|
-
[dispatchUpdate]
|
|
2461
|
-
);
|
|
2462
|
-
const handleChangeWidth = useCallback6(
|
|
2463
|
-
(value) => dispatchUpdate({ columnDefaultWidth: parseInt(value.toString(), 10) }),
|
|
2464
|
-
[dispatchUpdate]
|
|
2465
|
-
);
|
|
2466
|
-
return /* @__PURE__ */ jsxs8(
|
|
2467
|
-
"div",
|
|
2468
|
-
{
|
|
2469
|
-
className: classBase8,
|
|
2470
|
-
...props,
|
|
2471
|
-
style: {
|
|
2472
|
-
...styleProp
|
|
2473
|
-
},
|
|
2474
|
-
children: [
|
|
2475
|
-
/* @__PURE__ */ jsx10(Text4, { as: "h4", children: "Grid Settings" }),
|
|
2476
|
-
/* @__PURE__ */ jsxs8(Panel3, { children: [
|
|
2477
|
-
/* @__PURE__ */ jsx10(
|
|
2478
|
-
FormField3,
|
|
2479
|
-
{
|
|
2480
|
-
label: "Format column labels",
|
|
2481
|
-
labelPlacement: "left",
|
|
2482
|
-
ActivationIndicatorComponent: NullActivationIndicator2,
|
|
2483
|
-
children: /* @__PURE__ */ jsxs8(
|
|
2484
|
-
RadioButtonGroup2,
|
|
2485
|
-
{
|
|
2486
|
-
"aria-label": "Format column labels",
|
|
2487
|
-
value: config.columnFormatHeader,
|
|
2488
|
-
legend: "Format column labels",
|
|
2489
|
-
onChange: handleChangeLabelFormatting,
|
|
2490
|
-
children: [
|
|
2491
|
-
/* @__PURE__ */ jsx10(RadioButton2, { label: "No Formatting", value: void 0 }),
|
|
2492
|
-
/* @__PURE__ */ jsx10(RadioButton2, { label: "Capitalize", value: "capitalize" }),
|
|
2493
|
-
/* @__PURE__ */ jsx10(RadioButton2, { label: "Uppercase", value: "uppercase" })
|
|
2494
|
-
]
|
|
2495
|
-
}
|
|
2496
|
-
)
|
|
2497
|
-
}
|
|
2498
|
-
),
|
|
2499
|
-
/* @__PURE__ */ jsx10(FormField3, { label: "Default Column Width", labelPlacement: "left", children: /* @__PURE__ */ jsx10(
|
|
2500
|
-
StepperInput3,
|
|
2501
|
-
{
|
|
2502
|
-
value: (_a = config.columnDefaultWidth) != null ? _a : 100,
|
|
2503
|
-
onChange: handleChangeWidth
|
|
2504
|
-
}
|
|
2505
|
-
) })
|
|
2506
|
-
] })
|
|
2507
|
-
]
|
|
2508
|
-
}
|
|
2509
|
-
);
|
|
2510
|
-
};
|
|
2511
|
-
|
|
2512
|
-
// src/datagrid-configuration-ui/settings-panel/useGridSettings.ts
|
|
2513
|
-
import { useReducer } from "react";
|
|
2514
|
-
import { moveItem } from "@heswell/salt-lab";
|
|
2515
|
-
import { fromServerDataType } from "@vuu-ui/vuu-utils";
|
|
2516
|
-
var gridSettingsReducer = (state, action) => {
|
|
2517
|
-
console.log(`gridSettingsReducer ${action.type}`);
|
|
2518
|
-
switch (action.type) {
|
|
2519
|
-
case "addColumn":
|
|
2520
|
-
return addColumn(state, action);
|
|
2521
|
-
case "addCalculatedColumn":
|
|
2522
|
-
return addCalculatedColumn(state, action);
|
|
2523
|
-
case "moveColumn":
|
|
2524
|
-
return moveColumn(state, action);
|
|
2525
|
-
case "removeColumn":
|
|
2526
|
-
return removeColumn(state, action);
|
|
2527
|
-
case "updateColumn":
|
|
2528
|
-
return state;
|
|
2529
|
-
case "updateColumnProp":
|
|
2530
|
-
return updateColumnProp(state, action);
|
|
2531
|
-
case "updateGridSettings":
|
|
2532
|
-
return updateGridSettings(state, action);
|
|
2533
|
-
case "updateColumnTypeFormatting":
|
|
2534
|
-
return updateColumnTypeFormatting(state, action);
|
|
2535
|
-
default:
|
|
2536
|
-
return state;
|
|
2537
|
-
}
|
|
2538
|
-
};
|
|
2539
|
-
var useGridSettings = (config) => {
|
|
2540
|
-
const [state, dispatchColumnAction] = useReducer(
|
|
2541
|
-
gridSettingsReducer,
|
|
2542
|
-
config
|
|
2543
|
-
);
|
|
2544
|
-
return {
|
|
2545
|
-
gridSettings: state,
|
|
2546
|
-
dispatchColumnAction
|
|
2547
|
-
};
|
|
2548
|
-
};
|
|
2549
|
-
function addColumn(state, { column, columns, index = -1 }) {
|
|
2550
|
-
const { columns: stateColumns } = state;
|
|
2551
|
-
if (index === -1) {
|
|
2552
|
-
if (Array.isArray(columns)) {
|
|
2553
|
-
return { ...state, columns: stateColumns.concat(columns) };
|
|
2554
|
-
} else if (column) {
|
|
2555
|
-
return { ...state, columns: stateColumns.concat(column) };
|
|
2556
|
-
}
|
|
2557
|
-
}
|
|
2558
|
-
return state;
|
|
2559
|
-
}
|
|
2560
|
-
function addCalculatedColumn(state, { columnName, columnType, expression }) {
|
|
2561
|
-
const { columns: stateColumns } = state;
|
|
2562
|
-
const calculatedColumn = {
|
|
2563
|
-
name: columnName,
|
|
2564
|
-
expression,
|
|
2565
|
-
serverDataType: columnType
|
|
2566
|
-
};
|
|
2567
|
-
return { ...state, columns: stateColumns.concat(calculatedColumn) };
|
|
2568
|
-
}
|
|
2569
|
-
function removeColumn(state, { column }) {
|
|
2570
|
-
const { columns: stateColumns } = state;
|
|
2571
|
-
return {
|
|
2572
|
-
...state,
|
|
2573
|
-
columns: stateColumns.filter((col) => col.name !== column.name)
|
|
2574
|
-
};
|
|
2575
|
-
}
|
|
2576
|
-
function moveColumn(state, { column, moveBy, moveFrom, moveTo }) {
|
|
2577
|
-
const { columns: stateColumns } = state;
|
|
2578
|
-
if (column && typeof moveBy === "number") {
|
|
2579
|
-
const idx = stateColumns.indexOf(column);
|
|
2580
|
-
const newColumns = stateColumns.slice();
|
|
2581
|
-
const [movedColumns] = newColumns.splice(idx, 1);
|
|
2582
|
-
newColumns.splice(idx + moveBy, 0, movedColumns);
|
|
2583
|
-
return {
|
|
2584
|
-
...state,
|
|
2585
|
-
columns: newColumns
|
|
2586
|
-
};
|
|
2587
|
-
} else if (typeof moveFrom === "number" && typeof moveTo === "number") {
|
|
2588
|
-
return {
|
|
2589
|
-
...state,
|
|
2590
|
-
columns: moveItem(stateColumns, moveFrom, moveTo)
|
|
2591
|
-
};
|
|
2592
|
-
} else {
|
|
2593
|
-
return state;
|
|
2594
|
-
}
|
|
2595
|
-
}
|
|
2596
|
-
function updateColumnProp(state, { align, column, hidden, label, width }) {
|
|
2597
|
-
let { columns: stateColumns } = state;
|
|
2598
|
-
if (align === "left" || align === "right") {
|
|
2599
|
-
stateColumns = replaceColumn(stateColumns, { ...column, align });
|
|
2600
|
-
}
|
|
2601
|
-
if (typeof hidden === "boolean") {
|
|
2602
|
-
stateColumns = replaceColumn(stateColumns, { ...column, hidden });
|
|
2603
|
-
}
|
|
2604
|
-
if (typeof label === "string") {
|
|
2605
|
-
stateColumns = replaceColumn(stateColumns, { ...column, label });
|
|
2606
|
-
}
|
|
2607
|
-
if (typeof width === "number") {
|
|
2608
|
-
stateColumns = replaceColumn(stateColumns, { ...column, width });
|
|
2609
|
-
}
|
|
2610
|
-
return {
|
|
2611
|
-
...state,
|
|
2612
|
-
columns: stateColumns
|
|
2613
|
-
};
|
|
2614
|
-
}
|
|
2615
|
-
function updateGridSettings(state, { columnFormatHeader }) {
|
|
2616
|
-
return {
|
|
2617
|
-
...state,
|
|
2618
|
-
columnFormatHeader: columnFormatHeader != null ? columnFormatHeader : state.columnFormatHeader
|
|
2619
|
-
};
|
|
2620
|
-
}
|
|
2621
|
-
function updateColumnTypeFormatting(state, {
|
|
2622
|
-
alignOnDecimals,
|
|
2623
|
-
column,
|
|
2624
|
-
decimals,
|
|
2625
|
-
zeroPad
|
|
2626
|
-
}) {
|
|
2627
|
-
const { columns: stateColumns } = state;
|
|
2628
|
-
const targetColumn = stateColumns.find((col) => col.name === column.name);
|
|
2629
|
-
if (targetColumn) {
|
|
2630
|
-
const {
|
|
2631
|
-
serverDataType = "string",
|
|
2632
|
-
type: columnType = fromServerDataType(serverDataType)
|
|
2633
|
-
} = column;
|
|
2634
|
-
const type = typeof columnType === "string" ? {
|
|
2635
|
-
name: columnType
|
|
2636
|
-
} : {
|
|
2637
|
-
...columnType
|
|
2638
|
-
};
|
|
2639
|
-
if (typeof alignOnDecimals === "boolean") {
|
|
2640
|
-
type.formatting = {
|
|
2641
|
-
...type.formatting,
|
|
2642
|
-
alignOnDecimals
|
|
2643
|
-
};
|
|
2644
|
-
}
|
|
2645
|
-
if (typeof decimals === "number") {
|
|
2646
|
-
type.formatting = {
|
|
2647
|
-
...type.formatting,
|
|
2648
|
-
decimals
|
|
2649
|
-
};
|
|
2650
|
-
}
|
|
2651
|
-
if (typeof zeroPad === "boolean") {
|
|
2652
|
-
type.formatting = {
|
|
2653
|
-
...type.formatting,
|
|
2654
|
-
zeroPad
|
|
2655
|
-
};
|
|
2656
|
-
}
|
|
2657
|
-
return {
|
|
2658
|
-
...state,
|
|
2659
|
-
columns: replaceColumn(stateColumns, { ...column, type })
|
|
2660
|
-
};
|
|
2661
|
-
} else {
|
|
2662
|
-
return state;
|
|
2663
|
-
}
|
|
2664
|
-
}
|
|
2665
|
-
function replaceColumn(columns, column) {
|
|
2666
|
-
return columns.map((col) => col.name === column.name ? column : col);
|
|
2667
|
-
}
|
|
2668
|
-
|
|
2669
|
-
// src/datagrid-configuration-ui/settings-panel/DatagridSettingsPanel.tsx
|
|
2670
|
-
import { Stack as Stack2 } from "@vuu-ui/vuu-layout";
|
|
2671
|
-
|
|
2672
|
-
// src/datagrid-configuration-ui/calculated-column-panel/CalculatedColumnPanel.tsx
|
|
2673
|
-
import { FormField as FormField4, Input as Input2 } from "@heswell/salt-lab";
|
|
2674
|
-
import { Button as Button2, Panel as Panel4, Text as Text5 } from "@salt-ds/core";
|
|
2675
|
-
import {
|
|
2676
|
-
useCallback as useCallback7,
|
|
2677
|
-
useRef as useRef4,
|
|
2678
|
-
useState as useState3
|
|
2679
|
-
} from "react";
|
|
2680
|
-
import { jsx as jsx11, jsxs as jsxs9 } from "react/jsx-runtime";
|
|
2681
|
-
var CalculatedColumnPanel = ({
|
|
2682
|
-
columns,
|
|
2683
|
-
dispatchColumnAction,
|
|
2684
|
-
table
|
|
2685
|
-
}) => {
|
|
2686
|
-
const [columnName, setColumnName] = useState3("");
|
|
2687
|
-
const [, setExpression] = useState3();
|
|
2688
|
-
const sourceRef = useRef4("");
|
|
2689
|
-
const suggestionProvider = useColumnExpressionSuggestionProvider({
|
|
2690
|
-
columns,
|
|
2691
|
-
table
|
|
2692
|
-
});
|
|
2693
|
-
const handleChangeName = useCallback7(
|
|
2694
|
-
(evt) => {
|
|
2695
|
-
const { value } = evt.target;
|
|
2696
|
-
setColumnName(value);
|
|
2697
|
-
},
|
|
2698
|
-
[]
|
|
2699
|
-
);
|
|
2700
|
-
const handleChangeExpression = useCallback7((source) => {
|
|
2701
|
-
sourceRef.current = source;
|
|
2702
|
-
}, []);
|
|
2703
|
-
const handleSubmitExpression = useCallback7(
|
|
2704
|
-
(source, expression) => {
|
|
2705
|
-
console.log({ source });
|
|
2706
|
-
setExpression(expression);
|
|
2707
|
-
},
|
|
2708
|
-
[]
|
|
2709
|
-
);
|
|
2710
|
-
const handleSave = useCallback7(() => {
|
|
2711
|
-
if (sourceRef.current) {
|
|
2712
|
-
console.log(
|
|
2713
|
-
`save expression ${JSON.stringify(sourceRef.current, null, 2)}`
|
|
2714
|
-
);
|
|
2715
|
-
dispatchColumnAction({
|
|
2716
|
-
type: "addCalculatedColumn",
|
|
2717
|
-
columnName,
|
|
2718
|
-
expression: sourceRef.current,
|
|
2719
|
-
columnType: "string"
|
|
2720
|
-
});
|
|
2721
|
-
}
|
|
2722
|
-
}, [columnName, dispatchColumnAction]);
|
|
2723
|
-
return /* @__PURE__ */ jsxs9(Panel4, { className: "vuuCalculatedColumnPanel", title: "Define Computed Column", children: [
|
|
2724
|
-
/* @__PURE__ */ jsx11(Text5, { styleAs: "h4", children: "Define Computed Column" }),
|
|
2725
|
-
/* @__PURE__ */ jsx11(FormField4, { label: "Column Name", labelPlacement: "left", children: /* @__PURE__ */ jsx11(Input2, { value: columnName, onChange: handleChangeName }) }),
|
|
2726
|
-
/* @__PURE__ */ jsx11(
|
|
2727
|
-
ColumnExpressionInput,
|
|
2728
|
-
{
|
|
2729
|
-
onChange: handleChangeExpression,
|
|
2730
|
-
onSubmitExpression: handleSubmitExpression,
|
|
2731
|
-
suggestionProvider
|
|
2732
|
-
}
|
|
2733
|
-
),
|
|
2734
|
-
/* @__PURE__ */ jsx11("div", { style: { marginTop: 12 }, children: /* @__PURE__ */ jsx11(Button2, { onClick: handleSave, children: "Add Column" }) })
|
|
2735
|
-
] });
|
|
2736
|
-
};
|
|
2737
|
-
|
|
2738
|
-
// src/datagrid-configuration-ui/settings-panel/DatagridSettingsPanel.tsx
|
|
2739
|
-
import { jsx as jsx12, jsxs as jsxs10 } from "react/jsx-runtime";
|
|
2740
|
-
var classBase9 = "vuuDatagridSettingsPanel";
|
|
2741
|
-
var getTabLabel = () => void 0;
|
|
2742
|
-
var icons = [
|
|
2743
|
-
"table-settings",
|
|
2744
|
-
"column-chooser",
|
|
2745
|
-
"column-settings",
|
|
2746
|
-
"define-column"
|
|
2747
|
-
];
|
|
2748
|
-
var getTabIcon = (component, tabIndex) => icons[tabIndex];
|
|
2749
|
-
var DatagridSettingsPanel = ({
|
|
2750
|
-
availableColumns,
|
|
2751
|
-
className,
|
|
2752
|
-
gridConfig,
|
|
2753
|
-
onCancel,
|
|
2754
|
-
onConfigChange,
|
|
2755
|
-
...props
|
|
2756
|
-
}) => {
|
|
2757
|
-
var _a;
|
|
2758
|
-
console.log(`DatagridSettingsPanel render`);
|
|
2759
|
-
const [selectedTabIndex, setSelectedTabIndex] = useState4(0);
|
|
2760
|
-
const { gridSettings, dispatchColumnAction } = useGridSettings(gridConfig);
|
|
2761
|
-
const [selectedColumnName, setSelectedColumnName] = useState4(
|
|
2762
|
-
null
|
|
2763
|
-
);
|
|
2764
|
-
const handleColumnSelected = useCallback8(
|
|
2765
|
-
(selected) => {
|
|
2766
|
-
setSelectedColumnName(selected ? selected.name : null);
|
|
2767
|
-
},
|
|
2768
|
-
[]
|
|
2769
|
-
);
|
|
2770
|
-
const handleApply = useCallback8(
|
|
2771
|
-
(evt, closePanel = false) => {
|
|
2772
|
-
console.log(`1) DataGridSettingsPanel fire onConfigChange`);
|
|
2773
|
-
onConfigChange == null ? void 0 : onConfigChange(gridSettings, closePanel);
|
|
2774
|
-
},
|
|
2775
|
-
[gridSettings, onConfigChange]
|
|
2776
|
-
);
|
|
2777
|
-
const handleTabSelectionChanged = useCallback8((selectedTabIndex2) => {
|
|
2778
|
-
setSelectedTabIndex(selectedTabIndex2);
|
|
2779
|
-
}, []);
|
|
2780
|
-
const handleSave = useCallback8(
|
|
2781
|
-
(evt) => handleApply(evt, true),
|
|
2782
|
-
[handleApply]
|
|
2783
|
-
);
|
|
2784
|
-
const selectedColumn = selectedColumnName === null ? null : (_a = gridSettings.columns.find((col) => col.name === selectedColumnName)) != null ? _a : null;
|
|
2785
|
-
const tabstripProps2 = {
|
|
2786
|
-
activeTabIndex: selectedTabIndex,
|
|
2787
|
-
enableRenameTab: false,
|
|
2788
|
-
orientation: "vertical"
|
|
2789
|
-
};
|
|
2790
|
-
const handleAddCalculatedColumn = useCallback8(
|
|
2791
|
-
() => setSelectedTabIndex(3),
|
|
2792
|
-
[]
|
|
2793
|
-
);
|
|
2794
|
-
const panelShift = selectedTabIndex === 2 ? "right" : void 0;
|
|
2795
|
-
return /* @__PURE__ */ jsxs10("div", { ...props, className: cx6(classBase9, className), children: [
|
|
2796
|
-
/* @__PURE__ */ jsxs10(
|
|
2797
|
-
Stack2,
|
|
2798
|
-
{
|
|
2799
|
-
TabstripProps: tabstripProps2,
|
|
2800
|
-
className: `${classBase9}-stack`,
|
|
2801
|
-
getTabIcon,
|
|
2802
|
-
getTabLabel,
|
|
2803
|
-
active: selectedTabIndex === 2 ? 1 : selectedTabIndex,
|
|
2804
|
-
onTabSelectionChanged: handleTabSelectionChanged,
|
|
2805
|
-
showTabs: true,
|
|
2806
|
-
children: [
|
|
2807
|
-
/* @__PURE__ */ jsx12(
|
|
2808
|
-
GridSettingsPanel,
|
|
2809
|
-
{
|
|
2810
|
-
config: gridSettings,
|
|
2811
|
-
dispatchColumnAction
|
|
2812
|
-
}
|
|
2813
|
-
),
|
|
2814
|
-
/* @__PURE__ */ jsxs10("div", { className: `${classBase9}-columnPanels`, "data-align": panelShift, children: [
|
|
2815
|
-
/* @__PURE__ */ jsx12(
|
|
2816
|
-
ColumnPicker,
|
|
2817
|
-
{
|
|
2818
|
-
availableColumns,
|
|
2819
|
-
chosenColumns: gridSettings.columns,
|
|
2820
|
-
dispatchColumnAction,
|
|
2821
|
-
onSelectionChange: handleColumnSelected,
|
|
2822
|
-
onAddCalculatedColumnClick: handleAddCalculatedColumn,
|
|
2823
|
-
selectedColumn
|
|
2824
|
-
}
|
|
2825
|
-
),
|
|
2826
|
-
selectedColumn === null ? /* @__PURE__ */ jsx12(Panel5, { className: "vuuColumnSettingsPanel", children: "Select a column" }) : /* @__PURE__ */ jsx12(
|
|
2827
|
-
ColumnSettingsPanel,
|
|
2828
|
-
{
|
|
2829
|
-
column: selectedColumn,
|
|
2830
|
-
dispatchColumnAction,
|
|
2831
|
-
style: { background: "white", flex: "1 0 150px" }
|
|
2832
|
-
}
|
|
2833
|
-
)
|
|
2834
|
-
] }),
|
|
2835
|
-
/* @__PURE__ */ jsx12("div", { title: "Column Settings", children: "Column Settings" }),
|
|
2836
|
-
/* @__PURE__ */ jsx12(
|
|
2837
|
-
CalculatedColumnPanel,
|
|
2838
|
-
{
|
|
2839
|
-
columns: gridSettings.columns,
|
|
2840
|
-
dispatchColumnAction,
|
|
2841
|
-
table: { module: "SIMUL", table: "instruments" }
|
|
2842
|
-
}
|
|
2843
|
-
)
|
|
2844
|
-
]
|
|
2845
|
-
}
|
|
2846
|
-
),
|
|
2847
|
-
/* @__PURE__ */ jsxs10("div", { className: `${classBase9}-buttonBar`, children: [
|
|
2848
|
-
/* @__PURE__ */ jsx12(Button3, { onClick: onCancel, children: "Cancel" }),
|
|
2849
|
-
/* @__PURE__ */ jsx12(Button3, { onClick: handleApply, children: "Apply" }),
|
|
2850
|
-
/* @__PURE__ */ jsx12(Button3, { onClick: handleSave, children: "Save" })
|
|
2851
|
-
] })
|
|
2852
|
-
] });
|
|
2853
|
-
};
|
|
2854
|
-
|
|
2855
|
-
// src/datasource-stats/DatasourceStats.tsx
|
|
2856
|
-
import { useEffect as useEffect3, useState as useState5 } from "react";
|
|
2857
|
-
import cx7 from "classnames";
|
|
2858
|
-
import { jsx as jsx13, jsxs as jsxs11 } from "react/jsx-runtime";
|
|
2859
|
-
var classBase10 = "vuuDatasourceStats";
|
|
2860
|
-
var numberFormatter = new Intl.NumberFormat();
|
|
2861
|
-
var DataSourceStats = ({
|
|
2862
|
-
className: classNameProp,
|
|
2863
|
-
dataSource
|
|
2864
|
-
}) => {
|
|
2865
|
-
const [range, setRange] = useState5(dataSource.range);
|
|
2866
|
-
const [size, setSize] = useState5(dataSource.size);
|
|
2867
|
-
useEffect3(() => {
|
|
2868
|
-
setSize(dataSource.size);
|
|
2869
|
-
dataSource.on("resize", setSize);
|
|
2870
|
-
dataSource.on("range", setRange);
|
|
2871
|
-
}, [dataSource]);
|
|
2872
|
-
const className = cx7(classBase10, classNameProp);
|
|
2873
|
-
const from = numberFormatter.format(range.from);
|
|
2874
|
-
const to = numberFormatter.format(range.to - 1);
|
|
2875
|
-
const value = numberFormatter.format(size);
|
|
2876
|
-
return /* @__PURE__ */ jsxs11("div", { className, children: [
|
|
2877
|
-
/* @__PURE__ */ jsx13("span", { children: "Showing rows" }),
|
|
2878
|
-
/* @__PURE__ */ jsx13("span", { className: `${classBase10}-range`, children: from }),
|
|
2879
|
-
/* @__PURE__ */ jsx13("span", { className: `${classBase10}-range`, children: to }),
|
|
2880
|
-
/* @__PURE__ */ jsx13("span", { children: "of" }),
|
|
2881
|
-
/* @__PURE__ */ jsx13("span", { className: `${classBase10}-size`, children: value })
|
|
2882
|
-
] });
|
|
2883
|
-
};
|
|
2884
|
-
export {
|
|
2885
|
-
ColumnExpressionInput,
|
|
2886
|
-
ColumnNamedTerms,
|
|
2887
|
-
DataSourceStats,
|
|
2888
|
-
DatagridSettingsPanel,
|
|
2889
|
-
columnExpressionLanguageSupport,
|
|
2890
|
-
isCompleteExpression,
|
|
2891
|
-
isCompleteRelationalExpression,
|
|
2892
|
-
lastNamedChild,
|
|
2893
|
-
useColumnExpressionEditor,
|
|
2894
|
-
useColumnExpressionSuggestionProvider,
|
|
2895
|
-
walkTree
|
|
2896
|
-
};
|
|
1
|
+
var qe=(n,e,t)=>{if(!e.has(n))throw TypeError("Cannot "+t)};var u=(n,e,t)=>(qe(n,e,"read from private field"),t?t.call(n):e.get(n)),S=(n,e,t)=>{if(e.has(n))throw TypeError("Cannot add the same private member more than once");e instanceof WeakSet?e.add(n):e.set(n,t)},N=(n,e,t,o)=>(qe(n,e,"write to private field"),o?o.call(n,t):e.set(n,t),t);import{DOWN1 as Kn,DOWN2 as jn,isTypeDescriptor as et,metadataKeys as nt,registerComponent as tt,UP1 as ot,UP2 as rt}from"@vuu-ui/vuu-utils";import st from"classnames";import{useEffect as zn,useRef as Zn}from"react";import{isTypeDescriptor as Jn}from"@vuu-ui/vuu-utils";import{getMovingValueDirection as qn,isValidNumber as _e}from"@vuu-ui/vuu-utils";var _n=[void 0,void 0,void 0,void 0];function Ke(n,e,t){var x;let o=Zn(),[i,r,s,p]=o.current||_n,{type:l}=t,c=Jn(l)?(x=l.formatting)==null?void 0:x.decimals:void 0,g=n===i&&_e(e)&&_e(r)&&t===s?qn(e,p,r,c):"";return zn(()=>{o.current=[n,e,t,g]}),g}import{jsx as ut,jsxs as mt}from"react/jsx-runtime";var it=String.fromCharCode(11014),at=String.fromCharCode(11015),{KEY:lt}=nt,ge="vuuBackgroundCell",te={ArrowOnly:"arrow",BackgroundOnly:"bg-only",ArrowBackground:"arrow-bg"},pt=n=>et(n)&&n.renderer&&"flashStyle"in n.renderer?n.renderer.flashStyle:te.BackgroundOnly,ct=({column:n,row:e})=>{let{key:t,type:o,valueFormatter:i}=n,r=e[t],s=pt(o),p=Ke(e[lt],r,n),l=s===te.ArrowOnly||s===te.ArrowBackground?p===ot||p===rt?it:p===Kn||p===jn?at:null:null,c=p?" "+p:"",g=st(ge,c,{[`${ge}-arrowOnly`]:s===te.ArrowOnly,[`${ge}-arrowBackground`]:s===te.ArrowBackground});return mt("div",{className:g,tabIndex:-1,children:[ut("div",{className:`${ge}-flasher`,children:l}),i(e[n.key])]})};tt("background",ct,"cell-renderer",{serverDataType:["long","int","double"]});import{isColumnTypeRenderer as dt,isTypeDescriptor as gt,registerComponent as ft}from"@vuu-ui/vuu-utils";import Ct from"classnames";import{jsx as Se,jsxs as je}from"react/jsx-runtime";var oe="vuuProgressCell",xt=({column:n,columnMap:e,row:t})=>{let{type:o}=n,i=t[n.key],r=!1,s=0;if(gt(o)&&dt(o.renderer)){let{associatedField:l}=o.renderer,c=t[e[l]];if(typeof i=="number"&&typeof c=="number")s=Math.min(Math.round(i/c*100),100),r=isFinite(s);else{let g=parseFloat(i);if(Number.isFinite(g)){let x=parseFloat(c);Number.isFinite(x)&&(s=Math.min(Math.round(g/x*100),100),r=isFinite(s))}}}let p=Ct(oe,{});return je("div",{className:p,tabIndex:-1,children:[r?je("span",{className:`${oe}-track`,children:[Se("span",{className:`${oe}-bg`}),Se("span",{className:`${oe}-bar`,style:{"--progress-bar-pct":`-${100-s}%`}})]}):null,Se("span",{className:`${oe}-text`,children:`${s} %`})]})};ft("vuu.progress",xt,"cell-renderer",{serverDataType:["long","int","double"]});import{autocompletion as Bt,defaultKeymap as $t,EditorState as Ut,EditorView as fn,ensureSyntaxTree as Mt,keymap as Be,minimalSetup as Gt,startCompletion as Cn}from"@vuu-ui/vuu-codemirror";import{createEl as xn}from"@vuu-ui/vuu-utils";import{useEffect as Wt,useMemo as Xt,useRef as $e}from"react";import{LanguageSupport as bt,LRLanguage as yt,styleTags as Et,tags as Ce}from"@vuu-ui/vuu-codemirror";import{LRParser as ht}from"@lezer/lr";var fe=ht.deserialize({version:14,states:"&fOVQPOOO!SQPO'#C^OVQPO'#CcQ!pQPOOO#OQPO'#CkO#TQPO'#CrOOQO'#Cy'#CyO#YQPO,58}OVQPO,59QOVQPO,59QOVQPO,59VOVQPO'#CtOOQO,59^,59^OOQO1G.i1G.iOOQO1G.l1G.lO#kQPO1G.lO$fQPO'#CmO%WQQO1G.qOOQO'#C{'#C{O%cQPO,59`OOQO'#Cn'#CnO%wQPO,59XOVQPO,59ZOVQPO,59[OVQPO7+$]OVQPO'#CuO&`QPO1G.zOOQO1G.z1G.zO&hQQO'#C^O&rQQO1G.sO'ZQQO1G.uOOQO1G.v1G.vO'fQPO<<GwO'wQPO,59aOOQO-E6s-E6sOOQO7+$f7+$fOVQPOAN=cO(]QQO1G.lO(tQPOG22}OOQOLD(iLD(iO%wQPO,59QO%wQPO,59Q",stateData:")[~OlOS~ORUOSUOTUOUUOWQO`SOnPO~OWgXZQX[QX]QX^QXeQX~OjQXXQXpQXqQXrQXsQXtQXuQX~PnOZWO[WO]XO^XO~OWYO~OWZO~OX]OZWO[WO]XO^XO~OZWO[WO]Yi^YijYiXYipYiqYirYisYitYiuYieYi~OZWO[WO]XO^XOpdOqdOrdOsdOtdOudO~OehOvfOwgO~OXkOZWO[WO]XO^XOeiO~ORUOSUOTUOUUOWQO`SOnlO~OXsOeiO~OvQXwQX~PnOZxO[xO]yO^yOeaivaiwai~OwgOecivci~OZWO[WO]XO^XOetO~OZWO[WO]XO^XOXiaeia~OZxO[xO]Yi^YieYivYiwYi~OXwOZWO[WO]XO^XO~O`UTn~",goto:"#spPPqPPPPqPPqPPPPqP!R!W!R!RPq!Z!k!nPPP!tP#jmUOQWXYZefghitxyVbYfgRe`mTOQWXYZefghitxyR[TQjcRrjQROQVQS^WxQ_XU`YfgQcZQmeQphQqiQuyRvtQaYQnfRog",nodeNames:"\u26A0 ColumnDefinitionExpression Column Number String True False ParenthesizedExpression OpenBrace CloseBrace ArithmeticExpression Divide Times Plus Minus ConditionalExpression If RelationalExpression RelationalOperator AndCondition OrCondition Comma CallExpression Function ArgList",maxTerm:39,skippedNodes:[0],repeatNodeCount:1,tokenData:".^~RnXY#PYZ#P]^#Ppq#Pqr#brs#mxy$eyz$jz{$o{|$t|}$y}!O%O!O!P%T!P!Q%c!Q![%h!^!_%s!_!`&Q!`!a&V!c!}&d#R#S&d#T#U&u#U#Y&d#Y#Z(Y#Z#]&d#]#^*j#^#c&d#c#d+f#d#h&d#h#i,b#i#o&d~#USl~XY#PYZ#P]^#Ppq#P~#eP!_!`#h~#mOu~~#pWOX#mZ]#m^r#mrs$Ys#O#m#P;'S#m;'S;=`$_<%lO#m~$_OS~~$bP;=`<%l#m~$jOW~~$oOX~~$tO[~~$yO]~~%OOe~~%TO^~~%WP!Q![%Z~%`PR~!Q![%Z~%hOZ~~%mQR~!O!P%Z!Q![%h~%xPr~!_!`%{~&QOt~~&VOp~~&[Pq~!_!`&_~&dOs~P&iSnP!Q![&d!c!}&d#R#S&d#T#o&dR&zUnP!Q![&d!c!}&d#R#S&d#T#b&d#b#c'^#c#o&dR'cUnP!Q![&d!c!}&d#R#S&d#T#W&d#W#X'u#X#o&dR'|SvQnP!Q![&d!c!}&d#R#S&d#T#o&d~(_TnP!Q![&d!c!}&d#R#S&d#T#U(n#U#o&d~(sUnP!Q![&d!c!}&d#R#S&d#T#`&d#`#a)V#a#o&d~)[UnP!Q![&d!c!}&d#R#S&d#T#g&d#g#h)n#h#o&d~)sUnP!Q![&d!c!}&d#R#S&d#T#X&d#X#Y*V#Y#o&d~*^SU~nP!Q![&d!c!}&d#R#S&d#T#o&d~*oUnP!Q![&d!c!}&d#R#S&d#T#Y&d#Y#Z+R#Z#o&d~+YS`~nP!Q![&d!c!}&d#R#S&d#T#o&dR+kUnP!Q![&d!c!}&d#R#S&d#T#f&d#f#g+}#g#o&dR,USwQnP!Q![&d!c!}&d#R#S&d#T#o&d~,gUnP!Q![&d!c!}&d#R#S&d#T#f&d#f#g,y#g#o&d~-OUnP!Q![&d!c!}&d#R#S&d#T#i&d#i#j-b#j#o&d~-gUnP!Q![&d!c!}&d#R#S&d#T#X&d#X#Y-y#Y#o&d~.QST~nP!Q![&d!c!}&d#R#S&d#T#o&d",tokenizers:[0,1],topRules:{ColumnDefinitionExpression:[0,1]},tokenPrec:375});var Ot=yt.define({name:"VuuColumnExpression",parser:fe.configure({props:[Et({Function:Ce.variableName,String:Ce.string,Or:Ce.emphasis,Operator:Ce.operator})]})}),en=()=>new bt(Ot);var Te=class{constructor(e){switch(this.value=e,typeof e){case"boolean":this.type="booleanLiteralExpression";break;case"number":this.type="numericLiteralExpression";break;default:this.type="stringLiteralExpression"}}toJSON(){return{type:this.type,value:this.value}}},we=class{constructor(e){this.type="colExpression";this.column=e}toJSON(){return{type:this.type,column:this.column}}},se,F,De=class{constructor(e="unknown"){S(this,se,[{type:"unknown"},{type:"unknown"}]);S(this,F,void 0);this.type="arithmeticExpression";N(this,F,e)}get op(){return u(this,F)}set op(e){N(this,F,e)}get expressions(){return u(this,se)}toJSON(){return{type:this.type,op:u(this,F),expressions:u(this,se)}}};se=new WeakMap,F=new WeakMap;var X,Re=class{constructor(e){S(this,X,[]);this.type="callExpression";this.functionName=e}get expressions(){return u(this,X)}get arguments(){return u(this,X)}toJSON(){return{type:this.type,functionName:this.functionName,arguments:u(this,X).map(e=>{var t;return(t=e.toJSON)==null?void 0:t.call(e)})}}};X=new WeakMap;var ie,H,G=class{constructor(){S(this,ie,[{type:"unknown"},{type:"unknown"}]);S(this,H,"unknown");this.type="relationalExpression"}get op(){return u(this,H)}set op(e){N(this,H,e)}get expressions(){return u(this,ie)}toJSON(){return{type:this.type,op:u(this,H),expressions:u(this,ie)}}};ie=new WeakMap,H=new WeakMap;var ae,V,W=class{constructor(e){S(this,ae,[{type:"unknown"},{type:"unknown"}]);S(this,V,void 0);this.type="booleanCondition";N(this,V,e)}get op(){return u(this,V)}get expressions(){return u(this,ae)}toJSON(){return{type:this.type,op:u(this,V),expressions:u(this,ae).map(e=>{var t;return(t=e.toJSON)==null?void 0:t.call(e)})}}};ae=new WeakMap,V=new WeakMap;var T,re=class{constructor(e){S(this,T,void 0);this.type="conditionalExpression";N(this,T,[e?new W(e):new G,{type:"unknown"},{type:"unknown"}])}get expressions(){return u(this,T)}get condition(){return u(this,T)[0]}get truthyExpression(){return u(this,T)[1]}set truthyExpression(e){u(this,T)[1]=e}get falsyExpression(){return u(this,T)[2]}set falsyExpression(e){u(this,T)[2]=e}toJSON(){var e,t,o,i,r;return{type:this.type,condition:(t=(e=this.condition).toJSON)==null?void 0:t.call(e),truthyExpression:this.truthyExpression,falsyExpression:(r=(i=(o=this.falsyExpression)==null?void 0:o.toJSON)==null?void 0:i.call(o))!=null?r:this.falsyExpression}}};T=new WeakMap;var Q=n=>n.type==="unknown",xe=n=>n.type==="arithmeticExpression",vt=n=>n.type==="callExpression",M=n=>n.type==="conditionalExpression",Pt=n=>n.type==="relationalExpression"||n.type==="booleanCondition";var St=n=>n.type==="booleanCondition",ke=n=>(n==null?void 0:n.type)==="relationalExpression";var P=n=>{if(Q(n))return n;if(ke(n)){let[e,t]=n.expressions;if(O(e))return P(e);if(n.op==="unknown")return n;if(O(t))return P(t)}else if(Pt(n)){let{expressions:e=[]}=n;for(let t of e)if(O(t))return P(t)}else if(M(n)){let{condition:e,truthyExpression:t,falsyExpression:o}=n;if(O(e))return P(e);if(O(t))return P(t);if(O(o))return P(o)}else if(xe(n)){let{expressions:e=[]}=n;for(let t of e)if(O(t))return P(t)}},he=(n,e,t)=>{let{expressions:o=[]}=n;if(o.includes(e)){let i=o.indexOf(e);return o.splice(i,1,t),!0}else for(let i of o)if(he(i,e,t))return!0;return!1},O=n=>Q(n)?!0:M(n)?O(n.condition)||O(n.truthyExpression)||O(n.falsyExpression):ke(n)||St(n)?n.op===void 0||n.expressions.some(e=>O(e)):!1,nn=(n,e)=>{let t=P(n);t?t.expressions?t.expressions.push(e):console.warn("don't know how to treat targetExpression"):console.error("no target expression found")},C,L,Ae=class{constructor(){S(this,C,void 0);S(this,L,[])}setCondition(e){if(u(this,C)===void 0)this.addExpression(new re(e));else if(M(u(this,C))){if(O(u(this,C).condition)){let t=e?new W(e):new G;this.addExpression(t)}else if(Q(u(this,C).truthyExpression))u(this,C).truthyExpression=new re(e);else if(O(u(this,C).truthyExpression)){let t=e?new W(e):new G;this.addExpression(t)}else if(Q(u(this,C).falsyExpression))u(this,C).falsyExpression=new re(e);else if(O(u(this,C).falsyExpression)){let t=e?new W(e):new G;this.addExpression(t)}}else console.error("setCondition called unexpectedly")}addExpression(e){if(u(this,L).length>0){let t=u(this,L).at(-1);t==null||t.arguments.push(e)}else if(u(this,C)===void 0)N(this,C,e);else if(xe(u(this,C))){let t=P(u(this,C));t&&Q(t)&&he(u(this,C),t,e)}else if(M(u(this,C))&&O(u(this,C))){let t=P(u(this,C));t&&Q(t)?he(u(this,C),t,e):t&&nn(t,e)}}setFunction(e){let t=new Re(e);this.addExpression(t),u(this,L).push(t)}setColumn(e){this.addExpression(new we(e))}setArithmeticOp(e){let t=e,o=u(this,C);xe(o)&&(o.op=t)}setRelationalOperator(e){let t=e;if(u(this,C)&&M(u(this,C))){let o=P(u(this,C));ke(o)?o.op=t:console.error(`no target expression found (op = ${e})`)}}setValue(e){let t=new Te(e);if(u(this,C)===void 0)N(this,C,t);else if(xe(u(this,C)))this.addExpression(t);else if(vt(u(this,C)))u(this,C).arguments.push(t);else if(M(u(this,C)))if(O(u(this,C))){let o=P(u(this,C));o&&Q(o)?he(u(this,C),o,t):o&&nn(o,t)}else console.log("what do we do with value, in a complete expression")}closeBrace(){u(this,L).pop()}get expression(){return u(this,C)}toJSON(){var e;return(e=u(this,C))==null?void 0:e.toJSON()}};C=new WeakMap,L=new WeakMap;var tn=(n,e)=>{let t=new Ae,o=n.cursor();do{let{name:i,from:r,to:s}=o;switch(i){case"AndCondition":t.setCondition("and");break;case"OrCondition":t.setCondition("or");break;case"RelationalExpression":t.setCondition();break;case"ArithmeticExpression":t.addExpression(new De);break;case"Column":{let p=e.substring(r,s);t.setColumn(p)}break;case"Function":{let p=e.substring(r,s);t.setFunction(p)}break;case"Times":case"Divide":case"Plus":case"Minus":{let p=e.substring(r,s);t.setArithmeticOp(p)}break;case"RelationalOperator":{let p=e.substring(r,s);t.setRelationalOperator(p)}break;case"False":case"True":{let p=e.substring(r,s);t.setValue(p==="true")}break;case"String":t.setValue(e.substring(r+1,s-1));break;case"Number":t.setValue(parseFloat(e.substring(r,s)));break;case"CloseBrace":t.closeBrace();break;default:}}while(o.next());return t.toJSON()};var Tt=fe.configure({strict:!0}),on=["Number","String"],Ne=[...on,"AndCondition","ArithmeticExpression","BooleanOperator","RelationalOperatorOperator","CallExpression","CloseBrace","Column","Comma","ConditionalExpression","Divide","Equal","If","Minus","OpenBrace","OrCondition","ParenthesizedExpression","Plus","RelationalExpression","RelationalOperator","Times"],rn=n=>{try{return Tt.parse(n),!0}catch{return!1}},Qe=n=>{let{lastChild:e}=n;for(;e&&!Ne.includes(e.name);)e=e.prevSibling,console.log(e==null?void 0:e.name);return e},sn=n=>{if((n==null?void 0:n.name)==="RelationalExpression"){let{firstChild:e}=n,t=Qe(n);if((e==null?void 0:e.name)==="Column"&&typeof(t==null?void 0:t.name)=="string"&&on.includes(t.name))return!0}return!1};import{HighlightStyle as wt,syntaxHighlighting as Dt,tags as an}from"@vuu-ui/vuu-codemirror";var Rt=wt.define([{tag:an.variableName,color:"var(--vuuFilterEditor-variableColor)"},{tag:an.comment,color:"green",fontStyle:"italic"}]),ln=Dt(Rt);import{EditorView as At}from"@vuu-ui/vuu-codemirror";var pn=At.theme({"&":{border:"solid 1px var(--salt-container-primary-borderColor)",color:"var(--vuuFilterEditor-color)",backgroundColor:"var(--vuuFilterEditor-background)"},".cm-content":{caretColor:"var(--vuuFilterEditor-cursorColor)"},"&.cm-focused .cm-cursor":{borderLeftColor:"var(--vuuFilterEditor-cursorColor)"},"&.cm-focused .cm-selectionBackground, ::selection":{backgroundColor:"var(--vuuFilterEditor-selectionBackground)"},".cm-selectionBackground, ::selection":{backgroundColor:"var(--vuuFilterEditor-selectionBackground)"},".cm-scroller":{fontFamily:"var(--vuuFilterEditor-fontFamily)"},".cm-tooltip":{background:"var(--vuuFilterEditor-tooltipBackground)",border:"var(--vuuFilterEditor-tooltipBorder)",boxShadow:"var(--vuuFilterEditor-tooltipElevation)","&.cm-tooltip-autocomplete > ul":{fontFamily:"var(--vuuFilterEditor-fontFamily)",fontSize:"var(--vuuFilterEditor-fontSize)",maxHeight:"240px"},"&.cm-tooltip-autocomplete > ul > li":{height:"var(--vuuFilterEditor-suggestion-height)",padding:"0 3px",lineHeight:"var(--vuuFilterEditor-suggestion-height)"},"&.cm-tooltip-autocomplete li[aria-selected]":{background:"var(--vuuFilterEditor-suggestion-selectedBackground)",color:"var(--vuuFilterEditor-suggestion-selectedColor)"},"&.cm-tooltip-autocomplete li .cm-completionDetail":{color:"var(--vuuFilterEditor-suggestion-detailColor)"}}},{dark:!1});import{booleanJoinSuggestions as kt,getNamedParentNode as cn,getPreviousNode as Nt,getValue as R,syntaxTree as Qt}from"@vuu-ui/vuu-codemirror";import{useCallback as un}from"react";var Ft=(n,e)=>e?n.map(t=>{var o;return{...t,apply:typeof t.apply=="function"?t.apply:`${e}${(o=t.apply)!=null?o:t.label}`}}):n,Lt=n=>n===void 0?!1:["Times","Divide","Plus","Minus"].includes(n.name),Y=(n,e)=>{var i;let{lastChild:t}=n,{pos:o}=e;for(;t;)if(t.from<o&&Ne.includes(t.name)){if(t.name==="ParenthesizedExpression"){let s=(i=t.firstChild)==null?void 0:i.nextSibling;s&&(t=s)}return t}else t=t.prevSibling},mn=(n,e)=>{var t;if(n.name==="ArgList"){let o=n.prevSibling;if(o)return R(o,e)}else if(n.name==="OpenBrace"){let o=(t=n.parent)==null?void 0:t.prevSibling;if((o==null?void 0:o.name)==="Function")return R(o,e)}},dn=(n,e)=>{if(n.name==="RelationalExpression"){let t=Qe(n);if((t==null?void 0:t.name)==="RelationalOperator")return R(t,e)}else{let t=n.prevSibling;if((t==null?void 0:t.name)==="RelationalOperator")return R(t,e)}},Ie=(n,e)=>{var t;if(n.name==="RelationalExpression"){if(((t=n.firstChild)==null?void 0:t.name)==="Column")return R(n.firstChild,e)}else{let o=n.prevSibling;if((o==null?void 0:o.name)==="Column")return R(o,e);if((o==null?void 0:o.name)==="RelationalOperator")return Ie(o,e)}},Fe=async(n,e,t,o={})=>{let i=await e.getSuggestions(t,o),{startsWith:r=""}=o;return{from:n.pos-r.length,options:i}},Le=(n,e,t,o,i)=>{let r=Y(n,e);switch(console.log(`conditional expression last child ${r==null?void 0:r.name}`),r==null?void 0:r.name){case"If":return Fe(e,t,"expression",{prefix:"( "});case"OpenBrace":return Fe(e,t,"expression");case"Condition":return Fe(e,t,"expression",{prefix:", "});case"CloseBrace":if(o){let s=[{apply:()=>{i==null||i()},label:"Save Expression",boost:10}];return{from:e.pos,options:s}}}},It=(n,e)=>{let t=[{apply:()=>{e==null||e()},label:"Save Expression",boost:10}];return{from:n.pos,options:t}},gn=(n,e)=>{let t=un(async(o,i,r={})=>{let s=await n.getSuggestions(i,r),{startsWith:p=""}=r;return{from:o.pos-p.length,options:s}},[n]);return un(async o=>{var x,h;let{state:i,pos:r}=o,s=(x=o.matchBefore(/\w*/))!=null?x:{from:0,to:0,text:void 0},l=Qt(i).resolveInner(r,-1),c=i.doc.toString(),g=rn(c);switch(console.log({nodeBeforeName:l.name}),l.name){case"If":return console.log("conditional expression If"),t(o,"expression",{prefix:"( "});case"Condition":{let a=Y(l,o);if((a==null?void 0:a.name)==="Column"){let m=Nt(a);if((m==null?void 0:m.name)!=="RelationalOperator")return t(o,"condition-operator",{columnName:R(a,i)});console.log(`Condition last child Column, prev child ${m==null?void 0:m.name}`)}else if((a==null?void 0:a.name)==="RelationalOperator")return t(o,"expression");console.log(`condition last child ${a==null?void 0:a.name}`)}break;case"ConditionalExpression":return Le(l,o,n);case"RelationalExpression":{if(sn(l))return{from:o.pos,options:kt.concat({label:", <truthy expression>, <falsy expression>",apply:", "})};{let a=dn(l,i),m=Ie(l,i);if(a)return t(o,"expression");{let f=await n.getSuggestions("condition-operator",{columnName:m});return{from:o.pos,options:f}}}}break;case"RelationalOperator":return t(o,"expression");case"String":{let a=dn(l,i),m=Ie(l,i),{from:f,to:d}=l;if(d-f===2&&o.pos===f+1){if(m&&a)return t(o,"columnValue",{columnName:m,operator:a,startsWith:s.text})}else if(d-f>2&&o.pos===d)return t(o,"expression",{prefix:", "});console.log(`we have a string, column is ${m} ${f} ${d}`)}break;case"ArithmeticExpression":{let a=Y(l,o);if((a==null?void 0:a.name)==="Column")return t(o,"expression");if(Lt(a)){let m=a.name;return t(o,"column",{operator:m})}}break;case"OpenBrace":{let a=mn(l,i);return t(o,"expression",{functionName:a})}break;case"ArgList":{let a=mn(l,i),m=Y(l,o),f=(m==null?void 0:m.name)==="OpenBrace"?void 0:",",d=await n.getSuggestions("expression",{functionName:a});return d=f?Ft(d,", "):d,(m==null?void 0:m.name)!=="OpenBrace"&&(m==null?void 0:m.name)!=="Comma"&&(d=[{apply:") ",boost:10,label:"Done - no more arguments"}].concat(d)),{from:o.pos,options:d}}case"Equal":if(c.trim()==="=")return t(o,"expression");break;case"ParenthesizedExpression":case"ColumnDefinitionExpression":if(o.pos===0)return t(o,"expression");{let a=Y(l,o);if((a==null?void 0:a.name)==="Column"){if(g){let m=[{apply:()=>{e.current()},label:"Save Expression",boost:10}],f=R(a,i),d=await n.getSuggestions("operator",{columnName:f});return{from:o.pos,options:m.concat(d)}}}else if((a==null?void 0:a.name)==="CallExpression"){if(g){let m=[{apply:()=>{e.current()},label:"Save Expression",boost:10}];return{from:o.pos,options:m}}}else if((a==null?void 0:a.name)==="ArithmeticExpression"){if(g){let m=[{apply:()=>{e.current()},label:"Save Expression",boost:10}],f=Y(a,o);if((f==null?void 0:f.name)==="Column"){let d=R(f,i),y=await n.getSuggestions("operator",{columnName:d});m=m.concat(y)}return{from:o.pos,options:m}}}else if((a==null?void 0:a.name)==="ConditionalExpression")return Le(a,o,n,g,e.current);break}case"Column":if(await n.isPartialMatch("expression",void 0,s.text))return t(o,"expression",{startsWith:s.text});break;case"Comma":{let a=cn(l);if((a==null?void 0:a.name)==="ConditionalExpression")return t(o,"expression")}break;case"CloseBrace":{let a=cn(l);if((a==null?void 0:a.name)==="ConditionalExpression")return Le(a,o,n,g,e.current);if((a==null?void 0:a.name)==="ArgList"&&g)return It(o,e.current);console.log(`does closebrace denote an ARgList or a parenthetised expression ? ${a}`)}break;default:((h=l==null?void 0:l.prevSibling)==null?void 0:h.name)==="FilterClause"&&console.log("looks like we ight be a or|and operator")}},[t,e,n])};var le=n=>{if(n.current==null)throw Error("EditorView not defined");return n.current},Ht=()=>"vuuSuggestion",Vt=()=>console.log("noooop"),Yt=n=>"expressionType"in n,zt=n=>{if(Yt(n)){let e=xn("div","expression-type-container"),t=xn("span","expression-type",n.expressionType);return e.appendChild(t),e}else return null},hn=({onChange:n,onSubmitExpression:e,suggestionProvider:t})=>{let o=$e(null),i=$e(Vt),r=$e(),s=gn(t,i),[p,l]=Xt(()=>{let c=()=>{let f=le(r),d=f.state.doc.toString(),y=Mt(f.state,f.state.doc.length,5e3);if(y){let v=tn(y,d);return[d,v]}else return["",void 0]},g=()=>{le(r).setState(m())},x=()=>{let[f,d]=c();e==null||e(f,d),g()},h=f=>Be.of([{key:f,run(){return x(),!0}}]),a=f=>Be.of([{key:f,run(){return Cn(le(r)),!0}}]),m=()=>Ut.create({doc:"",extensions:[Gt,Bt({addToOptions:[{render:zt,position:70}],override:[s],optionClass:Ht}),en(),Be.of($t),h("Ctrl-Enter"),a("ArrowDown"),fn.updateListener.of(f=>{let d=le(r);if(f.docChanged){Cn(d);let y=d.state.doc.toString();n==null||n(y,void 0)}}),pn,ln]});return i.current=()=>{x(),setTimeout(()=>{le(r).focus()},100)},[m,g]},[s,n,e]);return Wt(()=>{if(!o.current)throw Error("editor not in dom");return r.current=new fn({state:p(),parent:o.current}),()=>{var c;(c=r.current)==null||c.destroy()}},[s,p]),{editorRef:o,clearInput:l}};import{jsx as Jt}from"react/jsx-runtime";var Zt="vuuColumnExpressionInput",bn=({onChange:n,onSubmitExpression:e,suggestionProvider:t})=>{let{editorRef:o}=hn({onChange:n,onSubmitExpression:e,suggestionProvider:t});return Jt("div",{className:`${Zt}`,ref:o})};import{AnnotationType as qt,getRelationalOperators as _t,numericOperators as Kt,stringOperators as jt,toSuggestions as eo}from"@vuu-ui/vuu-codemirror";import{getTypeaheadParams as no,useTypeaheadSuggestions as to}from"@vuu-ui/vuu-data";import{isNumericColumn as Me,isTextColumn as oo}from"@vuu-ui/vuu-utils";import{useCallback as Ue,useRef as ro}from"react";var z=[{accepts:"string",description:"Returns multiple string values as a single joined string. Arguments may be string literal values, string columns or other string expressions. Non string arguments may also be included, these will be converted to strings.",example:{expression:'concatenate("example", "-test")',result:'"example-test"'},name:"concatenate",params:{description:"( string, string, [ string* ] )"},type:"string"},{accepts:["string","string"],description:"Tests a string value to determine whether it contains a given substring. Accepts two arguments: source text and target substring. Returns true if <source text> contains one or more occurrences of <target subscring>",example:{expression:'contains("Royal Bank of Scotland", "bank")',result:"true"},name:"contains",params:{description:"( string )"},type:"boolean"},{accepts:["string","number"],description:"Returns the leftmost <number> characters from <string>. First argument may be a string literal, string column or other string expression.",example:{expression:'left("USD Benchmark Report", 3)',result:'"USD"'},name:"left",params:{count:2,description:"( string, number )"},type:"string"},{accepts:"string",description:"Returns the number of characters in <string>. Argument may be a string literal, string column or other string expression.",example:{expression:'len("example")',result:"7"},name:"len",params:{description:"(string)"},type:"number"},{accepts:"string",description:"Convert a string value to lowercase. Argument may be a string column or other string expression.",example:{expression:'lower("examPLE")',result:'"example"'},name:"lower",params:{description:"( string )"},type:"string"},{accepts:"string",description:"Convert a string value to uppercase. Argument may be a string column or other string expression.",example:{expression:'upper("example")',result:'"EXAMPLE"'},name:"upper",params:{description:"( string )"},type:"string"},{accepts:["string","number"],description:"Returns the rightmost <number> characters from <string>. First argument may be a string literal, string column or other string expression.",example:{expression:"blah",result:"blah"},name:"right",params:{description:"( string )"},type:"string"},{accepts:["string","string","string"],description:"Replace characters within a string. Accepts three arguments: source text, text to replace and replacement text. Returns a copy of <source text> with any occurrences of <text to replace> replaced by <replacement text>",example:{expression:"blah",result:"blah"},name:"replace",params:{description:"( string )"},type:"string"},{accepts:"number",description:"Converts a number to a string.",example:{expression:"blah",result:"blah"},name:"text",params:{description:"( string )"},type:"string"},{accepts:"string",description:"Tests a string value to determine whether it starts with a given substring. Accepts two arguments: source text and target substring. Returns true if <source text> starts with <target subscring>.",example:{expression:"blah",result:"blah"},name:"starts",params:{description:"( string )"},type:"boolean"},{accepts:"string",description:"Tests a string value to determine whether it ends with a given substring. Accepts two arguments: source text and target substring. Returns true if <source text> ends with <target subscring>.",example:{expression:"blah",result:"blah"},name:"ends",params:{description:"( string )"},type:"boolean"},{accepts:"number",description:"blah",example:{expression:"blah",result:"blah"},name:"min",params:{description:"( string )"},type:"number"},{accepts:"number",description:"blah",example:{expression:"blah",result:"blah"},name:"max",params:{description:"( string )"},type:"number"},{accepts:"number",description:"blah",example:{expression:"blah",result:"blah"},name:"sum",params:{description:"( string )"},type:"number"},{accepts:"number",description:"blah",example:{expression:"blah",result:"blah"},name:"round",params:{description:"( string )"},type:"number"},{accepts:"any",description:"blah",example:{expression:"blah",result:"blah"},name:"or",params:{description:"( string )"},type:"boolean"},{accepts:"any",description:"blah",example:{expression:"blah",result:"blah"},name:"and",params:{description:"( string )"},type:"boolean"},{accepts:"any",description:"Return one of two possible result values, depending on the evaluation of a filter expression. If <filterExpression> resolves to true, result is <expression1>, otherwise <expression2>. ",example:{expression:"blah",result:"blah"},name:"if",params:{description:"( filterExpression, expression1, expression 2)"},type:"variable"}];import{createEl as A}from"@vuu-ui/vuu-utils";var yn=({name:n,description:e,example:t,params:o,type:i})=>{let r=A("div","vuuFunctionDoc"),s=A("div","function-heading"),p=A("span","function-name",n),l=A("span","param-list",o.description),c=A("span","function-type",i);s.appendChild(p),s.appendChild(l),s.appendChild(c);let g=A("p",void 0,e);if(r.appendChild(s),r.appendChild(g),t){let x=A("div","example-container","Example:"),h=A("div","example-expression",t.expression),a=A("div","example-result",t.result);x.appendChild(h),x.appendChild(a),r.appendChild(x)}return r};var so=[],I=n=>n.map(e=>{var t;return{...e,apply:((t=e.apply)!=null?t:e.label)+" "}}),io=(n,{functionName:e,operator:t})=>{if(t)return n.filter(Me);if(e){let o=z.find(i=>i.name===e);if(o)switch(o.accepts){case"string":return n.filter(oo);case"number":return n.filter(Me);default:return n}}return n},En=(n,e)=>io(n,e).map(o=>{var r;let i=(r=o.label)!=null?r:o.name;return{apply:e.prefix?`${e.prefix}${i}`:i,label:i,boost:5,type:"column",expressionType:o.serverDataType}}),ao=[{apply:"* ",boost:2,label:"*",type:"operator"},{apply:"/ ",boost:2,label:"/",type:"operator"},{apply:"+ ",boost:2,label:"+",type:"operator"},{apply:"- ",boost:2,label:"-",type:"operator"}],lo=n=>n===void 0||Me(n)?ao:so,po=n=>{switch(n.serverDataType){case"string":case"char":return I(jt);case"int":case"long":case"double":return I(Kt)}},Ge=n=>({apply:`${n.name}( `,boost:2,expressionType:n.type,info:()=>yn(n),label:n.name,type:"function"}),co=n=>{if(n){if(typeof n.accepts=="string")return n.accepts;if(Array.isArray(n.accepts))return n.accepts.every(e=>e==="string")?"string":"any"}return"any"},uo=z.map(Ge),mo=({functionName:n})=>{if(n){let e=z.find(o=>o.name===n),t=co(e);if(e)switch(t){case"string":return z.filter(o=>o.type==="string"||o.type==="variable").map(Ge);case"number":return z.filter(o=>o.type==="number"||o.type==="variable").map(Ge);default:}}return uo},go={},On=({columns:n,table:e})=>{let t=Ue(p=>p?n.find(l=>l.name===p):void 0,[n]),o=ro(),i=to(),r=Ue(async(p,l=go)=>{let{columnName:c,functionName:g,operator:x,prefix:h}=l;switch(p){case"expression":{let a=await I(En(n,{functionName:g,prefix:h})).concat(mo(l));return o.current=a}case"column":{let a=await En(n,l);return o.current=I(a)}case"operator":{let a=await lo(t(c));return o.current=I(a)}case"relational-operator":{let a=await _t(t(c));return o.current=I(a)}case"condition-operator":{let a=t(c);if(a){let m=await po(a);if(m)return o.current=I(m)}}break;case"columnValue":if(c&&x){let a=no(e,c),m=await i(a);return o.current=eo(m,{suffix:""}),o.current.forEach(f=>{f.apply=(d,y,v)=>{let w=new qt,ne=v+y.label.length+1;d.dispatch({changes:{from:v,insert:y.label},selection:{anchor:ne,head:ne},annotations:w.of(y)})}}),o.current}break}return[]},[n,t,i,e]),s=Ue(async(p,l,c)=>{let{current:g}=o,x=!1,h=g||await r(p,{columnName:l});if(c&&h)for(let a of h){if(a.label===c)return!1;a.label.startsWith(c)&&(x=!0)}return x},[r]);return{getSuggestions:r,isPartialMatch:s}};import{Button as Ze,Panel as fr}from"@salt-ds/core";import Cr from"classnames";import{useCallback as me,useState as Hn}from"react";import{List as Pn}from"@heswell/salt-lab";import{Button as pe,Text as Sn,useIdMemo as ho}from"@salt-ds/core";import{useCallback as B,useState as bo}from"react";import{ListItem as fo}from"@heswell/salt-lab";import Co from"classnames";import{jsx as We,jsxs as xo}from"react/jsx-runtime";var Z="vuuColumnListItem",vn=({className:n,item:e,label:t,style:o,...i})=>{let r=Co(Z,n,{[`${Z}-calculated`]:e==null?void 0:e.expression,[`${Z}-hidden`]:e==null?void 0:e.hidden});return xo(fo,{className:r,...i,children:[We("span",{className:`${Z}-iconType`}),We("label",{className:`${Z}-label`,children:t}),We("span",{className:`${Z}-iconHidden`})]})};import{jsx as E,jsxs as q}from"react/jsx-runtime";var J="vuuColumnPicker",yo=(n,e)=>n.filter(t=>e.find(o=>o.name===t.name)==null),Tn=({availableColumns:n,id:e,dispatchColumnAction:t,onAddCalculatedColumnClick:o,onSelectionChange:i,chosenColumns:r,selectedColumn:s})=>{let[p,l]=bo([]),c=ho(e),g=yo(n,r),x=B(()=>{p.length>0&&(l([]),t({type:"addColumn",columns:p}))},[t,p]),h=B(()=>s&&t({type:"removeColumn",column:s}),[s,t]),a=B(()=>s&&t({type:"moveColumn",column:s,moveBy:-1}),[t,s]),m=B(()=>s&&t({type:"moveColumn",column:s,moveBy:1}),[t,s]),f=B((v,w)=>l(w),[]),d=B((v,w)=>i==null?void 0:i(w),[i]),y=B((v,w)=>{t({type:"moveColumn",moveFrom:v,moveTo:w})},[t]);return q("div",{className:J,id:c,children:[q("div",{className:`${J}-listColumn`,children:[E("label",{htmlFor:`available-${c}`,children:E(Sn,{as:"h4",children:"Available Columns"})}),E("div",{className:`${J}-listContainer`,style:{flex:1,overflow:"hidden"},children:E(Pn,{borderless:!0,checkable:!1,height:"100%",id:`available-${c}`,itemHeight:24,itemToString:v=>v.name,onSelectionChange:f,selected:p,selectionStrategy:"extended",source:g})}),E("div",{style:{display:"flex",alignItems:"center",flex:"0 0 32px",marginTop:"var(--salt-size-basis-unit)"},children:q(pe,{onClick:x,disabled:p.length===0,children:["Show",E("span",{"data-icon":"arrow-thin-right",style:{marginLeft:8}})]})})]}),q("div",{className:`${J}-listColumn`,children:[E("label",{htmlFor:`selected-${c}`,children:E(Sn,{as:"h4",children:"Included Columns"})}),E("div",{className:`${J}-listContainer`,style:{flex:1,overflow:"hidden"},children:E(Pn,{ListItem:vn,allowDragDrop:!0,borderless:!0,height:"100%",id:`selected-${c}`,itemHeight:24,itemToString:v=>v.name,onMoveListItem:y,onSelectionChange:d,selected:s,style:{flex:1},source:r})}),q("div",{style:{alignItems:"center",flex:"0 0 32px",display:"flex",gap:6,marginTop:"var(--salt-size-basis-unit)"},children:[q(pe,{onClick:h,disabled:s===null,children:[E("span",{"data-icon":"arrow-thin-left",style:{marginRight:8}}),"Hide"]}),E(pe,{"aria-label":"Move column up",onClick:a,disabled:s===null||(r==null?void 0:r.indexOf(s))===0,style:{width:28},children:E("span",{"data-icon":"arrow-thin-up"})}),E(pe,{"aria-label":"Move column down",onClick:m,disabled:s===null||r.indexOf(s)===r.length-1,style:{width:28},children:E("span",{"data-icon":"arrow-thin-down"})}),E(pe,{"aria-label":"Add calculated column",className:`${J}-addCalculatedColumn`,onClick:o,variant:"primary",children:E("span",{"data-icon":"add"})})]})]})]})};import{Stack as $o}from"@vuu-ui/vuu-layout";import{Checkbox as Uo,FormField as $,Input as He,RadioButton as ce,RadioButtonGroup as Fn,StepperInput as Mo}from"@heswell/salt-lab";import{Panel as Ln,Text as Go}from"@salt-ds/core";import Wo from"classnames";import{useCallback as K,useState as Xo}from"react";import{getRegisteredCellRenderers as Ro}from"@vuu-ui/vuu-utils";import{Dropdown as Ao}from"@heswell/salt-lab";import{Panel as ko}from"@salt-ds/core";import kn from"classnames";import{useMemo as No}from"react";import{FormField as Eo,StepperInput as Oo,Switch as wn}from"@heswell/salt-lab";import{Text as vo}from"@salt-ds/core";import{useCallback as be}from"react";import{Fragment as Dn,jsx as _,jsxs as To}from"react/jsx-runtime";var Po={alignOnDecimals:!1,decimals:4,zeroPad:!1},So=(n,e)=>{let t=typeof n=="object"&&n.formatting?n.formatting:{};return["alignOnDecimals","decimals","zeroPad"].reduce((i,r)=>t[r]!==void 0?{...i,[r]:t[r]}:(e==null?void 0:e[r])!==void 0?{...i,[r]:e[r]}:i,Po)},Rn=({column:n,dispatchColumnAction:e})=>{let{decimals:t,alignOnDecimals:o,zeroPad:i}=So(n==null?void 0:n.type),r=be(c=>e({type:"updateColumnTypeFormatting",column:n,...c}),[n,e]),s=be(c=>r({decimals:parseInt(c.toString(),10)}),[r]),p=be((c,g)=>r({alignOnDecimals:g}),[r]),l=be((c,g)=>r({zeroPad:g}),[r]);switch(n.serverDataType){case"double":return To(Dn,{children:[_(Eo,{label:"No of Decimals",labelPlacement:"top",children:_(Oo,{value:t,onChange:s})}),_(wn,{checked:o,label:"Align on decimals",LabelProps:{className:"vuuColumnPanelSwitch"},onChange:p}),_(wn,{checked:i,label:"Zero pad",LabelProps:{className:"vuuColumnPanelSwitch"},onChange:l})]});case"long":case"int":return _(Dn,{children:_(vo,{children:"Work in progress"})});default:return null}};import{Fragment as wo,jsx as Do}from"react/jsx-runtime";var An=({column:n,dispatchColumnAction:e})=>Do(wo,{children:"String"});import{Fragment as Io,jsx as ye,jsxs as Bo}from"react/jsx-runtime";var Xe="vuuColumnTypePanel",Qo=["Default Renderer (int, long)"],Fo=["Default Renderer (double)"],Nn=["Default Renderer (string)"],Lo=n=>{let t=Ro(n.serverDataType).map(o=>o.name);switch(console.log({customRendererNames:t}),n.serverDataType){case"char":case"string":return Nn;case"int":case"long":return Qo;case"double":return Fo.concat(t);default:return Nn}},Qn=({className:n,column:e,dispatchColumnAction:t,...o})=>{let i=No(()=>{switch(e.serverDataType){case"double":case"int":case"long":return ye(Rn,{column:e,dispatchColumnAction:t});default:return ye(An,{column:e,dispatchColumnAction:t})}},[e,t]),{serverDataType:r="string"}=e,s=Lo(e);return Bo(Io,{children:[ye(Ao,{className:kn(`${Xe}-renderer`),fullWidth:!0,selected:s[0],source:s}),ye(ko,{...o,className:kn(Xe,n,`${Xe}-${r}`),children:i})]})};import{jsx as b,jsxs as j}from"react/jsx-runtime";var In="vuuColumnSettingsPanel",Ho={className:"salt-density-high"},Bn=()=>null,$n=({column:n,dispatchColumnAction:e,style:t,...o})=>{var h,a,m,f;let[i,r]=Xo(0),s=K(d=>e({type:"updateColumnProp",column:n,...d}),[n,e]),p=K(d=>s({align:d.target.value}),[s]),l=K(d=>s({pin:d.target.value}),[s]),c=K((d,y)=>s({hidden:y}),[s]),g=K((d,y)=>s({label:y}),[s]),x=K(d=>s({width:parseInt(d.toString(),10)}),[s]);return j("div",{className:In,...o,style:{...t},children:[b(Go,{as:"h4",children:"Column Settings"}),j($o,{active:i,showTabs:!0,className:Wo(`${In}-columnTabs`),onTabSelectionChanged:r,TabstripProps:Ho,children:[j(Ln,{title:"Column",children:[b($,{label:"Hidden",labelPlacement:"left",children:b(Uo,{checked:n.hidden===!0,onChange:c})}),b($,{label:"Label",labelPlacement:"left",children:b(He,{value:(h=n.label)!=null?h:n.name,onChange:g})}),b($,{label:"Width",labelPlacement:"left",children:b(Mo,{value:(a=n.width)!=null?a:100,onChange:x})}),b($,{label:"Align",labelPlacement:"left",ActivationIndicatorComponent:Bn,children:j(Fn,{"aria-label":"Column Align",value:(m=n.align)!=null?m:"left",legend:"Align",onChange:p,children:[b(ce,{label:"Left",value:"left"}),b(ce,{label:"Right",value:"right"})]})}),b($,{label:"Pin Column",labelPlacement:"left",ActivationIndicatorComponent:Bn,children:j(Fn,{"aria-label":"Pin Column",value:(f=n.pin)!=null?f:"",legend:"Pin Column",onChange:l,children:[b(ce,{label:"Do not pin",value:""}),b(ce,{label:"Left",value:"left"}),b(ce,{label:"Right",value:"right"})]})})]}),b(Qn,{column:n,dispatchColumnAction:e,title:"Data Cell"}),j(Ln,{title:"Vuu",variant:"secondary",children:[b($,{label:"Name",labelPlacement:"top",readOnly:!0,variant:"secondary",children:b(He,{value:n.name})}),b($,{label:"Vuu type",labelPlacement:"top",readOnly:!0,variant:"secondary",children:b(He,{value:n.serverDataType})})]})]})]})};import{FormField as Un,RadioButton as Ve,RadioButtonGroup as Vo,StepperInput as Yo}from"@heswell/salt-lab";import{Panel as zo,Text as Zo}from"@salt-ds/core";import{useCallback as Ye}from"react";import{jsx as U,jsxs as ze}from"react/jsx-runtime";var Jo="vuuGridSettingsPanel",qo=()=>null,Mn=({config:n,dispatchColumnAction:e,style:t,...o})=>{var p;let i=Ye(l=>e({type:"updateGridSettings",...l}),[e]),r=Ye(l=>i({columnFormatHeader:l.target.value}),[i]),s=Ye(l=>i({columnDefaultWidth:parseInt(l.toString(),10)}),[i]);return ze("div",{className:Jo,...o,style:{...t},children:[U(Zo,{as:"h4",children:"Grid Settings"}),ze(zo,{children:[U(Un,{label:"Format column labels",labelPlacement:"left",ActivationIndicatorComponent:qo,children:ze(Vo,{"aria-label":"Format column labels",value:n.columnFormatHeader,legend:"Format column labels",onChange:r,children:[U(Ve,{label:"No Formatting",value:void 0}),U(Ve,{label:"Capitalize",value:"capitalize"}),U(Ve,{label:"Uppercase",value:"uppercase"})]})}),U(Un,{label:"Default Column Width",labelPlacement:"left",children:U(Yo,{value:(p=n.columnDefaultWidth)!=null?p:100,onChange:s})})]})]})};import{useReducer as _o}from"react";import{moveItem as Ko}from"@heswell/salt-lab";import{fromServerDataType as jo}from"@vuu-ui/vuu-utils";var er=(n,e)=>{switch(console.log(`gridSettingsReducer ${e.type}`),e.type){case"addColumn":return nr(n,e);case"addCalculatedColumn":return tr(n,e);case"moveColumn":return rr(n,e);case"removeColumn":return or(n,e);case"updateColumn":return n;case"updateColumnProp":return sr(n,e);case"updateGridSettings":return ir(n,e);case"updateColumnTypeFormatting":return ar(n,e);default:return n}},Gn=n=>{let[e,t]=_o(er,n);return{gridSettings:e,dispatchColumnAction:t}};function nr(n,{column:e,columns:t,index:o=-1}){let{columns:i}=n;if(o===-1){if(Array.isArray(t))return{...n,columns:i.concat(t)};if(e)return{...n,columns:i.concat(e)}}return n}function tr(n,{columnName:e,columnType:t,expression:o}){let{columns:i}=n,r={name:e,expression:o,serverDataType:t};return{...n,columns:i.concat(r)}}function or(n,{column:e}){let{columns:t}=n;return{...n,columns:t.filter(o=>o.name!==e.name)}}function rr(n,{column:e,moveBy:t,moveFrom:o,moveTo:i}){let{columns:r}=n;if(e&&typeof t=="number"){let s=r.indexOf(e),p=r.slice(),[l]=p.splice(s,1);return p.splice(s+t,0,l),{...n,columns:p}}else return typeof o=="number"&&typeof i=="number"?{...n,columns:Ko(r,o,i)}:n}function sr(n,{align:e,column:t,hidden:o,label:i,width:r}){let{columns:s}=n;return(e==="left"||e==="right")&&(s=ue(s,{...t,align:e})),typeof o=="boolean"&&(s=ue(s,{...t,hidden:o})),typeof i=="string"&&(s=ue(s,{...t,label:i})),typeof r=="number"&&(s=ue(s,{...t,width:r})),{...n,columns:s}}function ir(n,{columnFormatHeader:e}){return{...n,columnFormatHeader:e!=null?e:n.columnFormatHeader}}function ar(n,{alignOnDecimals:e,column:t,decimals:o,zeroPad:i}){let{columns:r}=n;if(r.find(p=>p.name===t.name)){let{serverDataType:p="string",type:l=jo(p)}=t,c=typeof l=="string"?{name:l}:{...l};return typeof e=="boolean"&&(c.formatting={...c.formatting,alignOnDecimals:e}),typeof o=="number"&&(c.formatting={...c.formatting,decimals:o}),typeof i=="boolean"&&(c.formatting={...c.formatting,zeroPad:i}),{...n,columns:ue(r,{...t,type:c})}}else return n}function ue(n,e){return n.map(t=>t.name===e.name?e:t)}import{Stack as xr}from"@vuu-ui/vuu-layout";import{FormField as lr,Input as pr}from"@heswell/salt-lab";import{Button as cr,Panel as ur,Text as mr}from"@salt-ds/core";import{useCallback as Ee,useRef as dr,useState as Wn}from"react";import{jsx as ee,jsxs as gr}from"react/jsx-runtime";var Xn=({columns:n,dispatchColumnAction:e,table:t})=>{let[o,i]=Wn(""),[,r]=Wn(),s=dr(""),p=On({columns:n,table:t}),l=Ee(h=>{let{value:a}=h.target;i(a)},[]),c=Ee(h=>{s.current=h},[]),g=Ee((h,a)=>{console.log({source:h}),r(a)},[]),x=Ee(()=>{s.current&&(console.log(`save expression ${JSON.stringify(s.current,null,2)}`),e({type:"addCalculatedColumn",columnName:o,expression:s.current,columnType:"string"}))},[o,e]);return gr(ur,{className:"vuuCalculatedColumnPanel",title:"Define Computed Column",children:[ee(mr,{styleAs:"h4",children:"Define Computed Column"}),ee(lr,{label:"Column Name",labelPlacement:"left",children:ee(pr,{value:o,onChange:l})}),ee(bn,{onChange:c,onSubmitExpression:g,suggestionProvider:p}),ee("div",{style:{marginTop:12},children:ee(cr,{onClick:x,children:"Add Column"})})]})};import{jsx as k,jsxs as ve}from"react/jsx-runtime";var Oe="vuuDatagridSettingsPanel",hr=()=>{},br=["table-settings","column-chooser","column-settings","define-column"],yr=(n,e)=>br[e],ll=({availableColumns:n,className:e,gridConfig:t,onCancel:o,onConfigChange:i,...r})=>{var ne;console.log("DatagridSettingsPanel render");let[s,p]=Hn(0),{gridSettings:l,dispatchColumnAction:c}=Gn(t),[g,x]=Hn(null),h=me(D=>{x(D?D.name:null)},[]),a=me((D,Yn=!1)=>{console.log("1) DataGridSettingsPanel fire onConfigChange"),i==null||i(l,Yn)},[l,i]),m=me(D=>{p(D)},[]),f=me(D=>a(D,!0),[a]),d=g===null?null:(ne=l.columns.find(D=>D.name===g))!=null?ne:null,y={activeTabIndex:s,enableRenameTab:!1,orientation:"vertical"},v=me(()=>p(3),[]),w=s===2?"right":void 0;return ve("div",{...r,className:Cr(Oe,e),children:[ve(xr,{TabstripProps:y,className:`${Oe}-stack`,getTabIcon:yr,getTabLabel:hr,active:s===2?1:s,onTabSelectionChanged:m,showTabs:!0,children:[k(Mn,{config:l,dispatchColumnAction:c}),ve("div",{className:`${Oe}-columnPanels`,"data-align":w,children:[k(Tn,{availableColumns:n,chosenColumns:l.columns,dispatchColumnAction:c,onSelectionChange:h,onAddCalculatedColumnClick:v,selectedColumn:d}),d===null?k(fr,{className:"vuuColumnSettingsPanel",children:"Select a column"}):k($n,{column:d,dispatchColumnAction:c,style:{background:"white",flex:"1 0 150px"}})]}),k("div",{title:"Column Settings",children:"Column Settings"}),k(Xn,{columns:l.columns,dispatchColumnAction:c,table:{module:"SIMUL",table:"instruments"}})]}),ve("div",{className:`${Oe}-buttonBar`,children:[k(Ze,{onClick:o,children:"Cancel"}),k(Ze,{onClick:a,children:"Apply"}),k(Ze,{onClick:f,children:"Save"})]})]})};import{useEffect as Er,useState as Vn}from"react";import Or from"classnames";import{jsx as de,jsxs as vr}from"react/jsx-runtime";var Pe="vuuDatasourceStats",Je=new Intl.NumberFormat,El=({className:n,dataSource:e})=>{let[t,o]=Vn(e.range),[i,r]=Vn(e.size);Er(()=>{r(e.size),e.on("resize",r),e.on("range",o)},[e]);let s=Or(Pe,n),p=Je.format(t.from),l=Je.format(t.to-1),c=Je.format(i);return vr("div",{className:s,children:[de("span",{children:"Showing rows"}),de("span",{className:`${Pe}-range`,children:p}),de("span",{className:`${Pe}-range`,children:l}),de("span",{children:"of"}),de("span",{className:`${Pe}-size`,children:c})]})};export{bn as ColumnExpressionInput,Ne as ColumnNamedTerms,El as DataSourceStats,ll as DatagridSettingsPanel,en as columnExpressionLanguageSupport,rn as isCompleteExpression,sn as isCompleteRelationalExpression,Qe as lastNamedChild,hn as useColumnExpressionEditor,On as useColumnExpressionSuggestionProvider,tn as walkTree};
|
|
2897
2
|
//# sourceMappingURL=index.js.map
|