@vuu-ui/vuu-table-extras 0.8.8-debug → 0.8.8

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/esm/index.js CHANGED
@@ -1,3728 +1,2 @@
1
- var __accessCheck = (obj, member, msg) => {
2
- if (!member.has(obj))
3
- throw TypeError("Cannot " + msg);
4
- };
5
- var __privateGet = (obj, member, getter) => {
6
- __accessCheck(obj, member, "read from private field");
7
- return getter ? getter.call(obj) : member.get(obj);
8
- };
9
- var __privateAdd = (obj, member, value) => {
10
- if (member.has(obj))
11
- throw TypeError("Cannot add the same private member more than once");
12
- member instanceof WeakSet ? member.add(obj) : member.set(obj, value);
13
- };
14
- var __privateSet = (obj, member, value, setter) => {
15
- __accessCheck(obj, member, "write to private field");
16
- setter ? setter.call(obj, value) : member.set(obj, value);
17
- return value;
18
- };
19
-
20
- // src/cell-renderers/background-cell/BackgroundCell.tsx
21
- import {
22
- DOWN1,
23
- DOWN2,
24
- isTypeDescriptor as isTypeDescriptor2,
25
- metadataKeys,
26
- registerComponent,
27
- UP1,
28
- UP2
29
- } from "@vuu-ui/vuu-utils";
30
- import cx from "classnames";
31
-
32
- // src/cell-renderers/background-cell/useDirection.ts
33
- import {
34
- getMovingValueDirection,
35
- isTypeDescriptor,
36
- isValidNumber
37
- } from "@vuu-ui/vuu-utils";
38
- import { useEffect, useRef } from "react";
39
- var INITIAL_VALUE = [void 0, void 0, void 0, void 0];
40
- function useDirection(key, value, column) {
41
- var _a;
42
- const ref = useRef();
43
- const [prevKey, prevValue, prevColumn, prevDirection] = ref.current || INITIAL_VALUE;
44
- const { type: dataType } = column;
45
- const decimals = isTypeDescriptor(dataType) ? (_a = dataType.formatting) == null ? void 0 : _a.decimals : void 0;
46
- const direction = key === prevKey && isValidNumber(value) && isValidNumber(prevValue) && column === prevColumn ? getMovingValueDirection(value, prevDirection, prevValue, decimals) : "";
47
- useEffect(() => {
48
- ref.current = [key, value, column, direction];
49
- });
50
- return direction;
51
- }
52
-
53
- // src/cell-renderers/background-cell/BackgroundCell.tsx
54
- import { jsx, jsxs } from "react/jsx-runtime";
55
- var CHAR_ARROW_UP = String.fromCharCode(11014);
56
- var CHAR_ARROW_DOWN = String.fromCharCode(11015);
57
- var { KEY } = metadataKeys;
58
- var classBase = "vuuBackgroundCell";
59
- var FlashStyle = {
60
- ArrowOnly: "arrow",
61
- BackgroundOnly: "bg-only",
62
- ArrowBackground: "arrow-bg"
63
- };
64
- var getFlashStyle = (colType) => {
65
- if (isTypeDescriptor2(colType) && colType.renderer) {
66
- if ("flashStyle" in colType.renderer) {
67
- return colType.renderer["flashStyle"];
68
- }
69
- }
70
- return FlashStyle.BackgroundOnly;
71
- };
72
- var BackgroundCell = ({ column, row }) => {
73
- const { key, type, valueFormatter } = column;
74
- const value = row[key];
75
- const flashStyle = getFlashStyle(type);
76
- const direction = useDirection(row[KEY], value, column);
77
- const arrow = flashStyle === FlashStyle.ArrowOnly || flashStyle === FlashStyle.ArrowBackground ? direction === UP1 || direction === UP2 ? CHAR_ARROW_UP : direction === DOWN1 || direction === DOWN2 ? CHAR_ARROW_DOWN : null : null;
78
- const dirClass = direction ? ` ` + direction : "";
79
- const className = cx(classBase, dirClass, {
80
- [`${classBase}-arrowOnly`]: flashStyle === FlashStyle.ArrowOnly,
81
- [`${classBase}-arrowBackground`]: flashStyle === FlashStyle.ArrowBackground
82
- });
83
- return /* @__PURE__ */ jsxs("div", { className, tabIndex: -1, children: [
84
- /* @__PURE__ */ jsx("div", { className: `${classBase}-flasher`, children: arrow }),
85
- valueFormatter(row[column.key])
86
- ] });
87
- };
88
- registerComponent("background", BackgroundCell, "cell-renderer", {
89
- serverDataType: ["long", "int", "double"]
90
- });
91
-
92
- // src/cell-renderers/progress-cell/ProgressCell.tsx
93
- import {
94
- isColumnTypeRenderer,
95
- isTypeDescriptor as isTypeDescriptor3,
96
- registerComponent as registerComponent2
97
- } from "@vuu-ui/vuu-utils";
98
- import cx2 from "classnames";
99
- import { jsx as jsx2, jsxs as jsxs2 } from "react/jsx-runtime";
100
- var classBase2 = "vuuProgressCell";
101
- var ProgressCell = ({ column, columnMap, row }) => {
102
- const { type } = column;
103
- const value = row[column.key];
104
- let showProgress = false;
105
- let percentage = 0;
106
- if (isTypeDescriptor3(type) && isColumnTypeRenderer(type.renderer)) {
107
- const { associatedField } = type.renderer;
108
- const associatedValue = row[columnMap[associatedField]];
109
- if (typeof value === "number" && typeof associatedValue === "number") {
110
- percentage = Math.min(Math.round(value / associatedValue * 100), 100);
111
- showProgress = isFinite(percentage);
112
- } else {
113
- const floatValue = parseFloat(value);
114
- if (Number.isFinite(floatValue)) {
115
- const floatOtherValue = parseFloat(associatedValue);
116
- if (Number.isFinite(floatOtherValue)) {
117
- percentage = Math.min(
118
- Math.round(floatValue / floatOtherValue * 100),
119
- 100
120
- );
121
- showProgress = isFinite(percentage);
122
- }
123
- }
124
- }
125
- }
126
- const className = cx2(classBase2, {});
127
- return /* @__PURE__ */ jsxs2("div", { className, tabIndex: -1, children: [
128
- showProgress ? /* @__PURE__ */ jsxs2("span", { className: `${classBase2}-track`, children: [
129
- /* @__PURE__ */ jsx2("span", { className: `${classBase2}-bg` }),
130
- /* @__PURE__ */ jsx2(
131
- "span",
132
- {
133
- className: `${classBase2}-bar`,
134
- style: { "--progress-bar-pct": `-${100 - percentage}%` }
135
- }
136
- )
137
- ] }) : null,
138
- /* @__PURE__ */ jsx2("span", { className: `${classBase2}-text`, children: `${percentage} %` })
139
- ] });
140
- };
141
- registerComponent2("vuu.progress", ProgressCell, "cell-renderer", {
142
- serverDataType: ["long", "int", "double"]
143
- });
144
-
145
- // src/column-list/ColumnList.tsx
146
- import {
147
- List,
148
- ListItem
149
- } from "@vuu-ui/vuu-ui-controls";
150
- import { Checkbox } from "@salt-ds/core";
151
- import { Switch } from "@salt-ds/lab";
152
- import cx3 from "classnames";
153
- import { useCallback } from "react";
154
- import { jsx as jsx3, jsxs as jsxs3 } from "react/jsx-runtime";
155
- var classBase3 = "vuuColumnList";
156
- var classBaseListItem = "vuuColumnListItem";
157
- var ColumnListItem = ({
158
- className: classNameProp,
159
- item,
160
- ...listItemProps
161
- }) => {
162
- var _a;
163
- return /* @__PURE__ */ jsxs3(
164
- ListItem,
165
- {
166
- ...listItemProps,
167
- className: cx3(classNameProp, classBaseListItem),
168
- "data-name": item == null ? void 0 : item.name,
169
- children: [
170
- /* @__PURE__ */ jsx3(Switch, { className: `${classBase3}-switch`, checked: item == null ? void 0 : item.subscribed }),
171
- /* @__PURE__ */ jsx3("span", { className: `${classBase3}-text`, children: (_a = item == null ? void 0 : item.label) != null ? _a : item == null ? void 0 : item.name }),
172
- /* @__PURE__ */ jsx3(
173
- Checkbox,
174
- {
175
- className: `${classBase3}-checkBox`,
176
- checked: (item == null ? void 0 : item.hidden) !== true,
177
- disabled: (item == null ? void 0 : item.subscribed) !== true
178
- }
179
- )
180
- ]
181
- }
182
- );
183
- };
184
- var ColumnList = ({
185
- columnItems,
186
- onChange,
187
- onMoveListItem,
188
- ...htmlAttributes
189
- }) => {
190
- const handleChange = useCallback(
191
- (evt) => {
192
- const input = evt.target;
193
- const listItem = input.closest(`.${classBaseListItem}`);
194
- const {
195
- dataset: { name }
196
- } = listItem;
197
- if (name) {
198
- const saltSwitch = input.closest(`.${classBase3}-switch`);
199
- const saltCheckbox = input.closest(
200
- `.${classBase3}-checkBox`
201
- );
202
- if (saltSwitch) {
203
- onChange(name, "subscribed", input.checked);
204
- } else if (saltCheckbox) {
205
- onChange(name, "hidden", input.checked === false);
206
- }
207
- }
208
- },
209
- [onChange]
210
- );
211
- return /* @__PURE__ */ jsxs3("div", { ...htmlAttributes, className: classBase3, children: [
212
- /* @__PURE__ */ jsx3("div", { className: `${classBase3}-header`, children: /* @__PURE__ */ jsx3("span", { children: "Column Selection" }) }),
213
- /* @__PURE__ */ jsxs3("div", { className: `${classBase3}-colHeadings`, children: [
214
- /* @__PURE__ */ jsx3("span", { children: "Column subscription" }),
215
- /* @__PURE__ */ jsx3("span", { children: "Visibility" })
216
- ] }),
217
- /* @__PURE__ */ jsx3(
218
- List,
219
- {
220
- ListItem: ColumnListItem,
221
- allowDragDrop: true,
222
- height: "100%",
223
- onChange: handleChange,
224
- onMoveListItem,
225
- selectionStrategy: "none",
226
- source: columnItems,
227
- itemHeight: 33
228
- }
229
- )
230
- ] });
231
- };
232
-
233
- // src/column-expression-input/useColumnExpressionEditor.ts
234
- import {
235
- autocompletion,
236
- defaultKeymap,
237
- EditorState as EditorState2,
238
- EditorView as EditorView2,
239
- ensureSyntaxTree,
240
- keymap,
241
- minimalSetup,
242
- startCompletion
243
- } from "@vuu-ui/vuu-codemirror";
244
- import { createEl } from "@vuu-ui/vuu-utils";
245
- import { useEffect as useEffect2, useMemo, useRef as useRef2 } from "react";
246
-
247
- // src/column-expression-input/column-language-parser/ColumnExpressionLanguage.ts
248
- import {
249
- LanguageSupport,
250
- LRLanguage,
251
- styleTags,
252
- tags as tag
253
- } from "@vuu-ui/vuu-codemirror";
254
-
255
- // src/column-expression-input/column-language-parser/generated/column-parser.js
256
- import { LRParser } from "@lezer/lr";
257
- var parser = LRParser.deserialize({
258
- version: 14,
259
- 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",
260
- 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~",
261
- goto: "#spPPqPPPPqPPqPPPPqP!R!W!R!RPq!Z!k!nPPP!tP#jmUOQWXYZefghitxyVbYfgRe`mTOQWXYZefghitxyR[TQjcRrjQROQVQS^WxQ_XU`YfgQcZQmeQphQqiQuyRvtQaYQnfRog",
262
- 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",
263
- maxTerm: 39,
264
- skippedNodes: [0],
265
- repeatNodeCount: 1,
266
- 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",
267
- tokenizers: [0, 1],
268
- topRules: { "ColumnDefinitionExpression": [0, 1] },
269
- tokenPrec: 375
270
- });
271
-
272
- // src/column-expression-input/column-language-parser/ColumnExpressionLanguage.ts
273
- var columnExpressionLanguage = LRLanguage.define({
274
- name: "VuuColumnExpression",
275
- parser: parser.configure({
276
- props: [
277
- styleTags({
278
- Function: tag.variableName,
279
- String: tag.string,
280
- Or: tag.emphasis,
281
- Operator: tag.operator
282
- })
283
- ]
284
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
285
- })
286
- });
287
- var columnExpressionLanguageSupport = () => {
288
- return new LanguageSupport(
289
- columnExpressionLanguage
290
- /*, [exampleCompletion]*/
291
- );
292
- };
293
-
294
- // src/column-expression-input/column-language-parser/ColumnExpressionTreeWalker.ts
295
- var LiteralExpressionImpl = class {
296
- constructor(value) {
297
- this.value = value;
298
- switch (typeof value) {
299
- case "boolean":
300
- this.type = "booleanLiteralExpression";
301
- break;
302
- case "number":
303
- this.type = "numericLiteralExpression";
304
- break;
305
- default:
306
- this.type = "stringLiteralExpression";
307
- }
308
- }
309
- toJSON() {
310
- return {
311
- type: this.type,
312
- value: this.value
313
- };
314
- }
315
- };
316
- var ColumnExpressionImpl = class {
317
- constructor(columnName) {
318
- this.type = "colExpression";
319
- this.column = columnName;
320
- }
321
- toJSON() {
322
- return {
323
- type: this.type,
324
- column: this.column
325
- };
326
- }
327
- };
328
- var _expressions, _op;
329
- var ArithmeticExpressionImpl = class {
330
- constructor(op = "unknown") {
331
- __privateAdd(this, _expressions, [
332
- { type: "unknown" },
333
- { type: "unknown" }
334
- ]);
335
- __privateAdd(this, _op, void 0);
336
- this.type = "arithmeticExpression";
337
- __privateSet(this, _op, op);
338
- }
339
- get op() {
340
- return __privateGet(this, _op);
341
- }
342
- set op(op) {
343
- __privateSet(this, _op, op);
344
- }
345
- get expressions() {
346
- return __privateGet(this, _expressions);
347
- }
348
- toJSON() {
349
- return {
350
- type: this.type,
351
- op: __privateGet(this, _op),
352
- expressions: __privateGet(this, _expressions)
353
- };
354
- }
355
- };
356
- _expressions = new WeakMap();
357
- _op = new WeakMap();
358
- var _expressions2;
359
- var CallExpressionImpl = class {
360
- constructor(functionName) {
361
- __privateAdd(this, _expressions2, []);
362
- this.type = "callExpression";
363
- this.functionName = functionName;
364
- }
365
- get expressions() {
366
- return __privateGet(this, _expressions2);
367
- }
368
- get arguments() {
369
- return __privateGet(this, _expressions2);
370
- }
371
- toJSON() {
372
- return {
373
- type: this.type,
374
- functionName: this.functionName,
375
- arguments: __privateGet(this, _expressions2).map((e) => {
376
- var _a;
377
- return (_a = e.toJSON) == null ? void 0 : _a.call(e);
378
- })
379
- };
380
- }
381
- };
382
- _expressions2 = new WeakMap();
383
- var _expressions3, _op2;
384
- var RelationalExpressionImpl = class {
385
- constructor() {
386
- __privateAdd(this, _expressions3, [
387
- { type: "unknown" },
388
- { type: "unknown" }
389
- ]);
390
- __privateAdd(this, _op2, "unknown");
391
- this.type = "relationalExpression";
392
- }
393
- get op() {
394
- return __privateGet(this, _op2);
395
- }
396
- set op(op) {
397
- __privateSet(this, _op2, op);
398
- }
399
- get expressions() {
400
- return __privateGet(this, _expressions3);
401
- }
402
- toJSON() {
403
- return {
404
- type: this.type,
405
- op: __privateGet(this, _op2),
406
- expressions: __privateGet(this, _expressions3)
407
- };
408
- }
409
- };
410
- _expressions3 = new WeakMap();
411
- _op2 = new WeakMap();
412
- var _expressions4, _op3;
413
- var BooleanConditionImp = class {
414
- constructor(booleanOperator) {
415
- __privateAdd(this, _expressions4, [
416
- { type: "unknown" },
417
- { type: "unknown" }
418
- ]);
419
- __privateAdd(this, _op3, void 0);
420
- this.type = "booleanCondition";
421
- __privateSet(this, _op3, booleanOperator);
422
- }
423
- get op() {
424
- return __privateGet(this, _op3);
425
- }
426
- get expressions() {
427
- return __privateGet(this, _expressions4);
428
- }
429
- toJSON() {
430
- return {
431
- type: this.type,
432
- op: __privateGet(this, _op3),
433
- expressions: __privateGet(this, _expressions4).map((e) => {
434
- var _a;
435
- return (_a = e.toJSON) == null ? void 0 : _a.call(e);
436
- })
437
- };
438
- }
439
- };
440
- _expressions4 = new WeakMap();
441
- _op3 = new WeakMap();
442
- var _expressions5;
443
- var ConditionalExpressionImpl = class {
444
- constructor(booleanOperator) {
445
- __privateAdd(this, _expressions5, void 0);
446
- this.type = "conditionalExpression";
447
- __privateSet(this, _expressions5, [
448
- booleanOperator ? new BooleanConditionImp(booleanOperator) : new RelationalExpressionImpl(),
449
- { type: "unknown" },
450
- { type: "unknown" }
451
- ]);
452
- }
453
- get expressions() {
454
- return __privateGet(this, _expressions5);
455
- }
456
- get condition() {
457
- return __privateGet(this, _expressions5)[0];
458
- }
459
- get truthyExpression() {
460
- return __privateGet(this, _expressions5)[1];
461
- }
462
- set truthyExpression(expression) {
463
- __privateGet(this, _expressions5)[1] = expression;
464
- }
465
- get falsyExpression() {
466
- return __privateGet(this, _expressions5)[2];
467
- }
468
- set falsyExpression(expression) {
469
- __privateGet(this, _expressions5)[2] = expression;
470
- }
471
- toJSON() {
472
- var _a, _b, _c, _d, _e;
473
- return {
474
- type: this.type,
475
- condition: (_b = (_a = this.condition).toJSON) == null ? void 0 : _b.call(_a),
476
- truthyExpression: this.truthyExpression,
477
- falsyExpression: (_e = (_d = (_c = this.falsyExpression) == null ? void 0 : _c.toJSON) == null ? void 0 : _d.call(_c)) != null ? _e : this.falsyExpression
478
- };
479
- }
480
- };
481
- _expressions5 = new WeakMap();
482
- var isUnknown = (e) => e.type === "unknown";
483
- var isArithmeticExpression = (expression) => expression.type === "arithmeticExpression";
484
- var isCallExpression = (expression) => expression.type === "callExpression";
485
- var isConditionalExpression = (expression) => expression.type === "conditionalExpression";
486
- var isCondition = (expression) => expression.type === "relationalExpression" || expression.type === "booleanCondition";
487
- var isBooleanCondition = (expression) => expression.type === "booleanCondition";
488
- var isRelationalExpression = (expression) => (expression == null ? void 0 : expression.type) === "relationalExpression";
489
- var firstIncompleteExpression = (expression) => {
490
- if (isUnknown(expression)) {
491
- return expression;
492
- } else if (isRelationalExpression(expression)) {
493
- const [operand1, operand2] = expression.expressions;
494
- if (expressionIsIncomplete(operand1)) {
495
- return firstIncompleteExpression(operand1);
496
- } else if (expression.op === "unknown") {
497
- return expression;
498
- } else if (expressionIsIncomplete(operand2)) {
499
- return firstIncompleteExpression(operand2);
500
- }
501
- } else if (isCondition(expression)) {
502
- const { expressions = [] } = expression;
503
- for (const e of expressions) {
504
- if (expressionIsIncomplete(e)) {
505
- return firstIncompleteExpression(e);
506
- }
507
- }
508
- } else if (isConditionalExpression(expression)) {
509
- const { condition, truthyExpression, falsyExpression } = expression;
510
- if (expressionIsIncomplete(condition)) {
511
- return firstIncompleteExpression(condition);
512
- } else if (expressionIsIncomplete(truthyExpression)) {
513
- return firstIncompleteExpression(truthyExpression);
514
- } else if (expressionIsIncomplete(falsyExpression)) {
515
- return firstIncompleteExpression(falsyExpression);
516
- }
517
- } else if (isArithmeticExpression(expression)) {
518
- const { expressions = [] } = expression;
519
- for (const e of expressions) {
520
- if (expressionIsIncomplete(e)) {
521
- return firstIncompleteExpression(e);
522
- }
523
- }
524
- }
525
- };
526
- var replaceUnknownExpression = (incompleteExpression, unknownExpression, expression) => {
527
- const { expressions = [] } = incompleteExpression;
528
- if (expressions.includes(unknownExpression)) {
529
- const pos = expressions.indexOf(unknownExpression);
530
- expressions.splice(pos, 1, expression);
531
- return true;
532
- } else {
533
- for (const e of expressions) {
534
- if (replaceUnknownExpression(e, unknownExpression, expression)) {
535
- return true;
536
- }
537
- }
538
- }
539
- return false;
540
- };
541
- var expressionIsIncomplete = (expression) => {
542
- if (isUnknown(expression)) {
543
- return true;
544
- } else if (isConditionalExpression(expression)) {
545
- return expressionIsIncomplete(expression.condition) || expressionIsIncomplete(expression.truthyExpression) || expressionIsIncomplete(expression.falsyExpression);
546
- } else if (isRelationalExpression(expression) || isBooleanCondition(expression)) {
547
- return expression.op === void 0 || expression.expressions.some((e) => expressionIsIncomplete(e));
548
- }
549
- return false;
550
- };
551
- var addExpression = (expression, subExpression) => {
552
- const targetExpression = firstIncompleteExpression(expression);
553
- if (targetExpression) {
554
- if (targetExpression.expressions) {
555
- targetExpression.expressions.push(subExpression);
556
- } else {
557
- console.warn("don't know how to treat targetExpression");
558
- }
559
- } else {
560
- console.error("no target expression found");
561
- }
562
- };
563
- var _expression, _callStack;
564
- var ColumnExpression = class {
565
- constructor() {
566
- __privateAdd(this, _expression, void 0);
567
- __privateAdd(this, _callStack, []);
568
- }
569
- setCondition(booleanOperator) {
570
- if (__privateGet(this, _expression) === void 0) {
571
- this.addExpression(new ConditionalExpressionImpl(booleanOperator));
572
- } else if (isConditionalExpression(__privateGet(this, _expression))) {
573
- if (expressionIsIncomplete(__privateGet(this, _expression).condition)) {
574
- const condition = booleanOperator ? new BooleanConditionImp(booleanOperator) : new RelationalExpressionImpl();
575
- this.addExpression(condition);
576
- } else if (isUnknown(__privateGet(this, _expression).truthyExpression)) {
577
- __privateGet(this, _expression).truthyExpression = new ConditionalExpressionImpl(
578
- booleanOperator
579
- );
580
- } else if (expressionIsIncomplete(__privateGet(this, _expression).truthyExpression)) {
581
- const condition = booleanOperator ? new BooleanConditionImp(booleanOperator) : new RelationalExpressionImpl();
582
- this.addExpression(condition);
583
- } else if (isUnknown(__privateGet(this, _expression).falsyExpression)) {
584
- __privateGet(this, _expression).falsyExpression = new ConditionalExpressionImpl(
585
- booleanOperator
586
- );
587
- } else if (expressionIsIncomplete(__privateGet(this, _expression).falsyExpression)) {
588
- const condition = booleanOperator ? new BooleanConditionImp(booleanOperator) : new RelationalExpressionImpl();
589
- this.addExpression(condition);
590
- }
591
- } else {
592
- console.error("setCondition called unexpectedly");
593
- }
594
- }
595
- addExpression(expression) {
596
- if (__privateGet(this, _callStack).length > 0) {
597
- const currentCallExpression = __privateGet(this, _callStack).at(-1);
598
- currentCallExpression == null ? void 0 : currentCallExpression.arguments.push(expression);
599
- } else if (__privateGet(this, _expression) === void 0) {
600
- __privateSet(this, _expression, expression);
601
- } else if (isArithmeticExpression(__privateGet(this, _expression))) {
602
- const targetExpression = firstIncompleteExpression(__privateGet(this, _expression));
603
- if (targetExpression && isUnknown(targetExpression)) {
604
- replaceUnknownExpression(
605
- __privateGet(this, _expression),
606
- targetExpression,
607
- expression
608
- );
609
- }
610
- } else if (isConditionalExpression(__privateGet(this, _expression))) {
611
- if (expressionIsIncomplete(__privateGet(this, _expression))) {
612
- const targetExpression = firstIncompleteExpression(__privateGet(this, _expression));
613
- if (targetExpression && isUnknown(targetExpression)) {
614
- replaceUnknownExpression(
615
- __privateGet(this, _expression),
616
- targetExpression,
617
- expression
618
- );
619
- } else if (targetExpression) {
620
- addExpression(targetExpression, expression);
621
- }
622
- }
623
- }
624
- }
625
- setFunction(functionName) {
626
- const callExpression = new CallExpressionImpl(functionName);
627
- this.addExpression(callExpression);
628
- __privateGet(this, _callStack).push(callExpression);
629
- }
630
- setColumn(columnName) {
631
- this.addExpression(new ColumnExpressionImpl(columnName));
632
- }
633
- setArithmeticOp(value) {
634
- const op = value;
635
- const expression = __privateGet(this, _expression);
636
- if (isArithmeticExpression(expression)) {
637
- expression.op = op;
638
- }
639
- }
640
- setRelationalOperator(value) {
641
- const op = value;
642
- if (__privateGet(this, _expression) && isConditionalExpression(__privateGet(this, _expression))) {
643
- const targetExpression = firstIncompleteExpression(__privateGet(this, _expression));
644
- if (isRelationalExpression(targetExpression)) {
645
- targetExpression.op = op;
646
- } else {
647
- console.error(`no target expression found (op = ${value})`);
648
- }
649
- }
650
- }
651
- setValue(value) {
652
- const literalExpression = new LiteralExpressionImpl(value);
653
- if (__privateGet(this, _expression) === void 0) {
654
- __privateSet(this, _expression, literalExpression);
655
- } else if (isArithmeticExpression(__privateGet(this, _expression))) {
656
- this.addExpression(literalExpression);
657
- } else if (isCallExpression(__privateGet(this, _expression))) {
658
- __privateGet(this, _expression).arguments.push(literalExpression);
659
- } else if (isConditionalExpression(__privateGet(this, _expression))) {
660
- if (expressionIsIncomplete(__privateGet(this, _expression))) {
661
- const targetExpression = firstIncompleteExpression(__privateGet(this, _expression));
662
- if (targetExpression && isUnknown(targetExpression)) {
663
- replaceUnknownExpression(
664
- __privateGet(this, _expression),
665
- targetExpression,
666
- literalExpression
667
- );
668
- } else if (targetExpression) {
669
- addExpression(targetExpression, literalExpression);
670
- }
671
- } else {
672
- console.log("what do we do with value, in a complete expression");
673
- }
674
- }
675
- }
676
- closeBrace() {
677
- __privateGet(this, _callStack).pop();
678
- }
679
- get expression() {
680
- return __privateGet(this, _expression);
681
- }
682
- toJSON() {
683
- var _a;
684
- return (_a = __privateGet(this, _expression)) == null ? void 0 : _a.toJSON();
685
- }
686
- };
687
- _expression = new WeakMap();
688
- _callStack = new WeakMap();
689
- var walkTree = (tree, source) => {
690
- const columnExpression = new ColumnExpression();
691
- const cursor = tree.cursor();
692
- do {
693
- const { name, from, to } = cursor;
694
- switch (name) {
695
- case "AndCondition":
696
- columnExpression.setCondition("and");
697
- break;
698
- case "OrCondition":
699
- columnExpression.setCondition("or");
700
- break;
701
- case "RelationalExpression":
702
- columnExpression.setCondition();
703
- break;
704
- case "ArithmeticExpression":
705
- columnExpression.addExpression(new ArithmeticExpressionImpl());
706
- break;
707
- case "Column":
708
- {
709
- const columnName = source.substring(from, to);
710
- columnExpression.setColumn(columnName);
711
- }
712
- break;
713
- case "Function":
714
- {
715
- const functionName = source.substring(from, to);
716
- columnExpression.setFunction(functionName);
717
- }
718
- break;
719
- case "Times":
720
- case "Divide":
721
- case "Plus":
722
- case "Minus":
723
- {
724
- const op = source.substring(from, to);
725
- columnExpression.setArithmeticOp(op);
726
- }
727
- break;
728
- case "RelationalOperator":
729
- {
730
- const op = source.substring(from, to);
731
- columnExpression.setRelationalOperator(op);
732
- }
733
- break;
734
- case "False":
735
- case "True":
736
- {
737
- const value = source.substring(from, to);
738
- columnExpression.setValue(value === "true" ? true : false);
739
- }
740
- break;
741
- case "String":
742
- columnExpression.setValue(source.substring(from + 1, to - 1));
743
- break;
744
- case "Number":
745
- columnExpression.setValue(parseFloat(source.substring(from, to)));
746
- break;
747
- case "CloseBrace":
748
- columnExpression.closeBrace();
749
- break;
750
- default:
751
- }
752
- } while (cursor.next());
753
- return columnExpression.toJSON();
754
- };
755
-
756
- // src/column-expression-input/column-language-parser/column-expression-parse-utils.ts
757
- var strictParser = parser.configure({ strict: true });
758
- var RelationalOperands = ["Number", "String"];
759
- var ColumnNamedTerms = [
760
- ...RelationalOperands,
761
- "AndCondition",
762
- "ArithmeticExpression",
763
- "BooleanOperator",
764
- "RelationalOperatorOperator",
765
- "CallExpression",
766
- "CloseBrace",
767
- "Column",
768
- "Comma",
769
- "ConditionalExpression",
770
- "Divide",
771
- "Equal",
772
- "If",
773
- "Minus",
774
- "OpenBrace",
775
- "OrCondition",
776
- "ParenthesizedExpression",
777
- "Plus",
778
- "RelationalExpression",
779
- "RelationalOperator",
780
- "Times"
781
- ];
782
- var isCompleteExpression = (src) => {
783
- try {
784
- strictParser.parse(src);
785
- return true;
786
- } catch (err) {
787
- return false;
788
- }
789
- };
790
- var lastNamedChild = (node) => {
791
- let { lastChild } = node;
792
- while (lastChild && !ColumnNamedTerms.includes(lastChild.name)) {
793
- lastChild = lastChild.prevSibling;
794
- console.log(lastChild == null ? void 0 : lastChild.name);
795
- }
796
- return lastChild;
797
- };
798
- var isCompleteRelationalExpression = (node) => {
799
- if ((node == null ? void 0 : node.name) === "RelationalExpression") {
800
- const { firstChild } = node;
801
- const lastChild = lastNamedChild(node);
802
- if ((firstChild == null ? void 0 : firstChild.name) === "Column" && typeof (lastChild == null ? void 0 : lastChild.name) === "string" && RelationalOperands.includes(lastChild.name)) {
803
- return true;
804
- }
805
- }
806
- return false;
807
- };
808
-
809
- // src/column-expression-input/highlighting.ts
810
- import {
811
- HighlightStyle,
812
- syntaxHighlighting,
813
- tags
814
- } from "@vuu-ui/vuu-codemirror";
815
- var myHighlightStyle = HighlightStyle.define([
816
- { tag: tags.variableName, color: "var(--vuuFilterEditor-variableColor)" },
817
- { tag: tags.comment, color: "green", fontStyle: "italic" }
818
- ]);
819
- var vuuHighlighting = syntaxHighlighting(myHighlightStyle);
820
-
821
- // src/column-expression-input/theme.ts
822
- import { EditorView } from "@vuu-ui/vuu-codemirror";
823
- var vuuTheme = EditorView.theme(
824
- {
825
- "&": {
826
- border: "solid 1px var(--salt-container-primary-borderColor)",
827
- color: "var(--vuuFilterEditor-color)",
828
- backgroundColor: "var(--vuuFilterEditor-background)"
829
- },
830
- ".cm-content": {
831
- caretColor: "var(--vuuFilterEditor-cursorColor)"
832
- },
833
- "&.cm-focused .cm-cursor": {
834
- borderLeftColor: "var(--vuuFilterEditor-cursorColor)"
835
- },
836
- "&.cm-focused .cm-selectionBackground, ::selection": {
837
- backgroundColor: "var(--vuuFilterEditor-selectionBackground)"
838
- },
839
- ".cm-selectionBackground, ::selection": {
840
- backgroundColor: "var(--vuuFilterEditor-selectionBackground)"
841
- },
842
- ".cm-scroller": {
843
- fontFamily: "var(--vuuFilterEditor-fontFamily)"
844
- },
845
- ".cm-tooltip": {
846
- background: "var(--vuuFilterEditor-tooltipBackground)",
847
- border: "var(--vuuFilterEditor-tooltipBorder)",
848
- boxShadow: "var(--vuuFilterEditor-tooltipElevation)",
849
- "&.cm-tooltip-autocomplete > ul": {
850
- fontFamily: "var(--vuuFilterEditor-fontFamily)",
851
- fontSize: "var(--vuuFilterEditor-fontSize)",
852
- maxHeight: "240px"
853
- },
854
- "&.cm-tooltip-autocomplete > ul > li": {
855
- height: "var(--vuuFilterEditor-suggestion-height)",
856
- padding: "0 3px",
857
- lineHeight: "var(--vuuFilterEditor-suggestion-height)"
858
- },
859
- "&.cm-tooltip-autocomplete li[aria-selected]": {
860
- background: "var(--vuuFilterEditor-suggestion-selectedBackground)",
861
- color: "var(--vuuFilterEditor-suggestion-selectedColor)"
862
- },
863
- "&.cm-tooltip-autocomplete li .cm-completionDetail": {
864
- color: "var(--vuuFilterEditor-suggestion-detailColor)"
865
- }
866
- }
867
- },
868
- { dark: false }
869
- );
870
-
871
- // src/column-expression-input/useColumnAutoComplete.ts
872
- import {
873
- booleanJoinSuggestions,
874
- getNamedParentNode,
875
- getPreviousNode,
876
- getValue,
877
- syntaxTree
878
- } from "@vuu-ui/vuu-codemirror";
879
- import { useCallback as useCallback2 } from "react";
880
- var applyPrefix = (completions, prefix) => prefix ? completions.map((completion) => {
881
- var _a;
882
- return {
883
- ...completion,
884
- apply: typeof completion.apply === "function" ? completion.apply : `${prefix}${(_a = completion.apply) != null ? _a : completion.label}`
885
- };
886
- }) : completions;
887
- var isOperator = (node) => node === void 0 ? false : ["Times", "Divide", "Plus", "Minus"].includes(node.name);
888
- var getLastChild = (node, context) => {
889
- var _a;
890
- let { lastChild: childNode } = node;
891
- const { pos } = context;
892
- while (childNode) {
893
- const isBeforeCursor = childNode.from < pos;
894
- if (isBeforeCursor && ColumnNamedTerms.includes(childNode.name)) {
895
- if (childNode.name === "ParenthesizedExpression") {
896
- const expression = (_a = childNode.firstChild) == null ? void 0 : _a.nextSibling;
897
- if (expression) {
898
- childNode = expression;
899
- }
900
- }
901
- return childNode;
902
- } else {
903
- childNode = childNode.prevSibling;
904
- }
905
- }
906
- };
907
- var getFunctionName = (node, state) => {
908
- var _a;
909
- if (node.name === "ArgList") {
910
- const functionNode = node.prevSibling;
911
- if (functionNode) {
912
- return getValue(functionNode, state);
913
- }
914
- } else if (node.name === "OpenBrace") {
915
- const maybeFunction = (_a = node.parent) == null ? void 0 : _a.prevSibling;
916
- if ((maybeFunction == null ? void 0 : maybeFunction.name) === "Function") {
917
- return getValue(maybeFunction, state);
918
- }
919
- }
920
- };
921
- var getRelationalOperator = (node, state) => {
922
- if (node.name === "RelationalExpression") {
923
- const lastNode = lastNamedChild(node);
924
- if ((lastNode == null ? void 0 : lastNode.name) === "RelationalOperator") {
925
- return getValue(lastNode, state);
926
- }
927
- } else {
928
- const prevNode = node.prevSibling;
929
- if ((prevNode == null ? void 0 : prevNode.name) === "RelationalOperator") {
930
- return getValue(prevNode, state);
931
- }
932
- }
933
- };
934
- var getColumnName = (node, state) => {
935
- var _a;
936
- if (node.name === "RelationalExpression") {
937
- if (((_a = node.firstChild) == null ? void 0 : _a.name) === "Column") {
938
- return getValue(node.firstChild, state);
939
- }
940
- } else {
941
- const prevNode = node.prevSibling;
942
- if ((prevNode == null ? void 0 : prevNode.name) === "Column") {
943
- return getValue(prevNode, state);
944
- } else if ((prevNode == null ? void 0 : prevNode.name) === "RelationalOperator") {
945
- return getColumnName(prevNode, state);
946
- }
947
- }
948
- };
949
- var makeSuggestions = async (context, suggestionProvider, suggestionType, optionalArgs = {}) => {
950
- const options = await suggestionProvider.getSuggestions(
951
- suggestionType,
952
- optionalArgs
953
- );
954
- const { startsWith = "" } = optionalArgs;
955
- return { from: context.pos - startsWith.length, options };
956
- };
957
- var handleConditionalExpression = (node, context, suggestionProvider, maybeComplete, onSubmit) => {
958
- const lastChild = getLastChild(node, context);
959
- console.log(`conditional expression last child ${lastChild == null ? void 0 : lastChild.name}`);
960
- switch (lastChild == null ? void 0 : lastChild.name) {
961
- case "If":
962
- return makeSuggestions(context, suggestionProvider, "expression", {
963
- prefix: "( "
964
- });
965
- case "OpenBrace":
966
- return makeSuggestions(context, suggestionProvider, "expression");
967
- case "Condition":
968
- return makeSuggestions(context, suggestionProvider, "expression", {
969
- prefix: ", "
970
- });
971
- case "CloseBrace":
972
- if (maybeComplete) {
973
- const options = [
974
- {
975
- apply: () => {
976
- onSubmit == null ? void 0 : onSubmit();
977
- },
978
- label: "Save Expression",
979
- boost: 10
980
- }
981
- ];
982
- return { from: context.pos, options };
983
- }
984
- }
985
- };
986
- var promptToSave = (context, onSubmit) => {
987
- const options = [
988
- {
989
- apply: () => {
990
- onSubmit == null ? void 0 : onSubmit();
991
- },
992
- label: "Save Expression",
993
- boost: 10
994
- }
995
- ];
996
- return { from: context.pos, options };
997
- };
998
- var useColumnAutoComplete = (suggestionProvider, onSubmit) => {
999
- const makeSuggestions2 = useCallback2(
1000
- async (context, suggestionType, optionalArgs = {}) => {
1001
- const options = await suggestionProvider.getSuggestions(
1002
- suggestionType,
1003
- optionalArgs
1004
- );
1005
- const { startsWith = "" } = optionalArgs;
1006
- return { from: context.pos - startsWith.length, options };
1007
- },
1008
- [suggestionProvider]
1009
- );
1010
- return useCallback2(
1011
- async (context) => {
1012
- var _a, _b;
1013
- const { state, pos } = context;
1014
- const word = (_a = context.matchBefore(/\w*/)) != null ? _a : {
1015
- from: 0,
1016
- to: 0,
1017
- text: void 0
1018
- };
1019
- const tree = syntaxTree(state);
1020
- const nodeBefore = tree.resolveInner(pos, -1);
1021
- const text = state.doc.toString();
1022
- const maybeComplete = isCompleteExpression(text);
1023
- console.log({ nodeBeforeName: nodeBefore.name });
1024
- switch (nodeBefore.name) {
1025
- case "If": {
1026
- console.log(`conditional expression If`);
1027
- return makeSuggestions2(context, "expression", { prefix: "( " });
1028
- }
1029
- case "Condition":
1030
- {
1031
- const lastChild = getLastChild(nodeBefore, context);
1032
- if ((lastChild == null ? void 0 : lastChild.name) === "Column") {
1033
- const prevChild = getPreviousNode(lastChild);
1034
- if ((prevChild == null ? void 0 : prevChild.name) !== "RelationalOperator") {
1035
- return makeSuggestions2(context, "condition-operator", {
1036
- columnName: getValue(lastChild, state)
1037
- });
1038
- }
1039
- console.log(
1040
- `Condition last child Column, prev child ${prevChild == null ? void 0 : prevChild.name}`
1041
- );
1042
- } else if ((lastChild == null ? void 0 : lastChild.name) === "RelationalOperator") {
1043
- return makeSuggestions2(context, "expression");
1044
- }
1045
- console.log(`condition last child ${lastChild == null ? void 0 : lastChild.name}`);
1046
- }
1047
- break;
1048
- case "ConditionalExpression":
1049
- return handleConditionalExpression(
1050
- nodeBefore,
1051
- context,
1052
- suggestionProvider
1053
- );
1054
- case "RelationalExpression":
1055
- {
1056
- if (isCompleteRelationalExpression(nodeBefore)) {
1057
- return {
1058
- from: context.pos,
1059
- options: booleanJoinSuggestions.concat({
1060
- label: ", <truthy expression>, <falsy expression>",
1061
- apply: ", "
1062
- })
1063
- };
1064
- } else {
1065
- const operator = getRelationalOperator(nodeBefore, state);
1066
- const columnName = getColumnName(nodeBefore, state);
1067
- if (!operator) {
1068
- const options = await suggestionProvider.getSuggestions(
1069
- "condition-operator",
1070
- {
1071
- columnName
1072
- }
1073
- );
1074
- return { from: context.pos, options };
1075
- } else {
1076
- return makeSuggestions2(context, "expression");
1077
- }
1078
- }
1079
- }
1080
- break;
1081
- case "RelationalOperator":
1082
- return makeSuggestions2(context, "expression");
1083
- case "String":
1084
- {
1085
- const operator = getRelationalOperator(
1086
- nodeBefore,
1087
- state
1088
- );
1089
- const columnName = getColumnName(nodeBefore, state);
1090
- const { from, to } = nodeBefore;
1091
- if (to - from === 2 && context.pos === from + 1) {
1092
- if (columnName && operator) {
1093
- return makeSuggestions2(context, "columnValue", {
1094
- columnName,
1095
- operator,
1096
- startsWith: word.text
1097
- });
1098
- }
1099
- } else if (to - from > 2 && context.pos === to) {
1100
- return makeSuggestions2(context, "expression", {
1101
- prefix: ", "
1102
- });
1103
- }
1104
- console.log(
1105
- `we have a string, column is ${columnName} ${from} ${to}`
1106
- );
1107
- }
1108
- break;
1109
- case "ArithmeticExpression":
1110
- {
1111
- const lastChild = getLastChild(nodeBefore, context);
1112
- if ((lastChild == null ? void 0 : lastChild.name) === "Column") {
1113
- return makeSuggestions2(context, "expression");
1114
- } else if (isOperator(lastChild)) {
1115
- const operator = lastChild.name;
1116
- return makeSuggestions2(context, "column", { operator });
1117
- }
1118
- }
1119
- break;
1120
- case "OpenBrace":
1121
- {
1122
- const functionName = getFunctionName(nodeBefore, state);
1123
- return makeSuggestions2(context, "expression", { functionName });
1124
- }
1125
- break;
1126
- case "ArgList": {
1127
- const functionName = getFunctionName(nodeBefore, state);
1128
- const lastArgument = getLastChild(nodeBefore, context);
1129
- const prefix = (lastArgument == null ? void 0 : lastArgument.name) === "OpenBrace" ? void 0 : ",";
1130
- let options = await suggestionProvider.getSuggestions("expression", {
1131
- functionName
1132
- });
1133
- options = prefix ? applyPrefix(options, ", ") : options;
1134
- if ((lastArgument == null ? void 0 : lastArgument.name) !== "OpenBrace" && (lastArgument == null ? void 0 : lastArgument.name) !== "Comma") {
1135
- options = [
1136
- {
1137
- apply: ") ",
1138
- boost: 10,
1139
- label: "Done - no more arguments"
1140
- }
1141
- ].concat(options);
1142
- }
1143
- return { from: context.pos, options };
1144
- }
1145
- case "Equal":
1146
- if (text.trim() === "=") {
1147
- return makeSuggestions2(context, "expression");
1148
- }
1149
- break;
1150
- case "ParenthesizedExpression":
1151
- case "ColumnDefinitionExpression":
1152
- if (context.pos === 0) {
1153
- return makeSuggestions2(context, "expression");
1154
- } else {
1155
- const lastChild = getLastChild(nodeBefore, context);
1156
- if ((lastChild == null ? void 0 : lastChild.name) === "Column") {
1157
- if (maybeComplete) {
1158
- const options = [
1159
- {
1160
- apply: () => {
1161
- onSubmit.current();
1162
- },
1163
- label: "Save Expression",
1164
- boost: 10
1165
- }
1166
- ];
1167
- const columnName = getValue(lastChild, state);
1168
- const columnOptions = await suggestionProvider.getSuggestions("operator", {
1169
- columnName
1170
- });
1171
- return {
1172
- from: context.pos,
1173
- options: options.concat(columnOptions)
1174
- };
1175
- }
1176
- } else if ((lastChild == null ? void 0 : lastChild.name) === "CallExpression") {
1177
- if (maybeComplete) {
1178
- const options = [
1179
- {
1180
- apply: () => {
1181
- onSubmit.current();
1182
- },
1183
- label: "Save Expression",
1184
- boost: 10
1185
- }
1186
- ];
1187
- return {
1188
- from: context.pos,
1189
- options
1190
- };
1191
- }
1192
- } else if ((lastChild == null ? void 0 : lastChild.name) === "ArithmeticExpression") {
1193
- if (maybeComplete) {
1194
- let options = [
1195
- {
1196
- apply: () => {
1197
- onSubmit.current();
1198
- },
1199
- label: "Save Expression",
1200
- boost: 10
1201
- }
1202
- ];
1203
- const lastExpressionChild = getLastChild(lastChild, context);
1204
- if ((lastExpressionChild == null ? void 0 : lastExpressionChild.name) === "Column") {
1205
- const columnName = getValue(lastExpressionChild, state);
1206
- const suggestions = await suggestionProvider.getSuggestions(
1207
- "operator",
1208
- { columnName }
1209
- );
1210
- options = options.concat(suggestions);
1211
- }
1212
- return {
1213
- from: context.pos,
1214
- options
1215
- };
1216
- }
1217
- } else if ((lastChild == null ? void 0 : lastChild.name) === "ConditionalExpression") {
1218
- return handleConditionalExpression(
1219
- lastChild,
1220
- context,
1221
- suggestionProvider,
1222
- maybeComplete,
1223
- onSubmit.current
1224
- );
1225
- }
1226
- break;
1227
- }
1228
- case "Column":
1229
- {
1230
- const isPartialMatch = await suggestionProvider.isPartialMatch(
1231
- "expression",
1232
- void 0,
1233
- word.text
1234
- );
1235
- if (isPartialMatch) {
1236
- return makeSuggestions2(context, "expression", {
1237
- startsWith: word.text
1238
- });
1239
- }
1240
- }
1241
- break;
1242
- case "Comma":
1243
- {
1244
- const parentNode = getNamedParentNode(nodeBefore);
1245
- if ((parentNode == null ? void 0 : parentNode.name) === "ConditionalExpression") {
1246
- return makeSuggestions2(context, "expression");
1247
- }
1248
- }
1249
- break;
1250
- case "CloseBrace":
1251
- {
1252
- const parentNode = getNamedParentNode(nodeBefore);
1253
- if ((parentNode == null ? void 0 : parentNode.name) === "ConditionalExpression") {
1254
- return handleConditionalExpression(
1255
- parentNode,
1256
- context,
1257
- suggestionProvider,
1258
- maybeComplete,
1259
- onSubmit.current
1260
- );
1261
- } else if ((parentNode == null ? void 0 : parentNode.name) === "ArgList") {
1262
- if (maybeComplete) {
1263
- return promptToSave(context, onSubmit.current);
1264
- }
1265
- }
1266
- console.log(
1267
- `does closebrace denote an ARgList or a parenthetised expression ? ${parentNode}`
1268
- );
1269
- }
1270
- break;
1271
- default: {
1272
- if (((_b = nodeBefore == null ? void 0 : nodeBefore.prevSibling) == null ? void 0 : _b.name) === "FilterClause") {
1273
- console.log("looks like we ight be a or|and operator");
1274
- }
1275
- }
1276
- }
1277
- },
1278
- [makeSuggestions2, onSubmit, suggestionProvider]
1279
- );
1280
- };
1281
-
1282
- // src/column-expression-input/useColumnExpressionEditor.ts
1283
- var getView = (ref) => {
1284
- if (ref.current == void 0) {
1285
- throw Error("EditorView not defined");
1286
- }
1287
- return ref.current;
1288
- };
1289
- var getOptionClass = () => {
1290
- return "vuuSuggestion";
1291
- };
1292
- var noop = () => console.log("noooop");
1293
- var hasExpressionType = (completion) => "expressionType" in completion;
1294
- var injectOptionContent = (completion) => {
1295
- if (hasExpressionType(completion)) {
1296
- const div = createEl("div", "expression-type-container");
1297
- const span = createEl("span", "expression-type", completion.expressionType);
1298
- div.appendChild(span);
1299
- return div;
1300
- } else {
1301
- return null;
1302
- }
1303
- };
1304
- var useColumnExpressionEditor = ({
1305
- onChange,
1306
- onSubmitExpression,
1307
- suggestionProvider
1308
- }) => {
1309
- const editorRef = useRef2(null);
1310
- const onSubmit = useRef2(noop);
1311
- const viewRef = useRef2();
1312
- const completionFn = useColumnAutoComplete(suggestionProvider, onSubmit);
1313
- const [createState, clearInput] = useMemo(() => {
1314
- const parseExpression = () => {
1315
- const view = getView(viewRef);
1316
- const source = view.state.doc.toString();
1317
- const tree = ensureSyntaxTree(view.state, view.state.doc.length, 5e3);
1318
- if (tree) {
1319
- const expression = walkTree(tree, source);
1320
- return [source, expression];
1321
- } else {
1322
- return ["", void 0];
1323
- }
1324
- };
1325
- const clearInput2 = () => {
1326
- getView(viewRef).setState(createState2());
1327
- };
1328
- const submitExpressionAndClearInput = () => {
1329
- const [source, expression] = parseExpression();
1330
- onSubmitExpression == null ? void 0 : onSubmitExpression(source, expression);
1331
- clearInput2();
1332
- };
1333
- const submitFilter = (key) => {
1334
- return keymap.of([
1335
- {
1336
- key,
1337
- run() {
1338
- submitExpressionAndClearInput();
1339
- return true;
1340
- }
1341
- }
1342
- ]);
1343
- };
1344
- const showSuggestions = (key) => {
1345
- return keymap.of([
1346
- {
1347
- key,
1348
- run() {
1349
- startCompletion(getView(viewRef));
1350
- return true;
1351
- }
1352
- }
1353
- ]);
1354
- };
1355
- const createState2 = () => EditorState2.create({
1356
- doc: "",
1357
- extensions: [
1358
- minimalSetup,
1359
- autocompletion({
1360
- addToOptions: [
1361
- {
1362
- render: injectOptionContent,
1363
- position: 70
1364
- }
1365
- ],
1366
- override: [completionFn],
1367
- optionClass: getOptionClass
1368
- }),
1369
- columnExpressionLanguageSupport(),
1370
- keymap.of(defaultKeymap),
1371
- submitFilter("Ctrl-Enter"),
1372
- showSuggestions("ArrowDown"),
1373
- EditorView2.updateListener.of((v) => {
1374
- const view = getView(viewRef);
1375
- if (v.docChanged) {
1376
- startCompletion(view);
1377
- const source = view.state.doc.toString();
1378
- onChange == null ? void 0 : onChange(source, void 0);
1379
- }
1380
- }),
1381
- // Enforces single line view
1382
- // EditorState.transactionFilter.of((tr) =>
1383
- // tr.newDoc.lines > 1 ? [] : tr
1384
- // ),
1385
- vuuTheme,
1386
- vuuHighlighting
1387
- ]
1388
- });
1389
- onSubmit.current = () => {
1390
- submitExpressionAndClearInput();
1391
- setTimeout(() => {
1392
- getView(viewRef).focus();
1393
- }, 100);
1394
- };
1395
- return [createState2, clearInput2];
1396
- }, [completionFn, onChange, onSubmitExpression]);
1397
- useEffect2(() => {
1398
- if (!editorRef.current) {
1399
- throw Error("editor not in dom");
1400
- }
1401
- viewRef.current = new EditorView2({
1402
- state: createState(),
1403
- parent: editorRef.current
1404
- });
1405
- return () => {
1406
- var _a;
1407
- (_a = viewRef.current) == null ? void 0 : _a.destroy();
1408
- };
1409
- }, [completionFn, createState]);
1410
- return { editorRef, clearInput };
1411
- };
1412
-
1413
- // src/column-expression-input/ColumnExpressionInput.tsx
1414
- import { jsx as jsx4 } from "react/jsx-runtime";
1415
- var classBase4 = "vuuColumnExpressionInput";
1416
- var ColumnExpressionInput = ({
1417
- onChange,
1418
- onSubmitExpression,
1419
- suggestionProvider
1420
- }) => {
1421
- const { editorRef } = useColumnExpressionEditor({
1422
- onChange,
1423
- onSubmitExpression,
1424
- suggestionProvider
1425
- });
1426
- return /* @__PURE__ */ jsx4("div", { className: `${classBase4}`, ref: editorRef });
1427
- };
1428
-
1429
- // src/column-expression-input/useColumnExpressionSuggestionProvider.ts
1430
- import {
1431
- AnnotationType,
1432
- getRelationalOperators,
1433
- numericOperators,
1434
- stringOperators,
1435
- toSuggestions
1436
- } from "@vuu-ui/vuu-codemirror";
1437
- import {
1438
- getTypeaheadParams,
1439
- useTypeaheadSuggestions
1440
- } from "@vuu-ui/vuu-data-react";
1441
- import { isNumericColumn, isTextColumn } from "@vuu-ui/vuu-utils";
1442
- import { useCallback as useCallback3, useRef as useRef3 } from "react";
1443
-
1444
- // src/column-expression-input/column-function-descriptors.ts
1445
- var columnFunctionDescriptors = [
1446
- /**
1447
- * concatenate()
1448
- */
1449
- {
1450
- accepts: "string",
1451
- 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.",
1452
- example: {
1453
- expression: 'concatenate("example", "-test")',
1454
- result: '"example-test"'
1455
- },
1456
- name: "concatenate",
1457
- params: {
1458
- description: "( string, string, [ string* ] )"
1459
- },
1460
- type: "string"
1461
- },
1462
- /**
1463
- * contains()
1464
- */
1465
- {
1466
- accepts: ["string", "string"],
1467
- 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>",
1468
- example: {
1469
- expression: 'contains("Royal Bank of Scotland", "bank")',
1470
- result: "true"
1471
- },
1472
- name: "contains",
1473
- params: {
1474
- description: "( string )"
1475
- },
1476
- type: "boolean"
1477
- },
1478
- /**
1479
- * left()
1480
- */
1481
- {
1482
- accepts: ["string", "number"],
1483
- description: "Returns the leftmost <number> characters from <string>. First argument may be a string literal, string column or other string expression.",
1484
- example: {
1485
- expression: 'left("USD Benchmark Report", 3)',
1486
- result: '"USD"'
1487
- },
1488
- name: "left",
1489
- params: {
1490
- count: 2,
1491
- description: "( string, number )"
1492
- },
1493
- type: "string"
1494
- },
1495
- /**
1496
- * len()
1497
- */
1498
- {
1499
- accepts: "string",
1500
- description: "Returns the number of characters in <string>. Argument may be a string literal, string column or other string expression.",
1501
- example: {
1502
- expression: 'len("example")',
1503
- result: "7"
1504
- },
1505
- name: "len",
1506
- params: {
1507
- description: "(string)"
1508
- },
1509
- type: "number"
1510
- },
1511
- /**
1512
- * lower()
1513
- */
1514
- {
1515
- accepts: "string",
1516
- description: "Convert a string value to lowercase. Argument may be a string column or other string expression.",
1517
- example: {
1518
- expression: 'lower("examPLE")',
1519
- result: '"example"'
1520
- },
1521
- name: "lower",
1522
- params: {
1523
- description: "( string )"
1524
- },
1525
- type: "string"
1526
- },
1527
- /**
1528
- * upper()
1529
- */
1530
- {
1531
- accepts: "string",
1532
- description: "Convert a string value to uppercase. Argument may be a string column or other string expression.",
1533
- example: {
1534
- expression: 'upper("example")',
1535
- result: '"EXAMPLE"'
1536
- },
1537
- name: "upper",
1538
- params: {
1539
- description: "( string )"
1540
- },
1541
- type: "string"
1542
- },
1543
- /**
1544
- * right()
1545
- */
1546
- {
1547
- accepts: ["string", "number"],
1548
- description: "Returns the rightmost <number> characters from <string>. First argument may be a string literal, string column or other string expression.",
1549
- example: {
1550
- expression: "blah",
1551
- result: "blah"
1552
- },
1553
- name: "right",
1554
- params: {
1555
- description: "( string )"
1556
- },
1557
- type: "string"
1558
- },
1559
- /**
1560
- * replace()
1561
- */
1562
- {
1563
- accepts: ["string", "string", "string"],
1564
- 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>",
1565
- example: {
1566
- expression: "blah",
1567
- result: "blah"
1568
- },
1569
- name: "replace",
1570
- params: {
1571
- description: "( string )"
1572
- },
1573
- type: "string"
1574
- },
1575
- /**
1576
- * text()
1577
- */
1578
- {
1579
- accepts: "number",
1580
- description: "Converts a number to a string.",
1581
- example: {
1582
- expression: "blah",
1583
- result: "blah"
1584
- },
1585
- name: "text",
1586
- params: {
1587
- description: "( string )"
1588
- },
1589
- type: "string"
1590
- },
1591
- /**
1592
- * starts()
1593
- */
1594
- {
1595
- accepts: "string",
1596
- 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>.",
1597
- example: {
1598
- expression: "blah",
1599
- result: "blah"
1600
- },
1601
- name: "starts",
1602
- params: {
1603
- description: "( string )"
1604
- },
1605
- type: "boolean"
1606
- },
1607
- /**
1608
- * starts()
1609
- */
1610
- {
1611
- accepts: "string",
1612
- 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>.",
1613
- example: {
1614
- expression: "blah",
1615
- result: "blah"
1616
- },
1617
- name: "ends",
1618
- params: {
1619
- description: "( string )"
1620
- },
1621
- type: "boolean"
1622
- },
1623
- {
1624
- accepts: "number",
1625
- description: "blah",
1626
- example: {
1627
- expression: "blah",
1628
- result: "blah"
1629
- },
1630
- name: "min",
1631
- params: {
1632
- description: "( string )"
1633
- },
1634
- type: "number"
1635
- },
1636
- {
1637
- accepts: "number",
1638
- description: "blah",
1639
- example: {
1640
- expression: "blah",
1641
- result: "blah"
1642
- },
1643
- name: "max",
1644
- params: {
1645
- description: "( string )"
1646
- },
1647
- type: "number"
1648
- },
1649
- {
1650
- accepts: "number",
1651
- description: "blah",
1652
- example: {
1653
- expression: "blah",
1654
- result: "blah"
1655
- },
1656
- name: "sum",
1657
- params: {
1658
- description: "( string )"
1659
- },
1660
- type: "number"
1661
- },
1662
- {
1663
- accepts: "number",
1664
- description: "blah",
1665
- example: {
1666
- expression: "blah",
1667
- result: "blah"
1668
- },
1669
- name: "round",
1670
- params: {
1671
- description: "( string )"
1672
- },
1673
- type: "number"
1674
- },
1675
- {
1676
- accepts: "any",
1677
- description: "blah",
1678
- example: {
1679
- expression: "blah",
1680
- result: "blah"
1681
- },
1682
- name: "or",
1683
- params: {
1684
- description: "( string )"
1685
- },
1686
- type: "boolean"
1687
- },
1688
- {
1689
- accepts: "any",
1690
- description: "blah",
1691
- example: {
1692
- expression: "blah",
1693
- result: "blah"
1694
- },
1695
- name: "and",
1696
- params: {
1697
- description: "( string )"
1698
- },
1699
- type: "boolean"
1700
- },
1701
- {
1702
- accepts: "any",
1703
- 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>. ",
1704
- example: {
1705
- expression: "blah",
1706
- result: "blah"
1707
- },
1708
- name: "if",
1709
- params: {
1710
- description: "( filterExpression, expression1, expression 2)"
1711
- },
1712
- type: "variable"
1713
- }
1714
- ];
1715
-
1716
- // src/column-expression-input/functionDocInfo.ts
1717
- import { createEl as createEl2 } from "@vuu-ui/vuu-utils";
1718
- var functionDocInfo = ({
1719
- name,
1720
- description,
1721
- example,
1722
- params,
1723
- type
1724
- }) => {
1725
- const rootElement = createEl2("div", "vuuFunctionDoc");
1726
- const headingElement = createEl2("div", "function-heading");
1727
- const nameElement = createEl2("span", "function-name", name);
1728
- const paramElement = createEl2("span", "param-list", params.description);
1729
- const typeElement = createEl2("span", "function-type", type);
1730
- headingElement.appendChild(nameElement);
1731
- headingElement.appendChild(paramElement);
1732
- headingElement.appendChild(typeElement);
1733
- const child2 = createEl2("p", void 0, description);
1734
- rootElement.appendChild(headingElement);
1735
- rootElement.appendChild(child2);
1736
- if (example) {
1737
- const exampleElement = createEl2("div", "example-container", "Example:");
1738
- const expressionElement = createEl2(
1739
- "div",
1740
- "example-expression",
1741
- example.expression
1742
- );
1743
- const resultElement = createEl2("div", "example-result", example.result);
1744
- exampleElement.appendChild(expressionElement);
1745
- exampleElement.appendChild(resultElement);
1746
- rootElement.appendChild(exampleElement);
1747
- }
1748
- return rootElement;
1749
- };
1750
-
1751
- // src/column-expression-input/useColumnExpressionSuggestionProvider.ts
1752
- var NO_OPERATORS = [];
1753
- var withApplySpace = (suggestions) => suggestions.map((suggestion) => {
1754
- var _a;
1755
- return {
1756
- ...suggestion,
1757
- apply: ((_a = suggestion.apply) != null ? _a : suggestion.label) + " "
1758
- };
1759
- });
1760
- var getValidColumns = (columns, { functionName, operator }) => {
1761
- if (operator) {
1762
- return columns.filter(isNumericColumn);
1763
- } else if (functionName) {
1764
- const fn = columnFunctionDescriptors.find((f) => f.name === functionName);
1765
- if (fn) {
1766
- switch (fn.accepts) {
1767
- case "string":
1768
- return columns.filter(isTextColumn);
1769
- case "number":
1770
- return columns.filter(isNumericColumn);
1771
- default:
1772
- return columns;
1773
- }
1774
- }
1775
- }
1776
- return columns;
1777
- };
1778
- var getColumns = (columns, options) => {
1779
- const validColumns = getValidColumns(columns, options);
1780
- return validColumns.map((column) => {
1781
- var _a;
1782
- const label = (_a = column.label) != null ? _a : column.name;
1783
- return {
1784
- apply: options.prefix ? `${options.prefix}${label}` : label,
1785
- label,
1786
- boost: 5,
1787
- type: "column",
1788
- expressionType: column.serverDataType
1789
- };
1790
- });
1791
- };
1792
- var arithmeticOperators = [
1793
- { apply: "* ", boost: 2, label: "*", type: "operator" },
1794
- { apply: "/ ", boost: 2, label: "/", type: "operator" },
1795
- { apply: "+ ", boost: 2, label: "+", type: "operator" },
1796
- { apply: "- ", boost: 2, label: "-", type: "operator" }
1797
- ];
1798
- var getOperators = (column) => {
1799
- if (column === void 0 || isNumericColumn(column)) {
1800
- return arithmeticOperators;
1801
- } else {
1802
- return NO_OPERATORS;
1803
- }
1804
- };
1805
- var getConditionOperators = (column) => {
1806
- switch (column.serverDataType) {
1807
- case "string":
1808
- case "char":
1809
- return withApplySpace(
1810
- stringOperators
1811
- /*, startsWith*/
1812
- );
1813
- case "int":
1814
- case "long":
1815
- case "double":
1816
- return withApplySpace(numericOperators);
1817
- }
1818
- };
1819
- var toFunctionCompletion = (functionDescriptor) => ({
1820
- apply: `${functionDescriptor.name}( `,
1821
- boost: 2,
1822
- expressionType: functionDescriptor.type,
1823
- info: () => functionDocInfo(functionDescriptor),
1824
- label: functionDescriptor.name,
1825
- type: "function"
1826
- });
1827
- var getAcceptedTypes = (fn) => {
1828
- if (fn) {
1829
- if (typeof fn.accepts === "string") {
1830
- return fn.accepts;
1831
- } else if (Array.isArray(fn.accepts)) {
1832
- if (fn.accepts.every((s) => s === "string")) {
1833
- return "string";
1834
- } else {
1835
- return "any";
1836
- }
1837
- }
1838
- }
1839
- return "any";
1840
- };
1841
- var functions = columnFunctionDescriptors.map(toFunctionCompletion);
1842
- var getFunctions = ({ functionName }) => {
1843
- if (functionName) {
1844
- const fn = columnFunctionDescriptors.find((f) => f.name === functionName);
1845
- const acceptedTypes = getAcceptedTypes(fn);
1846
- if (fn) {
1847
- switch (acceptedTypes) {
1848
- case "string":
1849
- return columnFunctionDescriptors.filter((f) => f.type === "string" || f.type === "variable").map(toFunctionCompletion);
1850
- case "number":
1851
- return columnFunctionDescriptors.filter((f) => f.type === "number" || f.type === "variable").map(toFunctionCompletion);
1852
- default:
1853
- }
1854
- }
1855
- }
1856
- return functions;
1857
- };
1858
- var NONE = {};
1859
- var useColumnExpressionSuggestionProvider = ({
1860
- columns,
1861
- table
1862
- }) => {
1863
- const findColumn3 = useCallback3(
1864
- (name) => name ? columns.find((col) => col.name === name) : void 0,
1865
- [columns]
1866
- );
1867
- const latestSuggestionsRef = useRef3();
1868
- const getTypeaheadSuggestions = useTypeaheadSuggestions();
1869
- const getSuggestions = useCallback3(
1870
- async (suggestionType, options = NONE) => {
1871
- const { columnName, functionName, operator, prefix } = options;
1872
- switch (suggestionType) {
1873
- case "expression": {
1874
- const suggestions = await withApplySpace(
1875
- getColumns(columns, { functionName, prefix })
1876
- ).concat(getFunctions(options));
1877
- return latestSuggestionsRef.current = suggestions;
1878
- }
1879
- case "column": {
1880
- const suggestions = await getColumns(columns, options);
1881
- return latestSuggestionsRef.current = withApplySpace(suggestions);
1882
- }
1883
- case "operator": {
1884
- const suggestions = await getOperators(findColumn3(columnName));
1885
- return latestSuggestionsRef.current = withApplySpace(suggestions);
1886
- }
1887
- case "relational-operator": {
1888
- const suggestions = await getRelationalOperators(
1889
- findColumn3(columnName)
1890
- );
1891
- return latestSuggestionsRef.current = withApplySpace(suggestions);
1892
- }
1893
- case "condition-operator":
1894
- {
1895
- const column = findColumn3(columnName);
1896
- if (column) {
1897
- const suggestions = await getConditionOperators(column);
1898
- if (suggestions) {
1899
- return latestSuggestionsRef.current = withApplySpace(suggestions);
1900
- }
1901
- }
1902
- }
1903
- break;
1904
- case "columnValue":
1905
- if (columnName && operator) {
1906
- const params = getTypeaheadParams(
1907
- table,
1908
- columnName
1909
- /*, startsWith*/
1910
- );
1911
- const suggestions = await getTypeaheadSuggestions(params);
1912
- latestSuggestionsRef.current = toSuggestions(suggestions, {
1913
- suffix: ""
1914
- });
1915
- latestSuggestionsRef.current.forEach((suggestion) => {
1916
- suggestion.apply = (view, completion, from) => {
1917
- const annotation = new AnnotationType();
1918
- const cursorPos = from + completion.label.length + 1;
1919
- view.dispatch({
1920
- changes: { from, insert: completion.label },
1921
- selection: { anchor: cursorPos, head: cursorPos },
1922
- annotations: annotation.of(completion)
1923
- });
1924
- };
1925
- });
1926
- return latestSuggestionsRef.current;
1927
- }
1928
- break;
1929
- }
1930
- return [];
1931
- },
1932
- [columns, findColumn3, getTypeaheadSuggestions, table]
1933
- );
1934
- const isPartialMatch = useCallback3(
1935
- async (valueType, columnName, pattern) => {
1936
- const { current: latestSuggestions } = latestSuggestionsRef;
1937
- let maybe = false;
1938
- const suggestions = latestSuggestions || await getSuggestions(valueType, { columnName });
1939
- if (pattern && suggestions) {
1940
- for (const option of suggestions) {
1941
- if (option.label === pattern) {
1942
- return false;
1943
- } else if (option.label.startsWith(pattern)) {
1944
- maybe = true;
1945
- }
1946
- }
1947
- }
1948
- return maybe;
1949
- },
1950
- [getSuggestions]
1951
- );
1952
- return {
1953
- getSuggestions,
1954
- isPartialMatch
1955
- };
1956
- };
1957
-
1958
- // src/datagrid-configuration-ui/settings-panel/DatagridSettingsPanel.tsx
1959
- import { Button as Button2, Panel as Panel5 } from "@salt-ds/core";
1960
- import cx6 from "classnames";
1961
- import {
1962
- useCallback as useCallback8,
1963
- useState as useState3
1964
- } from "react";
1965
-
1966
- // src/datagrid-configuration-ui/column-settings-panel/ColumnSettingsPanel.tsx
1967
- import { Stack } from "@vuu-ui/vuu-layout";
1968
- import { StepperInput as StepperInput2 } from "@salt-ds/lab";
1969
- import {
1970
- Checkbox as Checkbox2,
1971
- FormField as FormField2,
1972
- FormFieldLabel as FormFieldLabel2,
1973
- Input,
1974
- Panel as Panel2,
1975
- RadioButton,
1976
- RadioButtonGroup,
1977
- Text as Text2
1978
- } from "@salt-ds/core";
1979
- import cx5 from "classnames";
1980
- import {
1981
- useCallback as useCallback5,
1982
- useState
1983
- } from "react";
1984
-
1985
- // src/datagrid-configuration-ui/column-type-panel/ColumnTypePanel.tsx
1986
- import { getRegisteredCellRenderers } from "@vuu-ui/vuu-utils";
1987
- import { Dropdown } from "@salt-ds/lab";
1988
- import { Panel } from "@salt-ds/core";
1989
- import cx4 from "classnames";
1990
- import { useMemo as useMemo2 } from "react";
1991
-
1992
- // src/datagrid-configuration-ui/column-type-panel/NumericColumnPanel.tsx
1993
- import { StepperInput, Switch as Switch2 } from "@salt-ds/lab";
1994
- import { FormField, FormFieldLabel, Text } from "@salt-ds/core";
1995
- import { useCallback as useCallback4 } from "react";
1996
- import { Fragment, jsx as jsx5, jsxs as jsxs4 } from "react/jsx-runtime";
1997
- var defaultValues = {
1998
- alignOnDecimals: false,
1999
- decimals: 4,
2000
- zeroPad: false
2001
- };
2002
- var getColumnValues = (columnType, gridDefaultValues) => {
2003
- const columnValue = typeof columnType === "object" && columnType.formatting ? columnType.formatting : {};
2004
- const properties = ["alignOnDecimals", "decimals", "zeroPad"];
2005
- return properties.reduce((configValues, property) => {
2006
- if (columnValue[property] !== void 0) {
2007
- return {
2008
- ...configValues,
2009
- [property]: columnValue[property]
2010
- };
2011
- } else if ((gridDefaultValues == null ? void 0 : gridDefaultValues[property]) !== void 0) {
2012
- return {
2013
- ...configValues,
2014
- [property]: gridDefaultValues[property]
2015
- };
2016
- }
2017
- return configValues;
2018
- }, defaultValues);
2019
- };
2020
- var NumericColumnPanel = ({
2021
- column,
2022
- dispatchColumnAction
2023
- }) => {
2024
- const { decimals, alignOnDecimals, zeroPad } = getColumnValues(column == null ? void 0 : column.type);
2025
- const dispatchUpdate = useCallback4(
2026
- (values) => dispatchColumnAction({
2027
- type: "updateColumnTypeFormatting",
2028
- column,
2029
- ...values
2030
- }),
2031
- [column, dispatchColumnAction]
2032
- );
2033
- const handleChangeDecimals = useCallback4(
2034
- (value) => dispatchUpdate({ decimals: parseInt(value.toString(), 10) }),
2035
- [dispatchUpdate]
2036
- );
2037
- const handleChangeAlignOnDecimals = useCallback4(
2038
- (evt) => dispatchUpdate({ alignOnDecimals: Boolean(evt.target.value) }),
2039
- [dispatchUpdate]
2040
- );
2041
- const handleChangeZeroPad = useCallback4(
2042
- (evt) => dispatchUpdate({ zeroPad: Boolean(evt.target.value) }),
2043
- [dispatchUpdate]
2044
- );
2045
- switch (column.serverDataType) {
2046
- case "double":
2047
- return /* @__PURE__ */ jsxs4(Fragment, { children: [
2048
- /* @__PURE__ */ jsxs4(FormField, { labelPlacement: "top", children: [
2049
- /* @__PURE__ */ jsx5(FormFieldLabel, { children: "No of Decimals" }),
2050
- /* @__PURE__ */ jsx5(StepperInput, { value: decimals, onChange: handleChangeDecimals })
2051
- ] }),
2052
- /* @__PURE__ */ jsx5(
2053
- Switch2,
2054
- {
2055
- checked: alignOnDecimals,
2056
- label: "Align on decimals",
2057
- onChange: handleChangeAlignOnDecimals
2058
- }
2059
- ),
2060
- /* @__PURE__ */ jsx5(
2061
- Switch2,
2062
- {
2063
- checked: zeroPad,
2064
- label: "Zero pad",
2065
- onChange: handleChangeZeroPad
2066
- }
2067
- )
2068
- ] });
2069
- case "long":
2070
- case "int":
2071
- return /* @__PURE__ */ jsx5(Fragment, { children: /* @__PURE__ */ jsx5(Text, { children: "Work in progress" }) });
2072
- default:
2073
- return null;
2074
- }
2075
- };
2076
-
2077
- // src/datagrid-configuration-ui/column-type-panel/StringColumnPanel.tsx
2078
- import { Fragment as Fragment2, jsx as jsx6 } from "react/jsx-runtime";
2079
- var StringColumnPanel = ({
2080
- column,
2081
- dispatchColumnAction
2082
- }) => {
2083
- console.log({ column, dispatchColumnAction });
2084
- return /* @__PURE__ */ jsx6(Fragment2, { children: "what" });
2085
- };
2086
-
2087
- // src/datagrid-configuration-ui/column-type-panel/ColumnTypePanel.tsx
2088
- import { Fragment as Fragment3, jsx as jsx7, jsxs as jsxs5 } from "react/jsx-runtime";
2089
- var classBase5 = "vuuColumnTypePanel";
2090
- var integerCellRenderers = ["Default Renderer (int, long)"];
2091
- var doubleCellRenderers = ["Default Renderer (double)"];
2092
- var stringCellRenderers = ["Default Renderer (string)"];
2093
- var getAvailableCellRenderers = (column) => {
2094
- const customCellRenderers = getRegisteredCellRenderers(column.serverDataType);
2095
- const customRendererNames = customCellRenderers.map((r) => r.name);
2096
- console.log({ customRendererNames });
2097
- switch (column.serverDataType) {
2098
- case "char":
2099
- case "string":
2100
- return stringCellRenderers;
2101
- case "int":
2102
- case "long":
2103
- return integerCellRenderers;
2104
- case "double":
2105
- return doubleCellRenderers.concat(customRendererNames);
2106
- default:
2107
- return stringCellRenderers;
2108
- }
2109
- };
2110
- var ColumnTypePanel = ({
2111
- className,
2112
- column,
2113
- dispatchColumnAction,
2114
- ...props
2115
- }) => {
2116
- const content = useMemo2(() => {
2117
- switch (column.serverDataType) {
2118
- case "double":
2119
- case "int":
2120
- case "long":
2121
- return /* @__PURE__ */ jsx7(
2122
- NumericColumnPanel,
2123
- {
2124
- column,
2125
- dispatchColumnAction
2126
- }
2127
- );
2128
- default:
2129
- return /* @__PURE__ */ jsx7(
2130
- StringColumnPanel,
2131
- {
2132
- column,
2133
- dispatchColumnAction
2134
- }
2135
- );
2136
- }
2137
- }, [column, dispatchColumnAction]);
2138
- const { serverDataType = "string" } = column;
2139
- const availableRenderers = getAvailableCellRenderers(column);
2140
- return /* @__PURE__ */ jsxs5(Fragment3, { children: [
2141
- /* @__PURE__ */ jsx7(
2142
- Dropdown,
2143
- {
2144
- className: cx4(`${classBase5}-renderer`),
2145
- fullWidth: true,
2146
- selected: availableRenderers[0],
2147
- source: availableRenderers
2148
- }
2149
- ),
2150
- /* @__PURE__ */ jsx7(
2151
- Panel,
2152
- {
2153
- ...props,
2154
- className: cx4(classBase5, className, `${classBase5}-${serverDataType}`),
2155
- children: content
2156
- }
2157
- )
2158
- ] });
2159
- };
2160
-
2161
- // src/datagrid-configuration-ui/column-settings-panel/ColumnSettingsPanel.tsx
2162
- import { jsx as jsx8, jsxs as jsxs6 } from "react/jsx-runtime";
2163
- var classBase6 = "vuuColumnSettingsPanel";
2164
- var tabstripProps = {
2165
- className: "salt-density-high"
2166
- };
2167
- var ColumnSettingsPanel = ({
2168
- column,
2169
- dispatchColumnAction,
2170
- style: styleProp,
2171
- ...props
2172
- }) => {
2173
- var _a, _b, _c, _d;
2174
- const [activeTab, setActiveTab] = useState(0);
2175
- const dispatchUpdate = useCallback5(
2176
- (values) => dispatchColumnAction({
2177
- type: "updateColumnProp",
2178
- column,
2179
- ...values
2180
- }),
2181
- [column, dispatchColumnAction]
2182
- );
2183
- const handleChangeAlign = useCallback5(
2184
- (evt) => dispatchUpdate({ align: evt.target.value }),
2185
- [dispatchUpdate]
2186
- );
2187
- const handleChangePin = useCallback5(
2188
- (evt) => dispatchUpdate({ pin: evt.target.value }),
2189
- [dispatchUpdate]
2190
- );
2191
- const handleChangeHidden = useCallback5(
2192
- (evt) => dispatchUpdate({ hidden: evt.target.checked }),
2193
- [dispatchUpdate]
2194
- );
2195
- const handleChangeLabel = useCallback5(
2196
- (evt) => dispatchUpdate({ label: evt.target.value }),
2197
- [dispatchUpdate]
2198
- );
2199
- const handleChangeWidth = useCallback5(
2200
- (value) => dispatchUpdate({ width: parseInt(value.toString(), 10) }),
2201
- [dispatchUpdate]
2202
- );
2203
- return /* @__PURE__ */ jsxs6(
2204
- "div",
2205
- {
2206
- className: classBase6,
2207
- ...props,
2208
- style: {
2209
- ...styleProp
2210
- },
2211
- children: [
2212
- /* @__PURE__ */ jsx8(Text2, { as: "h4", children: "Column Settings" }),
2213
- /* @__PURE__ */ jsxs6(
2214
- Stack,
2215
- {
2216
- active: activeTab,
2217
- className: cx5(`${classBase6}-columnTabs`),
2218
- onTabSelectionChanged: setActiveTab,
2219
- TabstripProps: tabstripProps,
2220
- children: [
2221
- /* @__PURE__ */ jsxs6(Panel2, { title: "Column", children: [
2222
- /* @__PURE__ */ jsxs6(FormField2, { labelPlacement: "left", children: [
2223
- /* @__PURE__ */ jsx8(FormFieldLabel2, { children: "Hidden" }),
2224
- /* @__PURE__ */ jsx8(
2225
- Checkbox2,
2226
- {
2227
- checked: column.hidden === true,
2228
- onChange: handleChangeHidden
2229
- }
2230
- )
2231
- ] }),
2232
- /* @__PURE__ */ jsxs6(FormField2, { labelPlacement: "left", children: [
2233
- /* @__PURE__ */ jsx8(FormFieldLabel2, { children: "Label" }),
2234
- /* @__PURE__ */ jsx8(
2235
- Input,
2236
- {
2237
- value: (_a = column.label) != null ? _a : column.name,
2238
- onChange: handleChangeLabel
2239
- }
2240
- )
2241
- ] }),
2242
- /* @__PURE__ */ jsxs6(FormField2, { labelPlacement: "left", children: [
2243
- /* @__PURE__ */ jsx8(FormFieldLabel2, { children: "Width" }),
2244
- /* @__PURE__ */ jsx8(
2245
- StepperInput2,
2246
- {
2247
- value: (_b = column.width) != null ? _b : 100,
2248
- onChange: handleChangeWidth
2249
- }
2250
- )
2251
- ] }),
2252
- /* @__PURE__ */ jsxs6(FormField2, { labelPlacement: "left", children: [
2253
- /* @__PURE__ */ jsx8(FormFieldLabel2, { children: "ALign" }),
2254
- /* @__PURE__ */ jsxs6(
2255
- RadioButtonGroup,
2256
- {
2257
- "aria-label": "Column Align",
2258
- value: (_c = column.align) != null ? _c : "left",
2259
- onChange: handleChangeAlign,
2260
- children: [
2261
- /* @__PURE__ */ jsx8(RadioButton, { label: "Left", value: "left" }),
2262
- /* @__PURE__ */ jsx8(RadioButton, { label: "Right", value: "right" })
2263
- ]
2264
- }
2265
- )
2266
- ] }),
2267
- /* @__PURE__ */ jsxs6(FormField2, { labelPlacement: "left", children: [
2268
- /* @__PURE__ */ jsx8(FormFieldLabel2, { children: "Pin Column" }),
2269
- /* @__PURE__ */ jsxs6(
2270
- RadioButtonGroup,
2271
- {
2272
- "aria-label": "Pin Column",
2273
- value: (_d = column.pin) != null ? _d : "",
2274
- onChange: handleChangePin,
2275
- children: [
2276
- /* @__PURE__ */ jsx8(RadioButton, { label: "Do not pin", value: "" }),
2277
- /* @__PURE__ */ jsx8(RadioButton, { label: "Left", value: "left" }),
2278
- /* @__PURE__ */ jsx8(RadioButton, { label: "Right", value: "right" })
2279
- ]
2280
- }
2281
- )
2282
- ] })
2283
- ] }),
2284
- /* @__PURE__ */ jsx8(
2285
- ColumnTypePanel,
2286
- {
2287
- column,
2288
- dispatchColumnAction,
2289
- title: "Data Cell"
2290
- }
2291
- ),
2292
- /* @__PURE__ */ jsxs6(Panel2, { title: "Vuu", variant: "secondary", children: [
2293
- /* @__PURE__ */ jsxs6(FormField2, { labelPlacement: "top", readOnly: true, children: [
2294
- /* @__PURE__ */ jsx8(FormFieldLabel2, { children: "Name" }),
2295
- /* @__PURE__ */ jsx8(Input, { value: column.name })
2296
- ] }),
2297
- /* @__PURE__ */ jsxs6(FormField2, { labelPlacement: "top", readOnly: true, children: [
2298
- /* @__PURE__ */ jsx8(FormFieldLabel2, { children: "Vuu Type" }),
2299
- /* @__PURE__ */ jsx8(Input, { value: column.serverDataType })
2300
- ] })
2301
- ] })
2302
- ]
2303
- }
2304
- )
2305
- ]
2306
- }
2307
- );
2308
- };
2309
-
2310
- // src/datagrid-configuration-ui/settings-panel/GridSettingsPanel.tsx
2311
- import {
2312
- FormField as FormField3,
2313
- FormFieldLabel as FormFieldLabel3,
2314
- Panel as Panel3,
2315
- RadioButton as RadioButton2,
2316
- RadioButtonGroup as RadioButtonGroup2,
2317
- Text as Text3
2318
- } from "@salt-ds/core";
2319
- import { StepperInput as StepperInput3 } from "@salt-ds/lab";
2320
- import { useCallback as useCallback6 } from "react";
2321
- import { jsx as jsx9, jsxs as jsxs7 } from "react/jsx-runtime";
2322
- var classBase7 = "vuuGridSettingsPanel";
2323
- var GridSettingsPanel = ({
2324
- config,
2325
- dispatchColumnAction,
2326
- style: styleProp,
2327
- ...props
2328
- }) => {
2329
- var _a;
2330
- const dispatchUpdate = useCallback6(
2331
- (values) => dispatchColumnAction({
2332
- type: "updateGridSettings",
2333
- ...values
2334
- }),
2335
- [dispatchColumnAction]
2336
- );
2337
- const handleChangeLabelFormatting = useCallback6(
2338
- (evt) => dispatchUpdate({
2339
- columnFormatHeader: evt.target.value
2340
- }),
2341
- [dispatchUpdate]
2342
- );
2343
- const handleChangeWidth = useCallback6(
2344
- (value) => dispatchUpdate({ columnDefaultWidth: parseInt(value.toString(), 10) }),
2345
- [dispatchUpdate]
2346
- );
2347
- return /* @__PURE__ */ jsxs7(
2348
- "div",
2349
- {
2350
- className: classBase7,
2351
- ...props,
2352
- style: {
2353
- ...styleProp
2354
- },
2355
- children: [
2356
- /* @__PURE__ */ jsx9(Text3, { as: "h4", children: "Grid Settings" }),
2357
- /* @__PURE__ */ jsxs7(Panel3, { children: [
2358
- /* @__PURE__ */ jsxs7(FormField3, { labelPlacement: "left", children: [
2359
- /* @__PURE__ */ jsx9(FormFieldLabel3, { children: "Format column labels" }),
2360
- /* @__PURE__ */ jsxs7(
2361
- RadioButtonGroup2,
2362
- {
2363
- "aria-label": "Format column labels",
2364
- value: config.columnFormatHeader,
2365
- onChange: handleChangeLabelFormatting,
2366
- children: [
2367
- /* @__PURE__ */ jsx9(RadioButton2, { label: "No Formatting", value: void 0 }),
2368
- /* @__PURE__ */ jsx9(RadioButton2, { label: "Capitalize", value: "capitalize" }),
2369
- /* @__PURE__ */ jsx9(RadioButton2, { label: "Uppercase", value: "uppercase" })
2370
- ]
2371
- }
2372
- )
2373
- ] }),
2374
- /* @__PURE__ */ jsxs7(FormField3, { labelPlacement: "left", children: [
2375
- /* @__PURE__ */ jsx9(FormFieldLabel3, { children: "Default Column Width" }),
2376
- /* @__PURE__ */ jsx9(
2377
- StepperInput3,
2378
- {
2379
- value: (_a = config.columnDefaultWidth) != null ? _a : 100,
2380
- onChange: handleChangeWidth
2381
- }
2382
- )
2383
- ] })
2384
- ] })
2385
- ]
2386
- }
2387
- );
2388
- };
2389
-
2390
- // src/datagrid-configuration-ui/settings-panel/useGridSettings.ts
2391
- import { useReducer } from "react";
2392
- import { moveItem } from "@vuu-ui/vuu-ui-controls";
2393
- import { fromServerDataType } from "@vuu-ui/vuu-utils";
2394
- var gridSettingsReducer = (state, action) => {
2395
- console.log(`gridSettingsReducer ${action.type}`);
2396
- switch (action.type) {
2397
- case "addColumn":
2398
- return addColumn(state, action);
2399
- case "addCalculatedColumn":
2400
- return addCalculatedColumn(state, action);
2401
- case "moveColumn":
2402
- return moveColumn(state, action);
2403
- case "removeColumn":
2404
- return removeColumn(state, action);
2405
- case "updateColumn":
2406
- return state;
2407
- case "updateColumnProp":
2408
- return updateColumnProp(state, action);
2409
- case "updateGridSettings":
2410
- return updateGridSettings(state, action);
2411
- case "updateColumnTypeFormatting":
2412
- return updateColumnTypeFormatting(state, action);
2413
- default:
2414
- return state;
2415
- }
2416
- };
2417
- var useGridSettings = (config) => {
2418
- const [state, dispatchColumnAction] = useReducer(
2419
- gridSettingsReducer,
2420
- config
2421
- );
2422
- return {
2423
- gridSettings: state,
2424
- dispatchColumnAction
2425
- };
2426
- };
2427
- function addColumn(state, { column, columns, index = -1 }) {
2428
- const { columns: stateColumns } = state;
2429
- if (index === -1) {
2430
- if (Array.isArray(columns)) {
2431
- return { ...state, columns: stateColumns.concat(columns) };
2432
- } else if (column) {
2433
- return { ...state, columns: stateColumns.concat(column) };
2434
- }
2435
- }
2436
- return state;
2437
- }
2438
- function addCalculatedColumn(state, { columnName, columnType, expression }) {
2439
- const { columns: stateColumns } = state;
2440
- const calculatedColumn = {
2441
- name: columnName,
2442
- expression,
2443
- serverDataType: columnType
2444
- };
2445
- return { ...state, columns: stateColumns.concat(calculatedColumn) };
2446
- }
2447
- function removeColumn(state, { column }) {
2448
- const { columns: stateColumns } = state;
2449
- return {
2450
- ...state,
2451
- columns: stateColumns.filter((col) => col.name !== column.name)
2452
- };
2453
- }
2454
- function moveColumn(state, { column, moveBy, moveFrom, moveTo }) {
2455
- const { columns: stateColumns } = state;
2456
- if (column && typeof moveBy === "number") {
2457
- const idx = stateColumns.indexOf(column);
2458
- const newColumns = stateColumns.slice();
2459
- const [movedColumns] = newColumns.splice(idx, 1);
2460
- newColumns.splice(idx + moveBy, 0, movedColumns);
2461
- return {
2462
- ...state,
2463
- columns: newColumns
2464
- };
2465
- } else if (typeof moveFrom === "number" && typeof moveTo === "number") {
2466
- return {
2467
- ...state,
2468
- columns: moveItem(stateColumns, moveFrom, moveTo)
2469
- };
2470
- } else {
2471
- return state;
2472
- }
2473
- }
2474
- function updateColumnProp(state, { align, column, hidden, label, width }) {
2475
- let { columns: stateColumns } = state;
2476
- if (align === "left" || align === "right") {
2477
- stateColumns = replaceColumn(stateColumns, { ...column, align });
2478
- }
2479
- if (typeof hidden === "boolean") {
2480
- stateColumns = replaceColumn(stateColumns, { ...column, hidden });
2481
- }
2482
- if (typeof label === "string") {
2483
- stateColumns = replaceColumn(stateColumns, { ...column, label });
2484
- }
2485
- if (typeof width === "number") {
2486
- stateColumns = replaceColumn(stateColumns, { ...column, width });
2487
- }
2488
- return {
2489
- ...state,
2490
- columns: stateColumns
2491
- };
2492
- }
2493
- function updateGridSettings(state, { columnFormatHeader }) {
2494
- return {
2495
- ...state,
2496
- columnFormatHeader: columnFormatHeader != null ? columnFormatHeader : state.columnFormatHeader
2497
- };
2498
- }
2499
- function updateColumnTypeFormatting(state, {
2500
- alignOnDecimals,
2501
- column,
2502
- decimals,
2503
- zeroPad
2504
- }) {
2505
- const { columns: stateColumns } = state;
2506
- const targetColumn = stateColumns.find((col) => col.name === column.name);
2507
- if (targetColumn) {
2508
- const {
2509
- serverDataType = "string",
2510
- type: columnType = fromServerDataType(serverDataType)
2511
- } = column;
2512
- const type = typeof columnType === "string" ? {
2513
- name: columnType
2514
- } : {
2515
- ...columnType
2516
- };
2517
- if (typeof alignOnDecimals === "boolean") {
2518
- type.formatting = {
2519
- ...type.formatting,
2520
- alignOnDecimals
2521
- };
2522
- }
2523
- if (typeof decimals === "number") {
2524
- type.formatting = {
2525
- ...type.formatting,
2526
- decimals
2527
- };
2528
- }
2529
- if (typeof zeroPad === "boolean") {
2530
- type.formatting = {
2531
- ...type.formatting,
2532
- zeroPad
2533
- };
2534
- }
2535
- return {
2536
- ...state,
2537
- columns: replaceColumn(stateColumns, { ...column, type })
2538
- };
2539
- } else {
2540
- return state;
2541
- }
2542
- }
2543
- function replaceColumn(columns, column) {
2544
- return columns.map((col) => col.name === column.name ? column : col);
2545
- }
2546
-
2547
- // src/datagrid-configuration-ui/settings-panel/DatagridSettingsPanel.tsx
2548
- import { Stack as Stack2 } from "@vuu-ui/vuu-layout";
2549
-
2550
- // src/datagrid-configuration-ui/calculated-column-panel/CalculatedColumnPanel.tsx
2551
- import {
2552
- Button,
2553
- FormField as FormField4,
2554
- FormFieldLabel as FormFieldLabel4,
2555
- Input as Input2,
2556
- Panel as Panel4,
2557
- Text as Text4
2558
- } from "@salt-ds/core";
2559
- import {
2560
- useCallback as useCallback7,
2561
- useRef as useRef4,
2562
- useState as useState2
2563
- } from "react";
2564
- import { jsx as jsx10, jsxs as jsxs8 } from "react/jsx-runtime";
2565
- var CalculatedColumnPanel = ({
2566
- columns,
2567
- dispatchColumnAction,
2568
- table
2569
- }) => {
2570
- const [columnName, setColumnName] = useState2("");
2571
- const [, setExpression] = useState2();
2572
- const sourceRef = useRef4("");
2573
- const suggestionProvider = useColumnExpressionSuggestionProvider({
2574
- columns,
2575
- table
2576
- });
2577
- const handleChangeName = useCallback7(
2578
- (evt) => {
2579
- const { value } = evt.target;
2580
- setColumnName(value);
2581
- },
2582
- []
2583
- );
2584
- const handleChangeExpression = useCallback7((source) => {
2585
- sourceRef.current = source;
2586
- }, []);
2587
- const handleSubmitExpression = useCallback7(
2588
- (source, expression) => {
2589
- console.log({ source });
2590
- setExpression(expression);
2591
- },
2592
- []
2593
- );
2594
- const handleSave = useCallback7(() => {
2595
- if (sourceRef.current) {
2596
- console.log(
2597
- `save expression ${JSON.stringify(sourceRef.current, null, 2)}`
2598
- );
2599
- dispatchColumnAction({
2600
- type: "addCalculatedColumn",
2601
- columnName,
2602
- expression: sourceRef.current,
2603
- columnType: "string"
2604
- });
2605
- }
2606
- }, [columnName, dispatchColumnAction]);
2607
- return /* @__PURE__ */ jsxs8(Panel4, { className: "vuuCalculatedColumnPanel", title: "Define Computed Column", children: [
2608
- /* @__PURE__ */ jsx10(Text4, { styleAs: "h4", children: "Define Computed Column" }),
2609
- /* @__PURE__ */ jsxs8(FormField4, { labelPlacement: "left", children: [
2610
- /* @__PURE__ */ jsx10(FormFieldLabel4, { children: "Column Name" }),
2611
- /* @__PURE__ */ jsx10(Input2, { value: columnName, onChange: handleChangeName })
2612
- ] }),
2613
- /* @__PURE__ */ jsx10(
2614
- ColumnExpressionInput,
2615
- {
2616
- onChange: handleChangeExpression,
2617
- onSubmitExpression: handleSubmitExpression,
2618
- suggestionProvider
2619
- }
2620
- ),
2621
- /* @__PURE__ */ jsx10("div", { style: { marginTop: 12 }, children: /* @__PURE__ */ jsx10(Button, { onClick: handleSave, children: "Add Column" }) })
2622
- ] });
2623
- };
2624
-
2625
- // src/datagrid-configuration-ui/settings-panel/DatagridSettingsPanel.tsx
2626
- import { jsx as jsx11, jsxs as jsxs9 } from "react/jsx-runtime";
2627
- var classBase8 = "vuuDatagridSettingsPanel";
2628
- var getTabLabel = () => void 0;
2629
- var icons = [
2630
- "table-settings",
2631
- "column-chooser",
2632
- "column-settings",
2633
- "define-column"
2634
- ];
2635
- var getTabIcon = (component, tabIndex) => icons[tabIndex];
2636
- var DatagridSettingsPanel = ({
2637
- availableColumns,
2638
- className,
2639
- gridConfig,
2640
- onCancel,
2641
- onConfigChange,
2642
- ...props
2643
- }) => {
2644
- var _a;
2645
- console.log(`DatagridSettingsPanel render`);
2646
- const [selectedTabIndex, setSelectedTabIndex] = useState3(0);
2647
- const { gridSettings, dispatchColumnAction } = useGridSettings(gridConfig);
2648
- const [selectedColumnName, setSelectedColumnName] = useState3(
2649
- null
2650
- );
2651
- const handleColumnSelected = useCallback8(
2652
- (selected) => {
2653
- setSelectedColumnName(selected ? selected.name : null);
2654
- },
2655
- []
2656
- );
2657
- const handleApply = useCallback8(
2658
- (evt, closePanel = false) => {
2659
- console.log(`1) DataGridSettingsPanel fire onConfigChange`);
2660
- onConfigChange == null ? void 0 : onConfigChange(gridSettings, closePanel);
2661
- },
2662
- [gridSettings, onConfigChange]
2663
- );
2664
- const handleTabSelectionChanged = useCallback8((selectedTabIndex2) => {
2665
- setSelectedTabIndex(selectedTabIndex2);
2666
- }, []);
2667
- const handleSave = useCallback8(
2668
- (evt) => handleApply(evt, true),
2669
- [handleApply]
2670
- );
2671
- const selectedColumn = selectedColumnName === null ? null : (_a = gridSettings.columns.find((col) => col.name === selectedColumnName)) != null ? _a : null;
2672
- const tabstripProps2 = {
2673
- activeTabIndex: selectedTabIndex,
2674
- allowRenameTab: false,
2675
- orientation: "vertical"
2676
- };
2677
- const handleAddCalculatedColumn = useCallback8(
2678
- () => setSelectedTabIndex(3),
2679
- []
2680
- );
2681
- const panelShift = selectedTabIndex === 2 ? "right" : void 0;
2682
- return /* @__PURE__ */ jsxs9("div", { ...props, className: cx6(classBase8, className), children: [
2683
- /* @__PURE__ */ jsxs9(
2684
- Stack2,
2685
- {
2686
- TabstripProps: tabstripProps2,
2687
- className: `${classBase8}-stack`,
2688
- getTabIcon,
2689
- getTabLabel,
2690
- active: selectedTabIndex === 2 ? 1 : selectedTabIndex,
2691
- onTabSelectionChanged: handleTabSelectionChanged,
2692
- children: [
2693
- /* @__PURE__ */ jsx11(
2694
- GridSettingsPanel,
2695
- {
2696
- config: gridSettings,
2697
- dispatchColumnAction
2698
- }
2699
- ),
2700
- /* @__PURE__ */ jsx11("div", { className: `${classBase8}-columnPanels`, "data-align": panelShift, children: selectedColumn === null ? /* @__PURE__ */ jsx11(Panel5, { className: "vuuColumnSettingsPanel", children: "Select a column" }) : /* @__PURE__ */ jsx11(
2701
- ColumnSettingsPanel,
2702
- {
2703
- column: selectedColumn,
2704
- dispatchColumnAction,
2705
- style: { background: "white", flex: "1 0 150px" }
2706
- }
2707
- ) }),
2708
- /* @__PURE__ */ jsx11("div", { title: "Column Settings", children: "Column Settings" }),
2709
- /* @__PURE__ */ jsx11(
2710
- CalculatedColumnPanel,
2711
- {
2712
- columns: gridSettings.columns,
2713
- dispatchColumnAction,
2714
- table: { module: "SIMUL", table: "instruments" }
2715
- }
2716
- )
2717
- ]
2718
- }
2719
- ),
2720
- /* @__PURE__ */ jsxs9("div", { className: `${classBase8}-buttonBar`, children: [
2721
- /* @__PURE__ */ jsx11(Button2, { onClick: onCancel, children: "Cancel" }),
2722
- /* @__PURE__ */ jsx11(Button2, { onClick: handleApply, children: "Apply" }),
2723
- /* @__PURE__ */ jsx11(Button2, { onClick: handleSave, children: "Save" })
2724
- ] })
2725
- ] });
2726
- };
2727
-
2728
- // src/datasource-stats/DatasourceStats.tsx
2729
- import { useEffect as useEffect3, useState as useState4 } from "react";
2730
- import cx7 from "classnames";
2731
- import { jsx as jsx12, jsxs as jsxs10 } from "react/jsx-runtime";
2732
- var classBase9 = "vuuDatasourceStats";
2733
- var numberFormatter = new Intl.NumberFormat();
2734
- var DataSourceStats = ({
2735
- className: classNameProp,
2736
- dataSource
2737
- }) => {
2738
- const [range, setRange] = useState4(dataSource.range);
2739
- const [size, setSize] = useState4(dataSource.size);
2740
- useEffect3(() => {
2741
- setSize(dataSource.size);
2742
- dataSource.on("resize", setSize);
2743
- dataSource.on("range", setRange);
2744
- }, [dataSource]);
2745
- const className = cx7(classBase9, classNameProp);
2746
- const from = numberFormatter.format(range.from);
2747
- const to = numberFormatter.format(range.to - 1);
2748
- const value = numberFormatter.format(size);
2749
- return /* @__PURE__ */ jsxs10("div", { className, children: [
2750
- /* @__PURE__ */ jsx12("span", { children: "Showing rows" }),
2751
- /* @__PURE__ */ jsx12("span", { className: `${classBase9}-range`, children: from }),
2752
- /* @__PURE__ */ jsx12("span", { className: `${classBase9}-range`, children: to }),
2753
- /* @__PURE__ */ jsx12("span", { children: "of" }),
2754
- /* @__PURE__ */ jsx12("span", { className: `${classBase9}-size`, children: value })
2755
- ] });
2756
- };
2757
-
2758
- // src/table-settings/TableSettingsPanel.tsx
2759
- import {
2760
- FormField as FormField5,
2761
- FormFieldLabel as FormFieldLabel5,
2762
- Input as Input3,
2763
- ToggleButton,
2764
- ToggleButtonGroup
2765
- } from "@salt-ds/core";
2766
-
2767
- // src/table-settings/useTableSettings.ts
2768
- import { useLayoutEffectSkipFirst as useLayoutEffectSkipFirst2 } from "@vuu-ui/vuu-layout";
2769
-
2770
- // ../vuu-table/src/table/ColumnResizer.tsx
2771
- import { useCallback as useCallback9, useRef as useRef5 } from "react";
2772
- import { jsx as jsx13 } from "react/jsx-runtime";
2773
-
2774
- // ../vuu-table/src/table/context-menu/buildContextMenuDescriptors.ts
2775
- import { isNumericColumn as isNumericColumn2 } from "@vuu-ui/vuu-utils";
2776
-
2777
- // ../vuu-table/src/table/context-menu/useTableContextMenu.ts
2778
- import { removeColumnFromFilter } from "@vuu-ui/vuu-utils";
2779
- import {
2780
- addGroupColumn,
2781
- addSortColumn,
2782
- AggregationType,
2783
- setAggregations,
2784
- setSortColumn
2785
- } from "@vuu-ui/vuu-utils";
2786
- var { Average, Count, Distinct, High, Low, Sum } = AggregationType;
2787
-
2788
- // ../vuu-table/src/table/Table.tsx
2789
- import { ContextMenuProvider } from "@vuu-ui/vuu-popups";
2790
- import { Button as Button3, useIdMemo } from "@salt-ds/core";
2791
-
2792
- // ../vuu-table/src/table/RowBasedTable.tsx
2793
- import {
2794
- buildColumnMap,
2795
- getColumnStyle as getColumnStyle3,
2796
- isGroupColumn as isGroupColumn2,
2797
- metadataKeys as metadataKeys5,
2798
- notHidden as notHidden2,
2799
- visibleColumnAtIndex
2800
- } from "@vuu-ui/vuu-utils";
2801
- import { useCallback as useCallback16, useMemo as useMemo3 } from "react";
2802
-
2803
- // ../vuu-table/src/table/TableRow.tsx
2804
- import {
2805
- isGroupColumn,
2806
- isJsonColumn,
2807
- isJsonGroup,
2808
- metadataKeys as metadataKeys4,
2809
- notHidden
2810
- } from "@vuu-ui/vuu-utils";
2811
- import cx9 from "classnames";
2812
- import { memo as memo2, useCallback as useCallback12 } from "react";
2813
-
2814
- // ../vuu-table/src/table/TableCell.tsx
2815
- import { getColumnStyle, metadataKeys as metadataKeys2 } from "@vuu-ui/vuu-utils";
2816
- import { EditableLabel } from "@vuu-ui/vuu-ui-controls";
2817
- import cx8 from "classnames";
2818
- import {
2819
- memo,
2820
- useCallback as useCallback10,
2821
- useRef as useRef6,
2822
- useState as useState5
2823
- } from "react";
2824
- import { jsx as jsx14 } from "react/jsx-runtime";
2825
- var { KEY: KEY2 } = metadataKeys2;
2826
- var TableCell = memo(
2827
- ({
2828
- className: classNameProp,
2829
- column,
2830
- columnMap,
2831
- onClick,
2832
- row
2833
- }) => {
2834
- const labelFieldRef = useRef6(null);
2835
- const {
2836
- align,
2837
- CellRenderer,
2838
- key,
2839
- pin,
2840
- editable,
2841
- resizing,
2842
- valueFormatter
2843
- } = column;
2844
- const [editing, setEditing] = useState5(false);
2845
- const value = valueFormatter(row[key]);
2846
- const [editableValue, setEditableValue] = useState5(value);
2847
- const handleTitleMouseDown = () => {
2848
- var _a;
2849
- (_a = labelFieldRef.current) == null ? void 0 : _a.focus();
2850
- };
2851
- const handleTitleKeyDown = (evt) => {
2852
- if (evt.key === "Enter") {
2853
- setEditing(true);
2854
- }
2855
- };
2856
- const handleClick = useCallback10(
2857
- (evt) => {
2858
- onClick == null ? void 0 : onClick(evt, column);
2859
- },
2860
- [column, onClick]
2861
- );
2862
- const handleEnterEditMode = () => {
2863
- setEditing(true);
2864
- };
2865
- const handleExitEditMode = (originalValue = "", finalValue = "", allowDeactivation = true, editCancelled = false) => {
2866
- var _a;
2867
- setEditing(false);
2868
- if (editCancelled) {
2869
- setEditableValue(originalValue);
2870
- } else if (finalValue !== originalValue) {
2871
- setEditableValue(finalValue);
2872
- }
2873
- if (allowDeactivation === false) {
2874
- (_a = labelFieldRef.current) == null ? void 0 : _a.focus();
2875
- }
2876
- };
2877
- const className = cx8(classNameProp, {
2878
- vuuAlignRight: align === "right",
2879
- vuuPinFloating: pin === "floating",
2880
- vuuPinLeft: pin === "left",
2881
- vuuPinRight: pin === "right",
2882
- "vuuTableCell-resizing": resizing
2883
- }) || void 0;
2884
- const style = getColumnStyle(column);
2885
- return editable ? /* @__PURE__ */ jsx14(
2886
- "div",
2887
- {
2888
- className,
2889
- "data-editable": true,
2890
- role: "cell",
2891
- style,
2892
- onKeyDown: handleTitleKeyDown,
2893
- children: /* @__PURE__ */ jsx14(
2894
- EditableLabel,
2895
- {
2896
- editing,
2897
- value: editableValue,
2898
- onChange: setEditableValue,
2899
- onMouseDownCapture: handleTitleMouseDown,
2900
- onEnterEditMode: handleEnterEditMode,
2901
- onExitEditMode: handleExitEditMode,
2902
- onKeyDown: handleTitleKeyDown,
2903
- ref: labelFieldRef,
2904
- tabIndex: 0
2905
- },
2906
- "title"
2907
- )
2908
- }
2909
- ) : /* @__PURE__ */ jsx14(
2910
- "div",
2911
- {
2912
- className,
2913
- role: "cell",
2914
- style,
2915
- onClick: handleClick,
2916
- children: CellRenderer ? /* @__PURE__ */ jsx14(CellRenderer, { column, columnMap, row }) : value
2917
- }
2918
- );
2919
- },
2920
- cellValuesAreEqual
2921
- );
2922
- TableCell.displayName = "TableCell";
2923
- function cellValuesAreEqual(prev, next) {
2924
- return prev.column === next.column && prev.onClick === next.onClick && prev.row[KEY2] === next.row[KEY2] && prev.row[prev.column.key] === next.row[next.column.key];
2925
- }
2926
-
2927
- // ../vuu-table/src/table/TableGroupCell.tsx
2928
- import {
2929
- getColumnStyle as getColumnStyle2,
2930
- getGroupValueAndOffset,
2931
- metadataKeys as metadataKeys3
2932
- } from "@vuu-ui/vuu-utils";
2933
- import { useCallback as useCallback11 } from "react";
2934
- import { jsx as jsx15, jsxs as jsxs11 } from "react/jsx-runtime";
2935
- var { IS_LEAF } = metadataKeys3;
2936
- var TableGroupCell = ({ column, onClick, row }) => {
2937
- const { columns } = column;
2938
- const [value, offset] = getGroupValueAndOffset(columns, row);
2939
- const handleClick = useCallback11(
2940
- (evt) => {
2941
- onClick == null ? void 0 : onClick(evt, column);
2942
- },
2943
- [column, onClick]
2944
- );
2945
- const style = getColumnStyle2(column);
2946
- const isLeaf = row[IS_LEAF];
2947
- const spacers = Array(offset).fill(0).map((n, i) => /* @__PURE__ */ jsx15("span", { className: "vuuTableGroupCell-spacer" }, i));
2948
- return /* @__PURE__ */ jsxs11(
2949
- "div",
2950
- {
2951
- className: "vuuTableGroupCell vuuPinLeft",
2952
- onClick: isLeaf ? void 0 : handleClick,
2953
- role: "cell",
2954
- style,
2955
- children: [
2956
- spacers,
2957
- isLeaf ? null : /* @__PURE__ */ jsx15("span", { className: "vuuTableGroupCell-toggle", "data-icon": "triangle-right" }),
2958
- /* @__PURE__ */ jsx15("span", { children: value })
2959
- ]
2960
- }
2961
- );
2962
- };
2963
-
2964
- // ../vuu-table/src/table/TableRow.tsx
2965
- import { jsx as jsx16, jsxs as jsxs12 } from "react/jsx-runtime";
2966
- var { IDX, IS_EXPANDED, SELECTED } = metadataKeys4;
2967
- var classBase10 = "vuuTableRow";
2968
- var TableRow = memo2(function Row({
2969
- columnMap,
2970
- columns,
2971
- offset,
2972
- onClick,
2973
- onToggleGroup,
2974
- virtualColSpan = 0,
2975
- row
2976
- }) {
2977
- const {
2978
- [IDX]: rowIndex,
2979
- [IS_EXPANDED]: isExpanded,
2980
- [SELECTED]: isSelected
2981
- } = row;
2982
- const className = cx9(classBase10, {
2983
- [`${classBase10}-even`]: rowIndex % 2 === 0,
2984
- [`${classBase10}-expanded`]: isExpanded,
2985
- [`${classBase10}-preSelected`]: isSelected === 2
2986
- });
2987
- const handleRowClick = useCallback12(
2988
- (evt) => {
2989
- const rangeSelect = evt.shiftKey;
2990
- const keepExistingSelection = evt.ctrlKey || evt.metaKey;
2991
- onClick == null ? void 0 : onClick(row, rangeSelect, keepExistingSelection);
2992
- },
2993
- [onClick, row]
2994
- );
2995
- const handleGroupCellClick = useCallback12(
2996
- (evt, column) => {
2997
- if (isGroupColumn(column) || isJsonGroup(column, row)) {
2998
- evt.stopPropagation();
2999
- onToggleGroup == null ? void 0 : onToggleGroup(row, column);
3000
- }
3001
- },
3002
- [onToggleGroup, row]
3003
- );
3004
- return /* @__PURE__ */ jsxs12(
3005
- "div",
3006
- {
3007
- "aria-selected": isSelected === 1 ? true : void 0,
3008
- "aria-rowindex": rowIndex,
3009
- className,
3010
- onClick: handleRowClick,
3011
- role: "row",
3012
- style: {
3013
- transform: `translate3d(0px, ${offset}px, 0px)`
3014
- },
3015
- children: [
3016
- virtualColSpan > 0 ? /* @__PURE__ */ jsx16("div", { role: "cell", style: { width: virtualColSpan } }) : null,
3017
- columns.filter(notHidden).map((column) => {
3018
- const isGroup = isGroupColumn(column);
3019
- const isJsonCell = isJsonColumn(column);
3020
- const Cell = isGroup ? TableGroupCell : TableCell;
3021
- return /* @__PURE__ */ jsx16(
3022
- Cell,
3023
- {
3024
- column,
3025
- columnMap,
3026
- onClick: isGroup || isJsonCell ? handleGroupCellClick : void 0,
3027
- row
3028
- },
3029
- column.name
3030
- );
3031
- })
3032
- ]
3033
- }
3034
- );
3035
- });
3036
-
3037
- // ../vuu-table/src/table/TableGroupHeaderCell.tsx
3038
- import cx10 from "classnames";
3039
- import { useRef as useRef8 } from "react";
3040
-
3041
- // ../vuu-table/src/table/useTableColumnResize.tsx
3042
- import { useCallback as useCallback13, useRef as useRef7 } from "react";
3043
-
3044
- // ../vuu-table/src/table/TableGroupHeaderCell.tsx
3045
- import { jsx as jsx17, jsxs as jsxs13 } from "react/jsx-runtime";
3046
-
3047
- // ../vuu-table/src/table/TableHeaderCell.tsx
3048
- import cx13 from "classnames";
3049
- import { useCallback as useCallback15, useRef as useRef9 } from "react";
3050
-
3051
- // ../vuu-table/src/table/SortIndicator.tsx
3052
- import cx11 from "classnames";
3053
-
3054
- // ../vuu-table/src/table/TableHeaderCell.tsx
3055
- import { useContextMenu as useContextMenu2 } from "@vuu-ui/vuu-popups";
3056
-
3057
- // ../vuu-table/src/table/filter-indicator.tsx
3058
- import { useContextMenu } from "@vuu-ui/vuu-popups";
3059
- import cx12 from "classnames";
3060
- import { useCallback as useCallback14 } from "react";
3061
- import { jsx as jsx18 } from "react/jsx-runtime";
3062
-
3063
- // ../vuu-table/src/table/TableHeaderCell.tsx
3064
- import { jsx as jsx19, jsxs as jsxs14 } from "react/jsx-runtime";
3065
-
3066
- // ../vuu-table/src/table/RowBasedTable.tsx
3067
- import { jsx as jsx20, jsxs as jsxs15 } from "react/jsx-runtime";
3068
- var { RENDER_IDX } = metadataKeys5;
3069
-
3070
- // ../vuu-table/src/table/useTable.ts
3071
- import { useContextMenu as usePopupContextMenu } from "@vuu-ui/vuu-popups";
3072
- import {
3073
- applySort,
3074
- buildColumnMap as buildColumnMap2,
3075
- isJsonGroup as isJsonGroup2,
3076
- metadataKeys as metadataKeys9,
3077
- moveItem as moveItem3
3078
- } from "@vuu-ui/vuu-utils";
3079
- import {
3080
- useCallback as useCallback26,
3081
- useEffect as useEffect8,
3082
- useMemo as useMemo9,
3083
- useRef as useRef19,
3084
- useState as useState9
3085
- } from "react";
3086
-
3087
- // ../vuu-table/src/table/useDataSource.ts
3088
- import {
3089
- isVuuFeatureAction,
3090
- isVuuFeatureInvocation
3091
- } from "@vuu-ui/vuu-data-react";
3092
- import { getFullRange, metadataKeys as metadataKeys6, WindowRange } from "@vuu-ui/vuu-utils";
3093
- import { useCallback as useCallback17, useEffect as useEffect4, useMemo as useMemo4, useRef as useRef10, useState as useState6 } from "react";
3094
- var { SELECTED: SELECTED2 } = metadataKeys6;
3095
-
3096
- // ../vuu-table/src/table/useDraggableColumn.ts
3097
- import { useDragDropNext as useDragDrop } from "@vuu-ui/vuu-ui-controls";
3098
- import { useCallback as useCallback18, useRef as useRef11 } from "react";
3099
-
3100
- // ../vuu-table/src/table/useKeyboardNavigation.ts
3101
- import { withinRange } from "@vuu-ui/vuu-utils";
3102
- import {
3103
- useCallback as useCallback19,
3104
- useEffect as useEffect5,
3105
- useLayoutEffect,
3106
- useMemo as useMemo5,
3107
- useRef as useRef12
3108
- } from "react";
3109
-
3110
- // ../vuu-table/src/table/keyUtils.ts
3111
- function union(set1, ...sets) {
3112
- const result = new Set(set1);
3113
- for (let set of sets) {
3114
- for (let element of set) {
3115
- result.add(element);
3116
- }
3117
- }
3118
- return result;
3119
- }
3120
- var ArrowUp = "ArrowUp";
3121
- var ArrowDown = "ArrowDown";
3122
- var ArrowLeft = "ArrowLeft";
3123
- var ArrowRight = "ArrowRight";
3124
- var Home = "Home";
3125
- var End = "End";
3126
- var PageUp = "PageUp";
3127
- var PageDown = "PageDown";
3128
- var actionKeys = /* @__PURE__ */ new Set(["Enter", "Delete", " "]);
3129
- var focusKeys = /* @__PURE__ */ new Set(["Tab"]);
3130
- var arrowLeftRightKeys = /* @__PURE__ */ new Set(["ArrowRight", "ArrowLeft"]);
3131
- var navigationKeys = /* @__PURE__ */ new Set([
3132
- Home,
3133
- End,
3134
- PageUp,
3135
- PageDown,
3136
- ArrowDown,
3137
- ArrowLeft,
3138
- ArrowRight,
3139
- ArrowUp
3140
- ]);
3141
- var functionKeys = /* @__PURE__ */ new Set([
3142
- "F1",
3143
- "F2",
3144
- "F3",
3145
- "F4",
3146
- "F5",
3147
- "F6",
3148
- "F7",
3149
- "F8",
3150
- "F9",
3151
- "F10",
3152
- "F11",
3153
- "F12"
3154
- ]);
3155
- var specialKeys = union(
3156
- actionKeys,
3157
- navigationKeys,
3158
- arrowLeftRightKeys,
3159
- functionKeys,
3160
- focusKeys
3161
- );
3162
-
3163
- // ../vuu-table/src/table/useMeasuredContainer.ts
3164
- import { isValidNumber as isValidNumber2 } from "@vuu-ui/vuu-utils";
3165
- import { useCallback as useCallback21, useMemo as useMemo6, useRef as useRef14, useState as useState7 } from "react";
3166
-
3167
- // ../vuu-table/src/table/useResizeObserver.ts
3168
- import { useCallback as useCallback20, useEffect as useEffect6, useRef as useRef13 } from "react";
3169
- var observedMap = /* @__PURE__ */ new Map();
3170
- var getTargetSize = (element, size, dimension) => {
3171
- switch (dimension) {
3172
- case "height":
3173
- return size.height;
3174
- case "clientHeight":
3175
- return element.clientHeight;
3176
- case "clientWidth":
3177
- return element.clientWidth;
3178
- case "contentHeight":
3179
- return size.contentHeight;
3180
- case "contentWidth":
3181
- return size.contentWidth;
3182
- case "scrollHeight":
3183
- return Math.ceil(element.scrollHeight);
3184
- case "scrollWidth":
3185
- return Math.ceil(element.scrollWidth);
3186
- case "width":
3187
- return size.width;
3188
- default:
3189
- return 0;
3190
- }
3191
- };
3192
- var resizeObserver = new ResizeObserver((entries) => {
3193
- for (const entry of entries) {
3194
- const { target, borderBoxSize, contentBoxSize } = entry;
3195
- const observedTarget = observedMap.get(target);
3196
- if (observedTarget) {
3197
- const [{ blockSize: height, inlineSize: width }] = borderBoxSize;
3198
- const [{ blockSize: contentHeight, inlineSize: contentWidth }] = contentBoxSize;
3199
- const { onResize, measurements } = observedTarget;
3200
- let sizeChanged = false;
3201
- for (const [dimension, size] of Object.entries(measurements)) {
3202
- const newSize = getTargetSize(
3203
- target,
3204
- { height, width, contentHeight, contentWidth },
3205
- dimension
3206
- );
3207
- if (newSize !== size) {
3208
- sizeChanged = true;
3209
- measurements[dimension] = newSize;
3210
- }
3211
- }
3212
- if (sizeChanged) {
3213
- onResize && onResize(measurements);
3214
- }
3215
- }
3216
- }
3217
- });
3218
-
3219
- // ../vuu-table/src/table/useSelection.ts
3220
- import {
3221
- deselectItem,
3222
- isRowSelected,
3223
- metadataKeys as metadataKeys7,
3224
- selectItem
3225
- } from "@vuu-ui/vuu-utils";
3226
- import { useCallback as useCallback22, useRef as useRef15 } from "react";
3227
- var { IDX: IDX2 } = metadataKeys7;
3228
-
3229
- // ../vuu-table/src/table/useTableModel.ts
3230
- import {
3231
- applyFilterToColumns,
3232
- applyGroupByToColumns,
3233
- applySortToColumns,
3234
- findColumn,
3235
- getCellRenderer,
3236
- getColumnName as getColumnName2,
3237
- getTableHeadings,
3238
- getValueFormatter,
3239
- isFilteredColumn,
3240
- isGroupColumn as isGroupColumn3,
3241
- isPinned,
3242
- isTypeDescriptor as isTypeDescriptor4,
3243
- metadataKeys as metadataKeys8,
3244
- updateColumn,
3245
- sortPinnedColumns,
3246
- stripFilterFromColumns,
3247
- moveItem as moveItem2
3248
- } from "@vuu-ui/vuu-utils";
3249
- import { useReducer as useReducer2 } from "react";
3250
- var KEY_OFFSET = metadataKeys8.count;
3251
-
3252
- // ../vuu-table/src/table/useTableScroll.ts
3253
- import { useCallback as useCallback23, useRef as useRef16 } from "react";
3254
-
3255
- // ../vuu-table/src/table/useTableViewport.ts
3256
- import { useCallback as useCallback24, useMemo as useMemo7, useRef as useRef17 } from "react";
3257
- import {
3258
- actualRowPositioning,
3259
- virtualRowPositioning
3260
- } from "@vuu-ui/vuu-utils";
3261
-
3262
- // ../vuu-table/src/table/useVirtualViewport.ts
3263
- import {
3264
- getColumnsInViewport,
3265
- itemsChanged
3266
- } from "@vuu-ui/vuu-utils";
3267
- import { useCallback as useCallback25, useEffect as useEffect7, useMemo as useMemo8, useRef as useRef18, useState as useState8 } from "react";
3268
-
3269
- // ../vuu-table/src/table/useTable.ts
3270
- var { KEY: KEY3, IS_EXPANDED: IS_EXPANDED2, IS_LEAF: IS_LEAF2 } = metadataKeys9;
3271
-
3272
- // ../vuu-table/src/table/Table.tsx
3273
- import cx14 from "classnames";
3274
- import { isDataLoading } from "@vuu-ui/vuu-utils";
3275
- import { jsx as jsx21, jsxs as jsxs16 } from "react/jsx-runtime";
3276
-
3277
- // ../vuu-table/src/table/cell-renderers/json-cell/JsonCell.tsx
3278
- import cx15 from "classnames";
3279
- import {
3280
- isJsonAttribute,
3281
- metadataKeys as metadataKeys10,
3282
- registerComponent as registerComponent3
3283
- } from "@vuu-ui/vuu-utils";
3284
- import { jsx as jsx22, jsxs as jsxs17 } from "react/jsx-runtime";
3285
- var classBase11 = "vuuJsonCell";
3286
- var { IS_EXPANDED: IS_EXPANDED3, KEY: KEY4 } = metadataKeys10;
3287
- var localKey = (key) => {
3288
- const pos = key.lastIndexOf("|");
3289
- if (pos === -1) {
3290
- return "";
3291
- } else {
3292
- return key.slice(pos + 1);
3293
- }
3294
- };
3295
- var JsonCell = ({ column, row }) => {
3296
- const {
3297
- key: columnKey
3298
- /*, type, valueFormatter */
3299
- } = column;
3300
- let value = row[columnKey];
3301
- let isToggle = false;
3302
- if (isJsonAttribute(value)) {
3303
- value = value.slice(0, -1);
3304
- isToggle = true;
3305
- }
3306
- const rowKey = localKey(row[KEY4]);
3307
- const className = cx15({
3308
- [`${classBase11}-name`]: rowKey === value,
3309
- [`${classBase11}-value`]: rowKey !== value,
3310
- [`${classBase11}-group`]: isToggle
3311
- });
3312
- if (isToggle) {
3313
- const toggleIcon = row[IS_EXPANDED3] ? "minus-box" : "plus-box";
3314
- return /* @__PURE__ */ jsxs17("span", { className, children: [
3315
- /* @__PURE__ */ jsx22("span", { className: `${classBase11}-value`, children: value }),
3316
- /* @__PURE__ */ jsx22("span", { className: `${classBase11}-toggle`, "data-icon": toggleIcon })
3317
- ] });
3318
- } else if (value) {
3319
- return /* @__PURE__ */ jsx22("span", { className, children: value });
3320
- } else {
3321
- return null;
3322
- }
3323
- };
3324
- registerComponent3("json", JsonCell, "cell-renderer", {});
3325
-
3326
- // ../vuu-table/src/table-next/TableNext.tsx
3327
- import { ContextMenuProvider as ContextMenuProvider2 } from "@vuu-ui/vuu-popups";
3328
- import { metadataKeys as metadataKeys14, notHidden as notHidden4 } from "@vuu-ui/vuu-utils";
3329
-
3330
- // ../vuu-table/src/table-next/HeaderCell.tsx
3331
- import { useCallback as useCallback30, useRef as useRef23 } from "react";
3332
-
3333
- // ../vuu-table/src/table-next/useCell.ts
3334
- import { getColumnStyle as getColumnStyle4 } from "@vuu-ui/vuu-utils";
3335
- import cx16 from "classnames";
3336
- import { useMemo as useMemo10 } from "react";
3337
- var useCell = (column, classBase14, isHeader) => (
3338
- // TODO measure perf without the memo, might not be worth the cost
3339
- useMemo10(() => {
3340
- const className = cx16(classBase14, {
3341
- vuuPinFloating: column.pin === "floating",
3342
- vuuPinLeft: column.pin === "left",
3343
- vuuPinRight: column.pin === "right",
3344
- vuuEndPin: isHeader && column.endPin,
3345
- [`${classBase14}-resizing`]: column.resizing,
3346
- [`${classBase14}-right`]: column.align === "right"
3347
- });
3348
- const style = getColumnStyle4(column);
3349
- return {
3350
- className,
3351
- style
3352
- };
3353
- }, [column, classBase14, isHeader])
3354
- );
3355
-
3356
- // ../vuu-table/src/table-next/ColumnMenu.tsx
3357
- import { useContextMenu as useContextMenu3 } from "@vuu-ui/vuu-popups";
3358
- import cx17 from "classnames";
3359
- import {
3360
- useCallback as useCallback27,
3361
- useRef as useRef20,
3362
- useState as useState10
3363
- } from "react";
3364
- import { jsx as jsx23 } from "react/jsx-runtime";
3365
-
3366
- // ../vuu-table/src/table-next/column-resizing/ColumnResizer.tsx
3367
- import { useCallback as useCallback28, useRef as useRef21 } from "react";
3368
- import { jsx as jsx24 } from "react/jsx-runtime";
3369
-
3370
- // ../vuu-table/src/table-next/column-resizing/useTableColumnResize.tsx
3371
- import { useCallback as useCallback29, useRef as useRef22 } from "react";
3372
-
3373
- // ../vuu-table/src/table-next/HeaderCell.tsx
3374
- import { jsx as jsx25, jsxs as jsxs18 } from "react/jsx-runtime";
3375
-
3376
- // ../vuu-table/src/table-next/Row.tsx
3377
- import {
3378
- isGroupColumn as isGroupColumn4,
3379
- metadataKeys as metadataKeys12,
3380
- notHidden as notHidden3,
3381
- RowSelected
3382
- } from "@vuu-ui/vuu-utils";
3383
- import cx18 from "classnames";
3384
- import { memo as memo3, useCallback as useCallback32 } from "react";
3385
-
3386
- // ../vuu-table/src/table-next/TableCell.tsx
3387
- import { jsx as jsx26 } from "react/jsx-runtime";
3388
- var TableCell2 = ({ column, row }) => {
3389
- const { className, style } = useCell(column, "vuuTableNextCell");
3390
- return /* @__PURE__ */ jsx26("div", { className, role: "cell", style, children: row[column.key] });
3391
- };
3392
-
3393
- // ../vuu-table/src/table-next/TableGroupCell.tsx
3394
- import { getGroupValueAndOffset as getGroupValueAndOffset2, metadataKeys as metadataKeys11 } from "@vuu-ui/vuu-utils";
3395
- import { useCallback as useCallback31 } from "react";
3396
- import { jsx as jsx27, jsxs as jsxs19 } from "react/jsx-runtime";
3397
- var { IS_LEAF: IS_LEAF3 } = metadataKeys11;
3398
- var TableGroupCell2 = ({ column, onClick, row }) => {
3399
- const { columns } = column;
3400
- const [value, offset] = getGroupValueAndOffset2(columns, row);
3401
- const { className, style } = useCell(column, "vuuTable2-groupCell");
3402
- const handleClick = useCallback31(
3403
- (evt) => {
3404
- onClick == null ? void 0 : onClick(evt, column);
3405
- },
3406
- [column, onClick]
3407
- );
3408
- const isLeaf = row[IS_LEAF3];
3409
- const spacers = Array(offset).fill(0).map((n, i) => /* @__PURE__ */ jsx27("span", { className: "vuuTable2-groupCell-spacer" }, i));
3410
- return /* @__PURE__ */ jsxs19(
3411
- "div",
3412
- {
3413
- className,
3414
- role: "cell",
3415
- style,
3416
- onClick: isLeaf ? void 0 : handleClick,
3417
- children: [
3418
- spacers,
3419
- isLeaf ? null : /* @__PURE__ */ jsx27(
3420
- "span",
3421
- {
3422
- className: "vuuTable2-groupCell-toggle",
3423
- "data-icon": "vuu-triangle-right"
3424
- }
3425
- ),
3426
- /* @__PURE__ */ jsx27("span", { children: value })
3427
- ]
3428
- }
3429
- );
3430
- };
3431
-
3432
- // ../vuu-table/src/table-next/Row.tsx
3433
- import { jsx as jsx28 } from "react/jsx-runtime";
3434
- import { createElement } from "react";
3435
- var { IDX: IDX3, IS_EXPANDED: IS_EXPANDED4, SELECTED: SELECTED3 } = metadataKeys12;
3436
- var classBase12 = "vuuTableNextRow";
3437
- var Row2 = memo3(
3438
- ({
3439
- className: classNameProp,
3440
- columnMap,
3441
- columns,
3442
- row,
3443
- offset,
3444
- onClick,
3445
- onToggleGroup,
3446
- ...htmlAttributes
3447
- }) => {
3448
- const {
3449
- [IDX3]: rowIndex,
3450
- [IS_EXPANDED4]: isExpanded,
3451
- [SELECTED3]: selectionStatus
3452
- } = row;
3453
- const handleRowClick = useCallback32(
3454
- (evt) => {
3455
- const rangeSelect = evt.shiftKey;
3456
- const keepExistingSelection = evt.ctrlKey || evt.metaKey;
3457
- onClick == null ? void 0 : onClick(row, rangeSelect, keepExistingSelection);
3458
- },
3459
- [onClick, row]
3460
- );
3461
- const { True, First, Last } = RowSelected;
3462
- const className = cx18(classBase12, classNameProp, {
3463
- [`${classBase12}-even`]: rowIndex % 2 === 0,
3464
- [`${classBase12}-expanded`]: isExpanded,
3465
- [`${classBase12}-selected`]: selectionStatus & True,
3466
- [`${classBase12}-selectedStart`]: selectionStatus & First,
3467
- [`${classBase12}-selectedEnd`]: selectionStatus & Last
3468
- });
3469
- const style = typeof offset === "number" ? { transform: `translate3d(0px, ${offset}px, 0px)` } : void 0;
3470
- return /* @__PURE__ */ createElement(
3471
- "div",
3472
- {
3473
- ...htmlAttributes,
3474
- key: `row-${row[0]}`,
3475
- role: "row",
3476
- className,
3477
- onClick: handleRowClick,
3478
- style
3479
- },
3480
- /* @__PURE__ */ jsx28("span", { className: `${classBase12}-selectionDecorator vuuStickyLeft` }),
3481
- columns.filter(notHidden3).map((column) => {
3482
- const isGroup = isGroupColumn4(column);
3483
- const Cell = isGroup ? TableGroupCell2 : TableCell2;
3484
- return /* @__PURE__ */ jsx28(Cell, { column, row }, column.key);
3485
- }),
3486
- /* @__PURE__ */ jsx28("span", { className: `${classBase12}-selectionDecorator vuuStickyRight` })
3487
- );
3488
- }
3489
- );
3490
- Row2.displayName = "Row";
3491
-
3492
- // ../vuu-table/src/table-next/useTableNext.ts
3493
- import {
3494
- useLayoutEffectSkipFirst,
3495
- useLayoutProviderDispatch
3496
- } from "@vuu-ui/vuu-layout";
3497
- import { useContextMenu as usePopupContextMenu2 } from "@vuu-ui/vuu-popups";
3498
- import {
3499
- applySort as applySort2,
3500
- buildColumnMap as buildColumnMap3,
3501
- isValidNumber as isValidNumber3,
3502
- updateColumn as updateColumn2,
3503
- visibleColumnAtIndex as visibleColumnAtIndex2
3504
- } from "@vuu-ui/vuu-utils";
3505
- import { useCallback as useCallback36, useMemo as useMemo13, useState as useState12 } from "react";
3506
-
3507
- // ../vuu-table/src/table-next/table-config.ts
3508
- var updateTableConfig = (config, action) => {
3509
- switch (action.type) {
3510
- case "col-size":
3511
- return {
3512
- ...config,
3513
- columns: config.columns.map(
3514
- (col) => col.name === action.column.name ? { ...col, width: action.width } : col
3515
- )
3516
- };
3517
- case "column-prop":
3518
- return {
3519
- ...config,
3520
- columns: config.columns.map(
3521
- (col) => col.name === action.column.name ? { ...col, [action.property]: action.value } : col
3522
- )
3523
- };
3524
- default:
3525
- return config;
3526
- }
3527
- };
3528
-
3529
- // ../vuu-table/src/table-next/useDataSource.ts
3530
- import { useCallback as useCallback33, useMemo as useMemo11, useState as useState11 } from "react";
3531
-
3532
- // ../vuu-table/src/table-next/useInitialValue.ts
3533
- import { useMemo as useMemo12, useRef as useRef24 } from "react";
3534
-
3535
- // ../vuu-table/src/table-next/useTableModel.ts
3536
- import { moveItem as moveItem4 } from "@vuu-ui/vuu-ui-controls";
3537
- import {
3538
- applyFilterToColumns as applyFilterToColumns2,
3539
- applyGroupByToColumns as applyGroupByToColumns2,
3540
- applySortToColumns as applySortToColumns2,
3541
- findColumn as findColumn2,
3542
- getCellRenderer as getCellRenderer2,
3543
- getColumnName as getColumnName3,
3544
- getTableHeadings as getTableHeadings2,
3545
- getValueFormatter as getValueFormatter2,
3546
- isFilteredColumn as isFilteredColumn2,
3547
- isGroupColumn as isGroupColumn5,
3548
- isPinned as isPinned2,
3549
- isTypeDescriptor as isTypeDescriptor5,
3550
- logger,
3551
- metadataKeys as metadataKeys13,
3552
- sortPinnedColumns as sortPinnedColumns2,
3553
- stripFilterFromColumns as stripFilterFromColumns2
3554
- } from "@vuu-ui/vuu-utils";
3555
- import { useReducer as useReducer3 } from "react";
3556
- var { info } = logger("useTableModel");
3557
- var KEY_OFFSET2 = metadataKeys13.count;
3558
-
3559
- // ../vuu-table/src/table-next/useTableScroll.ts
3560
- import { useCallback as useCallback34, useRef as useRef25 } from "react";
3561
-
3562
- // ../vuu-table/src/table-next/useVirtualViewport.ts
3563
- import { useCallback as useCallback35, useRef as useRef26 } from "react";
3564
-
3565
- // ../vuu-table/src/table-next/TableNext.tsx
3566
- import { jsx as jsx29, jsxs as jsxs20 } from "react/jsx-runtime";
3567
- var { IDX: IDX4, RENDER_IDX: RENDER_IDX2 } = metadataKeys14;
3568
-
3569
- // src/table-settings/useTableSettings.ts
3570
- import { useCallback as useCallback37, useMemo as useMemo14, useState as useState13 } from "react";
3571
- var buildColumnItems = (availableColumns, configuredColumns) => {
3572
- return availableColumns.map(({ name, serverDataType }) => {
3573
- const configuredColumn = configuredColumns.find((col) => col.name === name);
3574
- return {
3575
- hidden: configuredColumn == null ? void 0 : configuredColumn.hidden,
3576
- label: configuredColumn == null ? void 0 : configuredColumn.label,
3577
- name,
3578
- serverDataType,
3579
- subscribed: configuredColumn !== void 0
3580
- };
3581
- });
3582
- };
3583
- var useTableSettings = ({
3584
- availableColumns,
3585
- onConfigChange,
3586
- tableConfig: tableConfigProp
3587
- }) => {
3588
- const [tableConfig, setTableConfig] = useState13(tableConfigProp);
3589
- const columnItems = useMemo14(
3590
- () => buildColumnItems(availableColumns, tableConfig.columns),
3591
- [availableColumns, tableConfig.columns]
3592
- );
3593
- const handleMoveListItem = useCallback37(
3594
- (fromIndex, toIndex) => {
3595
- console.log(`move list item from ${fromIndex} to ${toIndex}`);
3596
- },
3597
- []
3598
- );
3599
- const handleColumnChange = useCallback37(
3600
- (name, property, value) => {
3601
- const columnItem = columnItems.find((col) => col.name === name);
3602
- if (property === "subscribed") {
3603
- console.log(`unsubscribe from ${name}`);
3604
- } else if (columnItem == null ? void 0 : columnItem.subscribed) {
3605
- const column = tableConfig.columns.find((col) => col.name === name);
3606
- if (column) {
3607
- const newConfig = updateTableConfig(tableConfig, {
3608
- type: "column-prop",
3609
- property,
3610
- column,
3611
- value
3612
- });
3613
- setTableConfig(newConfig);
3614
- }
3615
- }
3616
- },
3617
- [columnItems, tableConfig]
3618
- );
3619
- const handleChangeColumnLabels = useCallback37((evt) => {
3620
- const { value } = evt.target;
3621
- const columnFormatHeader = value === "0" ? void 0 : value === "1" ? "capitalize" : "uppercase";
3622
- setTableConfig((config) => ({
3623
- ...config,
3624
- columnFormatHeader
3625
- }));
3626
- }, []);
3627
- useLayoutEffectSkipFirst2(() => {
3628
- onConfigChange == null ? void 0 : onConfigChange(tableConfig);
3629
- }, [onConfigChange, tableConfig]);
3630
- const columnLabelsValue = tableConfig.columnFormatHeader === void 0 ? 0 : tableConfig.columnFormatHeader === "capitalize" ? 1 : 2;
3631
- return {
3632
- columnItems,
3633
- columnLabelsValue,
3634
- onChangeColumnLabels: handleChangeColumnLabels,
3635
- onColumnChange: handleColumnChange,
3636
- onMoveListItem: handleMoveListItem
3637
- };
3638
- };
3639
-
3640
- // src/table-settings/TableSettingsPanel.tsx
3641
- import { jsx as jsx30, jsxs as jsxs21 } from "react/jsx-runtime";
3642
- var classBase13 = "vuuTableSettingsPanel";
3643
- var TableSettingsPanel = ({
3644
- availableColumns,
3645
- onConfigChange,
3646
- tableConfig,
3647
- ...htmlAttributes
3648
- }) => {
3649
- const {
3650
- columnItems,
3651
- columnLabelsValue,
3652
- onChangeColumnLabels,
3653
- onColumnChange,
3654
- onMoveListItem
3655
- } = useTableSettings({
3656
- availableColumns,
3657
- onConfigChange,
3658
- tableConfig
3659
- });
3660
- return /* @__PURE__ */ jsxs21("div", { ...htmlAttributes, className: classBase13, children: [
3661
- /* @__PURE__ */ jsxs21(FormField5, { children: [
3662
- /* @__PURE__ */ jsx30(FormFieldLabel5, { children: "Column Labels" }),
3663
- /* @__PURE__ */ jsxs21(
3664
- ToggleButtonGroup,
3665
- {
3666
- className: "vuuToggleButtonGroup",
3667
- onChange: onChangeColumnLabels,
3668
- value: columnLabelsValue,
3669
- children: [
3670
- /* @__PURE__ */ jsx30(
3671
- ToggleButton,
3672
- {
3673
- className: "vuuIconToggleButton",
3674
- "data-icon": "text-strikethrough",
3675
- value: 0
3676
- }
3677
- ),
3678
- /* @__PURE__ */ jsx30(
3679
- ToggleButton,
3680
- {
3681
- className: "vuuIconToggleButton",
3682
- "data-icon": "text-Tt",
3683
- value: 1
3684
- }
3685
- ),
3686
- /* @__PURE__ */ jsx30(
3687
- ToggleButton,
3688
- {
3689
- className: "vuuIconToggleButton",
3690
- "data-icon": "text-T",
3691
- value: 2
3692
- }
3693
- )
3694
- ]
3695
- }
3696
- )
3697
- ] }),
3698
- /* @__PURE__ */ jsxs21(FormField5, { children: [
3699
- /* @__PURE__ */ jsx30(FormFieldLabel5, { children: "Default Column Width" }),
3700
- /* @__PURE__ */ jsx30(Input3, { className: "vuuInput" })
3701
- ] }),
3702
- /* @__PURE__ */ jsx30(
3703
- ColumnList,
3704
- {
3705
- columnItems,
3706
- onChange: onColumnChange,
3707
- onMoveListItem
3708
- }
3709
- )
3710
- ] });
3711
- };
3712
- export {
3713
- ColumnExpressionInput,
3714
- ColumnList,
3715
- ColumnNamedTerms,
3716
- DataSourceStats,
3717
- DatagridSettingsPanel,
3718
- TableSettingsPanel,
3719
- columnExpressionLanguageSupport,
3720
- isCompleteExpression,
3721
- isCompleteRelationalExpression,
3722
- lastNamedChild,
3723
- useColumnExpressionEditor,
3724
- useColumnExpressionSuggestionProvider,
3725
- useTableSettings,
3726
- walkTree
3727
- };
1
+ var ft=(t,e,n)=>{if(!e.has(t))throw TypeError("Cannot "+n)};var d=(t,e,n)=>(ft(t,e,"read from private field"),n?n.call(t):e.get(t)),w=(t,e,n)=>{if(e.has(t))throw TypeError("Cannot add the same private member more than once");e instanceof WeakSet?e.add(t):e.set(t,n)},L=(t,e,n,o)=>(ft(t,e,"write to private field"),o?o.call(t,n):e.set(t,n),n);import{DOWN1 as In,DOWN2 as zn,isTypeDescriptor as $n,metadataKeys as Vn,registerComponent as Kn,UP1 as Bn,UP2 as Wn}from"@vuu-ui/vuu-utils";import Gn from"classnames";import{getMovingValueDirection as Hn,isTypeDescriptor as Ln,isValidNumber as gt}from"@vuu-ui/vuu-utils";import{useEffect as kn,useRef as Nn}from"react";var Fn=[void 0,void 0,void 0,void 0];function Ct(t,e,n){var g;let o=Nn(),[r,s,i,u]=o.current||Fn,{type:a}=n,c=Ln(a)?(g=a.formatting)==null?void 0:g.decimals:void 0,p=t===r&&gt(e)&&gt(s)&&n===i?Hn(e,u,s,c):"";return kn(()=>{o.current=[t,e,n,p]}),p}import{jsx as Zn,jsxs as Jn}from"react/jsx-runtime";var Qn=String.fromCharCode(11014),Un=String.fromCharCode(11015),{KEY:Xn}=Vn,be="vuuBackgroundCell",oe={ArrowOnly:"arrow",BackgroundOnly:"bg-only",ArrowBackground:"arrow-bg"},Yn=t=>$n(t)&&t.renderer&&"flashStyle"in t.renderer?t.renderer.flashStyle:oe.BackgroundOnly,_n=({column:t,row:e})=>{let{key:n,type:o,valueFormatter:r}=t,s=e[n],i=Yn(o),u=Ct(e[Xn],s,t),a=i===oe.ArrowOnly||i===oe.ArrowBackground?u===Bn||u===Wn?Qn:u===In||u===zn?Un:null:null,c=u?" "+u:"",p=Gn(be,c,{[`${be}-arrowOnly`]:i===oe.ArrowOnly,[`${be}-arrowBackground`]:i===oe.ArrowBackground});return Jn("div",{className:p,tabIndex:-1,children:[Zn("div",{className:`${be}-flasher`,children:a}),r(e[t.key])]})};Kn("background",_n,"cell-renderer",{serverDataType:["long","int","double"]});import{isColumnTypeRenderer as qn,isTypeDescriptor as jn,registerComponent as eo}from"@vuu-ui/vuu-utils";import to from"classnames";import{jsx as He,jsxs as bt}from"react/jsx-runtime";var re="vuuProgressCell",no=({column:t,columnMap:e,row:n})=>{let{type:o}=t,r=n[t.key],s=!1,i=0;if(jn(o)&&qn(o.renderer)){let{associatedField:a}=o.renderer,c=n[e[a]];if(typeof r=="number"&&typeof c=="number")i=Math.min(Math.round(r/c*100),100),s=isFinite(i);else{let p=parseFloat(r);if(Number.isFinite(p)){let g=parseFloat(c);Number.isFinite(g)&&(i=Math.min(Math.round(p/g*100),100),s=isFinite(i))}}}let u=to(re,{});return bt("div",{className:u,tabIndex:-1,children:[s?bt("span",{className:`${re}-track`,children:[He("span",{className:`${re}-bg`}),He("span",{className:`${re}-bar`,style:{"--progress-bar-pct":`-${100-i}%`}})]}):null,He("span",{className:`${re}-text`,children:`${i} %`})]})};eo("vuu.progress",no,"cell-renderer",{serverDataType:["long","int","double"]});import{List as oo,ListItem as ro}from"@vuu-ui/vuu-ui-controls";import{Checkbox as so}from"@salt-ds/core";import{Switch as io}from"@salt-ds/lab";import lo from"classnames";import{useCallback as ao}from"react";import{jsx as N,jsxs as Le}from"react/jsx-runtime";var k="vuuColumnList",ht="vuuColumnListItem",uo=({className:t,item:e,...n})=>{var o;return Le(ro,{...n,className:lo(t,ht),"data-name":e==null?void 0:e.name,children:[N(io,{className:`${k}-switch`,checked:e==null?void 0:e.subscribed}),N("span",{className:`${k}-text`,children:(o=e==null?void 0:e.label)!=null?o:e==null?void 0:e.name}),N(so,{className:`${k}-checkBox`,checked:(e==null?void 0:e.hidden)!==!0,disabled:(e==null?void 0:e.subscribed)!==!0})]})},xt=({columnItems:t,onChange:e,onMoveListItem:n,...o})=>{let r=ao(s=>{let i=s.target,u=i.closest(`.${ht}`),{dataset:{name:a}}=u;if(a){let c=i.closest(`.${k}-switch`),p=i.closest(`.${k}-checkBox`);c?e(a,"subscribed",i.checked):p&&e(a,"hidden",i.checked===!1)}},[e]);return Le("div",{...o,className:k,children:[N("div",{className:`${k}-header`,children:N("span",{children:"Column Selection"})}),Le("div",{className:`${k}-colHeadings`,children:[N("span",{children:"Column subscription"}),N("span",{children:"Visibility"})]}),N(oo,{ListItem:uo,allowDragDrop:!0,height:"100%",onChange:r,onMoveListItem:n,selectionStrategy:"none",source:t,itemHeight:33})]})};import{autocompletion as Oo,defaultKeymap as Ao,EditorState as Ho,EditorView as kt,ensureSyntaxTree as Lo,keymap as Qe,minimalSetup as ko,startCompletion as Nt}from"@vuu-ui/vuu-codemirror";import{createEl as Ft}from"@vuu-ui/vuu-utils";import{useEffect as No,useMemo as Fo,useRef as Ue}from"react";import{LanguageSupport as mo,LRLanguage as po,styleTags as fo,tags as xe}from"@vuu-ui/vuu-codemirror";import{LRParser as co}from"@lezer/lr";var he=co.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 go=po.define({name:"VuuColumnExpression",parser:he.configure({props:[fo({Function:xe.variableName,String:xe.string,Or:xe.emphasis,Operator:xe.operator})]})}),yt=()=>new mo(go);var ke=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}}},Ne=class{constructor(e){this.type="colExpression";this.column=e}toJSON(){return{type:this.type,column:this.column}}},ie,$,Fe=class{constructor(e="unknown"){w(this,ie,[{type:"unknown"},{type:"unknown"}]);w(this,$,void 0);this.type="arithmeticExpression";L(this,$,e)}get op(){return d(this,$)}set op(e){L(this,$,e)}get expressions(){return d(this,ie)}toJSON(){return{type:this.type,op:d(this,$),expressions:d(this,ie)}}};ie=new WeakMap,$=new WeakMap;var _,Ie=class{constructor(e){w(this,_,[]);this.type="callExpression";this.functionName=e}get expressions(){return d(this,_)}get arguments(){return d(this,_)}toJSON(){return{type:this.type,functionName:this.functionName,arguments:d(this,_).map(e=>{var n;return(n=e.toJSON)==null?void 0:n.call(e)})}}};_=new WeakMap;var le,Z,X=class{constructor(){w(this,le,[{type:"unknown"},{type:"unknown"}]);w(this,Z,"unknown");this.type="relationalExpression"}get op(){return d(this,Z)}set op(e){L(this,Z,e)}get expressions(){return d(this,le)}toJSON(){return{type:this.type,op:d(this,Z),expressions:d(this,le)}}};le=new WeakMap,Z=new WeakMap;var ae,J,Y=class{constructor(e){w(this,ae,[{type:"unknown"},{type:"unknown"}]);w(this,J,void 0);this.type="booleanCondition";L(this,J,e)}get op(){return d(this,J)}get expressions(){return d(this,ae)}toJSON(){return{type:this.type,op:d(this,J),expressions:d(this,ae).map(e=>{var n;return(n=e.toJSON)==null?void 0:n.call(e)})}}};ae=new WeakMap,J=new WeakMap;var D,se=class{constructor(e){w(this,D,void 0);this.type="conditionalExpression";L(this,D,[e?new Y(e):new X,{type:"unknown"},{type:"unknown"}])}get expressions(){return d(this,D)}get condition(){return d(this,D)[0]}get truthyExpression(){return d(this,D)[1]}set truthyExpression(e){d(this,D)[1]=e}get falsyExpression(){return d(this,D)[2]}set falsyExpression(e){d(this,D)[2]=e}toJSON(){var e,n,o,r,s;return{type:this.type,condition:(n=(e=this.condition).toJSON)==null?void 0:n.call(e),truthyExpression:this.truthyExpression,falsyExpression:(s=(r=(o=this.falsyExpression)==null?void 0:o.toJSON)==null?void 0:r.call(o))!=null?s:this.falsyExpression}}};D=new WeakMap;var z=t=>t.type==="unknown",ye=t=>t.type==="arithmeticExpression",Co=t=>t.type==="callExpression",U=t=>t.type==="conditionalExpression",bo=t=>t.type==="relationalExpression"||t.type==="booleanCondition";var ho=t=>t.type==="booleanCondition",$e=t=>(t==null?void 0:t.type)==="relationalExpression";var E=t=>{if(z(t))return t;if($e(t)){let[e,n]=t.expressions;if(v(e))return E(e);if(t.op==="unknown")return t;if(v(n))return E(n)}else if(bo(t)){let{expressions:e=[]}=t;for(let n of e)if(v(n))return E(n)}else if(U(t)){let{condition:e,truthyExpression:n,falsyExpression:o}=t;if(v(e))return E(e);if(v(n))return E(n);if(v(o))return E(o)}else if(ye(t)){let{expressions:e=[]}=t;for(let n of e)if(v(n))return E(n)}},ve=(t,e,n)=>{let{expressions:o=[]}=t;if(o.includes(e)){let r=o.indexOf(e);return o.splice(r,1,n),!0}else for(let r of o)if(ve(r,e,n))return!0;return!1},v=t=>z(t)?!0:U(t)?v(t.condition)||v(t.truthyExpression)||v(t.falsyExpression):$e(t)||ho(t)?t.op===void 0||t.expressions.some(e=>v(e)):!1,vt=(t,e)=>{let n=E(t);n?n.expressions?n.expressions.push(e):console.warn("don't know how to treat targetExpression"):console.error("no target expression found")},h,V,ze=class{constructor(){w(this,h,void 0);w(this,V,[])}setCondition(e){if(d(this,h)===void 0)this.addExpression(new se(e));else if(U(d(this,h))){if(v(d(this,h).condition)){let n=e?new Y(e):new X;this.addExpression(n)}else if(z(d(this,h).truthyExpression))d(this,h).truthyExpression=new se(e);else if(v(d(this,h).truthyExpression)){let n=e?new Y(e):new X;this.addExpression(n)}else if(z(d(this,h).falsyExpression))d(this,h).falsyExpression=new se(e);else if(v(d(this,h).falsyExpression)){let n=e?new Y(e):new X;this.addExpression(n)}}else console.error("setCondition called unexpectedly")}addExpression(e){if(d(this,V).length>0){let n=d(this,V).at(-1);n==null||n.arguments.push(e)}else if(d(this,h)===void 0)L(this,h,e);else if(ye(d(this,h))){let n=E(d(this,h));n&&z(n)&&ve(d(this,h),n,e)}else if(U(d(this,h))&&v(d(this,h))){let n=E(d(this,h));n&&z(n)?ve(d(this,h),n,e):n&&vt(n,e)}}setFunction(e){let n=new Ie(e);this.addExpression(n),d(this,V).push(n)}setColumn(e){this.addExpression(new Ne(e))}setArithmeticOp(e){let n=e,o=d(this,h);ye(o)&&(o.op=n)}setRelationalOperator(e){let n=e;if(d(this,h)&&U(d(this,h))){let o=E(d(this,h));$e(o)?o.op=n:console.error(`no target expression found (op = ${e})`)}}setValue(e){let n=new ke(e);if(d(this,h)===void 0)L(this,h,n);else if(ye(d(this,h)))this.addExpression(n);else if(Co(d(this,h)))d(this,h).arguments.push(n);else if(U(d(this,h)))if(v(d(this,h))){let o=E(d(this,h));o&&z(o)?ve(d(this,h),o,n):o&&vt(o,n)}else console.log("what do we do with value, in a complete expression")}closeBrace(){d(this,V).pop()}get expression(){return d(this,h)}toJSON(){var e;return(e=d(this,h))==null?void 0:e.toJSON()}};h=new WeakMap,V=new WeakMap;var Tt=(t,e)=>{let n=new ze,o=t.cursor();do{let{name:r,from:s,to:i}=o;switch(r){case"AndCondition":n.setCondition("and");break;case"OrCondition":n.setCondition("or");break;case"RelationalExpression":n.setCondition();break;case"ArithmeticExpression":n.addExpression(new Fe);break;case"Column":{let u=e.substring(s,i);n.setColumn(u)}break;case"Function":{let u=e.substring(s,i);n.setFunction(u)}break;case"Times":case"Divide":case"Plus":case"Minus":{let u=e.substring(s,i);n.setArithmeticOp(u)}break;case"RelationalOperator":{let u=e.substring(s,i);n.setRelationalOperator(u)}break;case"False":case"True":{let u=e.substring(s,i);n.setValue(u==="true")}break;case"String":n.setValue(e.substring(s+1,i-1));break;case"Number":n.setValue(parseFloat(e.substring(s,i)));break;case"CloseBrace":n.closeBrace();break;default:}}while(o.next());return n.toJSON()};var xo=he.configure({strict:!0}),Et=["Number","String"],Ve=[...Et,"AndCondition","ArithmeticExpression","BooleanOperator","RelationalOperatorOperator","CallExpression","CloseBrace","Column","Comma","ConditionalExpression","Divide","Equal","If","Minus","OpenBrace","OrCondition","ParenthesizedExpression","Plus","RelationalExpression","RelationalOperator","Times"],St=t=>{try{return xo.parse(t),!0}catch{return!1}},Ke=t=>{let{lastChild:e}=t;for(;e&&!Ve.includes(e.name);)e=e.prevSibling,console.log(e==null?void 0:e.name);return e},wt=t=>{if((t==null?void 0:t.name)==="RelationalExpression"){let{firstChild:e}=t,n=Ke(t);if((e==null?void 0:e.name)==="Column"&&typeof(n==null?void 0:n.name)=="string"&&Et.includes(n.name))return!0}return!1};import{HighlightStyle as yo,syntaxHighlighting as vo,tags as Pt}from"@vuu-ui/vuu-codemirror";var To=yo.define([{tag:Pt.variableName,color:"var(--vuuFilterEditor-variableColor)"},{tag:Pt.comment,color:"green",fontStyle:"italic"}]),Rt=vo(To);import{EditorView as Eo}from"@vuu-ui/vuu-codemirror";var Dt=Eo.theme({"&":{border:"solid 1px var(--salt-container-primary-borderColor)",color:"var(--vuuFilterEditor-color)",backgroundColor:"var(--vuuFilterEditor-background)"},".cm-content":{caretColor:"var(--vuuFilterEditor-cursorColor)"},"&.cm-focused .cm-cursor":{borderLeftColor:"var(--vuuFilterEditor-cursorColor)"},"&.cm-focused .cm-selectionBackground, ::selection":{backgroundColor:"var(--vuuFilterEditor-selectionBackground)"},".cm-selectionBackground, ::selection":{backgroundColor:"var(--vuuFilterEditor-selectionBackground)"},".cm-scroller":{fontFamily:"var(--vuuFilterEditor-fontFamily)"},".cm-tooltip":{background:"var(--vuuFilterEditor-tooltipBackground)",border:"var(--vuuFilterEditor-tooltipBorder)",boxShadow:"var(--vuuFilterEditor-tooltipElevation)","&.cm-tooltip-autocomplete > ul":{fontFamily:"var(--vuuFilterEditor-fontFamily)",fontSize:"var(--vuuFilterEditor-fontSize)",maxHeight:"240px"},"&.cm-tooltip-autocomplete > ul > li":{height:"var(--vuuFilterEditor-suggestion-height)",padding:"0 3px",lineHeight:"var(--vuuFilterEditor-suggestion-height)"},"&.cm-tooltip-autocomplete li[aria-selected]":{background:"var(--vuuFilterEditor-suggestion-selectedBackground)",color:"var(--vuuFilterEditor-suggestion-selectedColor)"},"&.cm-tooltip-autocomplete li .cm-completionDetail":{color:"var(--vuuFilterEditor-suggestion-detailColor)"}}},{dark:!1});import{booleanJoinSuggestions as So,getNamedParentNode as Mt,getPreviousNode as wo,getValue as O,syntaxTree as Po}from"@vuu-ui/vuu-codemirror";import{useCallback as Ot}from"react";var Ro=(t,e)=>e?t.map(n=>{var o;return{...n,apply:typeof n.apply=="function"?n.apply:`${e}${(o=n.apply)!=null?o:n.label}`}}):t,Do=t=>t===void 0?!1:["Times","Divide","Plus","Minus"].includes(t.name),q=(t,e)=>{var r;let{lastChild:n}=t,{pos:o}=e;for(;n;)if(n.from<o&&Ve.includes(n.name)){if(n.name==="ParenthesizedExpression"){let i=(r=n.firstChild)==null?void 0:r.nextSibling;i&&(n=i)}return n}else n=n.prevSibling},At=(t,e)=>{var n;if(t.name==="ArgList"){let o=t.prevSibling;if(o)return O(o,e)}else if(t.name==="OpenBrace"){let o=(n=t.parent)==null?void 0:n.prevSibling;if((o==null?void 0:o.name)==="Function")return O(o,e)}},Ht=(t,e)=>{if(t.name==="RelationalExpression"){let n=Ke(t);if((n==null?void 0:n.name)==="RelationalOperator")return O(n,e)}else{let n=t.prevSibling;if((n==null?void 0:n.name)==="RelationalOperator")return O(n,e)}},Ge=(t,e)=>{var n;if(t.name==="RelationalExpression"){if(((n=t.firstChild)==null?void 0:n.name)==="Column")return O(t.firstChild,e)}else{let o=t.prevSibling;if((o==null?void 0:o.name)==="Column")return O(o,e);if((o==null?void 0:o.name)==="RelationalOperator")return Ge(o,e)}},Be=async(t,e,n,o={})=>{let r=await e.getSuggestions(n,o),{startsWith:s=""}=o;return{from:t.pos-s.length,options:r}},We=(t,e,n,o,r)=>{let s=q(t,e);switch(console.log(`conditional expression last child ${s==null?void 0:s.name}`),s==null?void 0:s.name){case"If":return Be(e,n,"expression",{prefix:"( "});case"OpenBrace":return Be(e,n,"expression");case"Condition":return Be(e,n,"expression",{prefix:", "});case"CloseBrace":if(o){let i=[{apply:()=>{r==null||r()},label:"Save Expression",boost:10}];return{from:e.pos,options:i}}}},Mo=(t,e)=>{let n=[{apply:()=>{e==null||e()},label:"Save Expression",boost:10}];return{from:t.pos,options:n}},Lt=(t,e)=>{let n=Ot(async(o,r,s={})=>{let i=await t.getSuggestions(r,s),{startsWith:u=""}=s;return{from:o.pos-u.length,options:i}},[t]);return Ot(async o=>{var g,b;let{state:r,pos:s}=o,i=(g=o.matchBefore(/\w*/))!=null?g:{from:0,to:0,text:void 0},a=Po(r).resolveInner(s,-1),c=r.doc.toString(),p=St(c);switch(console.log({nodeBeforeName:a.name}),a.name){case"If":return console.log("conditional expression If"),n(o,"expression",{prefix:"( "});case"Condition":{let l=q(a,o);if((l==null?void 0:l.name)==="Column"){let m=wo(l);if((m==null?void 0:m.name)!=="RelationalOperator")return n(o,"condition-operator",{columnName:O(l,r)});console.log(`Condition last child Column, prev child ${m==null?void 0:m.name}`)}else if((l==null?void 0:l.name)==="RelationalOperator")return n(o,"expression");console.log(`condition last child ${l==null?void 0:l.name}`)}break;case"ConditionalExpression":return We(a,o,t);case"RelationalExpression":{if(wt(a))return{from:o.pos,options:So.concat({label:", <truthy expression>, <falsy expression>",apply:", "})};{let l=Ht(a,r),m=Ge(a,r);if(l)return n(o,"expression");{let f=await t.getSuggestions("condition-operator",{columnName:m});return{from:o.pos,options:f}}}}break;case"RelationalOperator":return n(o,"expression");case"String":{let l=Ht(a,r),m=Ge(a,r),{from:f,to:C}=a;if(C-f===2&&o.pos===f+1){if(m&&l)return n(o,"columnValue",{columnName:m,operator:l,startsWith:i.text})}else if(C-f>2&&o.pos===C)return n(o,"expression",{prefix:", "});console.log(`we have a string, column is ${m} ${f} ${C}`)}break;case"ArithmeticExpression":{let l=q(a,o);if((l==null?void 0:l.name)==="Column")return n(o,"expression");if(Do(l)){let m=l.name;return n(o,"column",{operator:m})}}break;case"OpenBrace":{let l=At(a,r);return n(o,"expression",{functionName:l})}break;case"ArgList":{let l=At(a,r),m=q(a,o),f=(m==null?void 0:m.name)==="OpenBrace"?void 0:",",C=await t.getSuggestions("expression",{functionName:l});return C=f?Ro(C,", "):C,(m==null?void 0:m.name)!=="OpenBrace"&&(m==null?void 0:m.name)!=="Comma"&&(C=[{apply:") ",boost:10,label:"Done - no more arguments"}].concat(C)),{from:o.pos,options:C}}case"Equal":if(c.trim()==="=")return n(o,"expression");break;case"ParenthesizedExpression":case"ColumnDefinitionExpression":if(o.pos===0)return n(o,"expression");{let l=q(a,o);if((l==null?void 0:l.name)==="Column"){if(p){let m=[{apply:()=>{e.current()},label:"Save Expression",boost:10}],f=O(l,r),C=await t.getSuggestions("operator",{columnName:f});return{from:o.pos,options:m.concat(C)}}}else if((l==null?void 0:l.name)==="CallExpression"){if(p){let m=[{apply:()=>{e.current()},label:"Save Expression",boost:10}];return{from:o.pos,options:m}}}else if((l==null?void 0:l.name)==="ArithmeticExpression"){if(p){let m=[{apply:()=>{e.current()},label:"Save Expression",boost:10}],f=q(l,o);if((f==null?void 0:f.name)==="Column"){let C=O(f,r),x=await t.getSuggestions("operator",{columnName:C});m=m.concat(x)}return{from:o.pos,options:m}}}else if((l==null?void 0:l.name)==="ConditionalExpression")return We(l,o,t,p,e.current);break}case"Column":if(await t.isPartialMatch("expression",void 0,i.text))return n(o,"expression",{startsWith:i.text});break;case"Comma":{let l=Mt(a);if((l==null?void 0:l.name)==="ConditionalExpression")return n(o,"expression")}break;case"CloseBrace":{let l=Mt(a);if((l==null?void 0:l.name)==="ConditionalExpression")return We(l,o,t,p,e.current);if((l==null?void 0:l.name)==="ArgList"&&p)return Mo(o,e.current);console.log(`does closebrace denote an ARgList or a parenthetised expression ? ${l}`)}break;default:((b=a==null?void 0:a.prevSibling)==null?void 0:b.name)==="FilterClause"&&console.log("looks like we ight be a or|and operator")}},[n,e,t])};var ue=t=>{if(t.current==null)throw Error("EditorView not defined");return t.current},Io=()=>"vuuSuggestion",zo=()=>console.log("noooop"),$o=t=>"expressionType"in t,Vo=t=>{if($o(t)){let e=Ft("div","expression-type-container"),n=Ft("span","expression-type",t.expressionType);return e.appendChild(n),e}else return null},It=({onChange:t,onSubmitExpression:e,suggestionProvider:n})=>{let o=Ue(null),r=Ue(zo),s=Ue(),i=Lt(n,r),[u,a]=Fo(()=>{let c=()=>{let f=ue(s),C=f.state.doc.toString(),x=Lo(f.state,f.state.doc.length,5e3);if(x){let P=Tt(x,C);return[C,P]}else return["",void 0]},p=()=>{ue(s).setState(m())},g=()=>{let[f,C]=c();e==null||e(f,C),p()},b=f=>Qe.of([{key:f,run(){return g(),!0}}]),l=f=>Qe.of([{key:f,run(){return Nt(ue(s)),!0}}]),m=()=>Ho.create({doc:"",extensions:[ko,Oo({addToOptions:[{render:Vo,position:70}],override:[i],optionClass:Io}),yt(),Qe.of(Ao),b("Ctrl-Enter"),l("ArrowDown"),kt.updateListener.of(f=>{let C=ue(s);if(f.docChanged){Nt(C);let x=C.state.doc.toString();t==null||t(x,void 0)}}),Dt,Rt]});return r.current=()=>{g(),setTimeout(()=>{ue(s).focus()},100)},[m,p]},[i,t,e]);return No(()=>{if(!o.current)throw Error("editor not in dom");return s.current=new kt({state:u(),parent:o.current}),()=>{var c;(c=s.current)==null||c.destroy()}},[i,u]),{editorRef:o,clearInput:a}};import{jsx as Bo}from"react/jsx-runtime";var Ko="vuuColumnExpressionInput",zt=({onChange:t,onSubmitExpression:e,suggestionProvider:n})=>{let{editorRef:o}=It({onChange:t,onSubmitExpression:e,suggestionProvider:n});return Bo("div",{className:`${Ko}`,ref:o})};import{AnnotationType as Wo,getRelationalOperators as Go,numericOperators as Qo,stringOperators as Uo,toSuggestions as Xo}from"@vuu-ui/vuu-codemirror";import{getTypeaheadParams as Yo,useTypeaheadSuggestions as _o}from"@vuu-ui/vuu-data-react";import{isNumericColumn as Ye,isTextColumn as Zo}from"@vuu-ui/vuu-utils";import{useCallback as Xe,useRef as Jo}from"react";var j=[{accepts:"string",description:"Returns multiple string values as a single joined string. Arguments may be string literal values, string columns or other string expressions. Non string arguments may also be included, these will be converted to strings.",example:{expression:'concatenate("example", "-test")',result:'"example-test"'},name:"concatenate",params:{description:"( string, string, [ string* ] )"},type:"string"},{accepts:["string","string"],description:"Tests a string value to determine whether it contains a given substring. Accepts two arguments: source text and target substring. Returns true if <source text> contains one or more occurrences of <target subscring>",example:{expression:'contains("Royal Bank of Scotland", "bank")',result:"true"},name:"contains",params:{description:"( string )"},type:"boolean"},{accepts:["string","number"],description:"Returns the leftmost <number> characters from <string>. First argument may be a string literal, string column or other string expression.",example:{expression:'left("USD Benchmark Report", 3)',result:'"USD"'},name:"left",params:{count:2,description:"( string, number )"},type:"string"},{accepts:"string",description:"Returns the number of characters in <string>. Argument may be a string literal, string column or other string expression.",example:{expression:'len("example")',result:"7"},name:"len",params:{description:"(string)"},type:"number"},{accepts:"string",description:"Convert a string value to lowercase. Argument may be a string column or other string expression.",example:{expression:'lower("examPLE")',result:'"example"'},name:"lower",params:{description:"( string )"},type:"string"},{accepts:"string",description:"Convert a string value to uppercase. Argument may be a string column or other string expression.",example:{expression:'upper("example")',result:'"EXAMPLE"'},name:"upper",params:{description:"( string )"},type:"string"},{accepts:["string","number"],description:"Returns the rightmost <number> characters from <string>. First argument may be a string literal, string column or other string expression.",example:{expression:"blah",result:"blah"},name:"right",params:{description:"( string )"},type:"string"},{accepts:["string","string","string"],description:"Replace characters within a string. Accepts three arguments: source text, text to replace and replacement text. Returns a copy of <source text> with any occurrences of <text to replace> replaced by <replacement text>",example:{expression:"blah",result:"blah"},name:"replace",params:{description:"( string )"},type:"string"},{accepts:"number",description:"Converts a number to a string.",example:{expression:"blah",result:"blah"},name:"text",params:{description:"( string )"},type:"string"},{accepts:"string",description:"Tests a string value to determine whether it starts with a given substring. Accepts two arguments: source text and target substring. Returns true if <source text> starts with <target subscring>.",example:{expression:"blah",result:"blah"},name:"starts",params:{description:"( string )"},type:"boolean"},{accepts:"string",description:"Tests a string value to determine whether it ends with a given substring. Accepts two arguments: source text and target substring. Returns true if <source text> ends with <target subscring>.",example:{expression:"blah",result:"blah"},name:"ends",params:{description:"( string )"},type:"boolean"},{accepts:"number",description:"blah",example:{expression:"blah",result:"blah"},name:"min",params:{description:"( string )"},type:"number"},{accepts:"number",description:"blah",example:{expression:"blah",result:"blah"},name:"max",params:{description:"( string )"},type:"number"},{accepts:"number",description:"blah",example:{expression:"blah",result:"blah"},name:"sum",params:{description:"( string )"},type:"number"},{accepts:"number",description:"blah",example:{expression:"blah",result:"blah"},name:"round",params:{description:"( string )"},type:"number"},{accepts:"any",description:"blah",example:{expression:"blah",result:"blah"},name:"or",params:{description:"( string )"},type:"boolean"},{accepts:"any",description:"blah",example:{expression:"blah",result:"blah"},name:"and",params:{description:"( string )"},type:"boolean"},{accepts:"any",description:"Return one of two possible result values, depending on the evaluation of a filter expression. If <filterExpression> resolves to true, result is <expression1>, otherwise <expression2>. ",example:{expression:"blah",result:"blah"},name:"if",params:{description:"( filterExpression, expression1, expression 2)"},type:"variable"}];import{createEl as A}from"@vuu-ui/vuu-utils";var $t=({name:t,description:e,example:n,params:o,type:r})=>{let s=A("div","vuuFunctionDoc"),i=A("div","function-heading"),u=A("span","function-name",t),a=A("span","param-list",o.description),c=A("span","function-type",r);i.appendChild(u),i.appendChild(a),i.appendChild(c);let p=A("p",void 0,e);if(s.appendChild(i),s.appendChild(p),n){let g=A("div","example-container","Example:"),b=A("div","example-expression",n.expression),l=A("div","example-result",n.result);g.appendChild(b),g.appendChild(l),s.appendChild(g)}return s};var qo=[],K=t=>t.map(e=>{var n;return{...e,apply:((n=e.apply)!=null?n:e.label)+" "}}),jo=(t,{functionName:e,operator:n})=>{if(n)return t.filter(Ye);if(e){let o=j.find(r=>r.name===e);if(o)switch(o.accepts){case"string":return t.filter(Zo);case"number":return t.filter(Ye);default:return t}}return t},Vt=(t,e)=>jo(t,e).map(o=>{var s;let r=(s=o.label)!=null?s:o.name;return{apply:e.prefix?`${e.prefix}${r}`:r,label:r,boost:5,type:"column",expressionType:o.serverDataType}}),er=[{apply:"* ",boost:2,label:"*",type:"operator"},{apply:"/ ",boost:2,label:"/",type:"operator"},{apply:"+ ",boost:2,label:"+",type:"operator"},{apply:"- ",boost:2,label:"-",type:"operator"}],tr=t=>t===void 0||Ye(t)?er:qo,nr=t=>{switch(t.serverDataType){case"string":case"char":return K(Uo);case"int":case"long":case"double":return K(Qo)}},_e=t=>({apply:`${t.name}( `,boost:2,expressionType:t.type,info:()=>$t(t),label:t.name,type:"function"}),or=t=>{if(t){if(typeof t.accepts=="string")return t.accepts;if(Array.isArray(t.accepts))return t.accepts.every(e=>e==="string")?"string":"any"}return"any"},rr=j.map(_e),sr=({functionName:t})=>{if(t){let e=j.find(o=>o.name===t),n=or(e);if(e)switch(n){case"string":return j.filter(o=>o.type==="string"||o.type==="variable").map(_e);case"number":return j.filter(o=>o.type==="number"||o.type==="variable").map(_e);default:}}return rr},ir={},Kt=({columns:t,table:e})=>{let n=Xe(u=>u?t.find(a=>a.name===u):void 0,[t]),o=Jo(),r=_o(),s=Xe(async(u,a=ir)=>{let{columnName:c,functionName:p,operator:g,prefix:b}=a;switch(u){case"expression":{let l=await K(Vt(t,{functionName:p,prefix:b})).concat(sr(a));return o.current=l}case"column":{let l=await Vt(t,a);return o.current=K(l)}case"operator":{let l=await tr(n(c));return o.current=K(l)}case"relational-operator":{let l=await Go(n(c));return o.current=K(l)}case"condition-operator":{let l=n(c);if(l){let m=await nr(l);if(m)return o.current=K(m)}}break;case"columnValue":if(c&&g){let l=Yo(e,c),m=await r(l);return o.current=Xo(m,{suffix:""}),o.current.forEach(f=>{f.apply=(C,x,P)=>{let R=new Wo,I=P+x.label.length+1;C.dispatch({changes:{from:P,insert:x.label},selection:{anchor:I,head:I},annotations:R.of(x)})}}),o.current}break}return[]},[t,n,r,e]),i=Xe(async(u,a,c)=>{let{current:p}=o,g=!1,b=p||await s(u,{columnName:a});if(c&&b)for(let l of b){if(l.label===c)return!1;l.label.startsWith(c)&&(g=!0)}return g},[s]);return{getSuggestions:s,isPartialMatch:i}};import{Button as et,Panel as es}from"@salt-ds/core";import ts from"classnames";import{useCallback as de,useState as an}from"react";import{Stack as Sr}from"@vuu-ui/vuu-layout";import{StepperInput as wr}from"@salt-ds/lab";import{Checkbox as Pr,FormField as B,FormFieldLabel as W,Input as Je,Panel as Zt,RadioButton as ce,RadioButtonGroup as Jt,Text as Rr}from"@salt-ds/core";import Dr from"classnames";import{useCallback as te,useState as Mr}from"react";import{getRegisteredCellRenderers as gr}from"@vuu-ui/vuu-utils";import{Dropdown as Cr}from"@salt-ds/lab";import{Panel as br}from"@salt-ds/core";import Xt from"classnames";import{useMemo as hr}from"react";import{StepperInput as lr,Switch as Bt}from"@salt-ds/lab";import{FormField as ar,FormFieldLabel as ur,Text as cr}from"@salt-ds/core";import{useCallback as Te}from"react";import{Fragment as Gt,jsx as ee,jsxs as Wt}from"react/jsx-runtime";var mr={alignOnDecimals:!1,decimals:4,zeroPad:!1},pr=(t,e)=>{let n=typeof t=="object"&&t.formatting?t.formatting:{};return["alignOnDecimals","decimals","zeroPad"].reduce((r,s)=>n[s]!==void 0?{...r,[s]:n[s]}:(e==null?void 0:e[s])!==void 0?{...r,[s]:e[s]}:r,mr)},Qt=({column:t,dispatchColumnAction:e})=>{let{decimals:n,alignOnDecimals:o,zeroPad:r}=pr(t==null?void 0:t.type),s=Te(c=>e({type:"updateColumnTypeFormatting",column:t,...c}),[t,e]),i=Te(c=>s({decimals:parseInt(c.toString(),10)}),[s]),u=Te(c=>s({alignOnDecimals:!!c.target.value}),[s]),a=Te(c=>s({zeroPad:!!c.target.value}),[s]);switch(t.serverDataType){case"double":return Wt(Gt,{children:[Wt(ar,{labelPlacement:"top",children:[ee(ur,{children:"No of Decimals"}),ee(lr,{value:n,onChange:i})]}),ee(Bt,{checked:o,label:"Align on decimals",onChange:u}),ee(Bt,{checked:r,label:"Zero pad",onChange:a})]});case"long":case"int":return ee(Gt,{children:ee(cr,{children:"Work in progress"})});default:return null}};import{Fragment as dr,jsx as fr}from"react/jsx-runtime";var Ut=({column:t,dispatchColumnAction:e})=>(console.log({column:t,dispatchColumnAction:e}),fr(dr,{children:"what"}));import{Fragment as Tr,jsx as Ee,jsxs as Er}from"react/jsx-runtime";var Ze="vuuColumnTypePanel",xr=["Default Renderer (int, long)"],yr=["Default Renderer (double)"],Yt=["Default Renderer (string)"],vr=t=>{let n=gr(t.serverDataType).map(o=>o.name);switch(console.log({customRendererNames:n}),t.serverDataType){case"char":case"string":return Yt;case"int":case"long":return xr;case"double":return yr.concat(n);default:return Yt}},_t=({className:t,column:e,dispatchColumnAction:n,...o})=>{let r=hr(()=>{switch(e.serverDataType){case"double":case"int":case"long":return Ee(Qt,{column:e,dispatchColumnAction:n});default:return Ee(Ut,{column:e,dispatchColumnAction:n})}},[e,n]),{serverDataType:s="string"}=e,i=vr(e);return Er(Tr,{children:[Ee(Cr,{className:Xt(`${Ze}-renderer`),fullWidth:!0,selected:i[0],source:i}),Ee(br,{...o,className:Xt(Ze,t,`${Ze}-${s}`),children:r})]})};import{jsx as y,jsxs as T}from"react/jsx-runtime";var qt="vuuColumnSettingsPanel",Or={className:"salt-density-high"},jt=({column:t,dispatchColumnAction:e,style:n,...o})=>{var b,l,m,f;let[r,s]=Mr(0),i=te(C=>e({type:"updateColumnProp",column:t,...C}),[t,e]),u=te(C=>i({align:C.target.value}),[i]),a=te(C=>i({pin:C.target.value}),[i]),c=te(C=>i({hidden:C.target.checked}),[i]),p=te(C=>i({label:C.target.value}),[i]),g=te(C=>i({width:parseInt(C.toString(),10)}),[i]);return T("div",{className:qt,...o,style:{...n},children:[y(Rr,{as:"h4",children:"Column Settings"}),T(Sr,{active:r,className:Dr(`${qt}-columnTabs`),onTabSelectionChanged:s,TabstripProps:Or,children:[T(Zt,{title:"Column",children:[T(B,{labelPlacement:"left",children:[y(W,{children:"Hidden"}),y(Pr,{checked:t.hidden===!0,onChange:c})]}),T(B,{labelPlacement:"left",children:[y(W,{children:"Label"}),y(Je,{value:(b=t.label)!=null?b:t.name,onChange:p})]}),T(B,{labelPlacement:"left",children:[y(W,{children:"Width"}),y(wr,{value:(l=t.width)!=null?l:100,onChange:g})]}),T(B,{labelPlacement:"left",children:[y(W,{children:"ALign"}),T(Jt,{"aria-label":"Column Align",value:(m=t.align)!=null?m:"left",onChange:u,children:[y(ce,{label:"Left",value:"left"}),y(ce,{label:"Right",value:"right"})]})]}),T(B,{labelPlacement:"left",children:[y(W,{children:"Pin Column"}),T(Jt,{"aria-label":"Pin Column",value:(f=t.pin)!=null?f:"",onChange:a,children:[y(ce,{label:"Do not pin",value:""}),y(ce,{label:"Left",value:"left"}),y(ce,{label:"Right",value:"right"})]})]})]}),y(_t,{column:t,dispatchColumnAction:e,title:"Data Cell"}),T(Zt,{title:"Vuu",variant:"secondary",children:[T(B,{labelPlacement:"top",readOnly:!0,children:[y(W,{children:"Name"}),y(Je,{value:t.name})]}),T(B,{labelPlacement:"top",readOnly:!0,children:[y(W,{children:"Vuu Type"}),y(Je,{value:t.serverDataType})]})]})]})]})};import{FormField as en,FormFieldLabel as tn,Panel as Ar,RadioButton as qe,RadioButtonGroup as Hr,Text as Lr}from"@salt-ds/core";import{StepperInput as kr}from"@salt-ds/lab";import{useCallback as je}from"react";import{jsx as G,jsxs as me}from"react/jsx-runtime";var Nr="vuuGridSettingsPanel",nn=({config:t,dispatchColumnAction:e,style:n,...o})=>{var u;let r=je(a=>e({type:"updateGridSettings",...a}),[e]),s=je(a=>r({columnFormatHeader:a.target.value}),[r]),i=je(a=>r({columnDefaultWidth:parseInt(a.toString(),10)}),[r]);return me("div",{className:Nr,...o,style:{...n},children:[G(Lr,{as:"h4",children:"Grid Settings"}),me(Ar,{children:[me(en,{labelPlacement:"left",children:[G(tn,{children:"Format column labels"}),me(Hr,{"aria-label":"Format column labels",value:t.columnFormatHeader,onChange:s,children:[G(qe,{label:"No Formatting",value:void 0}),G(qe,{label:"Capitalize",value:"capitalize"}),G(qe,{label:"Uppercase",value:"uppercase"})]})]}),me(en,{labelPlacement:"left",children:[G(tn,{children:"Default Column Width"}),G(kr,{value:(u=t.columnDefaultWidth)!=null?u:100,onChange:i})]})]})]})};import{useReducer as Fr}from"react";import{moveItem as Ir}from"@vuu-ui/vuu-ui-controls";import{fromServerDataType as zr}from"@vuu-ui/vuu-utils";var $r=(t,e)=>{switch(console.log(`gridSettingsReducer ${e.type}`),e.type){case"addColumn":return Vr(t,e);case"addCalculatedColumn":return Kr(t,e);case"moveColumn":return Wr(t,e);case"removeColumn":return Br(t,e);case"updateColumn":return t;case"updateColumnProp":return Gr(t,e);case"updateGridSettings":return Qr(t,e);case"updateColumnTypeFormatting":return Ur(t,e);default:return t}},on=t=>{let[e,n]=Fr($r,t);return{gridSettings:e,dispatchColumnAction:n}};function Vr(t,{column:e,columns:n,index:o=-1}){let{columns:r}=t;if(o===-1){if(Array.isArray(n))return{...t,columns:r.concat(n)};if(e)return{...t,columns:r.concat(e)}}return t}function Kr(t,{columnName:e,columnType:n,expression:o}){let{columns:r}=t,s={name:e,expression:o,serverDataType:n};return{...t,columns:r.concat(s)}}function Br(t,{column:e}){let{columns:n}=t;return{...t,columns:n.filter(o=>o.name!==e.name)}}function Wr(t,{column:e,moveBy:n,moveFrom:o,moveTo:r}){let{columns:s}=t;if(e&&typeof n=="number"){let i=s.indexOf(e),u=s.slice(),[a]=u.splice(i,1);return u.splice(i+n,0,a),{...t,columns:u}}else return typeof o=="number"&&typeof r=="number"?{...t,columns:Ir(s,o,r)}:t}function Gr(t,{align:e,column:n,hidden:o,label:r,width:s}){let{columns:i}=t;return(e==="left"||e==="right")&&(i=pe(i,{...n,align:e})),typeof o=="boolean"&&(i=pe(i,{...n,hidden:o})),typeof r=="string"&&(i=pe(i,{...n,label:r})),typeof s=="number"&&(i=pe(i,{...n,width:s})),{...t,columns:i}}function Qr(t,{columnFormatHeader:e}){return{...t,columnFormatHeader:e!=null?e:t.columnFormatHeader}}function Ur(t,{alignOnDecimals:e,column:n,decimals:o,zeroPad:r}){let{columns:s}=t;if(s.find(u=>u.name===n.name)){let{serverDataType:u="string",type:a=zr(u)}=n,c=typeof a=="string"?{name:a}:{...a};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}),{...t,columns:pe(s,{...n,type:c})}}else return t}function pe(t,e){return t.map(n=>n.name===e.name?e:n)}import{Stack as ns}from"@vuu-ui/vuu-layout";import{Button as Xr,FormField as Yr,FormFieldLabel as _r,Input as Zr,Panel as Jr,Text as qr}from"@salt-ds/core";import{useCallback as Se,useRef as jr,useState as rn}from"react";import{jsx as ne,jsxs as sn}from"react/jsx-runtime";var ln=({columns:t,dispatchColumnAction:e,table:n})=>{let[o,r]=rn(""),[,s]=rn(),i=jr(""),u=Kt({columns:t,table:n}),a=Se(b=>{let{value:l}=b.target;r(l)},[]),c=Se(b=>{i.current=b},[]),p=Se((b,l)=>{console.log({source:b}),s(l)},[]),g=Se(()=>{i.current&&(console.log(`save expression ${JSON.stringify(i.current,null,2)}`),e({type:"addCalculatedColumn",columnName:o,expression:i.current,columnType:"string"}))},[o,e]);return sn(Jr,{className:"vuuCalculatedColumnPanel",title:"Define Computed Column",children:[ne(qr,{styleAs:"h4",children:"Define Computed Column"}),sn(Yr,{labelPlacement:"left",children:[ne(_r,{children:"Column Name"}),ne(Zr,{value:o,onChange:a})]}),ne(zt,{onChange:c,onSubmitExpression:p,suggestionProvider:u}),ne("div",{style:{marginTop:12},children:ne(Xr,{onClick:g,children:"Add Column"})})]})};import{jsx as H,jsxs as tt}from"react/jsx-runtime";var we="vuuDatagridSettingsPanel",os=()=>{},rs=["table-settings","column-chooser","column-settings","define-column"],ss=(t,e)=>rs[e],xc=({availableColumns:t,className:e,gridConfig:n,onCancel:o,onConfigChange:r,...s})=>{var I;console.log("DatagridSettingsPanel render");let[i,u]=an(0),{gridSettings:a,dispatchColumnAction:c}=on(n),[p,g]=an(null),b=de(S=>{g(S?S.name:null)},[]),l=de((S,Ae=!1)=>{console.log("1) DataGridSettingsPanel fire onConfigChange"),r==null||r(a,Ae)},[a,r]),m=de(S=>{u(S)},[]),f=de(S=>l(S,!0),[l]),C=p===null?null:(I=a.columns.find(S=>S.name===p))!=null?I:null,x={activeTabIndex:i,allowRenameTab:!1,orientation:"vertical"},P=de(()=>u(3),[]),R=i===2?"right":void 0;return tt("div",{...s,className:ts(we,e),children:[tt(ns,{TabstripProps:x,className:`${we}-stack`,getTabIcon:ss,getTabLabel:os,active:i===2?1:i,onTabSelectionChanged:m,children:[H(nn,{config:a,dispatchColumnAction:c}),H("div",{className:`${we}-columnPanels`,"data-align":R,children:C===null?H(es,{className:"vuuColumnSettingsPanel",children:"Select a column"}):H(jt,{column:C,dispatchColumnAction:c,style:{background:"white",flex:"1 0 150px"}})}),H("div",{title:"Column Settings",children:"Column Settings"}),H(ln,{columns:a.columns,dispatchColumnAction:c,table:{module:"SIMUL",table:"instruments"}})]}),tt("div",{className:`${we}-buttonBar`,children:[H(et,{onClick:o,children:"Cancel"}),H(et,{onClick:l,children:"Apply"}),H(et,{onClick:f,children:"Save"})]})]})};import{useEffect as is,useState as un}from"react";import ls from"classnames";import{jsx as fe,jsxs as as}from"react/jsx-runtime";var Pe="vuuDatasourceStats",nt=new Intl.NumberFormat,Hc=({className:t,dataSource:e})=>{let[n,o]=un(e.range),[r,s]=un(e.size);is(()=>{s(e.size),e.on("resize",s),e.on("range",o)},[e]);let i=ls(Pe,t),u=nt.format(n.from),a=nt.format(n.to-1),c=nt.format(r);return as("div",{className:i,children:[fe("span",{children:"Showing rows"}),fe("span",{className:`${Pe}-range`,children:u}),fe("span",{className:`${Pe}-range`,children:a}),fe("span",{children:"of"}),fe("span",{className:`${Pe}-size`,children:c})]})};import{FormField as Dn,FormFieldLabel as Mn,Input as zi,ToggleButton as ut,ToggleButtonGroup as $i}from"@salt-ds/core";import{useLayoutEffectSkipFirst as ki}from"@vuu-ui/vuu-layout";import{useCallback as Vc,useRef as Kc}from"react";import{jsx as Gc}from"react/jsx-runtime";import{isNumericColumn as Xc}from"@vuu-ui/vuu-utils";import{removeColumnFromFilter as Zc}from"@vuu-ui/vuu-utils";import{addGroupColumn as qc,addSortColumn as jc,AggregationType as us,setAggregations as em,setSortColumn as tm}from"@vuu-ui/vuu-utils";var{Average:nm,Count:om,Distinct:rm,High:sm,Low:im,Sum:lm}=us;import{ContextMenuProvider as CC}from"@vuu-ui/vuu-popups";import{Button as hC,useIdMemo as xC}from"@salt-ds/core";import{buildColumnMap as ed,getColumnStyle as td,isGroupColumn as nd,metadataKeys as zs,notHidden as od,visibleColumnAtIndex as rd}from"@vuu-ui/vuu-utils";import{useCallback as ld,useMemo as ad}from"react";import{isGroupColumn as dn,isJsonColumn as Ss,isJsonGroup as ws,metadataKeys as Ps,notHidden as Rs}from"@vuu-ui/vuu-utils";import Ds from"classnames";import{memo as Ms,useCallback as fn}from"react";import{getColumnStyle as cs,metadataKeys as ms}from"@vuu-ui/vuu-utils";import{EditableLabel as ps}from"@vuu-ui/vuu-ui-controls";import ds from"classnames";import{memo as fs,useCallback as gs,useRef as Cs,useState as cn}from"react";import{jsx as Re}from"react/jsx-runtime";var{KEY:mn}=ms,ot=fs(({className:t,column:e,columnMap:n,onClick:o,row:r})=>{let s=Cs(null),{align:i,CellRenderer:u,key:a,pin:c,editable:p,resizing:g,valueFormatter:b}=e,[l,m]=cn(!1),f=b(r[a]),[C,x]=cn(f),P=()=>{var M;(M=s.current)==null||M.focus()},R=M=>{M.key==="Enter"&&m(!0)},I=gs(M=>{o==null||o(M,e)},[e,o]),S=()=>{m(!0)},Ae=(M="",pt="",On=!0,An=!1)=>{var dt;m(!1),An?x(M):pt!==M&&x(pt),On===!1&&((dt=s.current)==null||dt.focus())},ct=ds(t,{vuuAlignRight:i==="right",vuuPinFloating:c==="floating",vuuPinLeft:c==="left",vuuPinRight:c==="right","vuuTableCell-resizing":g})||void 0,mt=cs(e);return p?Re("div",{className:ct,"data-editable":!0,role:"cell",style:mt,onKeyDown:R,children:Re(ps,{editing:l,value:C,onChange:x,onMouseDownCapture:P,onEnterEditMode:S,onExitEditMode:Ae,onKeyDown:R,ref:s,tabIndex:0},"title")}):Re("div",{className:ct,role:"cell",style:mt,onClick:I,children:u?Re(u,{column:e,columnMap:n,row:r}):f})},bs);ot.displayName="TableCell";function bs(t,e){return t.column===e.column&&t.onClick===e.onClick&&t.row[mn]===e.row[mn]&&t.row[t.column.key]===e.row[e.column.key]}import{getColumnStyle as hs,getGroupValueAndOffset as xs,metadataKeys as ys}from"@vuu-ui/vuu-utils";import{useCallback as vs}from"react";import{jsx as rt,jsxs as Es}from"react/jsx-runtime";var{IS_LEAF:Ts}=ys,pn=({column:t,onClick:e,row:n})=>{let{columns:o}=t,[r,s]=xs(o,n),i=vs(p=>{e==null||e(p,t)},[t,e]),u=hs(t),a=n[Ts],c=Array(s).fill(0).map((p,g)=>rt("span",{className:"vuuTableGroupCell-spacer"},g));return Es("div",{className:"vuuTableGroupCell vuuPinLeft",onClick:a?void 0:i,role:"cell",style:u,children:[c,a?null:rt("span",{className:"vuuTableGroupCell-toggle","data-icon":"triangle-right"}),rt("span",{children:r})]})};import{jsx as gn,jsxs as ks}from"react/jsx-runtime";var{IDX:Os,IS_EXPANDED:As,SELECTED:Hs}=Ps,De="vuuTableRow",Ls=Ms(function({columnMap:e,columns:n,offset:o,onClick:r,onToggleGroup:s,virtualColSpan:i=0,row:u}){let{[Os]:a,[As]:c,[Hs]:p}=u,g=Ds(De,{[`${De}-even`]:a%2===0,[`${De}-expanded`]:c,[`${De}-preSelected`]:p===2}),b=fn(m=>{let f=m.shiftKey,C=m.ctrlKey||m.metaKey;r==null||r(u,f,C)},[r,u]),l=fn((m,f)=>{(dn(f)||ws(f,u))&&(m.stopPropagation(),s==null||s(u,f))},[s,u]);return ks("div",{"aria-selected":p===1?!0:void 0,"aria-rowindex":a,className:g,onClick:b,role:"row",style:{transform:`translate3d(0px, ${o}px, 0px)`},children:[i>0?gn("div",{role:"cell",style:{width:i}}):null,n.filter(Rs).map(m=>{let f=dn(m),C=Ss(m);return gn(f?pn:ot,{column:m,columnMap:e,onClick:f||C?l:void 0,row:u},m.name)})]})});import qm from"classnames";import{useRef as tp}from"react";import{useCallback as Um,useRef as Xm}from"react";import{jsx as ip,jsxs as lp}from"react/jsx-runtime";import Hp from"classnames";import{useCallback as Fp,useRef as Ip}from"react";import pp from"classnames";import{useContextMenu as Wp}from"@vuu-ui/vuu-popups";import{useContextMenu as yp}from"@vuu-ui/vuu-popups";import Tp from"classnames";import{useCallback as wp}from"react";import{jsx as Dp}from"react/jsx-runtime";import{jsx as Up,jsxs as Xp}from"react/jsx-runtime";import{jsx as gd,jsxs as Cd}from"react/jsx-runtime";var{RENDER_IDX:dd}=zs;import{useContextMenu as kg}from"@vuu-ui/vuu-popups";import{applySort as Fg,buildColumnMap as Ig,isJsonGroup as zg,metadataKeys as ei,moveItem as $g}from"@vuu-ui/vuu-utils";import{useCallback as Bg,useEffect as Wg,useMemo as Gg,useRef as Qg,useState as Ug}from"react";import{isVuuFeatureAction as xd,isVuuFeatureInvocation as yd}from"@vuu-ui/vuu-data-react";import{getFullRange as Td,metadataKeys as $s,WindowRange as Ed}from"@vuu-ui/vuu-utils";import{useCallback as wd,useEffect as Pd,useMemo as Rd,useRef as Dd,useState as Md}from"react";var{SELECTED:Od}=$s;import{useDragDropNext as Ld}from"@vuu-ui/vuu-ui-controls";import{useCallback as Fd,useRef as Id}from"react";import{withinRange as Gd}from"@vuu-ui/vuu-utils";import{useCallback as _d,useEffect as Zd,useLayoutEffect as Jd,useMemo as qd,useRef as jd}from"react";function Vs(t,...e){let n=new Set(t);for(let o of e)for(let r of o)n.add(r);return n}var Cn="ArrowUp",bn="ArrowDown",hn="ArrowLeft",xn="ArrowRight";var yn="Home",vn="End",Tn="PageUp",En="PageDown";var Ks=new Set(["Enter","Delete"," "]),Bs=new Set(["Tab"]),Ws=new Set(["ArrowRight","ArrowLeft"]),Gs=new Set([yn,vn,Tn,En,bn,hn,xn,Cn]),Qs=new Set(["F1","F2","F3","F4","F5","F6","F7","F8","F9","F10","F11","F12"]),$d=Vs(Ks,Gs,Ws,Qs,Bs);import{isValidNumber as ff}from"@vuu-ui/vuu-utils";import{useCallback as bf,useMemo as hf,useRef as xf,useState as yf}from"react";import{useCallback as lf,useEffect as af,useRef as uf}from"react";var Us=new Map,Xs=(t,e,n)=>{switch(n){case"height":return e.height;case"clientHeight":return t.clientHeight;case"clientWidth":return t.clientWidth;case"contentHeight":return e.contentHeight;case"contentWidth":return e.contentWidth;case"scrollHeight":return Math.ceil(t.scrollHeight);case"scrollWidth":return Math.ceil(t.scrollWidth);case"width":return e.width;default:return 0}},cf=new ResizeObserver(t=>{for(let e of t){let{target:n,borderBoxSize:o,contentBoxSize:r}=e,s=Us.get(n);if(s){let[{blockSize:i,inlineSize:u}]=o,[{blockSize:a,inlineSize:c}]=r,{onResize:p,measurements:g}=s,b=!1;for(let[l,m]of Object.entries(g)){let f=Xs(n,{height:i,width:u,contentHeight:a,contentWidth:c},l);f!==m&&(b=!0,g[l]=f)}b&&p&&p(g)}}});import{deselectItem as wf,isRowSelected as Pf,metadataKeys as Ys,selectItem as Rf}from"@vuu-ui/vuu-utils";import{useCallback as Mf,useRef as Of}from"react";var{IDX:Af}=Ys;import{applyFilterToColumns as kf,applyGroupByToColumns as Nf,applySortToColumns as Ff,findColumn as If,getCellRenderer as zf,getColumnName as $f,getTableHeadings as Vf,getValueFormatter as Kf,isFilteredColumn as Bf,isGroupColumn as Wf,isPinned as Gf,isTypeDescriptor as Qf,metadataKeys as _s,updateColumn as Uf,sortPinnedColumns as Xf,stripFilterFromColumns as Yf,moveItem as _f}from"@vuu-ui/vuu-utils";import{useReducer as qf}from"react";var jf=_s.count;import{useCallback as ng,useRef as og}from"react";import{useCallback as ig,useMemo as lg,useRef as ag}from"react";import{actualRowPositioning as cg,virtualRowPositioning as fg}from"@vuu-ui/vuu-utils";import{getColumnsInViewport as bg,itemsChanged as hg}from"@vuu-ui/vuu-utils";import{useCallback as vg,useEffect as Tg,useMemo as Eg,useRef as Sg,useState as wg}from"react";var{KEY:sC,IS_EXPANDED:iC,IS_LEAF:lC}=ei;import SC from"classnames";import{isDataLoading as DC}from"@vuu-ui/vuu-utils";import{jsx as OC,jsxs as AC}from"react/jsx-runtime";import ni from"classnames";import{isJsonAttribute as oi,metadataKeys as ri,registerComponent as si}from"@vuu-ui/vuu-utils";import{jsx as st,jsxs as ci}from"react/jsx-runtime";var ge="vuuJsonCell",{IS_EXPANDED:ii,KEY:li}=ri,ai=t=>{let e=t.lastIndexOf("|");return e===-1?"":t.slice(e+1)},ui=({column:t,row:e})=>{let{key:n}=t,o=e[n],r=!1;oi(o)&&(o=o.slice(0,-1),r=!0);let s=ai(e[li]),i=ni({[`${ge}-name`]:s===o,[`${ge}-value`]:s!==o,[`${ge}-group`]:r});if(r){let u=e[ii]?"minus-box":"plus-box";return ci("span",{className:i,children:[st("span",{className:`${ge}-value`,children:o}),st("span",{className:`${ge}-toggle`,"data-icon":u})]})}else return o?st("span",{className:i,children:o}):null};si("json",ui,"cell-renderer",{});import{ContextMenuProvider as Jx}from"@vuu-ui/vuu-popups";import{metadataKeys as Li,notHidden as jx}from"@vuu-ui/vuu-utils";import{useCallback as Wb,useRef as Gb}from"react";import{getColumnStyle as mi}from"@vuu-ui/vuu-utils";import pi from"classnames";import{useMemo as di}from"react";var Ce=(t,e,n)=>di(()=>{let o=pi(e,{vuuPinFloating:t.pin==="floating",vuuPinLeft:t.pin==="left",vuuPinRight:t.pin==="right",vuuEndPin:n&&t.endPin,[`${e}-resizing`]:t.resizing,[`${e}-right`]:t.align==="right"}),r=mi(t);return{className:o,style:r}},[t,e,n]);import{useContextMenu as sb}from"@vuu-ui/vuu-popups";import lb from"classnames";import{useCallback as mb,useRef as pb,useState as db}from"react";import{jsx as Cb}from"react/jsx-runtime";import{useCallback as vb,useRef as Tb}from"react";import{jsx as wb}from"react/jsx-runtime";import{useCallback as Mb,useRef as Ob}from"react";import{jsx as qb,jsxs as jb}from"react/jsx-runtime";import{isGroupColumn as yi,metadataKeys as vi,notHidden as Ti,RowSelected as Ei}from"@vuu-ui/vuu-utils";import Si from"classnames";import{memo as wi,useCallback as Pi}from"react";import{jsx as fi}from"react/jsx-runtime";var Sn=({column:t,row:e})=>{let{className:n,style:o}=Ce(t,"vuuTableNextCell");return fi("div",{className:n,role:"cell",style:o,children:e[t.key]})};import{getGroupValueAndOffset as gi,metadataKeys as Ci}from"@vuu-ui/vuu-utils";import{useCallback as bi}from"react";import{jsx as it,jsxs as xi}from"react/jsx-runtime";var{IS_LEAF:hi}=Ci,wn=({column:t,onClick:e,row:n})=>{let{columns:o}=t,[r,s]=gi(o,n),{className:i,style:u}=Ce(t,"vuuTable2-groupCell"),a=bi(g=>{e==null||e(g,t)},[t,e]),c=n[hi],p=Array(s).fill(0).map((g,b)=>it("span",{className:"vuuTable2-groupCell-spacer"},b));return xi("div",{className:i,role:"cell",style:u,onClick:c?void 0:a,children:[p,c?null:it("span",{className:"vuuTable2-groupCell-toggle","data-icon":"vuu-triangle-right"}),it("span",{children:r})]})};import{jsx as lt}from"react/jsx-runtime";import{createElement as Oi}from"react";var{IDX:Ri,IS_EXPANDED:Di,SELECTED:Mi}=vi,F="vuuTableNextRow",Pn=wi(({className:t,columnMap:e,columns:n,row:o,offset:r,onClick:s,onToggleGroup:i,...u})=>{let{[Ri]:a,[Di]:c,[Mi]:p}=o,g=Pi(x=>{let P=x.shiftKey,R=x.ctrlKey||x.metaKey;s==null||s(o,P,R)},[s,o]),{True:b,First:l,Last:m}=Ei,f=Si(F,t,{[`${F}-even`]:a%2===0,[`${F}-expanded`]:c,[`${F}-selected`]:p&b,[`${F}-selectedStart`]:p&l,[`${F}-selectedEnd`]:p&m}),C=typeof r=="number"?{transform:`translate3d(0px, ${r}px, 0px)`}:void 0;return Oi("div",{...u,key:`row-${o[0]}`,role:"row",className:f,onClick:g,style:C},lt("span",{className:`${F}-selectionDecorator vuuStickyLeft`}),n.filter(Ti).map(x=>{let R=yi(x)?wn:Sn;return lt(R,{column:x,row:o},x.key)}),lt("span",{className:`${F}-selectionDecorator vuuStickyRight`}))});Pn.displayName="Row";import{useLayoutEffectSkipFirst as yx,useLayoutProviderDispatch as vx}from"@vuu-ui/vuu-layout";import{useContextMenu as Ex}from"@vuu-ui/vuu-popups";import{applySort as wx,buildColumnMap as Px,isValidNumber as Rx,updateColumn as Dx,visibleColumnAtIndex as Mx}from"@vuu-ui/vuu-utils";import{useCallback as Hx,useMemo as Lx,useState as kx}from"react";var Me=(t,e)=>{switch(e.type){case"col-size":return{...t,columns:t.columns.map(n=>n.name===e.column.name?{...n,width:e.width}:n)};case"column-prop":return{...t,columns:t.columns.map(n=>n.name===e.column.name?{...n,[e.property]:e.value}:n)};default:return t}};import{useCallback as Ph,useMemo as Rh,useState as Dh}from"react";import{useMemo as Ah,useRef as Hh}from"react";import{moveItem as Nh}from"@vuu-ui/vuu-ui-controls";import{applyFilterToColumns as Ih,applyGroupByToColumns as zh,applySortToColumns as $h,findColumn as Vh,getCellRenderer as Kh,getColumnName as Bh,getTableHeadings as Wh,getValueFormatter as Gh,isFilteredColumn as Qh,isGroupColumn as Uh,isPinned as Xh,isTypeDescriptor as Yh,logger as Ai,metadataKeys as Hi,sortPinnedColumns as _h,stripFilterFromColumns as Zh}from"@vuu-ui/vuu-utils";import{useReducer as jh}from"react";var{info:ex}=Ai("useTableModel");var tx=Hi.count;import{useCallback as rx,useRef as sx}from"react";import{useCallback as ax,useRef as ux}from"react";import{jsx as ly,jsxs as ay}from"react/jsx-runtime";var{IDX:ry,RENDER_IDX:sy}=Li;import{useCallback as at,useMemo as Ni,useState as Fi}from"react";var Ii=(t,e)=>t.map(({name:n,serverDataType:o})=>{let r=e.find(s=>s.name===n);return{hidden:r==null?void 0:r.hidden,label:r==null?void 0:r.label,name:n,serverDataType:o,subscribed:r!==void 0}}),Rn=({availableColumns:t,onConfigChange:e,tableConfig:n})=>{let[o,r]=Fi(n),s=Ni(()=>Ii(t,o.columns),[t,o.columns]),i=at((p,g)=>{console.log(`move list item from ${p} to ${g}`)},[]),u=at((p,g,b)=>{let l=s.find(m=>m.name===p);if(g==="subscribed")console.log(`unsubscribe from ${p}`);else if(l!=null&&l.subscribed){let m=o.columns.find(f=>f.name===p);if(m){let f=Me(o,{type:"column-prop",property:g,column:m,value:b});r(f)}}},[s,o]),a=at(p=>{let{value:g}=p.target,b=g==="0"?void 0:g==="1"?"capitalize":"uppercase";r(l=>({...l,columnFormatHeader:b}))},[]);ki(()=>{e==null||e(o)},[e,o]);let c=o.columnFormatHeader===void 0?0:o.columnFormatHeader==="capitalize"?1:2;return{columnItems:s,columnLabelsValue:c,onChangeColumnLabels:a,onColumnChange:u,onMoveListItem:i}};import{jsx as Q,jsxs as Oe}from"react/jsx-runtime";var Vi="vuuTableSettingsPanel",My=({availableColumns:t,onConfigChange:e,tableConfig:n,...o})=>{let{columnItems:r,columnLabelsValue:s,onChangeColumnLabels:i,onColumnChange:u,onMoveListItem:a}=Rn({availableColumns:t,onConfigChange:e,tableConfig:n});return Oe("div",{...o,className:Vi,children:[Oe(Dn,{children:[Q(Mn,{children:"Column Labels"}),Oe($i,{className:"vuuToggleButtonGroup",onChange:i,value:s,children:[Q(ut,{className:"vuuIconToggleButton","data-icon":"text-strikethrough",value:0}),Q(ut,{className:"vuuIconToggleButton","data-icon":"text-Tt",value:1}),Q(ut,{className:"vuuIconToggleButton","data-icon":"text-T",value:2})]})]}),Oe(Dn,{children:[Q(Mn,{children:"Default Column Width"}),Q(zi,{className:"vuuInput"})]}),Q(xt,{columnItems:r,onChange:u,onMoveListItem:a})]})};export{zt as ColumnExpressionInput,xt as ColumnList,Ve as ColumnNamedTerms,Hc as DataSourceStats,xc as DatagridSettingsPanel,My as TableSettingsPanel,yt as columnExpressionLanguageSupport,St as isCompleteExpression,wt as isCompleteRelationalExpression,Ke as lastNamedChild,It as useColumnExpressionEditor,Kt as useColumnExpressionSuggestionProvider,Rn as useTableSettings,Tt as walkTree};
3728
2
  //# sourceMappingURL=index.js.map