@vuu-ui/vuu-table-extras 2.1.19-beta.1 → 2.1.19-beta.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (96) hide show
  1. package/package.json +13 -14
  2. package/src/calculated-column/CalculatedColumnPanel.js +95 -0
  3. package/src/calculated-column/useCalculatedColumnPanel.js +60 -0
  4. package/src/calculated-column/useEditCalculatedColumn.js +104 -0
  5. package/src/cell-edit-validators/CaseValidator.js +21 -0
  6. package/src/cell-edit-validators/PatternValidator.js +23 -0
  7. package/src/cell-edit-validators/index.js +2 -0
  8. package/src/cell-renderers/background-cell/BackgroundCell.css.js +103 -0
  9. package/src/cell-renderers/background-cell/BackgroundCell.js +76 -0
  10. package/src/cell-renderers/background-cell/BackgroundCellConfigurationEditor.css.js +9 -0
  11. package/src/cell-renderers/background-cell/BackgroundCellConfigurationEditor.js +71 -0
  12. package/src/cell-renderers/background-cell/BackgroundKeyframes.css.js +187 -0
  13. package/src/cell-renderers/background-cell/index.js +2 -0
  14. package/src/cell-renderers/background-cell/useDirection.js +25 -0
  15. package/src/cell-renderers/button-cell/IconButtonCell.css.js +23 -0
  16. package/src/cell-renderers/button-cell/IconButtonCell.js +33 -0
  17. package/src/cell-renderers/dropdown-cell/DropdownCell.css.js +36 -0
  18. package/src/cell-renderers/dropdown-cell/DropdownCell.js +84 -0
  19. package/src/cell-renderers/dropdown-cell/index.js +1 -0
  20. package/src/cell-renderers/index.js +6 -0
  21. package/src/cell-renderers/lookup-cell/LookupCell.js +15 -0
  22. package/src/cell-renderers/lookup-cell/index.js +1 -0
  23. package/src/cell-renderers/pct-progress-cell/PctProgressCell.css.js +31 -0
  24. package/src/cell-renderers/pct-progress-cell/PctProgressCell.js +49 -0
  25. package/src/cell-renderers/pct-progress-cell/index.js +1 -0
  26. package/src/cell-renderers/progress-cell/ProgressCell.css.js +43 -0
  27. package/src/cell-renderers/progress-cell/ProgressCell.js +74 -0
  28. package/src/cell-renderers/progress-cell/index.js +1 -0
  29. package/src/column-expression-input/ColumnExpressionInput.css.js +94 -0
  30. package/src/column-expression-input/ColumnExpressionInput.js +28 -0
  31. package/src/column-expression-input/column-function-descriptors.js +281 -0
  32. package/src/column-expression-input/column-language-parser/ColumnExpressionLanguage.js +18 -0
  33. package/src/column-expression-input/column-language-parser/ColumnExpressionTreeWalker.js +381 -0
  34. package/src/column-expression-input/column-language-parser/column-expression-parse-utils.js +56 -0
  35. package/src/column-expression-input/column-language-parser/index.js +3 -0
  36. package/src/column-expression-input/functionDocInfo.js +24 -0
  37. package/src/column-expression-input/highlighting.js +18 -0
  38. package/src/column-expression-input/index.js +4 -0
  39. package/src/column-expression-input/theme.js +57 -0
  40. package/src/column-expression-input/useColumnAutoComplete.js +307 -0
  41. package/src/column-expression-input/useColumnExpressionEditor.js +133 -0
  42. package/src/column-expression-input/useColumnExpressionSuggestionProvider.js +211 -0
  43. package/src/column-formatting-settings/BaseNumericFormattingSettings.js +96 -0
  44. package/src/column-formatting-settings/ColumnFormattingPanel.js +112 -0
  45. package/src/column-formatting-settings/DateTimeFormattingSettings.js +116 -0
  46. package/src/column-formatting-settings/LongTypeFormattingSettings.css.js +11 -0
  47. package/src/column-formatting-settings/LongTypeFormattingSettings.js +54 -0
  48. package/src/column-formatting-settings/index.js +3 -0
  49. package/src/column-menu/ColumnMenu.css.js +25 -0
  50. package/src/column-menu/ColumnMenu.js +69 -0
  51. package/src/column-menu/column-action-types.js +0 -0
  52. package/src/column-menu/column-menu-utils.js +318 -0
  53. package/src/column-menu/useColumnActions.js +77 -0
  54. package/src/column-picker/ColumnModel.js +113 -0
  55. package/src/column-picker/ColumnPicker.css.js +96 -0
  56. package/src/column-picker/ColumnPicker.js +204 -0
  57. package/src/column-picker/ColumnPickerAction.js +24 -0
  58. package/src/column-picker/useColumnPicker.js +42 -0
  59. package/src/column-picker/useTableColumnPicker.js +27 -0
  60. package/src/column-picker/useTableColumnPickerDeprecated.js +87 -0
  61. package/src/column-settings-panel/ColumnNameLabel.css.js +18 -0
  62. package/src/column-settings-panel/ColumnNameLabel.js +54 -0
  63. package/src/column-settings-panel/ColumnSettingsPanel.css.js +70 -0
  64. package/src/column-settings-panel/ColumnSettingsPanel.js +173 -0
  65. package/src/column-settings-panel/useColumnSettings.js +205 -0
  66. package/src/csv-upload/CsvUpload.css.js +28 -0
  67. package/src/csv-upload/CsvUpload.js +95 -0
  68. package/src/csv-upload/index.js +7 -0
  69. package/src/csv-upload/parse/csv-constants.js +3 -0
  70. package/src/csv-upload/parse/csv-errors.js +54 -0
  71. package/src/csv-upload/parse/csv-parse.js +79 -0
  72. package/src/csv-upload/parse/csv-schema-validation.js +45 -0
  73. package/src/csv-upload/parse/csv-upload-utils.js +59 -0
  74. package/src/csv-upload/parse/index.js +5 -0
  75. package/src/csv-upload/useCsvUpload.js +260 -0
  76. package/src/csv-upload/useCsvUploadSessionPreview.js +70 -0
  77. package/src/datasource-stats/DatasourceStats.css.js +56 -0
  78. package/src/datasource-stats/DatasourceStats.js +89 -0
  79. package/src/datasource-stats/useDatasourceStats.js +48 -0
  80. package/src/freeze-control/FreezeControl.css.js +108 -0
  81. package/src/freeze-control/FreezeControl.js +96 -0
  82. package/src/freeze-control/FrozenBanner.css.js +16 -0
  83. package/src/freeze-control/FrozenBanner.js +48 -0
  84. package/src/freeze-control/freezeControlBadge.js +9 -0
  85. package/src/freeze-control/useFreezeControl.js +68 -0
  86. package/src/index.js +22 -0
  87. package/src/tabbed-table-config-panel/TabbedTableConfigPanel.css.js +23 -0
  88. package/src/tabbed-table-config-panel/TabbedTableConfigPanel.js +99 -0
  89. package/src/tabbed-table-config-panel/TabbedTableSettingsAction.js +28 -0
  90. package/src/tabbed-table-config-panel/useTabbedTableConfigPanel.js +29 -0
  91. package/src/table-footer/TableFooter.css.js +22 -0
  92. package/src/table-footer/TableFooter.js +30 -0
  93. package/src/table-provider/TableProvider.js +33 -0
  94. package/src/table-settings-panel/TableSettingsPanel.css.js +70 -0
  95. package/src/table-settings-panel/TableSettingsPanel.js +128 -0
  96. package/src/table-settings-panel/useTableSettings.js +50 -0
package/package.json CHANGED
@@ -1,21 +1,21 @@
1
1
  {
2
- "version": "2.1.19-beta.1",
2
+ "version": "2.1.19-beta.2",
3
3
  "author": "heswell",
4
4
  "license": "Apache-2.0",
5
5
  "type": "module",
6
6
  "devDependencies": {
7
- "@vuu-ui/vuu-filter-types": "2.1.19-beta.1",
8
- "@vuu-ui/vuu-protocol-types": "2.1.19-beta.1"
7
+ "@vuu-ui/vuu-filter-types": "2.1.19-beta.2",
8
+ "@vuu-ui/vuu-protocol-types": "2.1.19-beta.2"
9
9
  },
10
10
  "dependencies": {
11
- "@vuu-ui/vuu-codemirror": "2.1.19-beta.1",
12
- "@vuu-ui/vuu-data-react": "2.1.19-beta.1",
13
- "@vuu-ui/vuu-data-types": "2.1.19-beta.1",
14
- "@vuu-ui/vuu-table-types": "2.1.19-beta.1",
15
- "@vuu-ui/vuu-popups": "2.1.19-beta.1",
16
- "@vuu-ui/vuu-table": "2.1.19-beta.1",
17
- "@vuu-ui/vuu-utils": "2.1.19-beta.1",
18
- "@vuu-ui/vuu-ui-controls": "2.1.19-beta.1",
11
+ "@vuu-ui/vuu-codemirror": "2.1.19-beta.2",
12
+ "@vuu-ui/vuu-data-react": "2.1.19-beta.2",
13
+ "@vuu-ui/vuu-data-types": "2.1.19-beta.2",
14
+ "@vuu-ui/vuu-table-types": "2.1.19-beta.2",
15
+ "@vuu-ui/vuu-popups": "2.1.19-beta.2",
16
+ "@vuu-ui/vuu-table": "2.1.19-beta.2",
17
+ "@vuu-ui/vuu-utils": "2.1.19-beta.2",
18
+ "@vuu-ui/vuu-ui-controls": "2.1.19-beta.2",
19
19
  "@lezer/lr": "1.4.2",
20
20
  "@salt-ds/core": "1.54.1",
21
21
  "@salt-ds/lab": "1.0.0-alpha.83",
@@ -31,13 +31,12 @@
31
31
  },
32
32
  "files": [
33
33
  "README.md",
34
- "esm",
35
- "cjs",
34
+ "src",
36
35
  "/types"
37
36
  ],
38
37
  "exports": {
39
38
  ".": {
40
- "import": "./index.js",
39
+ "import": "./src/index.js",
41
40
  "types": "./types/index.d.ts"
42
41
  }
43
42
  },
@@ -0,0 +1,95 @@
1
+ import { jsx, jsxs } from "react/jsx-runtime";
2
+ import { Dropdown, FormField, FormFieldLabel, Input, Option } from "@salt-ds/core";
3
+ import { useCalculatedColumnPanel } from "./useCalculatedColumnPanel.js";
4
+ import { useCallback, useRef } from "react";
5
+ import { getCalculatedColumnDetails } from "@vuu-ui/vuu-utils";
6
+ import { ColumnExpressionInput, useColumnExpressionSuggestionProvider } from "../column-expression-input/index.js";
7
+ const classBase = "vuuCalculatedColumnPanel";
8
+ const CalculatedColumnPanel = ({ column: columnProp, columnModel, onChangeColumn, onChangeServerDataType: onChangeServerDataTypeProp, vuuTable })=>{
9
+ const typeRef = useRef(null);
10
+ const { column, onChangeExpression, onChangeName, onChangeServerDataType } = useCalculatedColumnPanel({
11
+ column: columnProp,
12
+ onChangeColumn,
13
+ onChangeServerDataType: onChangeServerDataTypeProp
14
+ });
15
+ const initialExpressionRef = useRef(getCalculatedColumnDetails(column).expression ?? "");
16
+ const suggestionProvider = useColumnExpressionSuggestionProvider({
17
+ columns: columnModel.selectedColumns,
18
+ table: vuuTable
19
+ });
20
+ const handleSubmitExpression = useCallback(()=>{
21
+ if (typeRef.current) typeRef.current?.querySelector("button")?.focus();
22
+ }, []);
23
+ const { name, serverDataType } = getCalculatedColumnDetails(column);
24
+ return /*#__PURE__*/ jsxs("div", {
25
+ className: classBase,
26
+ children: [
27
+ /*#__PURE__*/ jsx("div", {
28
+ children: column.name
29
+ }),
30
+ /*#__PURE__*/ jsxs(FormField, {
31
+ "data-field": "column-name",
32
+ children: [
33
+ /*#__PURE__*/ jsx(FormFieldLabel, {
34
+ children: "Column Label"
35
+ }),
36
+ /*#__PURE__*/ jsx(Input, {
37
+ className: "vuuInput",
38
+ onChange: onChangeName,
39
+ value: name
40
+ })
41
+ ]
42
+ }),
43
+ /*#__PURE__*/ jsxs(FormField, {
44
+ "data-field": "column-expression",
45
+ children: [
46
+ /*#__PURE__*/ jsx(FormFieldLabel, {
47
+ children: "Expression"
48
+ }),
49
+ /*#__PURE__*/ jsx(ColumnExpressionInput, {
50
+ onChange: onChangeExpression,
51
+ onSubmitExpression: handleSubmitExpression,
52
+ source: initialExpressionRef.current,
53
+ suggestionProvider: suggestionProvider
54
+ })
55
+ ]
56
+ }),
57
+ /*#__PURE__*/ jsxs(FormField, {
58
+ "data-field": "type",
59
+ children: [
60
+ /*#__PURE__*/ jsx(FormFieldLabel, {
61
+ children: "Column type"
62
+ }),
63
+ /*#__PURE__*/ jsxs(Dropdown, {
64
+ className: `${classBase}-type`,
65
+ onSelectionChange: onChangeServerDataType,
66
+ ref: typeRef,
67
+ selected: serverDataType ? [
68
+ serverDataType
69
+ ] : [],
70
+ value: serverDataType,
71
+ children: [
72
+ /*#__PURE__*/ jsx(Option, {
73
+ value: "boolean",
74
+ children: "Boolean"
75
+ }),
76
+ /*#__PURE__*/ jsx(Option, {
77
+ value: "double",
78
+ children: "Double"
79
+ }),
80
+ /*#__PURE__*/ jsx(Option, {
81
+ value: "long",
82
+ children: "Long"
83
+ }),
84
+ /*#__PURE__*/ jsx(Option, {
85
+ value: "string",
86
+ children: "String"
87
+ })
88
+ ]
89
+ })
90
+ ]
91
+ })
92
+ ]
93
+ });
94
+ };
95
+ export { CalculatedColumnPanel };
@@ -0,0 +1,60 @@
1
+ import { getCalculatedColumnDetails, isVuuColumnDataType, setCalculatedColumnExpression, setCalculatedColumnName, setCalculatedColumnType } from "@vuu-ui/vuu-utils";
2
+ import { useCallback, useRef, useState } from "react";
3
+ const applyDefaults = (column)=>{
4
+ const { name, expression, serverDataType } = getCalculatedColumnDetails(column);
5
+ if (void 0 === serverDataType) return {
6
+ ...column,
7
+ name: `${name}:string:${expression}`
8
+ };
9
+ return column;
10
+ };
11
+ const useCalculatedColumnPanel = ({ column: columnProp, onChangeColumn, onChangeServerDataType: onChangeServerDataTypeProp })=>{
12
+ const [column, _setColumn] = useState(applyDefaults(columnProp));
13
+ const columnRef = useRef(columnProp);
14
+ const setColumn = useCallback((column)=>{
15
+ columnRef.current = column;
16
+ _setColumn(column);
17
+ }, []);
18
+ const onChangeName = useCallback((evt)=>{
19
+ const { value } = evt.target;
20
+ const newColumn = setCalculatedColumnName(column, value);
21
+ console.log(`name = ${newColumn.name}`);
22
+ setColumn(newColumn);
23
+ onChangeColumn(newColumn);
24
+ }, [
25
+ column,
26
+ onChangeColumn,
27
+ setColumn
28
+ ]);
29
+ const onChangeExpression = useCallback((value)=>{
30
+ console.log(`expression = ${value}`);
31
+ const expression = value.trim();
32
+ const { current: column } = columnRef;
33
+ const newColumn = setCalculatedColumnExpression(column, expression);
34
+ setColumn(newColumn);
35
+ onChangeColumn(newColumn);
36
+ }, [
37
+ onChangeColumn,
38
+ setColumn
39
+ ]);
40
+ const onChangeServerDataType = useCallback((_e, [serverDataType])=>{
41
+ if (isVuuColumnDataType(serverDataType)) {
42
+ const newColumn = setCalculatedColumnType(column, serverDataType);
43
+ setColumn(newColumn);
44
+ onChangeServerDataTypeProp?.(serverDataType);
45
+ onChangeColumn(newColumn);
46
+ }
47
+ }, [
48
+ column,
49
+ onChangeColumn,
50
+ onChangeServerDataTypeProp,
51
+ setColumn
52
+ ]);
53
+ return {
54
+ column,
55
+ onChangeExpression,
56
+ onChangeName,
57
+ onChangeServerDataType
58
+ };
59
+ };
60
+ export { useCalculatedColumnPanel };
@@ -0,0 +1,104 @@
1
+ import { jsx } from "react/jsx-runtime";
2
+ import { useModal } from "@vuu-ui/vuu-ui-controls";
3
+ import { useCallback, useRef } from "react";
4
+ import { CalculatedColumnPanel } from "./CalculatedColumnPanel.js";
5
+ const useEditCalculatedColumn = ({ calculatedColumn, columnModel, onSaveColumn, vuuTable })=>{
6
+ if (void 0 === vuuTable) throw Error("[useEditCalculatedColumn] vuuTable must be provided to create or edit a calculated column");
7
+ const { showPrompt } = useModal();
8
+ const calculatedColumnRef = useRef(void 0);
9
+ const handleChangeNewCalculatedColumn = useCallback((column)=>{
10
+ if (calculatedColumnRef.current) calculatedColumnRef.current.newColumn = column;
11
+ else throw Error("[TabbedTableConfigPanel] handleChangeNewCalculatedColumn");
12
+ }, []);
13
+ const handleSaveNewCalculatedColumn = useCallback(()=>{
14
+ if (calculatedColumnRef.current) {
15
+ const { current: { newColumn: calculatedColumn } } = calculatedColumnRef;
16
+ columnModel.addColumn(calculatedColumn, true);
17
+ calculatedColumnRef.current = void 0;
18
+ onSaveColumn?.(calculatedColumn);
19
+ }
20
+ const { current: calculatedColumn } = calculatedColumnRef;
21
+ if (calculatedColumn) {
22
+ columnModel.addColumn(calculatedColumn, true);
23
+ calculatedColumnRef.current = void 0;
24
+ onSaveColumn?.(calculatedColumn);
25
+ }
26
+ }, [
27
+ columnModel,
28
+ onSaveColumn
29
+ ]);
30
+ const handleCreateCalculatedColumn = useCallback(()=>{
31
+ if (vuuTable) {
32
+ const newColumn = {
33
+ name: "::",
34
+ serverDataType: "string"
35
+ };
36
+ calculatedColumnRef.current = {
37
+ newColumn
38
+ };
39
+ showPrompt(/*#__PURE__*/ jsx(CalculatedColumnPanel, {
40
+ column: newColumn,
41
+ columnModel: columnModel,
42
+ onChangeColumn: handleChangeNewCalculatedColumn,
43
+ vuuTable: vuuTable
44
+ }), {
45
+ confirmButtonLabel: "Save column",
46
+ onConfirm: handleSaveNewCalculatedColumn,
47
+ title: "Calculated column"
48
+ });
49
+ }
50
+ }, [
51
+ columnModel,
52
+ handleChangeNewCalculatedColumn,
53
+ handleSaveNewCalculatedColumn,
54
+ showPrompt,
55
+ vuuTable
56
+ ]);
57
+ const handleSaveColumnEdits = useCallback(()=>{
58
+ if (calculatedColumnRef.current) {
59
+ const { originalColumn, newColumn } = calculatedColumnRef.current;
60
+ if (originalColumn) {
61
+ calculatedColumnRef.current = void 0;
62
+ onSaveColumn?.(newColumn);
63
+ columnModel.updateColumn(originalColumn, newColumn);
64
+ }
65
+ }
66
+ }, [
67
+ columnModel,
68
+ onSaveColumn
69
+ ]);
70
+ const handleUpdateCalculatedColumn = useCallback((column)=>{
71
+ if (calculatedColumnRef.current) calculatedColumnRef.current.newColumn = column;
72
+ else throw Error("[TabbedTableConfigPanel] handleUpdateCalculatedColumn`");
73
+ }, []);
74
+ const handleEditCalculatedColumn = useCallback(()=>{
75
+ if (calculatedColumn && vuuTable) {
76
+ calculatedColumnRef.current = {
77
+ originalColumn: calculatedColumn,
78
+ newColumn: calculatedColumn
79
+ };
80
+ showPrompt(/*#__PURE__*/ jsx(CalculatedColumnPanel, {
81
+ column: calculatedColumn,
82
+ columnModel: columnModel,
83
+ onChangeColumn: handleUpdateCalculatedColumn,
84
+ vuuTable: vuuTable
85
+ }), {
86
+ confirmButtonLabel: "Save column",
87
+ onConfirm: handleSaveColumnEdits,
88
+ title: "Calculated column"
89
+ });
90
+ }
91
+ }, [
92
+ calculatedColumn,
93
+ columnModel,
94
+ handleSaveColumnEdits,
95
+ handleUpdateCalculatedColumn,
96
+ showPrompt,
97
+ vuuTable
98
+ ]);
99
+ return {
100
+ onCreateCalculatedColumn: handleCreateCalculatedColumn,
101
+ onEditCalculatedColumn: handleEditCalculatedColumn
102
+ };
103
+ };
104
+ export { useEditCalculatedColumn };
@@ -0,0 +1,21 @@
1
+ import { registerComponent } from "@vuu-ui/vuu-utils";
2
+ import { OK } from "@vuu-ui/vuu-data-react";
3
+ const isString = (value)=>"string" == typeof value;
4
+ const CaseValidator = (rule, value)=>{
5
+ if (!isString(value)) return {
6
+ ok: false,
7
+ message: "value must be a string"
8
+ };
9
+ if ("" === value) return OK;
10
+ if ("lower" === rule.value && value.toLowerCase() !== value) return {
11
+ ok: false,
12
+ message: "value must be all lowercase"
13
+ };
14
+ if ("upper" === rule.value && value.toUpperCase() !== value) return {
15
+ ok: false,
16
+ message: "value must be all uppercase"
17
+ };
18
+ return OK;
19
+ };
20
+ registerComponent("vuu-case", CaseValidator, "data-edit-validator", {});
21
+ export { CaseValidator };
@@ -0,0 +1,23 @@
1
+ import { registerComponent } from "@vuu-ui/vuu-utils";
2
+ import { OK } from "@vuu-ui/vuu-data-react";
3
+ const isString = (value)=>"string" == typeof value;
4
+ const defaultMessage = "value does not match expected pattern";
5
+ const PatternValidator = (rule, value)=>{
6
+ if ("string" != typeof rule.value) throw Error("Pattern validation rule must provide pattern");
7
+ if (!isString(value)) return {
8
+ ok: false,
9
+ message: "value must be a string"
10
+ };
11
+ if ("" === value) return OK;
12
+ {
13
+ const { message = defaultMessage } = rule;
14
+ const pattern = new RegExp(rule.value);
15
+ if (pattern.test(value)) return OK;
16
+ return {
17
+ ok: false,
18
+ message
19
+ };
20
+ }
21
+ };
22
+ registerComponent("vuu-pattern", PatternValidator, "data-edit-validator", {});
23
+ export { PatternValidator };
@@ -0,0 +1,2 @@
1
+ export * from "./CaseValidator.js";
2
+ export * from "./PatternValidator.js";
@@ -0,0 +1,103 @@
1
+ const css = `
2
+ .vuuBackgroundCell {
3
+ --background-animation-duration: 10s;
4
+ color: var(--vuuBackgroundCell-color, var(--salt-content-primary-foreground));
5
+ padding-right: var(--salt-size-unit);
6
+ position: relative;
7
+ }
8
+
9
+ .vuuBackgroundCell-arrowBackground, .vuuBackgroundCell-arrowOnly {
10
+ padding-left: 14px;
11
+ }
12
+
13
+ .vuuBackgroundCell-value {
14
+ z-index: 1;
15
+ position: relative;
16
+ }
17
+
18
+ .vuuBackgroundCell-arrow {
19
+ background-color: var(--background-cell-background);
20
+ text-align: left;
21
+ position: absolute;
22
+ inset: 0;
23
+ }
24
+
25
+ .vuuBackgroundCell-arrow + .num {
26
+ padding-left: 8px;
27
+ }
28
+
29
+ .right .vuuBackgroundCell-arrow {
30
+ text-align: right;
31
+ }
32
+
33
+ .right .vuuBackgroundCell-arrow + .num {
34
+ padding-right: 8px;
35
+ }
36
+
37
+ .vuuBackgroundCell-arrowOnly > .vuuBackgroundCell-arrow {
38
+ background-color: #0000;
39
+ }
40
+
41
+ .vuuBackgroundCell-backgroundOnly.up1, .vuuBackgroundCell-arrowBackground.up1 {
42
+ animation-duration: var(--background-animation-duration);
43
+ animation-name: vuubgup1;
44
+ }
45
+
46
+ .vuuBackgroundCell-backgroundOnly.up2, .vuuBackgroundCell-arrowBackground.up2 {
47
+ animation-duration: var(--background-animation-duration);
48
+ animation-name: vuubgup2;
49
+ }
50
+
51
+ .vuuBackgroundCell-backgroundOnly.down1, .vuuBackgroundCell-arrowBackground.down1 {
52
+ animation-duration: var(--background-animation-duration);
53
+ animation-name: vuubgdown1;
54
+ }
55
+
56
+ .vuuBackgroundCell-backgroundOnly.down2, .vuuBackgroundCell-arrowBackground.down2 {
57
+ animation-duration: var(--background-animation-duration);
58
+ animation-name: vuubgdown2;
59
+ }
60
+
61
+ .up1.vuuBackgroundCell-arrowOnly > .vuuBackgroundCell-arrow {
62
+ animation-name: vuuarrowup1;
63
+ animation-duration: 30s;
64
+ }
65
+
66
+ .up2.vuuBackgroundCell-arrowOnly > .vuuBackgroundCell-arrow {
67
+ animation-name: vuuarrowup2;
68
+ animation-duration: 30s;
69
+ }
70
+
71
+ .down1.vuuBackgroundCell-arrowOnly > .vuuBackgroundCell-arrow {
72
+ animation-name: vuuarrowdown1;
73
+ animation-duration: 30s;
74
+ }
75
+
76
+ .down2.vuuBackgroundCell-arrowOnly > .vuuBackgroundCell-arrow {
77
+ animation-name: vuuarrowdown2;
78
+ animation-duration: 30s;
79
+ }
80
+
81
+ .up1.vuuBackgroundCell-arrowBackground > .vuuBackgroundCell-arrow {
82
+ animation-name: vuubgarrowup1;
83
+ animation-duration: 30s;
84
+ }
85
+
86
+ .up2.vuuBackgroundCell-arrowBackground > .vuuBackgroundCell-arrow {
87
+ animation-name: vuubgarrowup2;
88
+ animation-duration: 30s;
89
+ }
90
+
91
+ .down1.vuuBackgroundCell-arrowBackground > .vuuBackgroundCell-arrow {
92
+ animation-name: vuubgarrowdown1;
93
+ animation-duration: 30s;
94
+ }
95
+
96
+ .down2.vuuBackgroundCell-arrowBackground > .vuuBackgroundCell-arrow {
97
+ animation-name: vuubgarrowdown2;
98
+ animation-duration: 30s;
99
+ }
100
+
101
+
102
+ `;
103
+ export default css;
@@ -0,0 +1,76 @@
1
+ import { jsx, jsxs } from "react/jsx-runtime";
2
+ import { useComponentCssInjection } from "@salt-ds/styles";
3
+ import { useWindow } from "@salt-ds/window";
4
+ import { DOWN1, DOWN2, UP1, UP2, dataAndColumnUnchanged, isTypeDescriptor, registerComponent } from "@vuu-ui/vuu-utils";
5
+ import clsx from "clsx";
6
+ import { memo } from "react";
7
+ import { useDirection } from "./useDirection.js";
8
+ import BackgroundCell_0 from "./BackgroundCell.css";
9
+ import BackgroundKeyframes from "./BackgroundKeyframes.css";
10
+ const CHAR_ARROW_UP = String.fromCharCode(11014);
11
+ const CHAR_ARROW_DOWN = String.fromCharCode(11015);
12
+ const classBase = "vuuBackgroundCell";
13
+ const FlashStyle = {
14
+ ArrowOnly: "arrow",
15
+ BackgroundOnly: "bg-only",
16
+ ArrowBackground: "arrow-bg"
17
+ };
18
+ const getFlashStyle = (colType)=>{
19
+ if (isTypeDescriptor(colType) && colType.renderer) {
20
+ if ("flashStyle" in colType.renderer) return colType.renderer["flashStyle"];
21
+ }
22
+ return FlashStyle.BackgroundOnly;
23
+ };
24
+ const BackgroundCell_BackgroundCell = /*#__PURE__*/ memo(function({ column, dataRow }) {
25
+ const targetWindow = useWindow();
26
+ useComponentCssInjection({
27
+ testId: "vuu-background-cell",
28
+ css: BackgroundCell_0,
29
+ window: targetWindow
30
+ });
31
+ useComponentCssInjection({
32
+ testId: "vuu-background-keyframes",
33
+ css: BackgroundKeyframes,
34
+ window: targetWindow
35
+ });
36
+ const { name, type, valueFormatter } = column;
37
+ const value = dataRow[name];
38
+ const flashStyle = getFlashStyle(type);
39
+ const direction = useDirection(dataRow.key, value, column);
40
+ const arrow = flashStyle === FlashStyle.ArrowOnly || flashStyle === FlashStyle.ArrowBackground ? direction === UP1 || direction === UP2 ? CHAR_ARROW_UP : direction === DOWN1 || direction === DOWN2 ? CHAR_ARROW_DOWN : null : null;
41
+ const dirClass = direction ? " " + direction : "";
42
+ const className = clsx(classBase, dirClass, {
43
+ [`${classBase}-backgroundOnly`]: flashStyle === FlashStyle.BackgroundOnly,
44
+ [`${classBase}-arrowOnly`]: flashStyle === FlashStyle.ArrowOnly,
45
+ [`${classBase}-arrowBackground`]: flashStyle === FlashStyle.ArrowBackground
46
+ });
47
+ return /*#__PURE__*/ jsxs("div", {
48
+ className: className,
49
+ tabIndex: -1,
50
+ children: [
51
+ /*#__PURE__*/ jsx("div", {
52
+ className: `${classBase}-arrow`,
53
+ children: arrow
54
+ }),
55
+ /*#__PURE__*/ jsx("span", {
56
+ className: `${classBase}-value`,
57
+ children: valueFormatter(dataRow[name])
58
+ })
59
+ ]
60
+ });
61
+ }, dataAndColumnUnchanged);
62
+ registerComponent("vuu.price-move-background", BackgroundCell_BackgroundCell, "cell-renderer", {
63
+ description: "Change background color of cell when value changes",
64
+ configEditor: "BackgroundCellConfigurationEditor",
65
+ label: "Background Flash",
66
+ serverDataType: [
67
+ "long",
68
+ "int",
69
+ "double",
70
+ "scaleddecimal2",
71
+ "scaleddecimal4",
72
+ "scaleddecimal6",
73
+ "scaleddecimal8"
74
+ ]
75
+ });
76
+ export { BackgroundCell_BackgroundCell as BackgroundCell };
@@ -0,0 +1,9 @@
1
+ const css = `
2
+ .vuuBackgroundCellConfiguration {
3
+ background-color: red;
4
+ height: 50px;
5
+ }
6
+
7
+
8
+ `;
9
+ export default css;
@@ -0,0 +1,71 @@
1
+ import { jsx, jsxs } from "react/jsx-runtime";
2
+ import { registerConfigurationEditor } from "@vuu-ui/vuu-utils";
3
+ import { Dropdown, FormField, FormFieldLabel, Option } from "@salt-ds/core";
4
+ import { useComponentCssInjection } from "@salt-ds/styles";
5
+ import { useWindow } from "@salt-ds/window";
6
+ import { useCallback, useState } from "react";
7
+ import BackgroundCellConfigurationEditor from "./BackgroundCellConfigurationEditor.css";
8
+ const classBase = "vuuBackgroundCellConfiguration";
9
+ const flashOptions = [
10
+ {
11
+ label: "Background Only",
12
+ value: "bg-only"
13
+ },
14
+ {
15
+ label: "Background and Arrow",
16
+ value: "arrow-bg"
17
+ },
18
+ {
19
+ label: "Arrow Only",
20
+ value: "arrow"
21
+ }
22
+ ];
23
+ const [defaultFlashOption] = flashOptions;
24
+ const valueFromColumn = (column)=>{
25
+ const { flashStyle } = column.type.renderer;
26
+ return flashOptions.find((o)=>o.value === flashStyle) || defaultFlashOption;
27
+ };
28
+ const BackgroundCellConfigurationEditor_BackgroundCellConfigurationEditor = ({ column, onChangeRendering })=>{
29
+ const targetWindow = useWindow();
30
+ useComponentCssInjection({
31
+ testId: "vuu-background-cell-configuration-editor",
32
+ css: BackgroundCellConfigurationEditor,
33
+ window: targetWindow
34
+ });
35
+ console.log({
36
+ type: column.type
37
+ });
38
+ const [flashStyle, setFlashStyle] = useState(valueFromColumn(column));
39
+ const handleSelectionChange = useCallback((_, [flashOption])=>{
40
+ setFlashStyle(flashOption);
41
+ const renderProps = column.type.renderer;
42
+ onChangeRendering({
43
+ ...renderProps,
44
+ flashStyle: flashOption?.value ?? defaultFlashOption.value
45
+ });
46
+ }, [
47
+ column.type,
48
+ onChangeRendering
49
+ ]);
50
+ return /*#__PURE__*/ jsxs(FormField, {
51
+ children: [
52
+ /*#__PURE__*/ jsx(FormFieldLabel, {
53
+ children: "Flash Style"
54
+ }),
55
+ /*#__PURE__*/ jsx(Dropdown, {
56
+ className: `${classBase}-flashStyle`,
57
+ onSelectionChange: handleSelectionChange,
58
+ selected: flashStyle ? [
59
+ flashStyle
60
+ ] : [],
61
+ value: flashStyle?.label,
62
+ children: flashOptions.map((flashOption, i)=>/*#__PURE__*/ jsx(Option, {
63
+ value: flashOption,
64
+ children: flashOption.label
65
+ }, i))
66
+ })
67
+ ]
68
+ });
69
+ };
70
+ registerConfigurationEditor("BackgroundCellConfigurationEditor", BackgroundCellConfigurationEditor_BackgroundCellConfigurationEditor);
71
+ export { BackgroundCellConfigurationEditor_BackgroundCellConfigurationEditor as BackgroundCellConfigurationEditor };