@vuu-ui/vuu-table-extras 0.6.26-debug → 0.6.26
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 -2867
- package/cjs/index.js.map +2 -2
- package/esm/index.js +1 -2902
- package/esm/index.js.map +2 -2
- package/index.css +1 -537
- package/index.css.map +1 -1
- package/package.json +8 -8
package/cjs/index.js
CHANGED
|
@@ -1,2868 +1,2 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __create = Object.create;
|
|
3
|
-
var __defProp = Object.defineProperty;
|
|
4
|
-
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
5
|
-
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
-
var __getProtoOf = Object.getPrototypeOf;
|
|
7
|
-
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
8
|
-
var __export = (target, all) => {
|
|
9
|
-
for (var name in all)
|
|
10
|
-
__defProp(target, name, { get: all[name], enumerable: true });
|
|
11
|
-
};
|
|
12
|
-
var __copyProps = (to, from, except, desc) => {
|
|
13
|
-
if (from && typeof from === "object" || typeof from === "function") {
|
|
14
|
-
for (let key of __getOwnPropNames(from))
|
|
15
|
-
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
16
|
-
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
17
|
-
}
|
|
18
|
-
return to;
|
|
19
|
-
};
|
|
20
|
-
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
21
|
-
// If the importer is in node compatibility mode or this is not an ESM
|
|
22
|
-
// file that has been converted to a CommonJS file using a Babel-
|
|
23
|
-
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
24
|
-
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
25
|
-
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
26
|
-
mod
|
|
27
|
-
));
|
|
28
|
-
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
29
|
-
var __accessCheck = (obj, member, msg) => {
|
|
30
|
-
if (!member.has(obj))
|
|
31
|
-
throw TypeError("Cannot " + msg);
|
|
32
|
-
};
|
|
33
|
-
var __privateGet = (obj, member, getter) => {
|
|
34
|
-
__accessCheck(obj, member, "read from private field");
|
|
35
|
-
return getter ? getter.call(obj) : member.get(obj);
|
|
36
|
-
};
|
|
37
|
-
var __privateAdd = (obj, member, value) => {
|
|
38
|
-
if (member.has(obj))
|
|
39
|
-
throw TypeError("Cannot add the same private member more than once");
|
|
40
|
-
member instanceof WeakSet ? member.add(obj) : member.set(obj, value);
|
|
41
|
-
};
|
|
42
|
-
var __privateSet = (obj, member, value, setter) => {
|
|
43
|
-
__accessCheck(obj, member, "write to private field");
|
|
44
|
-
setter ? setter.call(obj, value) : member.set(obj, value);
|
|
45
|
-
return value;
|
|
46
|
-
};
|
|
47
|
-
|
|
48
|
-
// src/index.ts
|
|
49
|
-
var src_exports = {};
|
|
50
|
-
__export(src_exports, {
|
|
51
|
-
ColumnExpressionInput: () => ColumnExpressionInput,
|
|
52
|
-
ColumnNamedTerms: () => ColumnNamedTerms,
|
|
53
|
-
DataSourceStats: () => DataSourceStats,
|
|
54
|
-
DatagridSettingsPanel: () => DatagridSettingsPanel,
|
|
55
|
-
columnExpressionLanguageSupport: () => columnExpressionLanguageSupport,
|
|
56
|
-
isCompleteExpression: () => isCompleteExpression,
|
|
57
|
-
isCompleteRelationalExpression: () => isCompleteRelationalExpression,
|
|
58
|
-
lastNamedChild: () => lastNamedChild,
|
|
59
|
-
useColumnExpressionEditor: () => useColumnExpressionEditor,
|
|
60
|
-
useColumnExpressionSuggestionProvider: () => useColumnExpressionSuggestionProvider,
|
|
61
|
-
walkTree: () => walkTree
|
|
62
|
-
});
|
|
63
|
-
module.exports = __toCommonJS(src_exports);
|
|
64
|
-
|
|
65
|
-
// src/cell-renderers/background-cell/BackgroundCell.tsx
|
|
66
|
-
var import_vuu_utils3 = require("@vuu-ui/vuu-utils");
|
|
67
|
-
var import_classnames = __toESM(require("classnames"), 1);
|
|
68
|
-
|
|
69
|
-
// src/cell-renderers/background-cell/useDirection.ts
|
|
70
|
-
var import_react = require("react");
|
|
71
|
-
var import_vuu_utils = require("@vuu-ui/vuu-utils");
|
|
72
|
-
var import_vuu_utils2 = require("@vuu-ui/vuu-utils");
|
|
73
|
-
var INITIAL_VALUE = [void 0, void 0, void 0, void 0];
|
|
74
|
-
function useDirection(key, value, column) {
|
|
75
|
-
var _a;
|
|
76
|
-
const ref = (0, import_react.useRef)();
|
|
77
|
-
const [prevKey, prevValue, prevColumn, prevDirection] = ref.current || INITIAL_VALUE;
|
|
78
|
-
const { type: dataType } = column;
|
|
79
|
-
const decimals = (0, import_vuu_utils.isTypeDescriptor)(dataType) ? (_a = dataType.formatting) == null ? void 0 : _a.decimals : void 0;
|
|
80
|
-
const direction = key === prevKey && (0, import_vuu_utils2.isValidNumber)(value) && (0, import_vuu_utils2.isValidNumber)(prevValue) && column === prevColumn ? (0, import_vuu_utils2.getMovingValueDirection)(value, prevDirection, prevValue, decimals) : "";
|
|
81
|
-
(0, import_react.useEffect)(() => {
|
|
82
|
-
ref.current = [key, value, column, direction];
|
|
83
|
-
});
|
|
84
|
-
return direction;
|
|
85
|
-
}
|
|
86
|
-
|
|
87
|
-
// src/cell-renderers/background-cell/BackgroundCell.tsx
|
|
88
|
-
var import_jsx_runtime = require("react/jsx-runtime");
|
|
89
|
-
var CHAR_ARROW_UP = String.fromCharCode(11014);
|
|
90
|
-
var CHAR_ARROW_DOWN = String.fromCharCode(11015);
|
|
91
|
-
var { KEY } = import_vuu_utils3.metadataKeys;
|
|
92
|
-
var classBase = "vuuBackgroundCell";
|
|
93
|
-
var FlashStyle = {
|
|
94
|
-
ArrowOnly: "arrow",
|
|
95
|
-
BackgroundOnly: "bg-only",
|
|
96
|
-
ArrowBackground: "arrow-bg"
|
|
97
|
-
};
|
|
98
|
-
var getFlashStyle = (colType) => {
|
|
99
|
-
if ((0, import_vuu_utils3.isTypeDescriptor)(colType) && colType.renderer) {
|
|
100
|
-
if ("flashStyle" in colType.renderer) {
|
|
101
|
-
return colType.renderer["flashStyle"];
|
|
102
|
-
}
|
|
103
|
-
}
|
|
104
|
-
return FlashStyle.BackgroundOnly;
|
|
105
|
-
};
|
|
106
|
-
var BackgroundCell = ({ column, row }) => {
|
|
107
|
-
const { key, type, valueFormatter } = column;
|
|
108
|
-
const value = row[key];
|
|
109
|
-
const flashStyle = getFlashStyle(type);
|
|
110
|
-
const direction = useDirection(row[KEY], value, column);
|
|
111
|
-
const arrow = flashStyle === FlashStyle.ArrowOnly || flashStyle === FlashStyle.ArrowBackground ? direction === import_vuu_utils3.UP1 || direction === import_vuu_utils3.UP2 ? CHAR_ARROW_UP : direction === import_vuu_utils3.DOWN1 || direction === import_vuu_utils3.DOWN2 ? CHAR_ARROW_DOWN : null : null;
|
|
112
|
-
const dirClass = direction ? ` ` + direction : "";
|
|
113
|
-
const className = (0, import_classnames.default)(classBase, dirClass, {
|
|
114
|
-
[`${classBase}-arrowOnly`]: flashStyle === FlashStyle.ArrowOnly,
|
|
115
|
-
[`${classBase}-arrowBackground`]: flashStyle === FlashStyle.ArrowBackground
|
|
116
|
-
});
|
|
117
|
-
return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { className, tabIndex: -1, children: [
|
|
118
|
-
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", { className: `${classBase}-flasher`, children: arrow }),
|
|
119
|
-
valueFormatter(row[column.key])
|
|
120
|
-
] });
|
|
121
|
-
};
|
|
122
|
-
(0, import_vuu_utils3.registerComponent)("background", BackgroundCell, "cell-renderer", {
|
|
123
|
-
serverDataType: ["long", "int", "double"]
|
|
124
|
-
});
|
|
125
|
-
|
|
126
|
-
// src/cell-renderers/progress-cell/ProgressCell.tsx
|
|
127
|
-
var import_vuu_utils4 = require("@vuu-ui/vuu-utils");
|
|
128
|
-
var import_classnames2 = __toESM(require("classnames"), 1);
|
|
129
|
-
var import_jsx_runtime2 = require("react/jsx-runtime");
|
|
130
|
-
var classBase2 = "vuuProgressCell";
|
|
131
|
-
var ProgressCell = ({ column, columnMap, row }) => {
|
|
132
|
-
const { type } = column;
|
|
133
|
-
const value = row[column.key];
|
|
134
|
-
let showProgress = false;
|
|
135
|
-
let percentage = 0;
|
|
136
|
-
if ((0, import_vuu_utils4.isTypeDescriptor)(type) && (0, import_vuu_utils4.isColumnTypeRenderer)(type.renderer)) {
|
|
137
|
-
const { associatedField } = type.renderer;
|
|
138
|
-
const associatedValue = row[columnMap[associatedField]];
|
|
139
|
-
if (typeof value === "number" && typeof associatedValue === "number") {
|
|
140
|
-
percentage = Math.min(Math.round(value / associatedValue * 100), 100);
|
|
141
|
-
showProgress = isFinite(percentage);
|
|
142
|
-
} else {
|
|
143
|
-
const floatValue = parseFloat(value);
|
|
144
|
-
if (Number.isFinite(floatValue)) {
|
|
145
|
-
const floatOtherValue = parseFloat(associatedValue);
|
|
146
|
-
if (Number.isFinite(floatOtherValue)) {
|
|
147
|
-
percentage = Math.min(
|
|
148
|
-
Math.round(floatValue / floatOtherValue * 100),
|
|
149
|
-
100
|
|
150
|
-
);
|
|
151
|
-
showProgress = isFinite(percentage);
|
|
152
|
-
}
|
|
153
|
-
}
|
|
154
|
-
}
|
|
155
|
-
}
|
|
156
|
-
const className = (0, import_classnames2.default)(classBase2, {});
|
|
157
|
-
return /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("div", { className, tabIndex: -1, children: [
|
|
158
|
-
showProgress ? /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("span", { className: `${classBase2}-track`, children: [
|
|
159
|
-
/* @__PURE__ */ (0, import_jsx_runtime2.jsx)("span", { className: `${classBase2}-bg` }),
|
|
160
|
-
/* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
|
|
161
|
-
"span",
|
|
162
|
-
{
|
|
163
|
-
className: `${classBase2}-bar`,
|
|
164
|
-
style: { "--progress-bar-pct": `-${100 - percentage}%` }
|
|
165
|
-
}
|
|
166
|
-
)
|
|
167
|
-
] }) : null,
|
|
168
|
-
/* @__PURE__ */ (0, import_jsx_runtime2.jsx)("span", { className: `${classBase2}-text`, children: `${percentage} %` })
|
|
169
|
-
] });
|
|
170
|
-
};
|
|
171
|
-
(0, import_vuu_utils4.registerComponent)("vuu.progress", ProgressCell, "cell-renderer", {
|
|
172
|
-
serverDataType: ["long", "int", "double"]
|
|
173
|
-
});
|
|
174
|
-
|
|
175
|
-
// src/column-expression-input/useColumnExpressionEditor.ts
|
|
176
|
-
var import_vuu_codemirror5 = require("@vuu-ui/vuu-codemirror");
|
|
177
|
-
var import_vuu_utils5 = require("@vuu-ui/vuu-utils");
|
|
178
|
-
var import_react3 = require("react");
|
|
179
|
-
|
|
180
|
-
// src/column-expression-input/column-language-parser/ColumnExpressionLanguage.ts
|
|
181
|
-
var import_vuu_codemirror = require("@vuu-ui/vuu-codemirror");
|
|
182
|
-
|
|
183
|
-
// src/column-expression-input/column-language-parser/generated/column-parser.js
|
|
184
|
-
var import_lr = require("@lezer/lr");
|
|
185
|
-
var parser = import_lr.LRParser.deserialize({
|
|
186
|
-
version: 14,
|
|
187
|
-
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",
|
|
188
|
-
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~",
|
|
189
|
-
goto: "#spPPqPPPPqPPqPPPPqP!R!W!R!RPq!Z!k!nPPP!tP#jmUOQWXYZefghitxyVbYfgRe`mTOQWXYZefghitxyR[TQjcRrjQROQVQS^WxQ_XU`YfgQcZQmeQphQqiQuyRvtQaYQnfRog",
|
|
190
|
-
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",
|
|
191
|
-
maxTerm: 39,
|
|
192
|
-
skippedNodes: [0],
|
|
193
|
-
repeatNodeCount: 1,
|
|
194
|
-
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",
|
|
195
|
-
tokenizers: [0, 1],
|
|
196
|
-
topRules: { "ColumnDefinitionExpression": [0, 1] },
|
|
197
|
-
tokenPrec: 375
|
|
198
|
-
});
|
|
199
|
-
|
|
200
|
-
// src/column-expression-input/column-language-parser/ColumnExpressionLanguage.ts
|
|
201
|
-
var columnExpressionLanguage = import_vuu_codemirror.LRLanguage.define({
|
|
202
|
-
name: "VuuColumnExpression",
|
|
203
|
-
parser: parser.configure({
|
|
204
|
-
props: [
|
|
205
|
-
(0, import_vuu_codemirror.styleTags)({
|
|
206
|
-
Function: import_vuu_codemirror.tags.variableName,
|
|
207
|
-
String: import_vuu_codemirror.tags.string,
|
|
208
|
-
Or: import_vuu_codemirror.tags.emphasis,
|
|
209
|
-
Operator: import_vuu_codemirror.tags.operator
|
|
210
|
-
})
|
|
211
|
-
]
|
|
212
|
-
})
|
|
213
|
-
});
|
|
214
|
-
var columnExpressionLanguageSupport = () => {
|
|
215
|
-
return new import_vuu_codemirror.LanguageSupport(
|
|
216
|
-
columnExpressionLanguage
|
|
217
|
-
/*, [exampleCompletion]*/
|
|
218
|
-
);
|
|
219
|
-
};
|
|
220
|
-
|
|
221
|
-
// src/column-expression-input/column-language-parser/ColumnExpressionTreeWalker.ts
|
|
222
|
-
var LiteralExpressionImpl = class {
|
|
223
|
-
constructor(value) {
|
|
224
|
-
this.value = value;
|
|
225
|
-
switch (typeof value) {
|
|
226
|
-
case "boolean":
|
|
227
|
-
this.type = "booleanLiteralExpression";
|
|
228
|
-
break;
|
|
229
|
-
case "number":
|
|
230
|
-
this.type = "numericLiteralExpression";
|
|
231
|
-
break;
|
|
232
|
-
default:
|
|
233
|
-
this.type = "stringLiteralExpression";
|
|
234
|
-
}
|
|
235
|
-
}
|
|
236
|
-
toJSON() {
|
|
237
|
-
return {
|
|
238
|
-
type: this.type,
|
|
239
|
-
value: this.value
|
|
240
|
-
};
|
|
241
|
-
}
|
|
242
|
-
};
|
|
243
|
-
var ColumnExpressionImpl = class {
|
|
244
|
-
constructor(columnName) {
|
|
245
|
-
this.type = "colExpression";
|
|
246
|
-
this.column = columnName;
|
|
247
|
-
}
|
|
248
|
-
toJSON() {
|
|
249
|
-
return {
|
|
250
|
-
type: this.type,
|
|
251
|
-
column: this.column
|
|
252
|
-
};
|
|
253
|
-
}
|
|
254
|
-
};
|
|
255
|
-
var _expressions, _op;
|
|
256
|
-
var ArithmeticExpressionImpl = class {
|
|
257
|
-
constructor(op = "unknown") {
|
|
258
|
-
__privateAdd(this, _expressions, [
|
|
259
|
-
{ type: "unknown" },
|
|
260
|
-
{ type: "unknown" }
|
|
261
|
-
]);
|
|
262
|
-
__privateAdd(this, _op, void 0);
|
|
263
|
-
this.type = "arithmeticExpression";
|
|
264
|
-
__privateSet(this, _op, op);
|
|
265
|
-
}
|
|
266
|
-
get op() {
|
|
267
|
-
return __privateGet(this, _op);
|
|
268
|
-
}
|
|
269
|
-
set op(op) {
|
|
270
|
-
__privateSet(this, _op, op);
|
|
271
|
-
}
|
|
272
|
-
get expressions() {
|
|
273
|
-
return __privateGet(this, _expressions);
|
|
274
|
-
}
|
|
275
|
-
toJSON() {
|
|
276
|
-
return {
|
|
277
|
-
type: this.type,
|
|
278
|
-
op: __privateGet(this, _op),
|
|
279
|
-
expressions: __privateGet(this, _expressions)
|
|
280
|
-
};
|
|
281
|
-
}
|
|
282
|
-
};
|
|
283
|
-
_expressions = new WeakMap();
|
|
284
|
-
_op = new WeakMap();
|
|
285
|
-
var _expressions2;
|
|
286
|
-
var CallExpressionImpl = class {
|
|
287
|
-
constructor(functionName) {
|
|
288
|
-
__privateAdd(this, _expressions2, []);
|
|
289
|
-
this.type = "callExpression";
|
|
290
|
-
this.functionName = functionName;
|
|
291
|
-
}
|
|
292
|
-
get expressions() {
|
|
293
|
-
return __privateGet(this, _expressions2);
|
|
294
|
-
}
|
|
295
|
-
get arguments() {
|
|
296
|
-
return __privateGet(this, _expressions2);
|
|
297
|
-
}
|
|
298
|
-
toJSON() {
|
|
299
|
-
return {
|
|
300
|
-
type: this.type,
|
|
301
|
-
functionName: this.functionName,
|
|
302
|
-
arguments: __privateGet(this, _expressions2).map((e) => {
|
|
303
|
-
var _a;
|
|
304
|
-
return (_a = e.toJSON) == null ? void 0 : _a.call(e);
|
|
305
|
-
})
|
|
306
|
-
};
|
|
307
|
-
}
|
|
308
|
-
};
|
|
309
|
-
_expressions2 = new WeakMap();
|
|
310
|
-
var _expressions3, _op2;
|
|
311
|
-
var RelationalExpressionImpl = class {
|
|
312
|
-
constructor() {
|
|
313
|
-
__privateAdd(this, _expressions3, [
|
|
314
|
-
{ type: "unknown" },
|
|
315
|
-
{ type: "unknown" }
|
|
316
|
-
]);
|
|
317
|
-
__privateAdd(this, _op2, "unknown");
|
|
318
|
-
this.type = "relationalExpression";
|
|
319
|
-
}
|
|
320
|
-
get op() {
|
|
321
|
-
return __privateGet(this, _op2);
|
|
322
|
-
}
|
|
323
|
-
set op(op) {
|
|
324
|
-
__privateSet(this, _op2, op);
|
|
325
|
-
}
|
|
326
|
-
get expressions() {
|
|
327
|
-
return __privateGet(this, _expressions3);
|
|
328
|
-
}
|
|
329
|
-
toJSON() {
|
|
330
|
-
return {
|
|
331
|
-
type: this.type,
|
|
332
|
-
op: __privateGet(this, _op2),
|
|
333
|
-
expressions: __privateGet(this, _expressions3)
|
|
334
|
-
};
|
|
335
|
-
}
|
|
336
|
-
};
|
|
337
|
-
_expressions3 = new WeakMap();
|
|
338
|
-
_op2 = new WeakMap();
|
|
339
|
-
var _expressions4, _op3;
|
|
340
|
-
var BooleanConditionImp = class {
|
|
341
|
-
constructor(booleanOperator) {
|
|
342
|
-
__privateAdd(this, _expressions4, [
|
|
343
|
-
{ type: "unknown" },
|
|
344
|
-
{ type: "unknown" }
|
|
345
|
-
]);
|
|
346
|
-
__privateAdd(this, _op3, void 0);
|
|
347
|
-
this.type = "booleanCondition";
|
|
348
|
-
__privateSet(this, _op3, booleanOperator);
|
|
349
|
-
}
|
|
350
|
-
get op() {
|
|
351
|
-
return __privateGet(this, _op3);
|
|
352
|
-
}
|
|
353
|
-
get expressions() {
|
|
354
|
-
return __privateGet(this, _expressions4);
|
|
355
|
-
}
|
|
356
|
-
toJSON() {
|
|
357
|
-
return {
|
|
358
|
-
type: this.type,
|
|
359
|
-
op: __privateGet(this, _op3),
|
|
360
|
-
expressions: __privateGet(this, _expressions4).map((e) => {
|
|
361
|
-
var _a;
|
|
362
|
-
return (_a = e.toJSON) == null ? void 0 : _a.call(e);
|
|
363
|
-
})
|
|
364
|
-
};
|
|
365
|
-
}
|
|
366
|
-
};
|
|
367
|
-
_expressions4 = new WeakMap();
|
|
368
|
-
_op3 = new WeakMap();
|
|
369
|
-
var _expressions5;
|
|
370
|
-
var ConditionalExpressionImpl = class {
|
|
371
|
-
constructor(booleanOperator) {
|
|
372
|
-
__privateAdd(this, _expressions5, void 0);
|
|
373
|
-
this.type = "conditionalExpression";
|
|
374
|
-
__privateSet(this, _expressions5, [
|
|
375
|
-
booleanOperator ? new BooleanConditionImp(booleanOperator) : new RelationalExpressionImpl(),
|
|
376
|
-
{ type: "unknown" },
|
|
377
|
-
{ type: "unknown" }
|
|
378
|
-
]);
|
|
379
|
-
}
|
|
380
|
-
get expressions() {
|
|
381
|
-
return __privateGet(this, _expressions5);
|
|
382
|
-
}
|
|
383
|
-
get condition() {
|
|
384
|
-
return __privateGet(this, _expressions5)[0];
|
|
385
|
-
}
|
|
386
|
-
get truthyExpression() {
|
|
387
|
-
return __privateGet(this, _expressions5)[1];
|
|
388
|
-
}
|
|
389
|
-
set truthyExpression(expression) {
|
|
390
|
-
__privateGet(this, _expressions5)[1] = expression;
|
|
391
|
-
}
|
|
392
|
-
get falsyExpression() {
|
|
393
|
-
return __privateGet(this, _expressions5)[2];
|
|
394
|
-
}
|
|
395
|
-
set falsyExpression(expression) {
|
|
396
|
-
__privateGet(this, _expressions5)[2] = expression;
|
|
397
|
-
}
|
|
398
|
-
toJSON() {
|
|
399
|
-
var _a, _b, _c, _d, _e;
|
|
400
|
-
return {
|
|
401
|
-
type: this.type,
|
|
402
|
-
condition: (_b = (_a = this.condition).toJSON) == null ? void 0 : _b.call(_a),
|
|
403
|
-
truthyExpression: this.truthyExpression,
|
|
404
|
-
falsyExpression: (_e = (_d = (_c = this.falsyExpression) == null ? void 0 : _c.toJSON) == null ? void 0 : _d.call(_c)) != null ? _e : this.falsyExpression
|
|
405
|
-
};
|
|
406
|
-
}
|
|
407
|
-
};
|
|
408
|
-
_expressions5 = new WeakMap();
|
|
409
|
-
var isUnknown = (e) => e.type === "unknown";
|
|
410
|
-
var isArithmeticExpression = (expression) => expression.type === "arithmeticExpression";
|
|
411
|
-
var isCallExpression = (expression) => expression.type === "callExpression";
|
|
412
|
-
var isConditionalExpression = (expression) => expression.type === "conditionalExpression";
|
|
413
|
-
var isCondition = (expression) => expression.type === "relationalExpression" || expression.type === "booleanCondition";
|
|
414
|
-
var isBooleanCondition = (expression) => expression.type === "booleanCondition";
|
|
415
|
-
var isRelationalExpression = (expression) => (expression == null ? void 0 : expression.type) === "relationalExpression";
|
|
416
|
-
var firstIncompleteExpression = (expression) => {
|
|
417
|
-
if (isUnknown(expression)) {
|
|
418
|
-
return expression;
|
|
419
|
-
} else if (isRelationalExpression(expression)) {
|
|
420
|
-
const [operand1, operand2] = expression.expressions;
|
|
421
|
-
if (expressionIsIncomplete(operand1)) {
|
|
422
|
-
return firstIncompleteExpression(operand1);
|
|
423
|
-
} else if (expression.op === "unknown") {
|
|
424
|
-
return expression;
|
|
425
|
-
} else if (expressionIsIncomplete(operand2)) {
|
|
426
|
-
return firstIncompleteExpression(operand2);
|
|
427
|
-
}
|
|
428
|
-
} else if (isCondition(expression)) {
|
|
429
|
-
const { expressions = [] } = expression;
|
|
430
|
-
for (const e of expressions) {
|
|
431
|
-
if (expressionIsIncomplete(e)) {
|
|
432
|
-
return firstIncompleteExpression(e);
|
|
433
|
-
}
|
|
434
|
-
}
|
|
435
|
-
} else if (isConditionalExpression(expression)) {
|
|
436
|
-
const { condition, truthyExpression, falsyExpression } = expression;
|
|
437
|
-
if (expressionIsIncomplete(condition)) {
|
|
438
|
-
return firstIncompleteExpression(condition);
|
|
439
|
-
} else if (expressionIsIncomplete(truthyExpression)) {
|
|
440
|
-
return firstIncompleteExpression(truthyExpression);
|
|
441
|
-
} else if (expressionIsIncomplete(falsyExpression)) {
|
|
442
|
-
return firstIncompleteExpression(falsyExpression);
|
|
443
|
-
}
|
|
444
|
-
} else if (isArithmeticExpression(expression)) {
|
|
445
|
-
const { expressions = [] } = expression;
|
|
446
|
-
for (const e of expressions) {
|
|
447
|
-
if (expressionIsIncomplete(e)) {
|
|
448
|
-
return firstIncompleteExpression(e);
|
|
449
|
-
}
|
|
450
|
-
}
|
|
451
|
-
}
|
|
452
|
-
};
|
|
453
|
-
var replaceUnknownExpression = (incompleteExpression, unknownExpression, expression) => {
|
|
454
|
-
const { expressions = [] } = incompleteExpression;
|
|
455
|
-
if (expressions.includes(unknownExpression)) {
|
|
456
|
-
const pos = expressions.indexOf(unknownExpression);
|
|
457
|
-
expressions.splice(pos, 1, expression);
|
|
458
|
-
return true;
|
|
459
|
-
} else {
|
|
460
|
-
for (const e of expressions) {
|
|
461
|
-
if (replaceUnknownExpression(e, unknownExpression, expression)) {
|
|
462
|
-
return true;
|
|
463
|
-
}
|
|
464
|
-
}
|
|
465
|
-
}
|
|
466
|
-
return false;
|
|
467
|
-
};
|
|
468
|
-
var expressionIsIncomplete = (expression) => {
|
|
469
|
-
if (isUnknown(expression)) {
|
|
470
|
-
return true;
|
|
471
|
-
} else if (isConditionalExpression(expression)) {
|
|
472
|
-
return expressionIsIncomplete(expression.condition) || expressionIsIncomplete(expression.truthyExpression) || expressionIsIncomplete(expression.falsyExpression);
|
|
473
|
-
} else if (isRelationalExpression(expression) || isBooleanCondition(expression)) {
|
|
474
|
-
return expression.op === void 0 || expression.expressions.some((e) => expressionIsIncomplete(e));
|
|
475
|
-
}
|
|
476
|
-
return false;
|
|
477
|
-
};
|
|
478
|
-
var addExpression = (expression, subExpression) => {
|
|
479
|
-
const targetExpression = firstIncompleteExpression(expression);
|
|
480
|
-
if (targetExpression) {
|
|
481
|
-
if (targetExpression.expressions) {
|
|
482
|
-
targetExpression.expressions.push(subExpression);
|
|
483
|
-
} else {
|
|
484
|
-
console.warn("don't know how to treat targetExpression");
|
|
485
|
-
}
|
|
486
|
-
} else {
|
|
487
|
-
console.error("no target expression found");
|
|
488
|
-
}
|
|
489
|
-
};
|
|
490
|
-
var _expression, _callStack;
|
|
491
|
-
var ColumnExpression = class {
|
|
492
|
-
constructor() {
|
|
493
|
-
__privateAdd(this, _expression, void 0);
|
|
494
|
-
__privateAdd(this, _callStack, []);
|
|
495
|
-
}
|
|
496
|
-
setCondition(booleanOperator) {
|
|
497
|
-
if (__privateGet(this, _expression) === void 0) {
|
|
498
|
-
this.addExpression(new ConditionalExpressionImpl(booleanOperator));
|
|
499
|
-
} else if (isConditionalExpression(__privateGet(this, _expression))) {
|
|
500
|
-
if (expressionIsIncomplete(__privateGet(this, _expression).condition)) {
|
|
501
|
-
const condition = booleanOperator ? new BooleanConditionImp(booleanOperator) : new RelationalExpressionImpl();
|
|
502
|
-
this.addExpression(condition);
|
|
503
|
-
} else if (isUnknown(__privateGet(this, _expression).truthyExpression)) {
|
|
504
|
-
__privateGet(this, _expression).truthyExpression = new ConditionalExpressionImpl(
|
|
505
|
-
booleanOperator
|
|
506
|
-
);
|
|
507
|
-
} else if (expressionIsIncomplete(__privateGet(this, _expression).truthyExpression)) {
|
|
508
|
-
const condition = booleanOperator ? new BooleanConditionImp(booleanOperator) : new RelationalExpressionImpl();
|
|
509
|
-
this.addExpression(condition);
|
|
510
|
-
} else if (isUnknown(__privateGet(this, _expression).falsyExpression)) {
|
|
511
|
-
__privateGet(this, _expression).falsyExpression = new ConditionalExpressionImpl(
|
|
512
|
-
booleanOperator
|
|
513
|
-
);
|
|
514
|
-
} else if (expressionIsIncomplete(__privateGet(this, _expression).falsyExpression)) {
|
|
515
|
-
const condition = booleanOperator ? new BooleanConditionImp(booleanOperator) : new RelationalExpressionImpl();
|
|
516
|
-
this.addExpression(condition);
|
|
517
|
-
}
|
|
518
|
-
} else {
|
|
519
|
-
console.error("setCondition called unexpectedly");
|
|
520
|
-
}
|
|
521
|
-
}
|
|
522
|
-
addExpression(expression) {
|
|
523
|
-
if (__privateGet(this, _callStack).length > 0) {
|
|
524
|
-
const currentCallExpression = __privateGet(this, _callStack).at(-1);
|
|
525
|
-
currentCallExpression == null ? void 0 : currentCallExpression.arguments.push(expression);
|
|
526
|
-
} else if (__privateGet(this, _expression) === void 0) {
|
|
527
|
-
__privateSet(this, _expression, expression);
|
|
528
|
-
} else if (isArithmeticExpression(__privateGet(this, _expression))) {
|
|
529
|
-
const targetExpression = firstIncompleteExpression(__privateGet(this, _expression));
|
|
530
|
-
if (targetExpression && isUnknown(targetExpression)) {
|
|
531
|
-
replaceUnknownExpression(
|
|
532
|
-
__privateGet(this, _expression),
|
|
533
|
-
targetExpression,
|
|
534
|
-
expression
|
|
535
|
-
);
|
|
536
|
-
}
|
|
537
|
-
} else if (isConditionalExpression(__privateGet(this, _expression))) {
|
|
538
|
-
if (expressionIsIncomplete(__privateGet(this, _expression))) {
|
|
539
|
-
const targetExpression = firstIncompleteExpression(__privateGet(this, _expression));
|
|
540
|
-
if (targetExpression && isUnknown(targetExpression)) {
|
|
541
|
-
replaceUnknownExpression(
|
|
542
|
-
__privateGet(this, _expression),
|
|
543
|
-
targetExpression,
|
|
544
|
-
expression
|
|
545
|
-
);
|
|
546
|
-
} else if (targetExpression) {
|
|
547
|
-
addExpression(targetExpression, expression);
|
|
548
|
-
}
|
|
549
|
-
}
|
|
550
|
-
}
|
|
551
|
-
}
|
|
552
|
-
setFunction(functionName) {
|
|
553
|
-
const callExpression = new CallExpressionImpl(functionName);
|
|
554
|
-
this.addExpression(callExpression);
|
|
555
|
-
__privateGet(this, _callStack).push(callExpression);
|
|
556
|
-
}
|
|
557
|
-
setColumn(columnName) {
|
|
558
|
-
this.addExpression(new ColumnExpressionImpl(columnName));
|
|
559
|
-
}
|
|
560
|
-
setArithmeticOp(value) {
|
|
561
|
-
const op = value;
|
|
562
|
-
const expression = __privateGet(this, _expression);
|
|
563
|
-
if (isArithmeticExpression(expression)) {
|
|
564
|
-
expression.op = op;
|
|
565
|
-
}
|
|
566
|
-
}
|
|
567
|
-
setRelationalOperator(value) {
|
|
568
|
-
const op = value;
|
|
569
|
-
if (__privateGet(this, _expression) && isConditionalExpression(__privateGet(this, _expression))) {
|
|
570
|
-
const targetExpression = firstIncompleteExpression(__privateGet(this, _expression));
|
|
571
|
-
if (isRelationalExpression(targetExpression)) {
|
|
572
|
-
targetExpression.op = op;
|
|
573
|
-
} else {
|
|
574
|
-
console.error(`no target expression found (op = ${value})`);
|
|
575
|
-
}
|
|
576
|
-
}
|
|
577
|
-
}
|
|
578
|
-
setValue(value) {
|
|
579
|
-
const literalExpression = new LiteralExpressionImpl(value);
|
|
580
|
-
if (__privateGet(this, _expression) === void 0) {
|
|
581
|
-
__privateSet(this, _expression, literalExpression);
|
|
582
|
-
} else if (isArithmeticExpression(__privateGet(this, _expression))) {
|
|
583
|
-
this.addExpression(literalExpression);
|
|
584
|
-
} else if (isCallExpression(__privateGet(this, _expression))) {
|
|
585
|
-
__privateGet(this, _expression).arguments.push(literalExpression);
|
|
586
|
-
} else if (isConditionalExpression(__privateGet(this, _expression))) {
|
|
587
|
-
if (expressionIsIncomplete(__privateGet(this, _expression))) {
|
|
588
|
-
const targetExpression = firstIncompleteExpression(__privateGet(this, _expression));
|
|
589
|
-
if (targetExpression && isUnknown(targetExpression)) {
|
|
590
|
-
replaceUnknownExpression(
|
|
591
|
-
__privateGet(this, _expression),
|
|
592
|
-
targetExpression,
|
|
593
|
-
literalExpression
|
|
594
|
-
);
|
|
595
|
-
} else if (targetExpression) {
|
|
596
|
-
addExpression(targetExpression, literalExpression);
|
|
597
|
-
}
|
|
598
|
-
} else {
|
|
599
|
-
console.log("what do we do with value, in a complete expression");
|
|
600
|
-
}
|
|
601
|
-
}
|
|
602
|
-
}
|
|
603
|
-
closeBrace() {
|
|
604
|
-
__privateGet(this, _callStack).pop();
|
|
605
|
-
}
|
|
606
|
-
get expression() {
|
|
607
|
-
return __privateGet(this, _expression);
|
|
608
|
-
}
|
|
609
|
-
toJSON() {
|
|
610
|
-
var _a;
|
|
611
|
-
return (_a = __privateGet(this, _expression)) == null ? void 0 : _a.toJSON();
|
|
612
|
-
}
|
|
613
|
-
};
|
|
614
|
-
_expression = new WeakMap();
|
|
615
|
-
_callStack = new WeakMap();
|
|
616
|
-
var walkTree = (tree, source) => {
|
|
617
|
-
const columnExpression = new ColumnExpression();
|
|
618
|
-
const cursor = tree.cursor();
|
|
619
|
-
do {
|
|
620
|
-
const { name, from, to } = cursor;
|
|
621
|
-
switch (name) {
|
|
622
|
-
case "AndCondition":
|
|
623
|
-
columnExpression.setCondition("and");
|
|
624
|
-
break;
|
|
625
|
-
case "OrCondition":
|
|
626
|
-
columnExpression.setCondition("or");
|
|
627
|
-
break;
|
|
628
|
-
case "RelationalExpression":
|
|
629
|
-
columnExpression.setCondition();
|
|
630
|
-
break;
|
|
631
|
-
case "ArithmeticExpression":
|
|
632
|
-
columnExpression.addExpression(new ArithmeticExpressionImpl());
|
|
633
|
-
break;
|
|
634
|
-
case "Column":
|
|
635
|
-
{
|
|
636
|
-
const columnName = source.substring(from, to);
|
|
637
|
-
columnExpression.setColumn(columnName);
|
|
638
|
-
}
|
|
639
|
-
break;
|
|
640
|
-
case "Function":
|
|
641
|
-
{
|
|
642
|
-
const functionName = source.substring(from, to);
|
|
643
|
-
columnExpression.setFunction(functionName);
|
|
644
|
-
}
|
|
645
|
-
break;
|
|
646
|
-
case "Times":
|
|
647
|
-
case "Divide":
|
|
648
|
-
case "Plus":
|
|
649
|
-
case "Minus":
|
|
650
|
-
{
|
|
651
|
-
const op = source.substring(from, to);
|
|
652
|
-
columnExpression.setArithmeticOp(op);
|
|
653
|
-
}
|
|
654
|
-
break;
|
|
655
|
-
case "RelationalOperator":
|
|
656
|
-
{
|
|
657
|
-
const op = source.substring(from, to);
|
|
658
|
-
columnExpression.setRelationalOperator(op);
|
|
659
|
-
}
|
|
660
|
-
break;
|
|
661
|
-
case "False":
|
|
662
|
-
case "True":
|
|
663
|
-
{
|
|
664
|
-
const value = source.substring(from, to);
|
|
665
|
-
columnExpression.setValue(value === "true" ? true : false);
|
|
666
|
-
}
|
|
667
|
-
break;
|
|
668
|
-
case "String":
|
|
669
|
-
columnExpression.setValue(source.substring(from + 1, to - 1));
|
|
670
|
-
break;
|
|
671
|
-
case "Number":
|
|
672
|
-
columnExpression.setValue(parseFloat(source.substring(from, to)));
|
|
673
|
-
break;
|
|
674
|
-
case "CloseBrace":
|
|
675
|
-
columnExpression.closeBrace();
|
|
676
|
-
break;
|
|
677
|
-
default:
|
|
678
|
-
}
|
|
679
|
-
} while (cursor.next());
|
|
680
|
-
return columnExpression.toJSON();
|
|
681
|
-
};
|
|
682
|
-
|
|
683
|
-
// src/column-expression-input/column-language-parser/column-expression-parse-utils.ts
|
|
684
|
-
var strictParser = parser.configure({ strict: true });
|
|
685
|
-
var RelationalOperands = ["Number", "String"];
|
|
686
|
-
var ColumnNamedTerms = [
|
|
687
|
-
...RelationalOperands,
|
|
688
|
-
"AndCondition",
|
|
689
|
-
"ArithmeticExpression",
|
|
690
|
-
"BooleanOperator",
|
|
691
|
-
"RelationalOperatorOperator",
|
|
692
|
-
"CallExpression",
|
|
693
|
-
"CloseBrace",
|
|
694
|
-
"Column",
|
|
695
|
-
"Comma",
|
|
696
|
-
"ConditionalExpression",
|
|
697
|
-
"Divide",
|
|
698
|
-
"Equal",
|
|
699
|
-
"If",
|
|
700
|
-
"Minus",
|
|
701
|
-
"OpenBrace",
|
|
702
|
-
"OrCondition",
|
|
703
|
-
"ParenthesizedExpression",
|
|
704
|
-
"Plus",
|
|
705
|
-
"RelationalExpression",
|
|
706
|
-
"RelationalOperator",
|
|
707
|
-
"Times"
|
|
708
|
-
];
|
|
709
|
-
var isCompleteExpression = (src) => {
|
|
710
|
-
try {
|
|
711
|
-
strictParser.parse(src);
|
|
712
|
-
return true;
|
|
713
|
-
} catch (err) {
|
|
714
|
-
return false;
|
|
715
|
-
}
|
|
716
|
-
};
|
|
717
|
-
var lastNamedChild = (node) => {
|
|
718
|
-
let { lastChild } = node;
|
|
719
|
-
while (lastChild && !ColumnNamedTerms.includes(lastChild.name)) {
|
|
720
|
-
lastChild = lastChild.prevSibling;
|
|
721
|
-
console.log(lastChild == null ? void 0 : lastChild.name);
|
|
722
|
-
}
|
|
723
|
-
return lastChild;
|
|
724
|
-
};
|
|
725
|
-
var isCompleteRelationalExpression = (node) => {
|
|
726
|
-
if ((node == null ? void 0 : node.name) === "RelationalExpression") {
|
|
727
|
-
const { firstChild } = node;
|
|
728
|
-
const lastChild = lastNamedChild(node);
|
|
729
|
-
if ((firstChild == null ? void 0 : firstChild.name) === "Column" && typeof (lastChild == null ? void 0 : lastChild.name) === "string" && RelationalOperands.includes(lastChild.name)) {
|
|
730
|
-
return true;
|
|
731
|
-
}
|
|
732
|
-
}
|
|
733
|
-
return false;
|
|
734
|
-
};
|
|
735
|
-
|
|
736
|
-
// src/column-expression-input/highlighting.ts
|
|
737
|
-
var import_vuu_codemirror2 = require("@vuu-ui/vuu-codemirror");
|
|
738
|
-
var myHighlightStyle = import_vuu_codemirror2.HighlightStyle.define([
|
|
739
|
-
{ tag: import_vuu_codemirror2.tags.variableName, color: "var(--vuuFilterEditor-variableColor)" },
|
|
740
|
-
{ tag: import_vuu_codemirror2.tags.comment, color: "green", fontStyle: "italic" }
|
|
741
|
-
]);
|
|
742
|
-
var vuuHighlighting = (0, import_vuu_codemirror2.syntaxHighlighting)(myHighlightStyle);
|
|
743
|
-
|
|
744
|
-
// src/column-expression-input/theme.ts
|
|
745
|
-
var import_vuu_codemirror3 = require("@vuu-ui/vuu-codemirror");
|
|
746
|
-
var vuuTheme = import_vuu_codemirror3.EditorView.theme(
|
|
747
|
-
{
|
|
748
|
-
"&": {
|
|
749
|
-
border: "solid 1px var(--salt-container-primary-borderColor)",
|
|
750
|
-
color: "var(--vuuFilterEditor-color)",
|
|
751
|
-
backgroundColor: "var(--vuuFilterEditor-background)"
|
|
752
|
-
},
|
|
753
|
-
".cm-content": {
|
|
754
|
-
caretColor: "var(--vuuFilterEditor-cursorColor)"
|
|
755
|
-
},
|
|
756
|
-
"&.cm-focused .cm-cursor": {
|
|
757
|
-
borderLeftColor: "var(--vuuFilterEditor-cursorColor)"
|
|
758
|
-
},
|
|
759
|
-
"&.cm-focused .cm-selectionBackground, ::selection": {
|
|
760
|
-
backgroundColor: "var(--vuuFilterEditor-selectionBackground)"
|
|
761
|
-
},
|
|
762
|
-
".cm-selectionBackground, ::selection": {
|
|
763
|
-
backgroundColor: "var(--vuuFilterEditor-selectionBackground)"
|
|
764
|
-
},
|
|
765
|
-
".cm-scroller": {
|
|
766
|
-
fontFamily: "var(--vuuFilterEditor-fontFamily)"
|
|
767
|
-
},
|
|
768
|
-
".cm-tooltip": {
|
|
769
|
-
background: "var(--vuuFilterEditor-tooltipBackground)",
|
|
770
|
-
border: "var(--vuuFilterEditor-tooltipBorder)",
|
|
771
|
-
boxShadow: "var(--vuuFilterEditor-tooltipElevation)",
|
|
772
|
-
"&.cm-tooltip-autocomplete > ul": {
|
|
773
|
-
fontFamily: "var(--vuuFilterEditor-fontFamily)",
|
|
774
|
-
fontSize: "var(--vuuFilterEditor-fontSize)",
|
|
775
|
-
maxHeight: "240px"
|
|
776
|
-
},
|
|
777
|
-
"&.cm-tooltip-autocomplete > ul > li": {
|
|
778
|
-
height: "var(--vuuFilterEditor-suggestion-height)",
|
|
779
|
-
padding: "0 3px",
|
|
780
|
-
lineHeight: "var(--vuuFilterEditor-suggestion-height)"
|
|
781
|
-
},
|
|
782
|
-
"&.cm-tooltip-autocomplete li[aria-selected]": {
|
|
783
|
-
background: "var(--vuuFilterEditor-suggestion-selectedBackground)",
|
|
784
|
-
color: "var(--vuuFilterEditor-suggestion-selectedColor)"
|
|
785
|
-
},
|
|
786
|
-
"&.cm-tooltip-autocomplete li .cm-completionDetail": {
|
|
787
|
-
color: "var(--vuuFilterEditor-suggestion-detailColor)"
|
|
788
|
-
}
|
|
789
|
-
}
|
|
790
|
-
},
|
|
791
|
-
{ dark: false }
|
|
792
|
-
);
|
|
793
|
-
|
|
794
|
-
// src/column-expression-input/useColumnAutoComplete.ts
|
|
795
|
-
var import_vuu_codemirror4 = require("@vuu-ui/vuu-codemirror");
|
|
796
|
-
var import_react2 = require("react");
|
|
797
|
-
var applyPrefix = (completions, prefix) => prefix ? completions.map((completion) => {
|
|
798
|
-
var _a;
|
|
799
|
-
return {
|
|
800
|
-
...completion,
|
|
801
|
-
apply: typeof completion.apply === "function" ? completion.apply : `${prefix}${(_a = completion.apply) != null ? _a : completion.label}`
|
|
802
|
-
};
|
|
803
|
-
}) : completions;
|
|
804
|
-
var isOperator = (node) => node === void 0 ? false : ["Times", "Divide", "Plus", "Minus"].includes(node.name);
|
|
805
|
-
var getLastChild = (node, context) => {
|
|
806
|
-
var _a;
|
|
807
|
-
let { lastChild: childNode } = node;
|
|
808
|
-
const { pos } = context;
|
|
809
|
-
while (childNode) {
|
|
810
|
-
const isBeforeCursor = childNode.from < pos;
|
|
811
|
-
if (isBeforeCursor && ColumnNamedTerms.includes(childNode.name)) {
|
|
812
|
-
if (childNode.name === "ParenthesizedExpression") {
|
|
813
|
-
const expression = (_a = childNode.firstChild) == null ? void 0 : _a.nextSibling;
|
|
814
|
-
if (expression) {
|
|
815
|
-
childNode = expression;
|
|
816
|
-
}
|
|
817
|
-
}
|
|
818
|
-
return childNode;
|
|
819
|
-
} else {
|
|
820
|
-
childNode = childNode.prevSibling;
|
|
821
|
-
}
|
|
822
|
-
}
|
|
823
|
-
};
|
|
824
|
-
var getFunctionName = (node, state) => {
|
|
825
|
-
var _a;
|
|
826
|
-
if (node.name === "ArgList") {
|
|
827
|
-
const functionNode = node.prevSibling;
|
|
828
|
-
if (functionNode) {
|
|
829
|
-
return (0, import_vuu_codemirror4.getValue)(functionNode, state);
|
|
830
|
-
}
|
|
831
|
-
} else if (node.name === "OpenBrace") {
|
|
832
|
-
const maybeFunction = (_a = node.parent) == null ? void 0 : _a.prevSibling;
|
|
833
|
-
if ((maybeFunction == null ? void 0 : maybeFunction.name) === "Function") {
|
|
834
|
-
return (0, import_vuu_codemirror4.getValue)(maybeFunction, state);
|
|
835
|
-
}
|
|
836
|
-
}
|
|
837
|
-
};
|
|
838
|
-
var getRelationalOperator = (node, state) => {
|
|
839
|
-
if (node.name === "RelationalExpression") {
|
|
840
|
-
const lastNode = lastNamedChild(node);
|
|
841
|
-
if ((lastNode == null ? void 0 : lastNode.name) === "RelationalOperator") {
|
|
842
|
-
return (0, import_vuu_codemirror4.getValue)(lastNode, state);
|
|
843
|
-
}
|
|
844
|
-
} else {
|
|
845
|
-
const prevNode = node.prevSibling;
|
|
846
|
-
if ((prevNode == null ? void 0 : prevNode.name) === "RelationalOperator") {
|
|
847
|
-
return (0, import_vuu_codemirror4.getValue)(prevNode, state);
|
|
848
|
-
}
|
|
849
|
-
}
|
|
850
|
-
};
|
|
851
|
-
var getColumnName = (node, state) => {
|
|
852
|
-
var _a;
|
|
853
|
-
if (node.name === "RelationalExpression") {
|
|
854
|
-
if (((_a = node.firstChild) == null ? void 0 : _a.name) === "Column") {
|
|
855
|
-
return (0, import_vuu_codemirror4.getValue)(node.firstChild, state);
|
|
856
|
-
}
|
|
857
|
-
} else {
|
|
858
|
-
const prevNode = node.prevSibling;
|
|
859
|
-
if ((prevNode == null ? void 0 : prevNode.name) === "Column") {
|
|
860
|
-
return (0, import_vuu_codemirror4.getValue)(prevNode, state);
|
|
861
|
-
} else if ((prevNode == null ? void 0 : prevNode.name) === "RelationalOperator") {
|
|
862
|
-
return getColumnName(prevNode, state);
|
|
863
|
-
}
|
|
864
|
-
}
|
|
865
|
-
};
|
|
866
|
-
var makeSuggestions = async (context, suggestionProvider, suggestionType, optionalArgs = {}) => {
|
|
867
|
-
const options = await suggestionProvider.getSuggestions(
|
|
868
|
-
suggestionType,
|
|
869
|
-
optionalArgs
|
|
870
|
-
);
|
|
871
|
-
const { startsWith = "" } = optionalArgs;
|
|
872
|
-
return { from: context.pos - startsWith.length, options };
|
|
873
|
-
};
|
|
874
|
-
var handleConditionalExpression = (node, context, suggestionProvider, maybeComplete, onSubmit) => {
|
|
875
|
-
const lastChild = getLastChild(node, context);
|
|
876
|
-
console.log(`conditional expression last child ${lastChild == null ? void 0 : lastChild.name}`);
|
|
877
|
-
switch (lastChild == null ? void 0 : lastChild.name) {
|
|
878
|
-
case "If":
|
|
879
|
-
return makeSuggestions(context, suggestionProvider, "expression", {
|
|
880
|
-
prefix: "( "
|
|
881
|
-
});
|
|
882
|
-
case "OpenBrace":
|
|
883
|
-
return makeSuggestions(context, suggestionProvider, "expression");
|
|
884
|
-
case "Condition":
|
|
885
|
-
return makeSuggestions(context, suggestionProvider, "expression", {
|
|
886
|
-
prefix: ", "
|
|
887
|
-
});
|
|
888
|
-
case "CloseBrace":
|
|
889
|
-
if (maybeComplete) {
|
|
890
|
-
const options = [
|
|
891
|
-
{
|
|
892
|
-
apply: () => {
|
|
893
|
-
onSubmit == null ? void 0 : onSubmit();
|
|
894
|
-
},
|
|
895
|
-
label: "Save Expression",
|
|
896
|
-
boost: 10
|
|
897
|
-
}
|
|
898
|
-
];
|
|
899
|
-
return { from: context.pos, options };
|
|
900
|
-
}
|
|
901
|
-
}
|
|
902
|
-
};
|
|
903
|
-
var promptToSave = (context, onSubmit) => {
|
|
904
|
-
const options = [
|
|
905
|
-
{
|
|
906
|
-
apply: () => {
|
|
907
|
-
onSubmit == null ? void 0 : onSubmit();
|
|
908
|
-
},
|
|
909
|
-
label: "Save Expression",
|
|
910
|
-
boost: 10
|
|
911
|
-
}
|
|
912
|
-
];
|
|
913
|
-
return { from: context.pos, options };
|
|
914
|
-
};
|
|
915
|
-
var useColumnAutoComplete = (suggestionProvider, onSubmit) => {
|
|
916
|
-
const makeSuggestions2 = (0, import_react2.useCallback)(
|
|
917
|
-
async (context, suggestionType, optionalArgs = {}) => {
|
|
918
|
-
const options = await suggestionProvider.getSuggestions(
|
|
919
|
-
suggestionType,
|
|
920
|
-
optionalArgs
|
|
921
|
-
);
|
|
922
|
-
const { startsWith = "" } = optionalArgs;
|
|
923
|
-
return { from: context.pos - startsWith.length, options };
|
|
924
|
-
},
|
|
925
|
-
[suggestionProvider]
|
|
926
|
-
);
|
|
927
|
-
return (0, import_react2.useCallback)(
|
|
928
|
-
async (context) => {
|
|
929
|
-
var _a, _b;
|
|
930
|
-
const { state, pos } = context;
|
|
931
|
-
const word = (_a = context.matchBefore(/\w*/)) != null ? _a : {
|
|
932
|
-
from: 0,
|
|
933
|
-
to: 0,
|
|
934
|
-
text: void 0
|
|
935
|
-
};
|
|
936
|
-
const tree = (0, import_vuu_codemirror4.syntaxTree)(state);
|
|
937
|
-
const nodeBefore = tree.resolveInner(pos, -1);
|
|
938
|
-
const text = state.doc.toString();
|
|
939
|
-
const maybeComplete = isCompleteExpression(text);
|
|
940
|
-
console.log({ nodeBeforeName: nodeBefore.name });
|
|
941
|
-
switch (nodeBefore.name) {
|
|
942
|
-
case "If": {
|
|
943
|
-
console.log(`conditional expression If`);
|
|
944
|
-
return makeSuggestions2(context, "expression", { prefix: "( " });
|
|
945
|
-
}
|
|
946
|
-
case "Condition":
|
|
947
|
-
{
|
|
948
|
-
const lastChild = getLastChild(nodeBefore, context);
|
|
949
|
-
if ((lastChild == null ? void 0 : lastChild.name) === "Column") {
|
|
950
|
-
const prevChild = (0, import_vuu_codemirror4.getPreviousNode)(lastChild);
|
|
951
|
-
if ((prevChild == null ? void 0 : prevChild.name) !== "RelationalOperator") {
|
|
952
|
-
return makeSuggestions2(context, "condition-operator", {
|
|
953
|
-
columnName: (0, import_vuu_codemirror4.getValue)(lastChild, state)
|
|
954
|
-
});
|
|
955
|
-
}
|
|
956
|
-
console.log(
|
|
957
|
-
`Condition last child Column, prev child ${prevChild == null ? void 0 : prevChild.name}`
|
|
958
|
-
);
|
|
959
|
-
} else if ((lastChild == null ? void 0 : lastChild.name) === "RelationalOperator") {
|
|
960
|
-
return makeSuggestions2(context, "expression");
|
|
961
|
-
}
|
|
962
|
-
console.log(`condition last child ${lastChild == null ? void 0 : lastChild.name}`);
|
|
963
|
-
}
|
|
964
|
-
break;
|
|
965
|
-
case "ConditionalExpression":
|
|
966
|
-
return handleConditionalExpression(
|
|
967
|
-
nodeBefore,
|
|
968
|
-
context,
|
|
969
|
-
suggestionProvider
|
|
970
|
-
);
|
|
971
|
-
case "RelationalExpression":
|
|
972
|
-
{
|
|
973
|
-
if (isCompleteRelationalExpression(nodeBefore)) {
|
|
974
|
-
return {
|
|
975
|
-
from: context.pos,
|
|
976
|
-
options: import_vuu_codemirror4.booleanJoinSuggestions.concat({
|
|
977
|
-
label: ", <truthy expression>, <falsy expression>",
|
|
978
|
-
apply: ", "
|
|
979
|
-
})
|
|
980
|
-
};
|
|
981
|
-
} else {
|
|
982
|
-
const operator = getRelationalOperator(nodeBefore, state);
|
|
983
|
-
const columnName = getColumnName(nodeBefore, state);
|
|
984
|
-
if (!operator) {
|
|
985
|
-
const options = await suggestionProvider.getSuggestions(
|
|
986
|
-
"condition-operator",
|
|
987
|
-
{
|
|
988
|
-
columnName
|
|
989
|
-
}
|
|
990
|
-
);
|
|
991
|
-
return { from: context.pos, options };
|
|
992
|
-
} else {
|
|
993
|
-
return makeSuggestions2(context, "expression");
|
|
994
|
-
}
|
|
995
|
-
}
|
|
996
|
-
}
|
|
997
|
-
break;
|
|
998
|
-
case "RelationalOperator":
|
|
999
|
-
return makeSuggestions2(context, "expression");
|
|
1000
|
-
case "String":
|
|
1001
|
-
{
|
|
1002
|
-
const operator = getRelationalOperator(
|
|
1003
|
-
nodeBefore,
|
|
1004
|
-
state
|
|
1005
|
-
);
|
|
1006
|
-
const columnName = getColumnName(nodeBefore, state);
|
|
1007
|
-
const { from, to } = nodeBefore;
|
|
1008
|
-
if (to - from === 2 && context.pos === from + 1) {
|
|
1009
|
-
if (columnName && operator) {
|
|
1010
|
-
return makeSuggestions2(context, "columnValue", {
|
|
1011
|
-
columnName,
|
|
1012
|
-
operator,
|
|
1013
|
-
startsWith: word.text
|
|
1014
|
-
});
|
|
1015
|
-
}
|
|
1016
|
-
} else if (to - from > 2 && context.pos === to) {
|
|
1017
|
-
return makeSuggestions2(context, "expression", {
|
|
1018
|
-
prefix: ", "
|
|
1019
|
-
});
|
|
1020
|
-
}
|
|
1021
|
-
console.log(
|
|
1022
|
-
`we have a string, column is ${columnName} ${from} ${to}`
|
|
1023
|
-
);
|
|
1024
|
-
}
|
|
1025
|
-
break;
|
|
1026
|
-
case "ArithmeticExpression":
|
|
1027
|
-
{
|
|
1028
|
-
const lastChild = getLastChild(nodeBefore, context);
|
|
1029
|
-
if ((lastChild == null ? void 0 : lastChild.name) === "Column") {
|
|
1030
|
-
return makeSuggestions2(context, "expression");
|
|
1031
|
-
} else if (isOperator(lastChild)) {
|
|
1032
|
-
const operator = lastChild.name;
|
|
1033
|
-
return makeSuggestions2(context, "column", { operator });
|
|
1034
|
-
}
|
|
1035
|
-
}
|
|
1036
|
-
break;
|
|
1037
|
-
case "OpenBrace":
|
|
1038
|
-
{
|
|
1039
|
-
const functionName = getFunctionName(nodeBefore, state);
|
|
1040
|
-
return makeSuggestions2(context, "expression", { functionName });
|
|
1041
|
-
}
|
|
1042
|
-
break;
|
|
1043
|
-
case "ArgList": {
|
|
1044
|
-
const functionName = getFunctionName(nodeBefore, state);
|
|
1045
|
-
const lastArgument = getLastChild(nodeBefore, context);
|
|
1046
|
-
const prefix = (lastArgument == null ? void 0 : lastArgument.name) === "OpenBrace" ? void 0 : ",";
|
|
1047
|
-
let options = await suggestionProvider.getSuggestions("expression", {
|
|
1048
|
-
functionName
|
|
1049
|
-
});
|
|
1050
|
-
options = prefix ? applyPrefix(options, ", ") : options;
|
|
1051
|
-
if ((lastArgument == null ? void 0 : lastArgument.name) !== "OpenBrace" && (lastArgument == null ? void 0 : lastArgument.name) !== "Comma") {
|
|
1052
|
-
options = [
|
|
1053
|
-
{
|
|
1054
|
-
apply: ") ",
|
|
1055
|
-
boost: 10,
|
|
1056
|
-
label: "Done - no more arguments"
|
|
1057
|
-
}
|
|
1058
|
-
].concat(options);
|
|
1059
|
-
}
|
|
1060
|
-
return { from: context.pos, options };
|
|
1061
|
-
}
|
|
1062
|
-
case "Equal":
|
|
1063
|
-
if (text.trim() === "=") {
|
|
1064
|
-
return makeSuggestions2(context, "expression");
|
|
1065
|
-
}
|
|
1066
|
-
break;
|
|
1067
|
-
case "ParenthesizedExpression":
|
|
1068
|
-
case "ColumnDefinitionExpression":
|
|
1069
|
-
if (context.pos === 0) {
|
|
1070
|
-
return makeSuggestions2(context, "expression");
|
|
1071
|
-
} else {
|
|
1072
|
-
const lastChild = getLastChild(nodeBefore, context);
|
|
1073
|
-
if ((lastChild == null ? void 0 : lastChild.name) === "Column") {
|
|
1074
|
-
if (maybeComplete) {
|
|
1075
|
-
const options = [
|
|
1076
|
-
{
|
|
1077
|
-
apply: () => {
|
|
1078
|
-
onSubmit.current();
|
|
1079
|
-
},
|
|
1080
|
-
label: "Save Expression",
|
|
1081
|
-
boost: 10
|
|
1082
|
-
}
|
|
1083
|
-
];
|
|
1084
|
-
const columnName = (0, import_vuu_codemirror4.getValue)(lastChild, state);
|
|
1085
|
-
const columnOptions = await suggestionProvider.getSuggestions("operator", {
|
|
1086
|
-
columnName
|
|
1087
|
-
});
|
|
1088
|
-
return {
|
|
1089
|
-
from: context.pos,
|
|
1090
|
-
options: options.concat(columnOptions)
|
|
1091
|
-
};
|
|
1092
|
-
}
|
|
1093
|
-
} else if ((lastChild == null ? void 0 : lastChild.name) === "CallExpression") {
|
|
1094
|
-
if (maybeComplete) {
|
|
1095
|
-
const options = [
|
|
1096
|
-
{
|
|
1097
|
-
apply: () => {
|
|
1098
|
-
onSubmit.current();
|
|
1099
|
-
},
|
|
1100
|
-
label: "Save Expression",
|
|
1101
|
-
boost: 10
|
|
1102
|
-
}
|
|
1103
|
-
];
|
|
1104
|
-
return {
|
|
1105
|
-
from: context.pos,
|
|
1106
|
-
options
|
|
1107
|
-
};
|
|
1108
|
-
}
|
|
1109
|
-
} else if ((lastChild == null ? void 0 : lastChild.name) === "ArithmeticExpression") {
|
|
1110
|
-
if (maybeComplete) {
|
|
1111
|
-
let options = [
|
|
1112
|
-
{
|
|
1113
|
-
apply: () => {
|
|
1114
|
-
onSubmit.current();
|
|
1115
|
-
},
|
|
1116
|
-
label: "Save Expression",
|
|
1117
|
-
boost: 10
|
|
1118
|
-
}
|
|
1119
|
-
];
|
|
1120
|
-
const lastExpressionChild = getLastChild(lastChild, context);
|
|
1121
|
-
if ((lastExpressionChild == null ? void 0 : lastExpressionChild.name) === "Column") {
|
|
1122
|
-
const columnName = (0, import_vuu_codemirror4.getValue)(lastExpressionChild, state);
|
|
1123
|
-
const suggestions = await suggestionProvider.getSuggestions(
|
|
1124
|
-
"operator",
|
|
1125
|
-
{ columnName }
|
|
1126
|
-
);
|
|
1127
|
-
options = options.concat(suggestions);
|
|
1128
|
-
}
|
|
1129
|
-
return {
|
|
1130
|
-
from: context.pos,
|
|
1131
|
-
options
|
|
1132
|
-
};
|
|
1133
|
-
}
|
|
1134
|
-
} else if ((lastChild == null ? void 0 : lastChild.name) === "ConditionalExpression") {
|
|
1135
|
-
return handleConditionalExpression(
|
|
1136
|
-
lastChild,
|
|
1137
|
-
context,
|
|
1138
|
-
suggestionProvider,
|
|
1139
|
-
maybeComplete,
|
|
1140
|
-
onSubmit.current
|
|
1141
|
-
);
|
|
1142
|
-
}
|
|
1143
|
-
break;
|
|
1144
|
-
}
|
|
1145
|
-
case "Column":
|
|
1146
|
-
{
|
|
1147
|
-
const isPartialMatch = await suggestionProvider.isPartialMatch(
|
|
1148
|
-
"expression",
|
|
1149
|
-
void 0,
|
|
1150
|
-
word.text
|
|
1151
|
-
);
|
|
1152
|
-
if (isPartialMatch) {
|
|
1153
|
-
return makeSuggestions2(context, "expression", {
|
|
1154
|
-
startsWith: word.text
|
|
1155
|
-
});
|
|
1156
|
-
}
|
|
1157
|
-
}
|
|
1158
|
-
break;
|
|
1159
|
-
case "Comma":
|
|
1160
|
-
{
|
|
1161
|
-
const parentNode = (0, import_vuu_codemirror4.getNamedParentNode)(nodeBefore);
|
|
1162
|
-
if ((parentNode == null ? void 0 : parentNode.name) === "ConditionalExpression") {
|
|
1163
|
-
return makeSuggestions2(context, "expression");
|
|
1164
|
-
}
|
|
1165
|
-
}
|
|
1166
|
-
break;
|
|
1167
|
-
case "CloseBrace":
|
|
1168
|
-
{
|
|
1169
|
-
const parentNode = (0, import_vuu_codemirror4.getNamedParentNode)(nodeBefore);
|
|
1170
|
-
if ((parentNode == null ? void 0 : parentNode.name) === "ConditionalExpression") {
|
|
1171
|
-
return handleConditionalExpression(
|
|
1172
|
-
parentNode,
|
|
1173
|
-
context,
|
|
1174
|
-
suggestionProvider,
|
|
1175
|
-
maybeComplete,
|
|
1176
|
-
onSubmit.current
|
|
1177
|
-
);
|
|
1178
|
-
} else if ((parentNode == null ? void 0 : parentNode.name) === "ArgList") {
|
|
1179
|
-
if (maybeComplete) {
|
|
1180
|
-
return promptToSave(context, onSubmit.current);
|
|
1181
|
-
}
|
|
1182
|
-
}
|
|
1183
|
-
console.log(
|
|
1184
|
-
`does closebrace denote an ARgList or a parenthetised expression ? ${parentNode}`
|
|
1185
|
-
);
|
|
1186
|
-
}
|
|
1187
|
-
break;
|
|
1188
|
-
default: {
|
|
1189
|
-
if (((_b = nodeBefore == null ? void 0 : nodeBefore.prevSibling) == null ? void 0 : _b.name) === "FilterClause") {
|
|
1190
|
-
console.log("looks like we ight be a or|and operator");
|
|
1191
|
-
}
|
|
1192
|
-
}
|
|
1193
|
-
}
|
|
1194
|
-
},
|
|
1195
|
-
[makeSuggestions2, onSubmit, suggestionProvider]
|
|
1196
|
-
);
|
|
1197
|
-
};
|
|
1198
|
-
|
|
1199
|
-
// src/column-expression-input/useColumnExpressionEditor.ts
|
|
1200
|
-
var getView = (ref) => {
|
|
1201
|
-
if (ref.current == void 0) {
|
|
1202
|
-
throw Error("EditorView not defined");
|
|
1203
|
-
}
|
|
1204
|
-
return ref.current;
|
|
1205
|
-
};
|
|
1206
|
-
var getOptionClass = () => {
|
|
1207
|
-
return "vuuSuggestion";
|
|
1208
|
-
};
|
|
1209
|
-
var noop = () => console.log("noooop");
|
|
1210
|
-
var hasExpressionType = (completion) => "expressionType" in completion;
|
|
1211
|
-
var injectOptionContent = (completion) => {
|
|
1212
|
-
if (hasExpressionType(completion)) {
|
|
1213
|
-
const div = (0, import_vuu_utils5.createEl)("div", "expression-type-container");
|
|
1214
|
-
const span = (0, import_vuu_utils5.createEl)("span", "expression-type", completion.expressionType);
|
|
1215
|
-
div.appendChild(span);
|
|
1216
|
-
return div;
|
|
1217
|
-
} else {
|
|
1218
|
-
return null;
|
|
1219
|
-
}
|
|
1220
|
-
};
|
|
1221
|
-
var useColumnExpressionEditor = ({
|
|
1222
|
-
onChange,
|
|
1223
|
-
onSubmitExpression,
|
|
1224
|
-
suggestionProvider
|
|
1225
|
-
}) => {
|
|
1226
|
-
const editorRef = (0, import_react3.useRef)(null);
|
|
1227
|
-
const onSubmit = (0, import_react3.useRef)(noop);
|
|
1228
|
-
const viewRef = (0, import_react3.useRef)();
|
|
1229
|
-
const completionFn = useColumnAutoComplete(suggestionProvider, onSubmit);
|
|
1230
|
-
const [createState, clearInput] = (0, import_react3.useMemo)(() => {
|
|
1231
|
-
const parseExpression = () => {
|
|
1232
|
-
const view = getView(viewRef);
|
|
1233
|
-
const source = view.state.doc.toString();
|
|
1234
|
-
const tree = (0, import_vuu_codemirror5.ensureSyntaxTree)(view.state, view.state.doc.length, 5e3);
|
|
1235
|
-
if (tree) {
|
|
1236
|
-
const expression = walkTree(tree, source);
|
|
1237
|
-
return [source, expression];
|
|
1238
|
-
} else {
|
|
1239
|
-
return ["", void 0];
|
|
1240
|
-
}
|
|
1241
|
-
};
|
|
1242
|
-
const clearInput2 = () => {
|
|
1243
|
-
getView(viewRef).setState(createState2());
|
|
1244
|
-
};
|
|
1245
|
-
const submitExpressionAndClearInput = () => {
|
|
1246
|
-
const [source, expression] = parseExpression();
|
|
1247
|
-
onSubmitExpression == null ? void 0 : onSubmitExpression(source, expression);
|
|
1248
|
-
clearInput2();
|
|
1249
|
-
};
|
|
1250
|
-
const submitFilter = (key) => {
|
|
1251
|
-
return import_vuu_codemirror5.keymap.of([
|
|
1252
|
-
{
|
|
1253
|
-
key,
|
|
1254
|
-
run() {
|
|
1255
|
-
submitExpressionAndClearInput();
|
|
1256
|
-
return true;
|
|
1257
|
-
}
|
|
1258
|
-
}
|
|
1259
|
-
]);
|
|
1260
|
-
};
|
|
1261
|
-
const showSuggestions = (key) => {
|
|
1262
|
-
return import_vuu_codemirror5.keymap.of([
|
|
1263
|
-
{
|
|
1264
|
-
key,
|
|
1265
|
-
run() {
|
|
1266
|
-
(0, import_vuu_codemirror5.startCompletion)(getView(viewRef));
|
|
1267
|
-
return true;
|
|
1268
|
-
}
|
|
1269
|
-
}
|
|
1270
|
-
]);
|
|
1271
|
-
};
|
|
1272
|
-
const createState2 = () => import_vuu_codemirror5.EditorState.create({
|
|
1273
|
-
doc: "",
|
|
1274
|
-
extensions: [
|
|
1275
|
-
import_vuu_codemirror5.minimalSetup,
|
|
1276
|
-
(0, import_vuu_codemirror5.autocompletion)({
|
|
1277
|
-
addToOptions: [
|
|
1278
|
-
{
|
|
1279
|
-
render: injectOptionContent,
|
|
1280
|
-
position: 70
|
|
1281
|
-
}
|
|
1282
|
-
],
|
|
1283
|
-
override: [completionFn],
|
|
1284
|
-
optionClass: getOptionClass
|
|
1285
|
-
}),
|
|
1286
|
-
columnExpressionLanguageSupport(),
|
|
1287
|
-
import_vuu_codemirror5.keymap.of(import_vuu_codemirror5.defaultKeymap),
|
|
1288
|
-
submitFilter("Ctrl-Enter"),
|
|
1289
|
-
showSuggestions("ArrowDown"),
|
|
1290
|
-
import_vuu_codemirror5.EditorView.updateListener.of((v) => {
|
|
1291
|
-
const view = getView(viewRef);
|
|
1292
|
-
if (v.docChanged) {
|
|
1293
|
-
(0, import_vuu_codemirror5.startCompletion)(view);
|
|
1294
|
-
const source = view.state.doc.toString();
|
|
1295
|
-
onChange == null ? void 0 : onChange(source, void 0);
|
|
1296
|
-
}
|
|
1297
|
-
}),
|
|
1298
|
-
// Enforces single line view
|
|
1299
|
-
// EditorState.transactionFilter.of((tr) =>
|
|
1300
|
-
// tr.newDoc.lines > 1 ? [] : tr
|
|
1301
|
-
// ),
|
|
1302
|
-
vuuTheme,
|
|
1303
|
-
vuuHighlighting
|
|
1304
|
-
]
|
|
1305
|
-
});
|
|
1306
|
-
onSubmit.current = () => {
|
|
1307
|
-
submitExpressionAndClearInput();
|
|
1308
|
-
setTimeout(() => {
|
|
1309
|
-
getView(viewRef).focus();
|
|
1310
|
-
}, 100);
|
|
1311
|
-
};
|
|
1312
|
-
return [createState2, clearInput2];
|
|
1313
|
-
}, [completionFn, onChange, onSubmitExpression]);
|
|
1314
|
-
(0, import_react3.useEffect)(() => {
|
|
1315
|
-
if (!editorRef.current) {
|
|
1316
|
-
throw Error("editor not in dom");
|
|
1317
|
-
}
|
|
1318
|
-
viewRef.current = new import_vuu_codemirror5.EditorView({
|
|
1319
|
-
state: createState(),
|
|
1320
|
-
parent: editorRef.current
|
|
1321
|
-
});
|
|
1322
|
-
return () => {
|
|
1323
|
-
var _a;
|
|
1324
|
-
(_a = viewRef.current) == null ? void 0 : _a.destroy();
|
|
1325
|
-
};
|
|
1326
|
-
}, [completionFn, createState]);
|
|
1327
|
-
return { editorRef, clearInput };
|
|
1328
|
-
};
|
|
1329
|
-
|
|
1330
|
-
// src/column-expression-input/ColumnExpressionInput.tsx
|
|
1331
|
-
var import_jsx_runtime3 = require("react/jsx-runtime");
|
|
1332
|
-
var classBase3 = "vuuColumnExpressionInput";
|
|
1333
|
-
var ColumnExpressionInput = ({
|
|
1334
|
-
onChange,
|
|
1335
|
-
onSubmitExpression,
|
|
1336
|
-
suggestionProvider
|
|
1337
|
-
}) => {
|
|
1338
|
-
const { editorRef } = useColumnExpressionEditor({
|
|
1339
|
-
onChange,
|
|
1340
|
-
onSubmitExpression,
|
|
1341
|
-
suggestionProvider
|
|
1342
|
-
});
|
|
1343
|
-
return /* @__PURE__ */ (0, import_jsx_runtime3.jsx)("div", { className: `${classBase3}`, ref: editorRef });
|
|
1344
|
-
};
|
|
1345
|
-
|
|
1346
|
-
// src/column-expression-input/useColumnExpressionSuggestionProvider.ts
|
|
1347
|
-
var import_vuu_codemirror6 = require("@vuu-ui/vuu-codemirror");
|
|
1348
|
-
var import_vuu_data = require("@vuu-ui/vuu-data");
|
|
1349
|
-
var import_vuu_utils7 = require("@vuu-ui/vuu-utils");
|
|
1350
|
-
var import_react4 = require("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
|
-
var import_vuu_utils6 = require("@vuu-ui/vuu-utils");
|
|
1626
|
-
var functionDocInfo = ({
|
|
1627
|
-
name,
|
|
1628
|
-
description,
|
|
1629
|
-
example,
|
|
1630
|
-
params,
|
|
1631
|
-
type
|
|
1632
|
-
}) => {
|
|
1633
|
-
const rootElement = (0, import_vuu_utils6.createEl)("div", "vuuFunctionDoc");
|
|
1634
|
-
const headingElement = (0, import_vuu_utils6.createEl)("div", "function-heading");
|
|
1635
|
-
const nameElement = (0, import_vuu_utils6.createEl)("span", "function-name", name);
|
|
1636
|
-
const paramElement = (0, import_vuu_utils6.createEl)("span", "param-list", params.description);
|
|
1637
|
-
const typeElement = (0, import_vuu_utils6.createEl)("span", "function-type", type);
|
|
1638
|
-
headingElement.appendChild(nameElement);
|
|
1639
|
-
headingElement.appendChild(paramElement);
|
|
1640
|
-
headingElement.appendChild(typeElement);
|
|
1641
|
-
const child2 = (0, import_vuu_utils6.createEl)("p", void 0, description);
|
|
1642
|
-
rootElement.appendChild(headingElement);
|
|
1643
|
-
rootElement.appendChild(child2);
|
|
1644
|
-
if (example) {
|
|
1645
|
-
const exampleElement = (0, import_vuu_utils6.createEl)("div", "example-container", "Example:");
|
|
1646
|
-
const expressionElement = (0, import_vuu_utils6.createEl)(
|
|
1647
|
-
"div",
|
|
1648
|
-
"example-expression",
|
|
1649
|
-
example.expression
|
|
1650
|
-
);
|
|
1651
|
-
const resultElement = (0, import_vuu_utils6.createEl)("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(import_vuu_utils7.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(import_vuu_utils7.isTextColumn);
|
|
1677
|
-
case "number":
|
|
1678
|
-
return columns.filter(import_vuu_utils7.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 || (0, import_vuu_utils7.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
|
-
import_vuu_codemirror6.stringOperators
|
|
1719
|
-
/*, startsWith*/
|
|
1720
|
-
);
|
|
1721
|
-
case "int":
|
|
1722
|
-
case "long":
|
|
1723
|
-
case "double":
|
|
1724
|
-
return withApplySpace(import_vuu_codemirror6.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 = (0, import_react4.useCallback)(
|
|
1772
|
-
(name) => name ? columns.find((col) => col.name === name) : void 0,
|
|
1773
|
-
[columns]
|
|
1774
|
-
);
|
|
1775
|
-
const latestSuggestionsRef = (0, import_react4.useRef)();
|
|
1776
|
-
const getTypeaheadSuggestions = (0, import_vuu_data.useTypeaheadSuggestions)();
|
|
1777
|
-
const getSuggestions = (0, import_react4.useCallback)(
|
|
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 (0, import_vuu_codemirror6.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 = (0, import_vuu_data.getTypeaheadParams)(
|
|
1815
|
-
table,
|
|
1816
|
-
columnName
|
|
1817
|
-
/*, startsWith*/
|
|
1818
|
-
);
|
|
1819
|
-
const suggestions = await getTypeaheadSuggestions(params);
|
|
1820
|
-
latestSuggestionsRef.current = (0, import_vuu_codemirror6.toSuggestions)(suggestions, {
|
|
1821
|
-
suffix: ""
|
|
1822
|
-
});
|
|
1823
|
-
latestSuggestionsRef.current.forEach((suggestion) => {
|
|
1824
|
-
suggestion.apply = (view, completion, from) => {
|
|
1825
|
-
const annotation = new import_vuu_codemirror6.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 = (0, import_react4.useCallback)(
|
|
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
|
-
var import_core7 = require("@salt-ds/core");
|
|
1868
|
-
var import_classnames6 = __toESM(require("classnames"), 1);
|
|
1869
|
-
var import_react12 = require("react");
|
|
1870
|
-
|
|
1871
|
-
// src/datagrid-configuration-ui/column-picker/ColumnPicker.tsx
|
|
1872
|
-
var import_salt_lab2 = require("@heswell/salt-lab");
|
|
1873
|
-
var import_core = require("@salt-ds/core");
|
|
1874
|
-
var import_react5 = require("react");
|
|
1875
|
-
|
|
1876
|
-
// src/datagrid-configuration-ui/column-picker/ColumnListItem.tsx
|
|
1877
|
-
var import_salt_lab = require("@heswell/salt-lab");
|
|
1878
|
-
var import_classnames3 = __toESM(require("classnames"), 1);
|
|
1879
|
-
var import_jsx_runtime4 = require("react/jsx-runtime");
|
|
1880
|
-
var classBase4 = "vuuColumnListItem";
|
|
1881
|
-
var ColumnListItem = ({
|
|
1882
|
-
className: classNameProp,
|
|
1883
|
-
item,
|
|
1884
|
-
label,
|
|
1885
|
-
style: styleProp,
|
|
1886
|
-
...restProps
|
|
1887
|
-
}) => {
|
|
1888
|
-
const className = (0, import_classnames3.default)(classBase4, classNameProp, {
|
|
1889
|
-
[`${classBase4}-calculated`]: item == null ? void 0 : item.expression,
|
|
1890
|
-
[`${classBase4}-hidden`]: item == null ? void 0 : item.hidden
|
|
1891
|
-
});
|
|
1892
|
-
return /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)(import_salt_lab.ListItem, { className, ...restProps, children: [
|
|
1893
|
-
/* @__PURE__ */ (0, import_jsx_runtime4.jsx)("span", { className: `${classBase4}-iconType` }),
|
|
1894
|
-
/* @__PURE__ */ (0, import_jsx_runtime4.jsx)("label", { className: `${classBase4}-label`, children: label }),
|
|
1895
|
-
/* @__PURE__ */ (0, import_jsx_runtime4.jsx)("span", { className: `${classBase4}-iconHidden` })
|
|
1896
|
-
] });
|
|
1897
|
-
};
|
|
1898
|
-
|
|
1899
|
-
// src/datagrid-configuration-ui/column-picker/ColumnPicker.tsx
|
|
1900
|
-
var import_jsx_runtime5 = require("react/jsx-runtime");
|
|
1901
|
-
var classBase5 = "vuuColumnPicker";
|
|
1902
|
-
var removeSelectedColumns = (availableColumns, selectedColumns) => {
|
|
1903
|
-
return availableColumns.filter(
|
|
1904
|
-
(column) => selectedColumns.find((col) => col.name === column.name) == null
|
|
1905
|
-
);
|
|
1906
|
-
};
|
|
1907
|
-
var ColumnPicker = ({
|
|
1908
|
-
availableColumns,
|
|
1909
|
-
id: idProp,
|
|
1910
|
-
dispatchColumnAction: dispatch,
|
|
1911
|
-
onAddCalculatedColumnClick,
|
|
1912
|
-
onSelectionChange,
|
|
1913
|
-
chosenColumns,
|
|
1914
|
-
selectedColumn
|
|
1915
|
-
}) => {
|
|
1916
|
-
const [selected1, setSelected1] = (0, import_react5.useState)([]);
|
|
1917
|
-
const id = (0, import_core.useIdMemo)(idProp);
|
|
1918
|
-
const unusedColumns = removeSelectedColumns(availableColumns, chosenColumns);
|
|
1919
|
-
const addColumn2 = (0, import_react5.useCallback)(() => {
|
|
1920
|
-
if (selected1.length > 0) {
|
|
1921
|
-
setSelected1([]);
|
|
1922
|
-
dispatch({ type: "addColumn", columns: selected1 });
|
|
1923
|
-
}
|
|
1924
|
-
}, [dispatch, selected1]);
|
|
1925
|
-
const removeColumn2 = (0, import_react5.useCallback)(
|
|
1926
|
-
() => selectedColumn && dispatch({ type: "removeColumn", column: selectedColumn }),
|
|
1927
|
-
[selectedColumn, dispatch]
|
|
1928
|
-
);
|
|
1929
|
-
const moveColumnUp = (0, import_react5.useCallback)(
|
|
1930
|
-
() => selectedColumn && dispatch({ type: "moveColumn", column: selectedColumn, moveBy: -1 }),
|
|
1931
|
-
[dispatch, selectedColumn]
|
|
1932
|
-
);
|
|
1933
|
-
const moveColumnDown = (0, import_react5.useCallback)(
|
|
1934
|
-
() => selectedColumn && dispatch({ type: "moveColumn", column: selectedColumn, moveBy: 1 }),
|
|
1935
|
-
[dispatch, selectedColumn]
|
|
1936
|
-
);
|
|
1937
|
-
const handleSelectionChange1 = (0, import_react5.useCallback)(
|
|
1938
|
-
(evt, selected) => setSelected1(selected),
|
|
1939
|
-
[]
|
|
1940
|
-
);
|
|
1941
|
-
const handleSelectionChange2 = (0, import_react5.useCallback)(
|
|
1942
|
-
(evt, selected) => onSelectionChange == null ? void 0 : onSelectionChange(selected),
|
|
1943
|
-
[onSelectionChange]
|
|
1944
|
-
);
|
|
1945
|
-
const handleDrop = (0, import_react5.useCallback)(
|
|
1946
|
-
(moveFrom, moveTo) => {
|
|
1947
|
-
dispatch({ type: "moveColumn", moveFrom, moveTo });
|
|
1948
|
-
},
|
|
1949
|
-
[dispatch]
|
|
1950
|
-
);
|
|
1951
|
-
return /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)("div", { className: classBase5, id, children: [
|
|
1952
|
-
/* @__PURE__ */ (0, import_jsx_runtime5.jsxs)("div", { className: `${classBase5}-listColumn`, children: [
|
|
1953
|
-
/* @__PURE__ */ (0, import_jsx_runtime5.jsx)("label", { htmlFor: `available-${id}`, children: /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(import_core.Text, { as: "h4", children: "Available Columns" }) }),
|
|
1954
|
-
/* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
|
|
1955
|
-
"div",
|
|
1956
|
-
{
|
|
1957
|
-
className: `${classBase5}-listContainer`,
|
|
1958
|
-
style: { flex: 1, overflow: "hidden" },
|
|
1959
|
-
children: /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
|
|
1960
|
-
import_salt_lab2.List,
|
|
1961
|
-
{
|
|
1962
|
-
borderless: true,
|
|
1963
|
-
checkable: false,
|
|
1964
|
-
height: "100%",
|
|
1965
|
-
id: `available-${id}`,
|
|
1966
|
-
itemHeight: 24,
|
|
1967
|
-
itemToString: (item) => item.name,
|
|
1968
|
-
onSelectionChange: handleSelectionChange1,
|
|
1969
|
-
selected: selected1,
|
|
1970
|
-
selectionStrategy: "extended",
|
|
1971
|
-
source: unusedColumns
|
|
1972
|
-
}
|
|
1973
|
-
)
|
|
1974
|
-
}
|
|
1975
|
-
),
|
|
1976
|
-
/* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
|
|
1977
|
-
"div",
|
|
1978
|
-
{
|
|
1979
|
-
style: {
|
|
1980
|
-
display: "flex",
|
|
1981
|
-
alignItems: "center",
|
|
1982
|
-
flex: "0 0 32px",
|
|
1983
|
-
marginTop: "var(--salt-size-basis-unit)"
|
|
1984
|
-
},
|
|
1985
|
-
children: /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)(import_core.Button, { onClick: addColumn2, disabled: selected1.length === 0, children: [
|
|
1986
|
-
"Show",
|
|
1987
|
-
/* @__PURE__ */ (0, import_jsx_runtime5.jsx)("span", { "data-icon": "arrow-thin-right", style: { marginLeft: 8 } })
|
|
1988
|
-
] })
|
|
1989
|
-
}
|
|
1990
|
-
)
|
|
1991
|
-
] }),
|
|
1992
|
-
/* @__PURE__ */ (0, import_jsx_runtime5.jsxs)("div", { className: `${classBase5}-listColumn`, children: [
|
|
1993
|
-
/* @__PURE__ */ (0, import_jsx_runtime5.jsx)("label", { htmlFor: `selected-${id}`, children: /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(import_core.Text, { as: "h4", children: "Included Columns" }) }),
|
|
1994
|
-
/* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
|
|
1995
|
-
"div",
|
|
1996
|
-
{
|
|
1997
|
-
className: `${classBase5}-listContainer`,
|
|
1998
|
-
style: { flex: 1, overflow: "hidden" },
|
|
1999
|
-
children: /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
|
|
2000
|
-
import_salt_lab2.List,
|
|
2001
|
-
{
|
|
2002
|
-
ListItem: ColumnListItem,
|
|
2003
|
-
allowDragDrop: true,
|
|
2004
|
-
borderless: true,
|
|
2005
|
-
height: "100%",
|
|
2006
|
-
id: `selected-${id}`,
|
|
2007
|
-
itemHeight: 24,
|
|
2008
|
-
itemToString: (item) => item.name,
|
|
2009
|
-
onMoveListItem: handleDrop,
|
|
2010
|
-
onSelectionChange: handleSelectionChange2,
|
|
2011
|
-
selected: selectedColumn,
|
|
2012
|
-
style: { flex: 1 },
|
|
2013
|
-
source: chosenColumns
|
|
2014
|
-
}
|
|
2015
|
-
)
|
|
2016
|
-
}
|
|
2017
|
-
),
|
|
2018
|
-
/* @__PURE__ */ (0, import_jsx_runtime5.jsxs)(
|
|
2019
|
-
"div",
|
|
2020
|
-
{
|
|
2021
|
-
style: {
|
|
2022
|
-
alignItems: "center",
|
|
2023
|
-
flex: "0 0 32px",
|
|
2024
|
-
display: "flex",
|
|
2025
|
-
gap: 6,
|
|
2026
|
-
marginTop: "var(--salt-size-basis-unit)"
|
|
2027
|
-
},
|
|
2028
|
-
children: [
|
|
2029
|
-
/* @__PURE__ */ (0, import_jsx_runtime5.jsxs)(import_core.Button, { onClick: removeColumn2, disabled: selectedColumn === null, children: [
|
|
2030
|
-
/* @__PURE__ */ (0, import_jsx_runtime5.jsx)("span", { "data-icon": "arrow-thin-left", style: { marginRight: 8 } }),
|
|
2031
|
-
"Hide"
|
|
2032
|
-
] }),
|
|
2033
|
-
/* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
|
|
2034
|
-
import_core.Button,
|
|
2035
|
-
{
|
|
2036
|
-
"aria-label": "Move column up",
|
|
2037
|
-
onClick: moveColumnUp,
|
|
2038
|
-
disabled: selectedColumn === null || (chosenColumns == null ? void 0 : chosenColumns.indexOf(selectedColumn)) === 0,
|
|
2039
|
-
style: { width: 28 },
|
|
2040
|
-
children: /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("span", { "data-icon": "arrow-thin-up" })
|
|
2041
|
-
}
|
|
2042
|
-
),
|
|
2043
|
-
/* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
|
|
2044
|
-
import_core.Button,
|
|
2045
|
-
{
|
|
2046
|
-
"aria-label": "Move column down",
|
|
2047
|
-
onClick: moveColumnDown,
|
|
2048
|
-
disabled: selectedColumn === null || chosenColumns.indexOf(selectedColumn) === chosenColumns.length - 1,
|
|
2049
|
-
style: { width: 28 },
|
|
2050
|
-
children: /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("span", { "data-icon": "arrow-thin-down" })
|
|
2051
|
-
}
|
|
2052
|
-
),
|
|
2053
|
-
/* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
|
|
2054
|
-
import_core.Button,
|
|
2055
|
-
{
|
|
2056
|
-
"aria-label": "Add calculated column",
|
|
2057
|
-
className: `${classBase5}-addCalculatedColumn`,
|
|
2058
|
-
onClick: onAddCalculatedColumnClick,
|
|
2059
|
-
variant: "primary",
|
|
2060
|
-
children: /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("span", { "data-icon": "add" })
|
|
2061
|
-
}
|
|
2062
|
-
)
|
|
2063
|
-
]
|
|
2064
|
-
}
|
|
2065
|
-
)
|
|
2066
|
-
] })
|
|
2067
|
-
] });
|
|
2068
|
-
};
|
|
2069
|
-
|
|
2070
|
-
// src/datagrid-configuration-ui/column-settings-panel/ColumnSettingsPanel.tsx
|
|
2071
|
-
var import_vuu_layout = require("@vuu-ui/vuu-layout");
|
|
2072
|
-
var import_salt_lab5 = require("@heswell/salt-lab");
|
|
2073
|
-
var import_core4 = require("@salt-ds/core");
|
|
2074
|
-
var import_classnames5 = __toESM(require("classnames"), 1);
|
|
2075
|
-
var import_react8 = require("react");
|
|
2076
|
-
|
|
2077
|
-
// src/datagrid-configuration-ui/column-type-panel/ColumnTypePanel.tsx
|
|
2078
|
-
var import_vuu_utils8 = require("@vuu-ui/vuu-utils");
|
|
2079
|
-
var import_salt_lab4 = require("@heswell/salt-lab");
|
|
2080
|
-
var import_core3 = require("@salt-ds/core");
|
|
2081
|
-
var import_classnames4 = __toESM(require("classnames"), 1);
|
|
2082
|
-
var import_react7 = require("react");
|
|
2083
|
-
|
|
2084
|
-
// src/datagrid-configuration-ui/column-type-panel/NumericColumnPanel.tsx
|
|
2085
|
-
var import_salt_lab3 = require("@heswell/salt-lab");
|
|
2086
|
-
var import_core2 = require("@salt-ds/core");
|
|
2087
|
-
var import_react6 = require("react");
|
|
2088
|
-
var import_jsx_runtime6 = require("react/jsx-runtime");
|
|
2089
|
-
var defaultValues = {
|
|
2090
|
-
alignOnDecimals: false,
|
|
2091
|
-
decimals: 4,
|
|
2092
|
-
zeroPad: false
|
|
2093
|
-
};
|
|
2094
|
-
var getColumnValues = (columnType, gridDefaultValues) => {
|
|
2095
|
-
const columnValue = typeof columnType === "object" && columnType.formatting ? columnType.formatting : {};
|
|
2096
|
-
const properties = ["alignOnDecimals", "decimals", "zeroPad"];
|
|
2097
|
-
return properties.reduce((configValues, property) => {
|
|
2098
|
-
if (columnValue[property] !== void 0) {
|
|
2099
|
-
return {
|
|
2100
|
-
...configValues,
|
|
2101
|
-
[property]: columnValue[property]
|
|
2102
|
-
};
|
|
2103
|
-
} else if ((gridDefaultValues == null ? void 0 : gridDefaultValues[property]) !== void 0) {
|
|
2104
|
-
return {
|
|
2105
|
-
...configValues,
|
|
2106
|
-
[property]: gridDefaultValues[property]
|
|
2107
|
-
};
|
|
2108
|
-
}
|
|
2109
|
-
return configValues;
|
|
2110
|
-
}, defaultValues);
|
|
2111
|
-
};
|
|
2112
|
-
var NumericColumnPanel = ({
|
|
2113
|
-
column,
|
|
2114
|
-
dispatchColumnAction
|
|
2115
|
-
}) => {
|
|
2116
|
-
const { decimals, alignOnDecimals, zeroPad } = getColumnValues(column == null ? void 0 : column.type);
|
|
2117
|
-
const dispatchUpdate = (0, import_react6.useCallback)(
|
|
2118
|
-
(values) => dispatchColumnAction({
|
|
2119
|
-
type: "updateColumnTypeFormatting",
|
|
2120
|
-
column,
|
|
2121
|
-
...values
|
|
2122
|
-
}),
|
|
2123
|
-
[column, dispatchColumnAction]
|
|
2124
|
-
);
|
|
2125
|
-
const handleChangeDecimals = (0, import_react6.useCallback)(
|
|
2126
|
-
(value) => dispatchUpdate({ decimals: parseInt(value.toString(), 10) }),
|
|
2127
|
-
[dispatchUpdate]
|
|
2128
|
-
);
|
|
2129
|
-
const handleChangeAlignOnDecimals = (0, import_react6.useCallback)(
|
|
2130
|
-
(evt, value) => dispatchUpdate({ alignOnDecimals: value }),
|
|
2131
|
-
[dispatchUpdate]
|
|
2132
|
-
);
|
|
2133
|
-
const handleChangeZeroPad = (0, import_react6.useCallback)(
|
|
2134
|
-
(evt, value) => dispatchUpdate({ zeroPad: value }),
|
|
2135
|
-
[dispatchUpdate]
|
|
2136
|
-
);
|
|
2137
|
-
switch (column.serverDataType) {
|
|
2138
|
-
case "double":
|
|
2139
|
-
return /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)(import_jsx_runtime6.Fragment, { children: [
|
|
2140
|
-
/* @__PURE__ */ (0, import_jsx_runtime6.jsx)(import_salt_lab3.FormField, { label: "No of Decimals", labelPlacement: "top", children: /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(import_salt_lab3.StepperInput, { value: decimals, onChange: handleChangeDecimals }) }),
|
|
2141
|
-
/* @__PURE__ */ (0, import_jsx_runtime6.jsx)(
|
|
2142
|
-
import_salt_lab3.Switch,
|
|
2143
|
-
{
|
|
2144
|
-
checked: alignOnDecimals,
|
|
2145
|
-
label: "Align on decimals",
|
|
2146
|
-
LabelProps: { className: "vuuColumnPanelSwitch" },
|
|
2147
|
-
onChange: handleChangeAlignOnDecimals
|
|
2148
|
-
}
|
|
2149
|
-
),
|
|
2150
|
-
/* @__PURE__ */ (0, import_jsx_runtime6.jsx)(
|
|
2151
|
-
import_salt_lab3.Switch,
|
|
2152
|
-
{
|
|
2153
|
-
checked: zeroPad,
|
|
2154
|
-
label: "Zero pad",
|
|
2155
|
-
LabelProps: { className: "vuuColumnPanelSwitch" },
|
|
2156
|
-
onChange: handleChangeZeroPad
|
|
2157
|
-
}
|
|
2158
|
-
)
|
|
2159
|
-
] });
|
|
2160
|
-
case "long":
|
|
2161
|
-
case "int":
|
|
2162
|
-
return /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(import_jsx_runtime6.Fragment, { children: /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(import_core2.Text, { children: "Work in progress" }) });
|
|
2163
|
-
default:
|
|
2164
|
-
return null;
|
|
2165
|
-
}
|
|
2166
|
-
};
|
|
2167
|
-
|
|
2168
|
-
// src/datagrid-configuration-ui/column-type-panel/StringColumnPanel.tsx
|
|
2169
|
-
var import_jsx_runtime7 = require("react/jsx-runtime");
|
|
2170
|
-
var StringColumnPanel = ({
|
|
2171
|
-
column,
|
|
2172
|
-
dispatchColumnAction
|
|
2173
|
-
}) => {
|
|
2174
|
-
return /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(import_jsx_runtime7.Fragment, { children: "String" });
|
|
2175
|
-
};
|
|
2176
|
-
|
|
2177
|
-
// src/datagrid-configuration-ui/column-type-panel/ColumnTypePanel.tsx
|
|
2178
|
-
var import_jsx_runtime8 = require("react/jsx-runtime");
|
|
2179
|
-
var classBase6 = "vuuColumnTypePanel";
|
|
2180
|
-
var integerCellRenderers = ["Default Renderer (int, long)"];
|
|
2181
|
-
var doubleCellRenderers = ["Default Renderer (double)"];
|
|
2182
|
-
var stringCellRenderers = ["Default Renderer (string)"];
|
|
2183
|
-
var getAvailableCellRenderers = (column) => {
|
|
2184
|
-
const customCellRenderers = (0, import_vuu_utils8.getRegisteredCellRenderers)(column.serverDataType);
|
|
2185
|
-
const customRendererNames = customCellRenderers.map((r) => r.name);
|
|
2186
|
-
console.log({ customRendererNames });
|
|
2187
|
-
switch (column.serverDataType) {
|
|
2188
|
-
case "char":
|
|
2189
|
-
case "string":
|
|
2190
|
-
return stringCellRenderers;
|
|
2191
|
-
case "int":
|
|
2192
|
-
case "long":
|
|
2193
|
-
return integerCellRenderers;
|
|
2194
|
-
case "double":
|
|
2195
|
-
return doubleCellRenderers.concat(customRendererNames);
|
|
2196
|
-
default:
|
|
2197
|
-
return stringCellRenderers;
|
|
2198
|
-
}
|
|
2199
|
-
};
|
|
2200
|
-
var ColumnTypePanel = ({
|
|
2201
|
-
className,
|
|
2202
|
-
column,
|
|
2203
|
-
dispatchColumnAction,
|
|
2204
|
-
...props
|
|
2205
|
-
}) => {
|
|
2206
|
-
const content = (0, import_react7.useMemo)(() => {
|
|
2207
|
-
switch (column.serverDataType) {
|
|
2208
|
-
case "double":
|
|
2209
|
-
case "int":
|
|
2210
|
-
case "long":
|
|
2211
|
-
return /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(
|
|
2212
|
-
NumericColumnPanel,
|
|
2213
|
-
{
|
|
2214
|
-
column,
|
|
2215
|
-
dispatchColumnAction
|
|
2216
|
-
}
|
|
2217
|
-
);
|
|
2218
|
-
default:
|
|
2219
|
-
return /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(
|
|
2220
|
-
StringColumnPanel,
|
|
2221
|
-
{
|
|
2222
|
-
column,
|
|
2223
|
-
dispatchColumnAction
|
|
2224
|
-
}
|
|
2225
|
-
);
|
|
2226
|
-
}
|
|
2227
|
-
}, [column, dispatchColumnAction]);
|
|
2228
|
-
const { serverDataType = "string" } = column;
|
|
2229
|
-
const availableRenderers = getAvailableCellRenderers(column);
|
|
2230
|
-
return /* @__PURE__ */ (0, import_jsx_runtime8.jsxs)(import_jsx_runtime8.Fragment, { children: [
|
|
2231
|
-
/* @__PURE__ */ (0, import_jsx_runtime8.jsx)(
|
|
2232
|
-
import_salt_lab4.Dropdown,
|
|
2233
|
-
{
|
|
2234
|
-
className: (0, import_classnames4.default)(`${classBase6}-renderer`),
|
|
2235
|
-
fullWidth: true,
|
|
2236
|
-
selected: availableRenderers[0],
|
|
2237
|
-
source: availableRenderers
|
|
2238
|
-
}
|
|
2239
|
-
),
|
|
2240
|
-
/* @__PURE__ */ (0, import_jsx_runtime8.jsx)(
|
|
2241
|
-
import_core3.Panel,
|
|
2242
|
-
{
|
|
2243
|
-
...props,
|
|
2244
|
-
className: (0, import_classnames4.default)(classBase6, className, `${classBase6}-${serverDataType}`),
|
|
2245
|
-
children: content
|
|
2246
|
-
}
|
|
2247
|
-
)
|
|
2248
|
-
] });
|
|
2249
|
-
};
|
|
2250
|
-
|
|
2251
|
-
// src/datagrid-configuration-ui/column-settings-panel/ColumnSettingsPanel.tsx
|
|
2252
|
-
var import_jsx_runtime9 = require("react/jsx-runtime");
|
|
2253
|
-
var classBase7 = "vuuColumnSettingsPanel";
|
|
2254
|
-
var tabstripProps = {
|
|
2255
|
-
className: "salt-density-high"
|
|
2256
|
-
};
|
|
2257
|
-
var NullActivationIndicator = () => null;
|
|
2258
|
-
var ColumnSettingsPanel = ({
|
|
2259
|
-
column,
|
|
2260
|
-
dispatchColumnAction,
|
|
2261
|
-
style: styleProp,
|
|
2262
|
-
...props
|
|
2263
|
-
}) => {
|
|
2264
|
-
var _a, _b, _c, _d;
|
|
2265
|
-
const [activeTab, setActiveTab] = (0, import_react8.useState)(0);
|
|
2266
|
-
const dispatchUpdate = (0, import_react8.useCallback)(
|
|
2267
|
-
(values) => dispatchColumnAction({
|
|
2268
|
-
type: "updateColumnProp",
|
|
2269
|
-
column,
|
|
2270
|
-
...values
|
|
2271
|
-
}),
|
|
2272
|
-
[column, dispatchColumnAction]
|
|
2273
|
-
);
|
|
2274
|
-
const handleChangeAlign = (0, import_react8.useCallback)(
|
|
2275
|
-
(evt) => dispatchUpdate({ align: evt.target.value }),
|
|
2276
|
-
[dispatchUpdate]
|
|
2277
|
-
);
|
|
2278
|
-
const handleChangePin = (0, import_react8.useCallback)(
|
|
2279
|
-
(evt) => dispatchUpdate({ pin: evt.target.value }),
|
|
2280
|
-
[dispatchUpdate]
|
|
2281
|
-
);
|
|
2282
|
-
const handleChangeHidden = (0, import_react8.useCallback)(
|
|
2283
|
-
(evt, value) => dispatchUpdate({ hidden: value }),
|
|
2284
|
-
[dispatchUpdate]
|
|
2285
|
-
);
|
|
2286
|
-
const handleChangeLabel = (0, import_react8.useCallback)(
|
|
2287
|
-
(evt, value) => dispatchUpdate({ label: value }),
|
|
2288
|
-
[dispatchUpdate]
|
|
2289
|
-
);
|
|
2290
|
-
const handleChangeWidth = (0, import_react8.useCallback)(
|
|
2291
|
-
(value) => dispatchUpdate({ width: parseInt(value.toString(), 10) }),
|
|
2292
|
-
[dispatchUpdate]
|
|
2293
|
-
);
|
|
2294
|
-
return /* @__PURE__ */ (0, import_jsx_runtime9.jsxs)(
|
|
2295
|
-
"div",
|
|
2296
|
-
{
|
|
2297
|
-
className: classBase7,
|
|
2298
|
-
...props,
|
|
2299
|
-
style: {
|
|
2300
|
-
...styleProp
|
|
2301
|
-
},
|
|
2302
|
-
children: [
|
|
2303
|
-
/* @__PURE__ */ (0, import_jsx_runtime9.jsx)(import_core4.Text, { as: "h4", children: "Column Settings" }),
|
|
2304
|
-
/* @__PURE__ */ (0, import_jsx_runtime9.jsxs)(
|
|
2305
|
-
import_vuu_layout.Stack,
|
|
2306
|
-
{
|
|
2307
|
-
active: activeTab,
|
|
2308
|
-
showTabs: true,
|
|
2309
|
-
className: (0, import_classnames5.default)(`${classBase7}-columnTabs`),
|
|
2310
|
-
onTabSelectionChanged: setActiveTab,
|
|
2311
|
-
TabstripProps: tabstripProps,
|
|
2312
|
-
children: [
|
|
2313
|
-
/* @__PURE__ */ (0, import_jsx_runtime9.jsxs)(import_core4.Panel, { title: "Column", children: [
|
|
2314
|
-
/* @__PURE__ */ (0, import_jsx_runtime9.jsx)(import_salt_lab5.FormField, { label: "Hidden", labelPlacement: "left", children: /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(
|
|
2315
|
-
import_salt_lab5.Checkbox,
|
|
2316
|
-
{
|
|
2317
|
-
checked: column.hidden === true,
|
|
2318
|
-
onChange: handleChangeHidden
|
|
2319
|
-
}
|
|
2320
|
-
) }),
|
|
2321
|
-
/* @__PURE__ */ (0, import_jsx_runtime9.jsx)(import_salt_lab5.FormField, { label: "Label", labelPlacement: "left", children: /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(
|
|
2322
|
-
import_salt_lab5.Input,
|
|
2323
|
-
{
|
|
2324
|
-
value: (_a = column.label) != null ? _a : column.name,
|
|
2325
|
-
onChange: handleChangeLabel
|
|
2326
|
-
}
|
|
2327
|
-
) }),
|
|
2328
|
-
/* @__PURE__ */ (0, import_jsx_runtime9.jsx)(import_salt_lab5.FormField, { label: "Width", labelPlacement: "left", children: /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(
|
|
2329
|
-
import_salt_lab5.StepperInput,
|
|
2330
|
-
{
|
|
2331
|
-
value: (_b = column.width) != null ? _b : 100,
|
|
2332
|
-
onChange: handleChangeWidth
|
|
2333
|
-
}
|
|
2334
|
-
) }),
|
|
2335
|
-
/* @__PURE__ */ (0, import_jsx_runtime9.jsx)(
|
|
2336
|
-
import_salt_lab5.FormField,
|
|
2337
|
-
{
|
|
2338
|
-
label: "Align",
|
|
2339
|
-
labelPlacement: "left",
|
|
2340
|
-
ActivationIndicatorComponent: NullActivationIndicator,
|
|
2341
|
-
children: /* @__PURE__ */ (0, import_jsx_runtime9.jsxs)(
|
|
2342
|
-
import_salt_lab5.RadioButtonGroup,
|
|
2343
|
-
{
|
|
2344
|
-
"aria-label": "Column Align",
|
|
2345
|
-
value: (_c = column.align) != null ? _c : "left",
|
|
2346
|
-
legend: "Align",
|
|
2347
|
-
onChange: handleChangeAlign,
|
|
2348
|
-
children: [
|
|
2349
|
-
/* @__PURE__ */ (0, import_jsx_runtime9.jsx)(import_salt_lab5.RadioButton, { label: "Left", value: "left" }),
|
|
2350
|
-
/* @__PURE__ */ (0, import_jsx_runtime9.jsx)(import_salt_lab5.RadioButton, { label: "Right", value: "right" })
|
|
2351
|
-
]
|
|
2352
|
-
}
|
|
2353
|
-
)
|
|
2354
|
-
}
|
|
2355
|
-
),
|
|
2356
|
-
/* @__PURE__ */ (0, import_jsx_runtime9.jsx)(
|
|
2357
|
-
import_salt_lab5.FormField,
|
|
2358
|
-
{
|
|
2359
|
-
label: "Pin Column",
|
|
2360
|
-
labelPlacement: "left",
|
|
2361
|
-
ActivationIndicatorComponent: NullActivationIndicator,
|
|
2362
|
-
children: /* @__PURE__ */ (0, import_jsx_runtime9.jsxs)(
|
|
2363
|
-
import_salt_lab5.RadioButtonGroup,
|
|
2364
|
-
{
|
|
2365
|
-
"aria-label": "Pin Column",
|
|
2366
|
-
value: (_d = column.pin) != null ? _d : "",
|
|
2367
|
-
legend: "Pin Column",
|
|
2368
|
-
onChange: handleChangePin,
|
|
2369
|
-
children: [
|
|
2370
|
-
/* @__PURE__ */ (0, import_jsx_runtime9.jsx)(import_salt_lab5.RadioButton, { label: "Do not pin", value: "" }),
|
|
2371
|
-
/* @__PURE__ */ (0, import_jsx_runtime9.jsx)(import_salt_lab5.RadioButton, { label: "Left", value: "left" }),
|
|
2372
|
-
/* @__PURE__ */ (0, import_jsx_runtime9.jsx)(import_salt_lab5.RadioButton, { label: "Right", value: "right" })
|
|
2373
|
-
]
|
|
2374
|
-
}
|
|
2375
|
-
)
|
|
2376
|
-
}
|
|
2377
|
-
)
|
|
2378
|
-
] }),
|
|
2379
|
-
/* @__PURE__ */ (0, import_jsx_runtime9.jsx)(
|
|
2380
|
-
ColumnTypePanel,
|
|
2381
|
-
{
|
|
2382
|
-
column,
|
|
2383
|
-
dispatchColumnAction,
|
|
2384
|
-
title: "Data Cell"
|
|
2385
|
-
}
|
|
2386
|
-
),
|
|
2387
|
-
/* @__PURE__ */ (0, import_jsx_runtime9.jsxs)(import_core4.Panel, { title: "Vuu", variant: "secondary", children: [
|
|
2388
|
-
/* @__PURE__ */ (0, import_jsx_runtime9.jsx)(
|
|
2389
|
-
import_salt_lab5.FormField,
|
|
2390
|
-
{
|
|
2391
|
-
label: "Name",
|
|
2392
|
-
labelPlacement: "top",
|
|
2393
|
-
readOnly: true,
|
|
2394
|
-
variant: "secondary",
|
|
2395
|
-
children: /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(import_salt_lab5.Input, { value: column.name })
|
|
2396
|
-
}
|
|
2397
|
-
),
|
|
2398
|
-
/* @__PURE__ */ (0, import_jsx_runtime9.jsx)(
|
|
2399
|
-
import_salt_lab5.FormField,
|
|
2400
|
-
{
|
|
2401
|
-
label: "Vuu type",
|
|
2402
|
-
labelPlacement: "top",
|
|
2403
|
-
readOnly: true,
|
|
2404
|
-
variant: "secondary",
|
|
2405
|
-
children: /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(import_salt_lab5.Input, { value: column.serverDataType })
|
|
2406
|
-
}
|
|
2407
|
-
)
|
|
2408
|
-
] })
|
|
2409
|
-
]
|
|
2410
|
-
}
|
|
2411
|
-
)
|
|
2412
|
-
]
|
|
2413
|
-
}
|
|
2414
|
-
);
|
|
2415
|
-
};
|
|
2416
|
-
|
|
2417
|
-
// src/datagrid-configuration-ui/settings-panel/GridSettingsPanel.tsx
|
|
2418
|
-
var import_salt_lab6 = require("@heswell/salt-lab");
|
|
2419
|
-
var import_core5 = require("@salt-ds/core");
|
|
2420
|
-
var import_react9 = require("react");
|
|
2421
|
-
var import_jsx_runtime10 = require("react/jsx-runtime");
|
|
2422
|
-
var classBase8 = "vuuGridSettingsPanel";
|
|
2423
|
-
var NullActivationIndicator2 = () => null;
|
|
2424
|
-
var GridSettingsPanel = ({
|
|
2425
|
-
config,
|
|
2426
|
-
dispatchColumnAction,
|
|
2427
|
-
style: styleProp,
|
|
2428
|
-
...props
|
|
2429
|
-
}) => {
|
|
2430
|
-
var _a;
|
|
2431
|
-
const dispatchUpdate = (0, import_react9.useCallback)(
|
|
2432
|
-
(values) => dispatchColumnAction({
|
|
2433
|
-
type: "updateGridSettings",
|
|
2434
|
-
...values
|
|
2435
|
-
}),
|
|
2436
|
-
[dispatchColumnAction]
|
|
2437
|
-
);
|
|
2438
|
-
const handleChangeLabelFormatting = (0, import_react9.useCallback)(
|
|
2439
|
-
(evt) => dispatchUpdate({
|
|
2440
|
-
columnFormatHeader: evt.target.value
|
|
2441
|
-
}),
|
|
2442
|
-
[dispatchUpdate]
|
|
2443
|
-
);
|
|
2444
|
-
const handleChangeWidth = (0, import_react9.useCallback)(
|
|
2445
|
-
(value) => dispatchUpdate({ columnDefaultWidth: parseInt(value.toString(), 10) }),
|
|
2446
|
-
[dispatchUpdate]
|
|
2447
|
-
);
|
|
2448
|
-
return /* @__PURE__ */ (0, import_jsx_runtime10.jsxs)(
|
|
2449
|
-
"div",
|
|
2450
|
-
{
|
|
2451
|
-
className: classBase8,
|
|
2452
|
-
...props,
|
|
2453
|
-
style: {
|
|
2454
|
-
...styleProp
|
|
2455
|
-
},
|
|
2456
|
-
children: [
|
|
2457
|
-
/* @__PURE__ */ (0, import_jsx_runtime10.jsx)(import_core5.Text, { as: "h4", children: "Grid Settings" }),
|
|
2458
|
-
/* @__PURE__ */ (0, import_jsx_runtime10.jsxs)(import_core5.Panel, { children: [
|
|
2459
|
-
/* @__PURE__ */ (0, import_jsx_runtime10.jsx)(
|
|
2460
|
-
import_salt_lab6.FormField,
|
|
2461
|
-
{
|
|
2462
|
-
label: "Format column labels",
|
|
2463
|
-
labelPlacement: "left",
|
|
2464
|
-
ActivationIndicatorComponent: NullActivationIndicator2,
|
|
2465
|
-
children: /* @__PURE__ */ (0, import_jsx_runtime10.jsxs)(
|
|
2466
|
-
import_salt_lab6.RadioButtonGroup,
|
|
2467
|
-
{
|
|
2468
|
-
"aria-label": "Format column labels",
|
|
2469
|
-
value: config.columnFormatHeader,
|
|
2470
|
-
legend: "Format column labels",
|
|
2471
|
-
onChange: handleChangeLabelFormatting,
|
|
2472
|
-
children: [
|
|
2473
|
-
/* @__PURE__ */ (0, import_jsx_runtime10.jsx)(import_salt_lab6.RadioButton, { label: "No Formatting", value: void 0 }),
|
|
2474
|
-
/* @__PURE__ */ (0, import_jsx_runtime10.jsx)(import_salt_lab6.RadioButton, { label: "Capitalize", value: "capitalize" }),
|
|
2475
|
-
/* @__PURE__ */ (0, import_jsx_runtime10.jsx)(import_salt_lab6.RadioButton, { label: "Uppercase", value: "uppercase" })
|
|
2476
|
-
]
|
|
2477
|
-
}
|
|
2478
|
-
)
|
|
2479
|
-
}
|
|
2480
|
-
),
|
|
2481
|
-
/* @__PURE__ */ (0, import_jsx_runtime10.jsx)(import_salt_lab6.FormField, { label: "Default Column Width", labelPlacement: "left", children: /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(
|
|
2482
|
-
import_salt_lab6.StepperInput,
|
|
2483
|
-
{
|
|
2484
|
-
value: (_a = config.columnDefaultWidth) != null ? _a : 100,
|
|
2485
|
-
onChange: handleChangeWidth
|
|
2486
|
-
}
|
|
2487
|
-
) })
|
|
2488
|
-
] })
|
|
2489
|
-
]
|
|
2490
|
-
}
|
|
2491
|
-
);
|
|
2492
|
-
};
|
|
2493
|
-
|
|
2494
|
-
// src/datagrid-configuration-ui/settings-panel/useGridSettings.ts
|
|
2495
|
-
var import_react10 = require("react");
|
|
2496
|
-
var import_salt_lab7 = require("@heswell/salt-lab");
|
|
2497
|
-
var import_vuu_utils9 = require("@vuu-ui/vuu-utils");
|
|
2498
|
-
var gridSettingsReducer = (state, action) => {
|
|
2499
|
-
console.log(`gridSettingsReducer ${action.type}`);
|
|
2500
|
-
switch (action.type) {
|
|
2501
|
-
case "addColumn":
|
|
2502
|
-
return addColumn(state, action);
|
|
2503
|
-
case "addCalculatedColumn":
|
|
2504
|
-
return addCalculatedColumn(state, action);
|
|
2505
|
-
case "moveColumn":
|
|
2506
|
-
return moveColumn(state, action);
|
|
2507
|
-
case "removeColumn":
|
|
2508
|
-
return removeColumn(state, action);
|
|
2509
|
-
case "updateColumn":
|
|
2510
|
-
return state;
|
|
2511
|
-
case "updateColumnProp":
|
|
2512
|
-
return updateColumnProp(state, action);
|
|
2513
|
-
case "updateGridSettings":
|
|
2514
|
-
return updateGridSettings(state, action);
|
|
2515
|
-
case "updateColumnTypeFormatting":
|
|
2516
|
-
return updateColumnTypeFormatting(state, action);
|
|
2517
|
-
default:
|
|
2518
|
-
return state;
|
|
2519
|
-
}
|
|
2520
|
-
};
|
|
2521
|
-
var useGridSettings = (config) => {
|
|
2522
|
-
const [state, dispatchColumnAction] = (0, import_react10.useReducer)(
|
|
2523
|
-
gridSettingsReducer,
|
|
2524
|
-
config
|
|
2525
|
-
);
|
|
2526
|
-
return {
|
|
2527
|
-
gridSettings: state,
|
|
2528
|
-
dispatchColumnAction
|
|
2529
|
-
};
|
|
2530
|
-
};
|
|
2531
|
-
function addColumn(state, { column, columns, index = -1 }) {
|
|
2532
|
-
const { columns: stateColumns } = state;
|
|
2533
|
-
if (index === -1) {
|
|
2534
|
-
if (Array.isArray(columns)) {
|
|
2535
|
-
return { ...state, columns: stateColumns.concat(columns) };
|
|
2536
|
-
} else if (column) {
|
|
2537
|
-
return { ...state, columns: stateColumns.concat(column) };
|
|
2538
|
-
}
|
|
2539
|
-
}
|
|
2540
|
-
return state;
|
|
2541
|
-
}
|
|
2542
|
-
function addCalculatedColumn(state, { columnName, columnType, expression }) {
|
|
2543
|
-
const { columns: stateColumns } = state;
|
|
2544
|
-
const calculatedColumn = {
|
|
2545
|
-
name: columnName,
|
|
2546
|
-
expression,
|
|
2547
|
-
serverDataType: columnType
|
|
2548
|
-
};
|
|
2549
|
-
return { ...state, columns: stateColumns.concat(calculatedColumn) };
|
|
2550
|
-
}
|
|
2551
|
-
function removeColumn(state, { column }) {
|
|
2552
|
-
const { columns: stateColumns } = state;
|
|
2553
|
-
return {
|
|
2554
|
-
...state,
|
|
2555
|
-
columns: stateColumns.filter((col) => col.name !== column.name)
|
|
2556
|
-
};
|
|
2557
|
-
}
|
|
2558
|
-
function moveColumn(state, { column, moveBy, moveFrom, moveTo }) {
|
|
2559
|
-
const { columns: stateColumns } = state;
|
|
2560
|
-
if (column && typeof moveBy === "number") {
|
|
2561
|
-
const idx = stateColumns.indexOf(column);
|
|
2562
|
-
const newColumns = stateColumns.slice();
|
|
2563
|
-
const [movedColumns] = newColumns.splice(idx, 1);
|
|
2564
|
-
newColumns.splice(idx + moveBy, 0, movedColumns);
|
|
2565
|
-
return {
|
|
2566
|
-
...state,
|
|
2567
|
-
columns: newColumns
|
|
2568
|
-
};
|
|
2569
|
-
} else if (typeof moveFrom === "number" && typeof moveTo === "number") {
|
|
2570
|
-
return {
|
|
2571
|
-
...state,
|
|
2572
|
-
columns: (0, import_salt_lab7.moveItem)(stateColumns, moveFrom, moveTo)
|
|
2573
|
-
};
|
|
2574
|
-
} else {
|
|
2575
|
-
return state;
|
|
2576
|
-
}
|
|
2577
|
-
}
|
|
2578
|
-
function updateColumnProp(state, { align, column, hidden, label, width }) {
|
|
2579
|
-
let { columns: stateColumns } = state;
|
|
2580
|
-
if (align === "left" || align === "right") {
|
|
2581
|
-
stateColumns = replaceColumn(stateColumns, { ...column, align });
|
|
2582
|
-
}
|
|
2583
|
-
if (typeof hidden === "boolean") {
|
|
2584
|
-
stateColumns = replaceColumn(stateColumns, { ...column, hidden });
|
|
2585
|
-
}
|
|
2586
|
-
if (typeof label === "string") {
|
|
2587
|
-
stateColumns = replaceColumn(stateColumns, { ...column, label });
|
|
2588
|
-
}
|
|
2589
|
-
if (typeof width === "number") {
|
|
2590
|
-
stateColumns = replaceColumn(stateColumns, { ...column, width });
|
|
2591
|
-
}
|
|
2592
|
-
return {
|
|
2593
|
-
...state,
|
|
2594
|
-
columns: stateColumns
|
|
2595
|
-
};
|
|
2596
|
-
}
|
|
2597
|
-
function updateGridSettings(state, { columnFormatHeader }) {
|
|
2598
|
-
return {
|
|
2599
|
-
...state,
|
|
2600
|
-
columnFormatHeader: columnFormatHeader != null ? columnFormatHeader : state.columnFormatHeader
|
|
2601
|
-
};
|
|
2602
|
-
}
|
|
2603
|
-
function updateColumnTypeFormatting(state, {
|
|
2604
|
-
alignOnDecimals,
|
|
2605
|
-
column,
|
|
2606
|
-
decimals,
|
|
2607
|
-
zeroPad
|
|
2608
|
-
}) {
|
|
2609
|
-
const { columns: stateColumns } = state;
|
|
2610
|
-
const targetColumn = stateColumns.find((col) => col.name === column.name);
|
|
2611
|
-
if (targetColumn) {
|
|
2612
|
-
const {
|
|
2613
|
-
serverDataType = "string",
|
|
2614
|
-
type: columnType = (0, import_vuu_utils9.fromServerDataType)(serverDataType)
|
|
2615
|
-
} = column;
|
|
2616
|
-
const type = typeof columnType === "string" ? {
|
|
2617
|
-
name: columnType
|
|
2618
|
-
} : {
|
|
2619
|
-
...columnType
|
|
2620
|
-
};
|
|
2621
|
-
if (typeof alignOnDecimals === "boolean") {
|
|
2622
|
-
type.formatting = {
|
|
2623
|
-
...type.formatting,
|
|
2624
|
-
alignOnDecimals
|
|
2625
|
-
};
|
|
2626
|
-
}
|
|
2627
|
-
if (typeof decimals === "number") {
|
|
2628
|
-
type.formatting = {
|
|
2629
|
-
...type.formatting,
|
|
2630
|
-
decimals
|
|
2631
|
-
};
|
|
2632
|
-
}
|
|
2633
|
-
if (typeof zeroPad === "boolean") {
|
|
2634
|
-
type.formatting = {
|
|
2635
|
-
...type.formatting,
|
|
2636
|
-
zeroPad
|
|
2637
|
-
};
|
|
2638
|
-
}
|
|
2639
|
-
return {
|
|
2640
|
-
...state,
|
|
2641
|
-
columns: replaceColumn(stateColumns, { ...column, type })
|
|
2642
|
-
};
|
|
2643
|
-
} else {
|
|
2644
|
-
return state;
|
|
2645
|
-
}
|
|
2646
|
-
}
|
|
2647
|
-
function replaceColumn(columns, column) {
|
|
2648
|
-
return columns.map((col) => col.name === column.name ? column : col);
|
|
2649
|
-
}
|
|
2650
|
-
|
|
2651
|
-
// src/datagrid-configuration-ui/settings-panel/DatagridSettingsPanel.tsx
|
|
2652
|
-
var import_vuu_layout2 = require("@vuu-ui/vuu-layout");
|
|
2653
|
-
|
|
2654
|
-
// src/datagrid-configuration-ui/calculated-column-panel/CalculatedColumnPanel.tsx
|
|
2655
|
-
var import_salt_lab8 = require("@heswell/salt-lab");
|
|
2656
|
-
var import_core6 = require("@salt-ds/core");
|
|
2657
|
-
var import_react11 = require("react");
|
|
2658
|
-
var import_jsx_runtime11 = require("react/jsx-runtime");
|
|
2659
|
-
var CalculatedColumnPanel = ({
|
|
2660
|
-
columns,
|
|
2661
|
-
dispatchColumnAction,
|
|
2662
|
-
table
|
|
2663
|
-
}) => {
|
|
2664
|
-
const [columnName, setColumnName] = (0, import_react11.useState)("");
|
|
2665
|
-
const [, setExpression] = (0, import_react11.useState)();
|
|
2666
|
-
const sourceRef = (0, import_react11.useRef)("");
|
|
2667
|
-
const suggestionProvider = useColumnExpressionSuggestionProvider({
|
|
2668
|
-
columns,
|
|
2669
|
-
table
|
|
2670
|
-
});
|
|
2671
|
-
const handleChangeName = (0, import_react11.useCallback)(
|
|
2672
|
-
(evt) => {
|
|
2673
|
-
const { value } = evt.target;
|
|
2674
|
-
setColumnName(value);
|
|
2675
|
-
},
|
|
2676
|
-
[]
|
|
2677
|
-
);
|
|
2678
|
-
const handleChangeExpression = (0, import_react11.useCallback)((source) => {
|
|
2679
|
-
sourceRef.current = source;
|
|
2680
|
-
}, []);
|
|
2681
|
-
const handleSubmitExpression = (0, import_react11.useCallback)(
|
|
2682
|
-
(source, expression) => {
|
|
2683
|
-
console.log({ source });
|
|
2684
|
-
setExpression(expression);
|
|
2685
|
-
},
|
|
2686
|
-
[]
|
|
2687
|
-
);
|
|
2688
|
-
const handleSave = (0, import_react11.useCallback)(() => {
|
|
2689
|
-
if (sourceRef.current) {
|
|
2690
|
-
console.log(
|
|
2691
|
-
`save expression ${JSON.stringify(sourceRef.current, null, 2)}`
|
|
2692
|
-
);
|
|
2693
|
-
dispatchColumnAction({
|
|
2694
|
-
type: "addCalculatedColumn",
|
|
2695
|
-
columnName,
|
|
2696
|
-
expression: sourceRef.current,
|
|
2697
|
-
columnType: "string"
|
|
2698
|
-
});
|
|
2699
|
-
}
|
|
2700
|
-
}, [columnName, dispatchColumnAction]);
|
|
2701
|
-
return /* @__PURE__ */ (0, import_jsx_runtime11.jsxs)(import_core6.Panel, { className: "vuuCalculatedColumnPanel", title: "Define Computed Column", children: [
|
|
2702
|
-
/* @__PURE__ */ (0, import_jsx_runtime11.jsx)(import_core6.Text, { styleAs: "h4", children: "Define Computed Column" }),
|
|
2703
|
-
/* @__PURE__ */ (0, import_jsx_runtime11.jsx)(import_salt_lab8.FormField, { label: "Column Name", labelPlacement: "left", children: /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(import_salt_lab8.Input, { value: columnName, onChange: handleChangeName }) }),
|
|
2704
|
-
/* @__PURE__ */ (0, import_jsx_runtime11.jsx)(
|
|
2705
|
-
ColumnExpressionInput,
|
|
2706
|
-
{
|
|
2707
|
-
onChange: handleChangeExpression,
|
|
2708
|
-
onSubmitExpression: handleSubmitExpression,
|
|
2709
|
-
suggestionProvider
|
|
2710
|
-
}
|
|
2711
|
-
),
|
|
2712
|
-
/* @__PURE__ */ (0, import_jsx_runtime11.jsx)("div", { style: { marginTop: 12 }, children: /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(import_core6.Button, { onClick: handleSave, children: "Add Column" }) })
|
|
2713
|
-
] });
|
|
2714
|
-
};
|
|
2715
|
-
|
|
2716
|
-
// src/datagrid-configuration-ui/settings-panel/DatagridSettingsPanel.tsx
|
|
2717
|
-
var import_jsx_runtime12 = require("react/jsx-runtime");
|
|
2718
|
-
var classBase9 = "vuuDatagridSettingsPanel";
|
|
2719
|
-
var getTabLabel = () => void 0;
|
|
2720
|
-
var icons = [
|
|
2721
|
-
"table-settings",
|
|
2722
|
-
"column-chooser",
|
|
2723
|
-
"column-settings",
|
|
2724
|
-
"define-column"
|
|
2725
|
-
];
|
|
2726
|
-
var getTabIcon = (component, tabIndex) => icons[tabIndex];
|
|
2727
|
-
var DatagridSettingsPanel = ({
|
|
2728
|
-
availableColumns,
|
|
2729
|
-
className,
|
|
2730
|
-
gridConfig,
|
|
2731
|
-
onCancel,
|
|
2732
|
-
onConfigChange,
|
|
2733
|
-
...props
|
|
2734
|
-
}) => {
|
|
2735
|
-
var _a;
|
|
2736
|
-
console.log(`DatagridSettingsPanel render`);
|
|
2737
|
-
const [selectedTabIndex, setSelectedTabIndex] = (0, import_react12.useState)(0);
|
|
2738
|
-
const { gridSettings, dispatchColumnAction } = useGridSettings(gridConfig);
|
|
2739
|
-
const [selectedColumnName, setSelectedColumnName] = (0, import_react12.useState)(
|
|
2740
|
-
null
|
|
2741
|
-
);
|
|
2742
|
-
const handleColumnSelected = (0, import_react12.useCallback)(
|
|
2743
|
-
(selected) => {
|
|
2744
|
-
setSelectedColumnName(selected ? selected.name : null);
|
|
2745
|
-
},
|
|
2746
|
-
[]
|
|
2747
|
-
);
|
|
2748
|
-
const handleApply = (0, import_react12.useCallback)(
|
|
2749
|
-
(evt, closePanel = false) => {
|
|
2750
|
-
console.log(`1) DataGridSettingsPanel fire onConfigChange`);
|
|
2751
|
-
onConfigChange == null ? void 0 : onConfigChange(gridSettings, closePanel);
|
|
2752
|
-
},
|
|
2753
|
-
[gridSettings, onConfigChange]
|
|
2754
|
-
);
|
|
2755
|
-
const handleTabSelectionChanged = (0, import_react12.useCallback)((selectedTabIndex2) => {
|
|
2756
|
-
setSelectedTabIndex(selectedTabIndex2);
|
|
2757
|
-
}, []);
|
|
2758
|
-
const handleSave = (0, import_react12.useCallback)(
|
|
2759
|
-
(evt) => handleApply(evt, true),
|
|
2760
|
-
[handleApply]
|
|
2761
|
-
);
|
|
2762
|
-
const selectedColumn = selectedColumnName === null ? null : (_a = gridSettings.columns.find((col) => col.name === selectedColumnName)) != null ? _a : null;
|
|
2763
|
-
const tabstripProps2 = {
|
|
2764
|
-
activeTabIndex: selectedTabIndex,
|
|
2765
|
-
enableRenameTab: false,
|
|
2766
|
-
orientation: "vertical"
|
|
2767
|
-
};
|
|
2768
|
-
const handleAddCalculatedColumn = (0, import_react12.useCallback)(
|
|
2769
|
-
() => setSelectedTabIndex(3),
|
|
2770
|
-
[]
|
|
2771
|
-
);
|
|
2772
|
-
const panelShift = selectedTabIndex === 2 ? "right" : void 0;
|
|
2773
|
-
return /* @__PURE__ */ (0, import_jsx_runtime12.jsxs)("div", { ...props, className: (0, import_classnames6.default)(classBase9, className), children: [
|
|
2774
|
-
/* @__PURE__ */ (0, import_jsx_runtime12.jsxs)(
|
|
2775
|
-
import_vuu_layout2.Stack,
|
|
2776
|
-
{
|
|
2777
|
-
TabstripProps: tabstripProps2,
|
|
2778
|
-
className: `${classBase9}-stack`,
|
|
2779
|
-
getTabIcon,
|
|
2780
|
-
getTabLabel,
|
|
2781
|
-
active: selectedTabIndex === 2 ? 1 : selectedTabIndex,
|
|
2782
|
-
onTabSelectionChanged: handleTabSelectionChanged,
|
|
2783
|
-
showTabs: true,
|
|
2784
|
-
children: [
|
|
2785
|
-
/* @__PURE__ */ (0, import_jsx_runtime12.jsx)(
|
|
2786
|
-
GridSettingsPanel,
|
|
2787
|
-
{
|
|
2788
|
-
config: gridSettings,
|
|
2789
|
-
dispatchColumnAction
|
|
2790
|
-
}
|
|
2791
|
-
),
|
|
2792
|
-
/* @__PURE__ */ (0, import_jsx_runtime12.jsxs)("div", { className: `${classBase9}-columnPanels`, "data-align": panelShift, children: [
|
|
2793
|
-
/* @__PURE__ */ (0, import_jsx_runtime12.jsx)(
|
|
2794
|
-
ColumnPicker,
|
|
2795
|
-
{
|
|
2796
|
-
availableColumns,
|
|
2797
|
-
chosenColumns: gridSettings.columns,
|
|
2798
|
-
dispatchColumnAction,
|
|
2799
|
-
onSelectionChange: handleColumnSelected,
|
|
2800
|
-
onAddCalculatedColumnClick: handleAddCalculatedColumn,
|
|
2801
|
-
selectedColumn
|
|
2802
|
-
}
|
|
2803
|
-
),
|
|
2804
|
-
selectedColumn === null ? /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(import_core7.Panel, { className: "vuuColumnSettingsPanel", children: "Select a column" }) : /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(
|
|
2805
|
-
ColumnSettingsPanel,
|
|
2806
|
-
{
|
|
2807
|
-
column: selectedColumn,
|
|
2808
|
-
dispatchColumnAction,
|
|
2809
|
-
style: { background: "white", flex: "1 0 150px" }
|
|
2810
|
-
}
|
|
2811
|
-
)
|
|
2812
|
-
] }),
|
|
2813
|
-
/* @__PURE__ */ (0, import_jsx_runtime12.jsx)("div", { title: "Column Settings", children: "Column Settings" }),
|
|
2814
|
-
/* @__PURE__ */ (0, import_jsx_runtime12.jsx)(
|
|
2815
|
-
CalculatedColumnPanel,
|
|
2816
|
-
{
|
|
2817
|
-
columns: gridSettings.columns,
|
|
2818
|
-
dispatchColumnAction,
|
|
2819
|
-
table: { module: "SIMUL", table: "instruments" }
|
|
2820
|
-
}
|
|
2821
|
-
)
|
|
2822
|
-
]
|
|
2823
|
-
}
|
|
2824
|
-
),
|
|
2825
|
-
/* @__PURE__ */ (0, import_jsx_runtime12.jsxs)("div", { className: `${classBase9}-buttonBar`, children: [
|
|
2826
|
-
/* @__PURE__ */ (0, import_jsx_runtime12.jsx)(import_core7.Button, { onClick: onCancel, children: "Cancel" }),
|
|
2827
|
-
/* @__PURE__ */ (0, import_jsx_runtime12.jsx)(import_core7.Button, { onClick: handleApply, children: "Apply" }),
|
|
2828
|
-
/* @__PURE__ */ (0, import_jsx_runtime12.jsx)(import_core7.Button, { onClick: handleSave, children: "Save" })
|
|
2829
|
-
] })
|
|
2830
|
-
] });
|
|
2831
|
-
};
|
|
2832
|
-
|
|
2833
|
-
// src/datasource-stats/DatasourceStats.tsx
|
|
2834
|
-
var import_react13 = require("react");
|
|
2835
|
-
var import_classnames7 = __toESM(require("classnames"), 1);
|
|
2836
|
-
var import_jsx_runtime13 = require("react/jsx-runtime");
|
|
2837
|
-
var classBase10 = "vuuDatasourceStats";
|
|
2838
|
-
var numberFormatter = new Intl.NumberFormat();
|
|
2839
|
-
var DataSourceStats = ({
|
|
2840
|
-
className: classNameProp,
|
|
2841
|
-
dataSource
|
|
2842
|
-
}) => {
|
|
2843
|
-
const [optimize, setOptimize] = (0, import_react13.useState)(
|
|
2844
|
-
dataSource.optimize
|
|
2845
|
-
);
|
|
2846
|
-
const [range, setRange] = (0, import_react13.useState)(dataSource.range);
|
|
2847
|
-
const [size, setSize] = (0, import_react13.useState)(dataSource.size);
|
|
2848
|
-
(0, import_react13.useEffect)(() => {
|
|
2849
|
-
setOptimize(dataSource.optimize);
|
|
2850
|
-
setSize(dataSource.size);
|
|
2851
|
-
dataSource.on("optimize", setOptimize);
|
|
2852
|
-
dataSource.on("resize", setSize);
|
|
2853
|
-
dataSource.on("range", setRange);
|
|
2854
|
-
}, [dataSource]);
|
|
2855
|
-
const className = (0, import_classnames7.default)(classBase10, classNameProp);
|
|
2856
|
-
const from = numberFormatter.format(range.from);
|
|
2857
|
-
const to = numberFormatter.format(range.to - 1);
|
|
2858
|
-
const value = numberFormatter.format(size);
|
|
2859
|
-
return /* @__PURE__ */ (0, import_jsx_runtime13.jsxs)("div", { className, children: [
|
|
2860
|
-
/* @__PURE__ */ (0, import_jsx_runtime13.jsx)("span", { children: "Showing rows" }),
|
|
2861
|
-
/* @__PURE__ */ (0, import_jsx_runtime13.jsx)("span", { className: `${classBase10}-range`, children: from }),
|
|
2862
|
-
/* @__PURE__ */ (0, import_jsx_runtime13.jsx)("span", { className: `${classBase10}-range`, children: to }),
|
|
2863
|
-
/* @__PURE__ */ (0, import_jsx_runtime13.jsx)("span", { children: "of" }),
|
|
2864
|
-
/* @__PURE__ */ (0, import_jsx_runtime13.jsx)("span", { className: `${classBase10}-size`, children: value }),
|
|
2865
|
-
/* @__PURE__ */ (0, import_jsx_runtime13.jsx)("span", { className: `${classBase10}-optimize`, children: optimize })
|
|
2866
|
-
] });
|
|
2867
|
-
};
|
|
1
|
+
"use strict";var ut=Object.create;var Fe=Object.defineProperty;var mt=Object.getOwnPropertyDescriptor;var dt=Object.getOwnPropertyNames;var gt=Object.getPrototypeOf,ft=Object.prototype.hasOwnProperty;var Ct=(n,e)=>{for(var t in e)Fe(n,t,{get:e[t],enumerable:!0})},yn=(n,e,t,o)=>{if(e&&typeof e=="object"||typeof e=="function")for(let r of dt(e))!ft.call(n,r)&&r!==t&&Fe(n,r,{get:()=>e[r],enumerable:!(o=mt(e,r))||o.enumerable});return n};var q=(n,e,t)=>(t=n!=null?ut(gt(n)):{},yn(e||!n||!n.__esModule?Fe(t,"default",{value:n,enumerable:!0}):t,n)),xt=n=>yn(Fe({},"__esModule",{value:!0}),n);var bn=(n,e,t)=>{if(!e.has(n))throw TypeError("Cannot "+t)};var u=(n,e,t)=>(bn(n,e,"read from private field"),t?t.call(n):e.get(n)),N=(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)},Z=(n,e,t,o)=>(bn(n,e,"write to private field"),o?o.call(n,t):e.set(n,t),t);var xo={};Ct(xo,{ColumnExpressionInput:()=>mn,ColumnNamedTerms:()=>Ge,DataSourceStats:()=>Co,DatagridSettingsPanel:()=>fo,columnExpressionLanguageSupport:()=>Je,isCompleteExpression:()=>on,isCompleteRelationalExpression:()=>rn,lastNamedChild:()=>We,useColumnExpressionEditor:()=>un,useColumnExpressionSuggestionProvider:()=>gn,walkTree:()=>tn});module.exports=xt(xo);var D=require("@vuu-ui/vuu-utils"),vn=q(require("classnames"),1);var Le=require("react"),En=require("@vuu-ui/vuu-utils"),Oe=require("@vuu-ui/vuu-utils"),ht=[void 0,void 0,void 0,void 0];function On(n,e,t){var x;let o=(0,Le.useRef)(),[r,i,s,p]=o.current||ht,{type:l}=t,c=(0,En.isTypeDescriptor)(l)?(x=l.formatting)==null?void 0:x.decimals:void 0,g=n===r&&(0,Oe.isValidNumber)(e)&&(0,Oe.isValidNumber)(i)&&t===s?(0,Oe.getMovingValueDirection)(e,p,i,c):"";return(0,Le.useEffect)(()=>{o.current=[n,e,t,g]}),g}var Be=require("react/jsx-runtime"),yt=String.fromCharCode(11014),bt=String.fromCharCode(11015),{KEY:Et}=D.metadataKeys,Ie="vuuBackgroundCell",ve={ArrowOnly:"arrow",BackgroundOnly:"bg-only",ArrowBackground:"arrow-bg"},Ot=n=>(0,D.isTypeDescriptor)(n)&&n.renderer&&"flashStyle"in n.renderer?n.renderer.flashStyle:ve.BackgroundOnly,vt=({column:n,row:e})=>{let{key:t,type:o,valueFormatter:r}=n,i=e[t],s=Ot(o),p=On(e[Et],i,n),l=s===ve.ArrowOnly||s===ve.ArrowBackground?p===D.UP1||p===D.UP2?yt:p===D.DOWN1||p===D.DOWN2?bt:null:null,c=p?" "+p:"",g=(0,vn.default)(Ie,c,{[`${Ie}-arrowOnly`]:s===ve.ArrowOnly,[`${Ie}-arrowBackground`]:s===ve.ArrowBackground});return(0,Be.jsxs)("div",{className:g,tabIndex:-1,children:[(0,Be.jsx)("div",{className:`${Ie}-flasher`,children:l}),r(e[n.key])]})};(0,D.registerComponent)("background",vt,"cell-renderer",{serverDataType:["long","int","double"]});var re=require("@vuu-ui/vuu-utils"),Pn=q(require("classnames"),1);var _=require("react/jsx-runtime"),Pe="vuuProgressCell",Pt=({column:n,columnMap:e,row:t})=>{let{type:o}=n,r=t[n.key],i=!1,s=0;if((0,re.isTypeDescriptor)(o)&&(0,re.isColumnTypeRenderer)(o.renderer)){let{associatedField:l}=o.renderer,c=t[e[l]];if(typeof r=="number"&&typeof c=="number")s=Math.min(Math.round(r/c*100),100),i=isFinite(s);else{let g=parseFloat(r);if(Number.isFinite(g)){let x=parseFloat(c);Number.isFinite(x)&&(s=Math.min(Math.round(g/x*100),100),i=isFinite(s))}}}let p=(0,Pn.default)(Pe,{});return(0,_.jsxs)("div",{className:p,tabIndex:-1,children:[i?(0,_.jsxs)("span",{className:`${Pe}-track`,children:[(0,_.jsx)("span",{className:`${Pe}-bg`}),(0,_.jsx)("span",{className:`${Pe}-bar`,style:{"--progress-bar-pct":`-${100-s}%`}})]}):null,(0,_.jsx)("span",{className:`${Pe}-text`,children:`${s} %`})]})};(0,re.registerComponent)("vuu.progress",Pt,"cell-renderer",{serverDataType:["long","int","double"]});var O=require("@vuu-ui/vuu-codemirror"),cn=require("@vuu-ui/vuu-utils"),J=require("react");var Q=require("@vuu-ui/vuu-codemirror");var Sn=require("@lezer/lr"),$e=Sn.LRParser.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 St=Q.LRLanguage.define({name:"VuuColumnExpression",parser:$e.configure({props:[(0,Q.styleTags)({Function:Q.tags.variableName,String:Q.tags.string,Or:Q.tags.emphasis,Operator:Q.tags.operator})]})}),Je=()=>new Q.LanguageSupport(St);var qe=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}}},_e=class{constructor(e){this.type="colExpression";this.column=e}toJSON(){return{type:this.type,column:this.column}}},Te,j,Ke=class{constructor(e="unknown"){N(this,Te,[{type:"unknown"},{type:"unknown"}]);N(this,j,void 0);this.type="arithmeticExpression";Z(this,j,e)}get op(){return u(this,j)}set op(e){Z(this,j,e)}get expressions(){return u(this,Te)}toJSON(){return{type:this.type,op:u(this,j),expressions:u(this,Te)}}};Te=new WeakMap,j=new WeakMap;var le,je=class{constructor(e){N(this,le,[]);this.type="callExpression";this.functionName=e}get expressions(){return u(this,le)}get arguments(){return u(this,le)}toJSON(){return{type:this.type,functionName:this.functionName,arguments:u(this,le).map(e=>{var t;return(t=e.toJSON)==null?void 0:t.call(e)})}}};le=new WeakMap;var we,pe,ie=class{constructor(){N(this,we,[{type:"unknown"},{type:"unknown"}]);N(this,pe,"unknown");this.type="relationalExpression"}get op(){return u(this,pe)}set op(e){Z(this,pe,e)}get expressions(){return u(this,we)}toJSON(){return{type:this.type,op:u(this,pe),expressions:u(this,we)}}};we=new WeakMap,pe=new WeakMap;var De,ce,ae=class{constructor(e){N(this,De,[{type:"unknown"},{type:"unknown"}]);N(this,ce,void 0);this.type="booleanCondition";Z(this,ce,e)}get op(){return u(this,ce)}get expressions(){return u(this,De)}toJSON(){return{type:this.type,op:u(this,ce),expressions:u(this,De).map(e=>{var t;return(t=e.toJSON)==null?void 0:t.call(e)})}}};De=new WeakMap,ce=new WeakMap;var I,Se=class{constructor(e){N(this,I,void 0);this.type="conditionalExpression";Z(this,I,[e?new ae(e):new ie,{type:"unknown"},{type:"unknown"}])}get expressions(){return u(this,I)}get condition(){return u(this,I)[0]}get truthyExpression(){return u(this,I)[1]}set truthyExpression(e){u(this,I)[1]=e}get falsyExpression(){return u(this,I)[2]}set falsyExpression(e){u(this,I)[2]=e}toJSON(){var e,t,o,r,i;return{type:this.type,condition:(t=(e=this.condition).toJSON)==null?void 0:t.call(e),truthyExpression:this.truthyExpression,falsyExpression:(i=(r=(o=this.falsyExpression)==null?void 0:o.toJSON)==null?void 0:r.call(o))!=null?i:this.falsyExpression}}};I=new WeakMap;var K=n=>n.type==="unknown",Ue=n=>n.type==="arithmeticExpression",Tt=n=>n.type==="callExpression",se=n=>n.type==="conditionalExpression",wt=n=>n.type==="relationalExpression"||n.type==="booleanCondition";var Dt=n=>n.type==="booleanCondition",nn=n=>(n==null?void 0:n.type)==="relationalExpression";var R=n=>{if(K(n))return n;if(nn(n)){let[e,t]=n.expressions;if(S(e))return R(e);if(n.op==="unknown")return n;if(S(t))return R(t)}else if(wt(n)){let{expressions:e=[]}=n;for(let t of e)if(S(t))return R(t)}else if(se(n)){let{condition:e,truthyExpression:t,falsyExpression:o}=n;if(S(e))return R(e);if(S(t))return R(t);if(S(o))return R(o)}else if(Ue(n)){let{expressions:e=[]}=n;for(let t of e)if(S(t))return R(t)}},Me=(n,e,t)=>{let{expressions:o=[]}=n;if(o.includes(e)){let r=o.indexOf(e);return o.splice(r,1,t),!0}else for(let r of o)if(Me(r,e,t))return!0;return!1},S=n=>K(n)?!0:se(n)?S(n.condition)||S(n.truthyExpression)||S(n.falsyExpression):nn(n)||Dt(n)?n.op===void 0||n.expressions.some(e=>S(e)):!1,Tn=(n,e)=>{let t=R(n);t?t.expressions?t.expressions.push(e):console.warn("don't know how to treat targetExpression"):console.error("no target expression found")},C,ee,en=class{constructor(){N(this,C,void 0);N(this,ee,[])}setCondition(e){if(u(this,C)===void 0)this.addExpression(new Se(e));else if(se(u(this,C))){if(S(u(this,C).condition)){let t=e?new ae(e):new ie;this.addExpression(t)}else if(K(u(this,C).truthyExpression))u(this,C).truthyExpression=new Se(e);else if(S(u(this,C).truthyExpression)){let t=e?new ae(e):new ie;this.addExpression(t)}else if(K(u(this,C).falsyExpression))u(this,C).falsyExpression=new Se(e);else if(S(u(this,C).falsyExpression)){let t=e?new ae(e):new ie;this.addExpression(t)}}else console.error("setCondition called unexpectedly")}addExpression(e){if(u(this,ee).length>0){let t=u(this,ee).at(-1);t==null||t.arguments.push(e)}else if(u(this,C)===void 0)Z(this,C,e);else if(Ue(u(this,C))){let t=R(u(this,C));t&&K(t)&&Me(u(this,C),t,e)}else if(se(u(this,C))&&S(u(this,C))){let t=R(u(this,C));t&&K(t)?Me(u(this,C),t,e):t&&Tn(t,e)}}setFunction(e){let t=new je(e);this.addExpression(t),u(this,ee).push(t)}setColumn(e){this.addExpression(new _e(e))}setArithmeticOp(e){let t=e,o=u(this,C);Ue(o)&&(o.op=t)}setRelationalOperator(e){let t=e;if(u(this,C)&&se(u(this,C))){let o=R(u(this,C));nn(o)?o.op=t:console.error(`no target expression found (op = ${e})`)}}setValue(e){let t=new qe(e);if(u(this,C)===void 0)Z(this,C,t);else if(Ue(u(this,C)))this.addExpression(t);else if(Tt(u(this,C)))u(this,C).arguments.push(t);else if(se(u(this,C)))if(S(u(this,C))){let o=R(u(this,C));o&&K(o)?Me(u(this,C),o,t):o&&Tn(o,t)}else console.log("what do we do with value, in a complete expression")}closeBrace(){u(this,ee).pop()}get expression(){return u(this,C)}toJSON(){var e;return(e=u(this,C))==null?void 0:e.toJSON()}};C=new WeakMap,ee=new WeakMap;var tn=(n,e)=>{let t=new en,o=n.cursor();do{let{name:r,from:i,to:s}=o;switch(r){case"AndCondition":t.setCondition("and");break;case"OrCondition":t.setCondition("or");break;case"RelationalExpression":t.setCondition();break;case"ArithmeticExpression":t.addExpression(new Ke);break;case"Column":{let p=e.substring(i,s);t.setColumn(p)}break;case"Function":{let p=e.substring(i,s);t.setFunction(p)}break;case"Times":case"Divide":case"Plus":case"Minus":{let p=e.substring(i,s);t.setArithmeticOp(p)}break;case"RelationalOperator":{let p=e.substring(i,s);t.setRelationalOperator(p)}break;case"False":case"True":{let p=e.substring(i,s);t.setValue(p==="true")}break;case"String":t.setValue(e.substring(i+1,s-1));break;case"Number":t.setValue(parseFloat(e.substring(i,s)));break;case"CloseBrace":t.closeBrace();break;default:}}while(o.next());return t.toJSON()};var Rt=$e.configure({strict:!0}),wn=["Number","String"],Ge=[...wn,"AndCondition","ArithmeticExpression","BooleanOperator","RelationalOperatorOperator","CallExpression","CloseBrace","Column","Comma","ConditionalExpression","Divide","Equal","If","Minus","OpenBrace","OrCondition","ParenthesizedExpression","Plus","RelationalExpression","RelationalOperator","Times"],on=n=>{try{return Rt.parse(n),!0}catch{return!1}},We=n=>{let{lastChild:e}=n;for(;e&&!Ge.includes(e.name);)e=e.prevSibling,console.log(e==null?void 0:e.name);return e},rn=n=>{if((n==null?void 0:n.name)==="RelationalExpression"){let{firstChild:e}=n,t=We(n);if((e==null?void 0:e.name)==="Column"&&typeof(t==null?void 0:t.name)=="string"&&wn.includes(t.name))return!0}return!1};var ne=require("@vuu-ui/vuu-codemirror"),At=ne.HighlightStyle.define([{tag:ne.tags.variableName,color:"var(--vuuFilterEditor-variableColor)"},{tag:ne.tags.comment,color:"green",fontStyle:"italic"}]),Dn=(0,ne.syntaxHighlighting)(At);var Rn=require("@vuu-ui/vuu-codemirror"),An=Rn.EditorView.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});var v=require("@vuu-ui/vuu-codemirror"),ln=require("react");var kt=(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,Nt=n=>n===void 0?!1:["Times","Divide","Plus","Minus"].includes(n.name),ue=(n,e)=>{var r;let{lastChild:t}=n,{pos:o}=e;for(;t;)if(t.from<o&&Ge.includes(t.name)){if(t.name==="ParenthesizedExpression"){let s=(r=t.firstChild)==null?void 0:r.nextSibling;s&&(t=s)}return t}else t=t.prevSibling},kn=(n,e)=>{var t;if(n.name==="ArgList"){let o=n.prevSibling;if(o)return(0,v.getValue)(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(0,v.getValue)(o,e)}},Nn=(n,e)=>{if(n.name==="RelationalExpression"){let t=We(n);if((t==null?void 0:t.name)==="RelationalOperator")return(0,v.getValue)(t,e)}else{let t=n.prevSibling;if((t==null?void 0:t.name)==="RelationalOperator")return(0,v.getValue)(t,e)}},pn=(n,e)=>{var t;if(n.name==="RelationalExpression"){if(((t=n.firstChild)==null?void 0:t.name)==="Column")return(0,v.getValue)(n.firstChild,e)}else{let o=n.prevSibling;if((o==null?void 0:o.name)==="Column")return(0,v.getValue)(o,e);if((o==null?void 0:o.name)==="RelationalOperator")return pn(o,e)}},sn=async(n,e,t,o={})=>{let r=await e.getSuggestions(t,o),{startsWith:i=""}=o;return{from:n.pos-i.length,options:r}},an=(n,e,t,o,r)=>{let i=ue(n,e);switch(console.log(`conditional expression last child ${i==null?void 0:i.name}`),i==null?void 0:i.name){case"If":return sn(e,t,"expression",{prefix:"( "});case"OpenBrace":return sn(e,t,"expression");case"Condition":return sn(e,t,"expression",{prefix:", "});case"CloseBrace":if(o){let s=[{apply:()=>{r==null||r()},label:"Save Expression",boost:10}];return{from:e.pos,options:s}}}},Qt=(n,e)=>{let t=[{apply:()=>{e==null||e()},label:"Save Expression",boost:10}];return{from:n.pos,options:t}},Qn=(n,e)=>{let t=(0,ln.useCallback)(async(o,r,i={})=>{let s=await n.getSuggestions(r,i),{startsWith:p=""}=i;return{from:o.pos-p.length,options:s}},[n]);return(0,ln.useCallback)(async o=>{var x,E;let{state:r,pos:i}=o,s=(x=o.matchBefore(/\w*/))!=null?x:{from:0,to:0,text:void 0},l=(0,v.syntaxTree)(r).resolveInner(i,-1),c=r.doc.toString(),g=on(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=ue(l,o);if((a==null?void 0:a.name)==="Column"){let m=(0,v.getPreviousNode)(a);if((m==null?void 0:m.name)!=="RelationalOperator")return t(o,"condition-operator",{columnName:(0,v.getValue)(a,r)});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 an(l,o,n);case"RelationalExpression":{if(rn(l))return{from:o.pos,options:v.booleanJoinSuggestions.concat({label:", <truthy expression>, <falsy expression>",apply:", "})};{let a=Nn(l,r),m=pn(l,r);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=Nn(l,r),m=pn(l,r),{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=ue(l,o);if((a==null?void 0:a.name)==="Column")return t(o,"expression");if(Nt(a)){let m=a.name;return t(o,"column",{operator:m})}}break;case"OpenBrace":{let a=kn(l,r);return t(o,"expression",{functionName:a})}break;case"ArgList":{let a=kn(l,r),m=ue(l,o),f=(m==null?void 0:m.name)==="OpenBrace"?void 0:",",d=await n.getSuggestions("expression",{functionName:a});return d=f?kt(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=ue(l,o);if((a==null?void 0:a.name)==="Column"){if(g){let m=[{apply:()=>{e.current()},label:"Save Expression",boost:10}],f=(0,v.getValue)(a,r),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=ue(a,o);if((f==null?void 0:f.name)==="Column"){let d=(0,v.getValue)(f,r),P=await n.getSuggestions("operator",{columnName:d});m=m.concat(P)}return{from:o.pos,options:m}}}else if((a==null?void 0:a.name)==="ConditionalExpression")return an(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=(0,v.getNamedParentNode)(l);if((a==null?void 0:a.name)==="ConditionalExpression")return t(o,"expression")}break;case"CloseBrace":{let a=(0,v.getNamedParentNode)(l);if((a==null?void 0:a.name)==="ConditionalExpression")return an(a,o,n,g,e.current);if((a==null?void 0:a.name)==="ArgList"&&g)return Qt(o,e.current);console.log(`does closebrace denote an ARgList or a parenthetised expression ? ${a}`)}break;default:((E=l==null?void 0:l.prevSibling)==null?void 0:E.name)==="FilterClause"&&console.log("looks like we ight be a or|and operator")}},[t,e,n])};var Re=n=>{if(n.current==null)throw Error("EditorView not defined");return n.current},Ft=()=>"vuuSuggestion",Lt=()=>console.log("noooop"),It=n=>"expressionType"in n,Bt=n=>{if(It(n)){let e=(0,cn.createEl)("div","expression-type-container"),t=(0,cn.createEl)("span","expression-type",n.expressionType);return e.appendChild(t),e}else return null},un=({onChange:n,onSubmitExpression:e,suggestionProvider:t})=>{let o=(0,J.useRef)(null),r=(0,J.useRef)(Lt),i=(0,J.useRef)(),s=Qn(t,r),[p,l]=(0,J.useMemo)(()=>{let c=()=>{let f=Re(i),d=f.state.doc.toString(),P=(0,O.ensureSyntaxTree)(f.state,f.state.doc.length,5e3);if(P){let w=tn(P,d);return[d,w]}else return["",void 0]},g=()=>{Re(i).setState(m())},x=()=>{let[f,d]=c();e==null||e(f,d),g()},E=f=>O.keymap.of([{key:f,run(){return x(),!0}}]),a=f=>O.keymap.of([{key:f,run(){return(0,O.startCompletion)(Re(i)),!0}}]),m=()=>O.EditorState.create({doc:"",extensions:[O.minimalSetup,(0,O.autocompletion)({addToOptions:[{render:Bt,position:70}],override:[s],optionClass:Ft}),Je(),O.keymap.of(O.defaultKeymap),E("Ctrl-Enter"),a("ArrowDown"),O.EditorView.updateListener.of(f=>{let d=Re(i);if(f.docChanged){(0,O.startCompletion)(d);let P=d.state.doc.toString();n==null||n(P,void 0)}}),An,Dn]});return r.current=()=>{x(),setTimeout(()=>{Re(i).focus()},100)},[m,g]},[s,n,e]);return(0,J.useEffect)(()=>{if(!o.current)throw Error("editor not in dom");return i.current=new O.EditorView({state:p(),parent:o.current}),()=>{var c;(c=i.current)==null||c.destroy()}},[s,p]),{editorRef:o,clearInput:l}};var Fn=require("react/jsx-runtime"),$t="vuuColumnExpressionInput",mn=({onChange:n,onSubmitExpression:e,suggestionProvider:t})=>{let{editorRef:o}=un({onChange:n,onSubmitExpression:e,suggestionProvider:t});return(0,Fn.jsx)("div",{className:`${$t}`,ref:o})};var $=require("@vuu-ui/vuu-codemirror"),Xe=require("@vuu-ui/vuu-data"),ge=require("@vuu-ui/vuu-utils"),de=require("react");var me=[{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"}];var B=require("@vuu-ui/vuu-utils"),Ln=({name:n,description:e,example:t,params:o,type:r})=>{let i=(0,B.createEl)("div","vuuFunctionDoc"),s=(0,B.createEl)("div","function-heading"),p=(0,B.createEl)("span","function-name",n),l=(0,B.createEl)("span","param-list",o.description),c=(0,B.createEl)("span","function-type",r);s.appendChild(p),s.appendChild(l),s.appendChild(c);let g=(0,B.createEl)("p",void 0,e);if(i.appendChild(s),i.appendChild(g),t){let x=(0,B.createEl)("div","example-container","Example:"),E=(0,B.createEl)("div","example-expression",t.expression),a=(0,B.createEl)("div","example-result",t.result);x.appendChild(E),x.appendChild(a),i.appendChild(x)}return i};var Ut=[],te=n=>n.map(e=>{var t;return{...e,apply:((t=e.apply)!=null?t:e.label)+" "}}),Mt=(n,{functionName:e,operator:t})=>{if(t)return n.filter(ge.isNumericColumn);if(e){let o=me.find(r=>r.name===e);if(o)switch(o.accepts){case"string":return n.filter(ge.isTextColumn);case"number":return n.filter(ge.isNumericColumn);default:return n}}return n},In=(n,e)=>Mt(n,e).map(o=>{var i;let r=(i=o.label)!=null?i:o.name;return{apply:e.prefix?`${e.prefix}${r}`:r,label:r,boost:5,type:"column",expressionType:o.serverDataType}}),Gt=[{apply:"* ",boost:2,label:"*",type:"operator"},{apply:"/ ",boost:2,label:"/",type:"operator"},{apply:"+ ",boost:2,label:"+",type:"operator"},{apply:"- ",boost:2,label:"-",type:"operator"}],Wt=n=>n===void 0||(0,ge.isNumericColumn)(n)?Gt:Ut,Xt=n=>{switch(n.serverDataType){case"string":case"char":return te($.stringOperators);case"int":case"long":case"double":return te($.numericOperators)}},dn=n=>({apply:`${n.name}( `,boost:2,expressionType:n.type,info:()=>Ln(n),label:n.name,type:"function"}),Ht=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"},Vt=me.map(dn),zt=({functionName:n})=>{if(n){let e=me.find(o=>o.name===n),t=Ht(e);if(e)switch(t){case"string":return me.filter(o=>o.type==="string"||o.type==="variable").map(dn);case"number":return me.filter(o=>o.type==="number"||o.type==="variable").map(dn);default:}}return Vt},Yt={},gn=({columns:n,table:e})=>{let t=(0,de.useCallback)(p=>p?n.find(l=>l.name===p):void 0,[n]),o=(0,de.useRef)(),r=(0,Xe.useTypeaheadSuggestions)(),i=(0,de.useCallback)(async(p,l=Yt)=>{let{columnName:c,functionName:g,operator:x,prefix:E}=l;switch(p){case"expression":{let a=await te(In(n,{functionName:g,prefix:E})).concat(zt(l));return o.current=a}case"column":{let a=await In(n,l);return o.current=te(a)}case"operator":{let a=await Wt(t(c));return o.current=te(a)}case"relational-operator":{let a=await(0,$.getRelationalOperators)(t(c));return o.current=te(a)}case"condition-operator":{let a=t(c);if(a){let m=await Xt(a);if(m)return o.current=te(m)}}break;case"columnValue":if(c&&x){let a=(0,Xe.getTypeaheadParams)(e,c),m=await r(a);return o.current=(0,$.toSuggestions)(m,{suffix:""}),o.current.forEach(f=>{f.apply=(d,P,w)=>{let G=new $.AnnotationType,Ee=w+P.label.length+1;d.dispatch({changes:{from:w,insert:P.label},selection:{anchor:Ee,head:Ee},annotations:G.of(P)})}}),o.current}break}return[]},[n,t,r,e]),s=(0,de.useCallback)(async(p,l,c)=>{let{current:g}=o,x=!1,E=g||await i(p,{columnName:l});if(c&&E)for(let a of E){if(a.label===c)return!1;a.label.startsWith(c)&&(x=!0)}return x},[i]);return{getSuggestions:i,isPartialMatch:s}};var ye=require("@salt-ds/core"),at=q(require("classnames"),1),z=require("react");var fn=require("@heswell/salt-lab"),F=require("@salt-ds/core"),U=require("react");var Bn=require("@heswell/salt-lab"),$n=q(require("classnames"),1);var Ce=require("react/jsx-runtime"),fe="vuuColumnListItem",Un=({className:n,item:e,label:t,style:o,...r})=>{let i=(0,$n.default)(fe,n,{[`${fe}-calculated`]:e==null?void 0:e.expression,[`${fe}-hidden`]:e==null?void 0:e.hidden});return(0,Ce.jsxs)(Bn.ListItem,{className:i,...r,children:[(0,Ce.jsx)("span",{className:`${fe}-iconType`}),(0,Ce.jsx)("label",{className:`${fe}-label`,children:t}),(0,Ce.jsx)("span",{className:`${fe}-iconHidden`})]})};var y=require("react/jsx-runtime"),xe="vuuColumnPicker",Zt=(n,e)=>n.filter(t=>e.find(o=>o.name===t.name)==null),Mn=({availableColumns:n,id:e,dispatchColumnAction:t,onAddCalculatedColumnClick:o,onSelectionChange:r,chosenColumns:i,selectedColumn:s})=>{let[p,l]=(0,U.useState)([]),c=(0,F.useIdMemo)(e),g=Zt(n,i),x=(0,U.useCallback)(()=>{p.length>0&&(l([]),t({type:"addColumn",columns:p}))},[t,p]),E=(0,U.useCallback)(()=>s&&t({type:"removeColumn",column:s}),[s,t]),a=(0,U.useCallback)(()=>s&&t({type:"moveColumn",column:s,moveBy:-1}),[t,s]),m=(0,U.useCallback)(()=>s&&t({type:"moveColumn",column:s,moveBy:1}),[t,s]),f=(0,U.useCallback)((w,G)=>l(G),[]),d=(0,U.useCallback)((w,G)=>r==null?void 0:r(G),[r]),P=(0,U.useCallback)((w,G)=>{t({type:"moveColumn",moveFrom:w,moveTo:G})},[t]);return(0,y.jsxs)("div",{className:xe,id:c,children:[(0,y.jsxs)("div",{className:`${xe}-listColumn`,children:[(0,y.jsx)("label",{htmlFor:`available-${c}`,children:(0,y.jsx)(F.Text,{as:"h4",children:"Available Columns"})}),(0,y.jsx)("div",{className:`${xe}-listContainer`,style:{flex:1,overflow:"hidden"},children:(0,y.jsx)(fn.List,{borderless:!0,checkable:!1,height:"100%",id:`available-${c}`,itemHeight:24,itemToString:w=>w.name,onSelectionChange:f,selected:p,selectionStrategy:"extended",source:g})}),(0,y.jsx)("div",{style:{display:"flex",alignItems:"center",flex:"0 0 32px",marginTop:"var(--salt-size-basis-unit)"},children:(0,y.jsxs)(F.Button,{onClick:x,disabled:p.length===0,children:["Show",(0,y.jsx)("span",{"data-icon":"arrow-thin-right",style:{marginLeft:8}})]})})]}),(0,y.jsxs)("div",{className:`${xe}-listColumn`,children:[(0,y.jsx)("label",{htmlFor:`selected-${c}`,children:(0,y.jsx)(F.Text,{as:"h4",children:"Included Columns"})}),(0,y.jsx)("div",{className:`${xe}-listContainer`,style:{flex:1,overflow:"hidden"},children:(0,y.jsx)(fn.List,{ListItem:Un,allowDragDrop:!0,borderless:!0,height:"100%",id:`selected-${c}`,itemHeight:24,itemToString:w=>w.name,onMoveListItem:P,onSelectionChange:d,selected:s,style:{flex:1},source:i})}),(0,y.jsxs)("div",{style:{alignItems:"center",flex:"0 0 32px",display:"flex",gap:6,marginTop:"var(--salt-size-basis-unit)"},children:[(0,y.jsxs)(F.Button,{onClick:E,disabled:s===null,children:[(0,y.jsx)("span",{"data-icon":"arrow-thin-left",style:{marginRight:8}}),"Hide"]}),(0,y.jsx)(F.Button,{"aria-label":"Move column up",onClick:a,disabled:s===null||(i==null?void 0:i.indexOf(s))===0,style:{width:28},children:(0,y.jsx)("span",{"data-icon":"arrow-thin-up"})}),(0,y.jsx)(F.Button,{"aria-label":"Move column down",onClick:m,disabled:s===null||i.indexOf(s)===i.length-1,style:{width:28},children:(0,y.jsx)("span",{"data-icon":"arrow-thin-down"})}),(0,y.jsx)(F.Button,{"aria-label":"Add calculated column",className:`${xe}-addCalculatedColumn`,onClick:o,variant:"primary",children:(0,y.jsx)("span",{"data-icon":"add"})})]})]})]})};var Kn=require("@vuu-ui/vuu-layout"),b=require("@heswell/salt-lab"),ke=require("@salt-ds/core"),jn=q(require("classnames"),1),H=require("react");var Vn=require("@vuu-ui/vuu-utils"),zn=require("@heswell/salt-lab"),Yn=require("@salt-ds/core"),xn=q(require("classnames"),1),Zn=require("react");var oe=require("@heswell/salt-lab"),Gn=require("@salt-ds/core"),Ae=require("react");var A=require("react/jsx-runtime"),Jt={alignOnDecimals:!1,decimals:4,zeroPad:!1},qt=(n,e)=>{let t=typeof n=="object"&&n.formatting?n.formatting:{};return["alignOnDecimals","decimals","zeroPad"].reduce((r,i)=>t[i]!==void 0?{...r,[i]:t[i]}:(e==null?void 0:e[i])!==void 0?{...r,[i]:e[i]}:r,Jt)},Wn=({column:n,dispatchColumnAction:e})=>{let{decimals:t,alignOnDecimals:o,zeroPad:r}=qt(n==null?void 0:n.type),i=(0,Ae.useCallback)(c=>e({type:"updateColumnTypeFormatting",column:n,...c}),[n,e]),s=(0,Ae.useCallback)(c=>i({decimals:parseInt(c.toString(),10)}),[i]),p=(0,Ae.useCallback)((c,g)=>i({alignOnDecimals:g}),[i]),l=(0,Ae.useCallback)((c,g)=>i({zeroPad:g}),[i]);switch(n.serverDataType){case"double":return(0,A.jsxs)(A.Fragment,{children:[(0,A.jsx)(oe.FormField,{label:"No of Decimals",labelPlacement:"top",children:(0,A.jsx)(oe.StepperInput,{value:t,onChange:s})}),(0,A.jsx)(oe.Switch,{checked:o,label:"Align on decimals",LabelProps:{className:"vuuColumnPanelSwitch"},onChange:p}),(0,A.jsx)(oe.Switch,{checked:r,label:"Zero pad",LabelProps:{className:"vuuColumnPanelSwitch"},onChange:l})]});case"long":case"int":return(0,A.jsx)(A.Fragment,{children:(0,A.jsx)(Gn.Text,{children:"Work in progress"})});default:return null}};var He=require("react/jsx-runtime"),Xn=({column:n,dispatchColumnAction:e})=>(0,He.jsx)(He.Fragment,{children:"String"});var X=require("react/jsx-runtime"),Cn="vuuColumnTypePanel",_t=["Default Renderer (int, long)"],Kt=["Default Renderer (double)"],Hn=["Default Renderer (string)"],jt=n=>{let t=(0,Vn.getRegisteredCellRenderers)(n.serverDataType).map(o=>o.name);switch(console.log({customRendererNames:t}),n.serverDataType){case"char":case"string":return Hn;case"int":case"long":return _t;case"double":return Kt.concat(t);default:return Hn}},Jn=({className:n,column:e,dispatchColumnAction:t,...o})=>{let r=(0,Zn.useMemo)(()=>{switch(e.serverDataType){case"double":case"int":case"long":return(0,X.jsx)(Wn,{column:e,dispatchColumnAction:t});default:return(0,X.jsx)(Xn,{column:e,dispatchColumnAction:t})}},[e,t]),{serverDataType:i="string"}=e,s=jt(e);return(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(zn.Dropdown,{className:(0,xn.default)(`${Cn}-renderer`),fullWidth:!0,selected:s[0],source:s}),(0,X.jsx)(Yn.Panel,{...o,className:(0,xn.default)(Cn,n,`${Cn}-${i}`),children:r})]})};var h=require("react/jsx-runtime"),qn="vuuColumnSettingsPanel",eo={className:"salt-density-high"},_n=()=>null,et=({column:n,dispatchColumnAction:e,style:t,...o})=>{var E,a,m,f;let[r,i]=(0,H.useState)(0),s=(0,H.useCallback)(d=>e({type:"updateColumnProp",column:n,...d}),[n,e]),p=(0,H.useCallback)(d=>s({align:d.target.value}),[s]),l=(0,H.useCallback)(d=>s({pin:d.target.value}),[s]),c=(0,H.useCallback)((d,P)=>s({hidden:P}),[s]),g=(0,H.useCallback)((d,P)=>s({label:P}),[s]),x=(0,H.useCallback)(d=>s({width:parseInt(d.toString(),10)}),[s]);return(0,h.jsxs)("div",{className:qn,...o,style:{...t},children:[(0,h.jsx)(ke.Text,{as:"h4",children:"Column Settings"}),(0,h.jsxs)(Kn.Stack,{active:r,showTabs:!0,className:(0,jn.default)(`${qn}-columnTabs`),onTabSelectionChanged:i,TabstripProps:eo,children:[(0,h.jsxs)(ke.Panel,{title:"Column",children:[(0,h.jsx)(b.FormField,{label:"Hidden",labelPlacement:"left",children:(0,h.jsx)(b.Checkbox,{checked:n.hidden===!0,onChange:c})}),(0,h.jsx)(b.FormField,{label:"Label",labelPlacement:"left",children:(0,h.jsx)(b.Input,{value:(E=n.label)!=null?E:n.name,onChange:g})}),(0,h.jsx)(b.FormField,{label:"Width",labelPlacement:"left",children:(0,h.jsx)(b.StepperInput,{value:(a=n.width)!=null?a:100,onChange:x})}),(0,h.jsx)(b.FormField,{label:"Align",labelPlacement:"left",ActivationIndicatorComponent:_n,children:(0,h.jsxs)(b.RadioButtonGroup,{"aria-label":"Column Align",value:(m=n.align)!=null?m:"left",legend:"Align",onChange:p,children:[(0,h.jsx)(b.RadioButton,{label:"Left",value:"left"}),(0,h.jsx)(b.RadioButton,{label:"Right",value:"right"})]})}),(0,h.jsx)(b.FormField,{label:"Pin Column",labelPlacement:"left",ActivationIndicatorComponent:_n,children:(0,h.jsxs)(b.RadioButtonGroup,{"aria-label":"Pin Column",value:(f=n.pin)!=null?f:"",legend:"Pin Column",onChange:l,children:[(0,h.jsx)(b.RadioButton,{label:"Do not pin",value:""}),(0,h.jsx)(b.RadioButton,{label:"Left",value:"left"}),(0,h.jsx)(b.RadioButton,{label:"Right",value:"right"})]})})]}),(0,h.jsx)(Jn,{column:n,dispatchColumnAction:e,title:"Data Cell"}),(0,h.jsxs)(ke.Panel,{title:"Vuu",variant:"secondary",children:[(0,h.jsx)(b.FormField,{label:"Name",labelPlacement:"top",readOnly:!0,variant:"secondary",children:(0,h.jsx)(b.Input,{value:n.name})}),(0,h.jsx)(b.FormField,{label:"Vuu type",labelPlacement:"top",readOnly:!0,variant:"secondary",children:(0,h.jsx)(b.Input,{value:n.serverDataType})})]})]})]})};var L=require("@heswell/salt-lab"),ze=require("@salt-ds/core"),Ve=require("react");var k=require("react/jsx-runtime"),no="vuuGridSettingsPanel",to=()=>null,nt=({config:n,dispatchColumnAction:e,style:t,...o})=>{var p;let r=(0,Ve.useCallback)(l=>e({type:"updateGridSettings",...l}),[e]),i=(0,Ve.useCallback)(l=>r({columnFormatHeader:l.target.value}),[r]),s=(0,Ve.useCallback)(l=>r({columnDefaultWidth:parseInt(l.toString(),10)}),[r]);return(0,k.jsxs)("div",{className:no,...o,style:{...t},children:[(0,k.jsx)(ze.Text,{as:"h4",children:"Grid Settings"}),(0,k.jsxs)(ze.Panel,{children:[(0,k.jsx)(L.FormField,{label:"Format column labels",labelPlacement:"left",ActivationIndicatorComponent:to,children:(0,k.jsxs)(L.RadioButtonGroup,{"aria-label":"Format column labels",value:n.columnFormatHeader,legend:"Format column labels",onChange:i,children:[(0,k.jsx)(L.RadioButton,{label:"No Formatting",value:void 0}),(0,k.jsx)(L.RadioButton,{label:"Capitalize",value:"capitalize"}),(0,k.jsx)(L.RadioButton,{label:"Uppercase",value:"uppercase"})]})}),(0,k.jsx)(L.FormField,{label:"Default Column Width",labelPlacement:"left",children:(0,k.jsx)(L.StepperInput,{value:(p=n.columnDefaultWidth)!=null?p:100,onChange:s})})]})]})};var tt=require("react"),ot=require("@heswell/salt-lab"),rt=require("@vuu-ui/vuu-utils"),oo=(n,e)=>{switch(console.log(`gridSettingsReducer ${e.type}`),e.type){case"addColumn":return ro(n,e);case"addCalculatedColumn":return so(n,e);case"moveColumn":return ao(n,e);case"removeColumn":return io(n,e);case"updateColumn":return n;case"updateColumnProp":return lo(n,e);case"updateGridSettings":return po(n,e);case"updateColumnTypeFormatting":return co(n,e);default:return n}},st=n=>{let[e,t]=(0,tt.useReducer)(oo,n);return{gridSettings:e,dispatchColumnAction:t}};function ro(n,{column:e,columns:t,index:o=-1}){let{columns:r}=n;if(o===-1){if(Array.isArray(t))return{...n,columns:r.concat(t)};if(e)return{...n,columns:r.concat(e)}}return n}function so(n,{columnName:e,columnType:t,expression:o}){let{columns:r}=n,i={name:e,expression:o,serverDataType:t};return{...n,columns:r.concat(i)}}function io(n,{column:e}){let{columns:t}=n;return{...n,columns:t.filter(o=>o.name!==e.name)}}function ao(n,{column:e,moveBy:t,moveFrom:o,moveTo:r}){let{columns:i}=n;if(e&&typeof t=="number"){let s=i.indexOf(e),p=i.slice(),[l]=p.splice(s,1);return p.splice(s+t,0,l),{...n,columns:p}}else return typeof o=="number"&&typeof r=="number"?{...n,columns:(0,ot.moveItem)(i,o,r)}:n}function lo(n,{align:e,column:t,hidden:o,label:r,width:i}){let{columns:s}=n;return(e==="left"||e==="right")&&(s=Ne(s,{...t,align:e})),typeof o=="boolean"&&(s=Ne(s,{...t,hidden:o})),typeof r=="string"&&(s=Ne(s,{...t,label:r})),typeof i=="number"&&(s=Ne(s,{...t,width:i})),{...n,columns:s}}function po(n,{columnFormatHeader:e}){return{...n,columnFormatHeader:e!=null?e:n.columnFormatHeader}}function co(n,{alignOnDecimals:e,column:t,decimals:o,zeroPad:r}){let{columns:i}=n;if(i.find(p=>p.name===t.name)){let{serverDataType:p="string",type:l=(0,rt.fromServerDataType)(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 r=="boolean"&&(c.formatting={...c.formatting,zeroPad:r}),{...n,columns:Ne(i,{...t,type:c})}}else return n}function Ne(n,e){return n.map(t=>t.name===e.name?e:t)}var lt=require("@vuu-ui/vuu-layout");var Ye=require("@heswell/salt-lab"),he=require("@salt-ds/core"),M=require("react");var V=require("react/jsx-runtime"),it=({columns:n,dispatchColumnAction:e,table:t})=>{let[o,r]=(0,M.useState)(""),[,i]=(0,M.useState)(),s=(0,M.useRef)(""),p=gn({columns:n,table:t}),l=(0,M.useCallback)(E=>{let{value:a}=E.target;r(a)},[]),c=(0,M.useCallback)(E=>{s.current=E},[]),g=(0,M.useCallback)((E,a)=>{console.log({source:E}),i(a)},[]),x=(0,M.useCallback)(()=>{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(0,V.jsxs)(he.Panel,{className:"vuuCalculatedColumnPanel",title:"Define Computed Column",children:[(0,V.jsx)(he.Text,{styleAs:"h4",children:"Define Computed Column"}),(0,V.jsx)(Ye.FormField,{label:"Column Name",labelPlacement:"left",children:(0,V.jsx)(Ye.Input,{value:o,onChange:l})}),(0,V.jsx)(mn,{onChange:c,onSubmitExpression:g,suggestionProvider:p}),(0,V.jsx)("div",{style:{marginTop:12},children:(0,V.jsx)(he.Button,{onClick:x,children:"Add Column"})})]})};var T=require("react/jsx-runtime"),Ze="vuuDatagridSettingsPanel",uo=()=>{},mo=["table-settings","column-chooser","column-settings","define-column"],go=(n,e)=>mo[e],fo=({availableColumns:n,className:e,gridConfig:t,onCancel:o,onConfigChange:r,...i})=>{var Ee;console.log("DatagridSettingsPanel render");let[s,p]=(0,z.useState)(0),{gridSettings:l,dispatchColumnAction:c}=st(t),[g,x]=(0,z.useState)(null),E=(0,z.useCallback)(W=>{x(W?W.name:null)},[]),a=(0,z.useCallback)((W,ct=!1)=>{console.log("1) DataGridSettingsPanel fire onConfigChange"),r==null||r(l,ct)},[l,r]),m=(0,z.useCallback)(W=>{p(W)},[]),f=(0,z.useCallback)(W=>a(W,!0),[a]),d=g===null?null:(Ee=l.columns.find(W=>W.name===g))!=null?Ee:null,P={activeTabIndex:s,enableRenameTab:!1,orientation:"vertical"},w=(0,z.useCallback)(()=>p(3),[]),G=s===2?"right":void 0;return(0,T.jsxs)("div",{...i,className:(0,at.default)(Ze,e),children:[(0,T.jsxs)(lt.Stack,{TabstripProps:P,className:`${Ze}-stack`,getTabIcon:go,getTabLabel:uo,active:s===2?1:s,onTabSelectionChanged:m,showTabs:!0,children:[(0,T.jsx)(nt,{config:l,dispatchColumnAction:c}),(0,T.jsxs)("div",{className:`${Ze}-columnPanels`,"data-align":G,children:[(0,T.jsx)(Mn,{availableColumns:n,chosenColumns:l.columns,dispatchColumnAction:c,onSelectionChange:E,onAddCalculatedColumnClick:w,selectedColumn:d}),d===null?(0,T.jsx)(ye.Panel,{className:"vuuColumnSettingsPanel",children:"Select a column"}):(0,T.jsx)(et,{column:d,dispatchColumnAction:c,style:{background:"white",flex:"1 0 150px"}})]}),(0,T.jsx)("div",{title:"Column Settings",children:"Column Settings"}),(0,T.jsx)(it,{columns:l.columns,dispatchColumnAction:c,table:{module:"SIMUL",table:"instruments"}})]}),(0,T.jsxs)("div",{className:`${Ze}-buttonBar`,children:[(0,T.jsx)(ye.Button,{onClick:o,children:"Cancel"}),(0,T.jsx)(ye.Button,{onClick:a,children:"Apply"}),(0,T.jsx)(ye.Button,{onClick:f,children:"Save"})]})]})};var be=require("react"),pt=q(require("classnames"),1);var Y=require("react/jsx-runtime"),Qe="vuuDatasourceStats",hn=new Intl.NumberFormat,Co=({className:n,dataSource:e})=>{let[t,o]=(0,be.useState)(e.optimize),[r,i]=(0,be.useState)(e.range),[s,p]=(0,be.useState)(e.size);(0,be.useEffect)(()=>{o(e.optimize),p(e.size),e.on("optimize",o),e.on("resize",p),e.on("range",i)},[e]);let l=(0,pt.default)(Qe,n),c=hn.format(r.from),g=hn.format(r.to-1),x=hn.format(s);return(0,Y.jsxs)("div",{className:l,children:[(0,Y.jsx)("span",{children:"Showing rows"}),(0,Y.jsx)("span",{className:`${Qe}-range`,children:c}),(0,Y.jsx)("span",{className:`${Qe}-range`,children:g}),(0,Y.jsx)("span",{children:"of"}),(0,Y.jsx)("span",{className:`${Qe}-size`,children:x}),(0,Y.jsx)("span",{className:`${Qe}-optimize`,children:t})]})};
|
|
2868
2
|
//# sourceMappingURL=index.js.map
|