@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
@@ -0,0 +1,187 @@
1
+ const css = `
2
+ @keyframes vuubgup1 {
3
+ 0% {
4
+ background-color: var(--salt-sentiment-positive-foreground-informative);
5
+ color: #fff;
6
+ }
7
+
8
+ 40% {
9
+ color: #fff;
10
+ }
11
+
12
+ 60% {
13
+ color: var(--salt-content-primary-foreground);
14
+ }
15
+
16
+ 100% {
17
+ color: var(--salt-content-primary-foreground);
18
+ background-color: #0000;
19
+ }
20
+ }
21
+
22
+ @keyframes vuubgup2 {
23
+ 0% {
24
+ background-color: var(--salt-sentiment-positive-foreground-informative);
25
+ color: #fff;
26
+ }
27
+
28
+ 30% {
29
+ color: #fff;
30
+ }
31
+
32
+ 33% {
33
+ color: var(--salt-content-primary-foreground);
34
+ }
35
+
36
+ 100% {
37
+ color: var(--salt-content-primary-foreground);
38
+ background-color: #0000;
39
+ }
40
+ }
41
+
42
+ @keyframes vuubgdown1 {
43
+ 0% {
44
+ background-color: var(--salt-sentiment-negative-foreground-informative);
45
+ color: #fff;
46
+ }
47
+
48
+ 30% {
49
+ color: #fff;
50
+ }
51
+
52
+ 33% {
53
+ color: var(--salt-content-primary-foreground);
54
+ }
55
+
56
+ 100% {
57
+ color: var(--salt-content-primary-foreground);
58
+ background-color: #0000;
59
+ }
60
+ }
61
+
62
+ @keyframes vuubgdown2 {
63
+ 0% {
64
+ background-color: var(--salt-sentiment-negative-foreground-informative);
65
+ color: #fff;
66
+ }
67
+
68
+ 30% {
69
+ color: #fff;
70
+ }
71
+
72
+ 33% {
73
+ color: var(--salt-content-primary-foreground);
74
+ }
75
+
76
+ 100% {
77
+ color: var(--salt-content-primary-foreground);
78
+ background-color: #0000;
79
+ }
80
+ }
81
+
82
+ @keyframes vuuarrowup1 {
83
+ from {
84
+ color: var(--salt-sentiment-positive-foreground-informative);
85
+ }
86
+
87
+ to {
88
+ color: #0000;
89
+ }
90
+ }
91
+
92
+ @keyframes vuuarrowup2 {
93
+ from {
94
+ color: var(--salt-sentiment-positive-foreground-informative);
95
+ }
96
+
97
+ to {
98
+ color: #0000;
99
+ }
100
+ }
101
+
102
+ @keyframes vuuarrowdown1 {
103
+ from {
104
+ color: var(--salt-sentiment-negative-foreground-informative);
105
+ }
106
+
107
+ to {
108
+ color: #0000;
109
+ }
110
+ }
111
+
112
+ @keyframes vuuarrowdown2 {
113
+ from {
114
+ color: var(--salt-sentiment-negative-foreground-informative);
115
+ }
116
+
117
+ to {
118
+ color: #0000;
119
+ }
120
+ }
121
+
122
+ @keyframes vuubgarrowup1 {
123
+ 0% {
124
+ color: var(--salt-sentiment-positive-foreground-informative);
125
+ background-color: var(--salt-sentiment-positive-foreground-informative);
126
+ }
127
+
128
+ 20% {
129
+ color: var(--salt-sentiment-positive-foreground-informative);
130
+ background-color: #0000;
131
+ }
132
+
133
+ 100% {
134
+ color: #0000;
135
+ background-color: #0000;
136
+ }
137
+ }
138
+
139
+ @keyframes vuubgarrowup2 {
140
+ 0% {
141
+ color: var(--salt-sentiment-positive-foreground-informative);
142
+ background-color: var(--salt-sentiment-positive-foreground-informative);
143
+ }
144
+
145
+ 100% {
146
+ color: #0000;
147
+ background-color: #0000;
148
+ }
149
+ }
150
+
151
+ @keyframes vuubgarrowdown1 {
152
+ 0% {
153
+ color: var(--salt-sentiment-negative-foreground-informative);
154
+ background-color: var(--salt-sentiment-negative-foreground-informative);
155
+ }
156
+
157
+ 20% {
158
+ color: var(--salt-sentiment-negative-foreground-informative);
159
+ background-color: #0000;
160
+ }
161
+
162
+ 100% {
163
+ color: #0000;
164
+ background-color: #0000;
165
+ }
166
+ }
167
+
168
+ @keyframes vuubgarrowdown2 {
169
+ 0% {
170
+ color: var(--salt-sentiment-negative-foreground-informative);
171
+ background-color: var(--salt-sentiment-negative-foreground-informative);
172
+ }
173
+
174
+ 20% {
175
+ color: var(--salt-sentiment-negative-foreground-informative);
176
+ background-color: #0000;
177
+ }
178
+
179
+ 100% {
180
+ color: #0000;
181
+ background-color: #0000;
182
+ }
183
+ }
184
+
185
+
186
+ `;
187
+ export default css;
@@ -0,0 +1,2 @@
1
+ export * from "./BackgroundCell.js";
2
+ export * from "./BackgroundCellConfigurationEditor.js";
@@ -0,0 +1,25 @@
1
+ import { getMovingValueDirection, isTypeDescriptor, isValidNumber } from "@vuu-ui/vuu-utils";
2
+ import { useEffect, useRef } from "react";
3
+ const INITIAL_VALUE = [
4
+ void 0,
5
+ void 0,
6
+ void 0,
7
+ void 0
8
+ ];
9
+ function useDirection(key, value, column) {
10
+ const ref = useRef(void 0);
11
+ const [prevKey, prevValue, prevColumn, prevDirection] = ref.current || INITIAL_VALUE;
12
+ const { type: dataType } = column;
13
+ const decimals = isTypeDescriptor(dataType) ? dataType.formatting?.decimals : void 0;
14
+ const direction = key === prevKey && isValidNumber(value) && isValidNumber(prevValue) && column === prevColumn ? getMovingValueDirection(value, prevDirection, prevValue, decimals) : "";
15
+ useEffect(()=>{
16
+ ref.current = [
17
+ key,
18
+ value,
19
+ column,
20
+ direction
21
+ ];
22
+ });
23
+ return direction;
24
+ }
25
+ export { useDirection };
@@ -0,0 +1,23 @@
1
+ const css = `
2
+ .vuuTableCell:has(.vuuIconButtonCell) {
3
+ padding: 0;
4
+ position: relative;
5
+ }
6
+
7
+ .vuuIconButtonCell {
8
+ --saltButton-height: 100%;
9
+ --saltButton-minWidth: 100%;
10
+ --saltButton-padding: 0;
11
+ --saltButton-width: 100%;
12
+ justify-content: center;
13
+ align-items: center;
14
+ height: 100%;
15
+ padding: 0;
16
+ font-weight: 500;
17
+ display: inline-flex;
18
+ position: relative;
19
+ }
20
+
21
+
22
+ `;
23
+ export default css;
@@ -0,0 +1,33 @@
1
+ import { jsx } from "react/jsx-runtime";
2
+ import { useCallback } from "react";
3
+ import { useComponentCssInjection } from "@salt-ds/styles";
4
+ import { useWindow } from "@salt-ds/window";
5
+ import IconButtonCell from "./IconButtonCell.css";
6
+ import { useRowAction } from "../../table-provider/TableProvider.js";
7
+ import { Button } from "@salt-ds/core";
8
+ const classBase = "vuuIconButtonCell";
9
+ const IconButtonCell_IconButtonCell = ({ column, dataRow })=>{
10
+ const targetWindow = useWindow();
11
+ useComponentCssInjection({
12
+ testId: "vuu-iconbutton-cell",
13
+ css: IconButtonCell,
14
+ window: targetWindow
15
+ });
16
+ const actionHandler = useRowAction(column.name);
17
+ const handleClick = useCallback((evt)=>{
18
+ evt.stopPropagation();
19
+ actionHandler(column.name, dataRow);
20
+ }, [
21
+ actionHandler,
22
+ column,
23
+ dataRow
24
+ ]);
25
+ return /*#__PURE__*/ jsx(Button, {
26
+ appearance: "transparent",
27
+ className: classBase,
28
+ "data-embedded": true,
29
+ "data-icon": true,
30
+ onClick: handleClick
31
+ });
32
+ };
33
+ export { IconButtonCell_IconButtonCell as IconButtonCell };
@@ -0,0 +1,36 @@
1
+ const css = `
2
+ .vuuTableCell {
3
+ & .vuuTableDropdownCell {
4
+ --vuu-icon-height: 15px;
5
+ --vuu-icon-left: calc(100% - var(--salt-spacing-300));
6
+ --vuu-icon-size: 8px;
7
+ --vuu-icon-top: -3px;
8
+ --salt-focused-outlineStyle: none;
9
+ --saltButton-borderRadius: 2px;
10
+ border: solid 1px var(--salt-editable-borderColor);
11
+ height: var(--vuu-table-embedded-control-height);
12
+ min-height: var(--vuu-table-embedded-control-height);
13
+ text-align: left;
14
+ border-radius: 2px;
15
+ font-weight: 500;
16
+ position: relative;
17
+
18
+ & button:focus-visible {
19
+ --saltButton-borderColor: var(--salt-focused-outlineColor);
20
+ --saltButton-borderWidth: 2px;
21
+ padding-left: 7px;
22
+ }
23
+
24
+ &.saltDropdown:focus {
25
+ outline: none;
26
+ }
27
+ }
28
+
29
+ & .vuuTableDropdownCell:focus {
30
+ border: solid 2px var(--salt-focused-outlineColor);
31
+ }
32
+ }
33
+
34
+
35
+ `;
36
+ export default css;
@@ -0,0 +1,84 @@
1
+ import { jsx } from "react/jsx-runtime";
2
+ import { useLookupValues } from "@vuu-ui/vuu-data-react";
3
+ import { dataColumnAndKeyUnchanged, dispatchCustomEvent, getSelectedOption, isRpcSuccess, registerComponent } from "@vuu-ui/vuu-utils";
4
+ import clsx from "clsx";
5
+ import { Dropdown, Option } from "@salt-ds/core";
6
+ import { useComponentCssInjection } from "@salt-ds/styles";
7
+ import { useWindow } from "@salt-ds/window";
8
+ import { memo, useCallback, useMemo, useRef, useState } from "react";
9
+ import DropdownCell_0 from "./DropdownCell.css";
10
+ const classBase = "vuuTableDropdownCell";
11
+ const DropdownCell_DropdownCell = /*#__PURE__*/ memo(function({ column, dataRow, editedDuringCurrentSession, onEdit }) {
12
+ const targetWindow = useWindow();
13
+ useComponentCssInjection({
14
+ testId: "vuu-dropdown-cell",
15
+ css: DropdownCell_0,
16
+ window: targetWindow
17
+ });
18
+ if (editedDuringCurrentSession) console.log(`${column.name} edited ${editedDuringCurrentSession}`);
19
+ const [open, setOpen] = useState(false);
20
+ const dataValue = dataRow[column.name];
21
+ const { values } = useLookupValues(column, dataValue);
22
+ const valueRef = useRef(void 0);
23
+ useMemo(()=>{
24
+ valueRef.current = getSelectedOption(values, dataValue);
25
+ }, [
26
+ dataValue,
27
+ values
28
+ ]);
29
+ const handleOpenChange = useCallback((isOpen)=>{
30
+ console.log(`handleOpenChange ${isOpen}`);
31
+ if (false === isOpen) setOpen(false);
32
+ }, []);
33
+ const handleSelectionChange = useCallback(async (evt, [selectedOption])=>{
34
+ if (selectedOption) {
35
+ const response = await onEdit?.({
36
+ editType: "commit",
37
+ isValid: true,
38
+ previousValue: valueRef.current?.value,
39
+ value: selectedOption.value
40
+ }, "commit");
41
+ if (isRpcSuccess(response)) dispatchCustomEvent(evt.target, "vuu-commit");
42
+ }
43
+ }, [
44
+ onEdit
45
+ ]);
46
+ const handleClick = useCallback(()=>{
47
+ if (!open) setOpen(true);
48
+ }, [
49
+ open
50
+ ]);
51
+ const handleKeyDown = useCallback((e)=>{
52
+ if ("Enter" === e.key && !open) {
53
+ e.preventDefault();
54
+ e.stopPropagation();
55
+ setOpen(true);
56
+ }
57
+ }, [
58
+ open
59
+ ]);
60
+ const { current: selectedOption } = valueRef;
61
+ return /*#__PURE__*/ jsx(Dropdown, {
62
+ className: clsx(classBase, {
63
+ [`${classBase}-edited`]: true === editedDuringCurrentSession
64
+ }),
65
+ "data-icon": "triangle-down",
66
+ onClick: handleClick,
67
+ onKeyDownCapture: handleKeyDown,
68
+ onOpenChange: handleOpenChange,
69
+ onSelectionChange: handleSelectionChange,
70
+ open: open,
71
+ selected: selectedOption ? [
72
+ selectedOption
73
+ ] : [],
74
+ value: selectedOption?.label,
75
+ children: values.map((listOption, i)=>/*#__PURE__*/ jsx(Option, {
76
+ value: listOption,
77
+ children: listOption.label
78
+ }, i))
79
+ });
80
+ }, (p, p1)=>p.editedDuringCurrentSession !== p1.editedDuringCurrentSession && dataColumnAndKeyUnchanged(p, p1));
81
+ registerComponent("dropdown-cell", DropdownCell_DropdownCell, "cell-renderer", {
82
+ userCanAssign: false
83
+ });
84
+ export { DropdownCell_DropdownCell as DropdownCell };
@@ -0,0 +1 @@
1
+ export * from "./DropdownCell.js";
@@ -0,0 +1,6 @@
1
+ export * from "./background-cell/index.js";
2
+ export * from "./dropdown-cell/index.js";
3
+ export * from "./lookup-cell/index.js";
4
+ export * from "./pct-progress-cell/index.js";
5
+ export * from "./progress-cell/index.js";
6
+ export { IconButtonCell } from "./button-cell/IconButtonCell.js";
@@ -0,0 +1,15 @@
1
+ import { jsx } from "react/jsx-runtime";
2
+ import { useLookupValues } from "@vuu-ui/vuu-data-react";
3
+ import { dataAndColumnUnchanged, registerComponent } from "@vuu-ui/vuu-utils";
4
+ import { memo } from "react";
5
+ const LookupCell_LookupCell = /*#__PURE__*/ memo(function({ column, dataRow }) {
6
+ const dataValue = dataRow[column.name];
7
+ const { initialValue: value } = useLookupValues(column, dataValue);
8
+ return /*#__PURE__*/ jsx("span", {
9
+ children: value?.label
10
+ });
11
+ }, dataAndColumnUnchanged);
12
+ registerComponent("lookup-cell", LookupCell_LookupCell, "cell-renderer", {
13
+ userCanAssign: false
14
+ });
15
+ export { LookupCell_LookupCell as LookupCell };
@@ -0,0 +1 @@
1
+ export * from "./LookupCell.js";
@@ -0,0 +1,31 @@
1
+ const css = `
2
+ .vuuPctProgressCell {
3
+ --progress-bar-width: 2px;
4
+ position: relative;
5
+ }
6
+
7
+ .vuuPctProgressCell-zero, .vuuPctProgressCell-complete {
8
+ --progress-bar-width: 0px;
9
+ }
10
+
11
+ .vuuPctProgressCell-progressBar {
12
+ background-color: var(--vuu-color-green-60-fade-30);
13
+ border-right: solid var(--progress-bar-width) var(--vuu-color-green-60);
14
+ height: 20px;
15
+ width: var(--progress-bar-pct, 0);
16
+ display: inline-block;
17
+ position: absolute;
18
+ left: 0;
19
+ overflow: hidden;
20
+ }
21
+
22
+ .vuuPctProgressCell-text {
23
+ text-align: left;
24
+ z-index: 1;
25
+ width: 80%;
26
+ display: inline-block;
27
+ }
28
+
29
+
30
+ `;
31
+ export default css;
@@ -0,0 +1,49 @@
1
+ import { jsx, jsxs } from "react/jsx-runtime";
2
+ import { registerComponent } from "@vuu-ui/vuu-utils";
3
+ import clsx from "clsx";
4
+ import { useComponentCssInjection } from "@salt-ds/styles";
5
+ import { useWindow } from "@salt-ds/window";
6
+ import PctProgressCell from "./PctProgressCell.css";
7
+ const classBase = "vuuPctProgressCell";
8
+ const getPercentageValue = (value)=>{
9
+ if (value >= 0 && value <= 1) return 100 * value;
10
+ if (value > 2) return 0;
11
+ if (value > 1) return 100;
12
+ return 0;
13
+ };
14
+ const PctProgressCell_PctProgressCell = ({ column, dataRow })=>{
15
+ const targetWindow = useWindow();
16
+ useComponentCssInjection({
17
+ testId: "vuu-pct-progress-cell",
18
+ css: PctProgressCell,
19
+ window: targetWindow
20
+ });
21
+ const value = dataRow[column.name];
22
+ const percentageValue = getPercentageValue(value);
23
+ const className = clsx(classBase, {});
24
+ return /*#__PURE__*/ jsxs("div", {
25
+ className: clsx(className, {
26
+ [`${classBase}-zero`]: 0 === percentageValue,
27
+ [`${classBase}-complete`]: percentageValue >= 100
28
+ }),
29
+ tabIndex: -1,
30
+ children: [
31
+ /*#__PURE__*/ jsx("span", {
32
+ className: `${classBase}-progressBar`,
33
+ style: {
34
+ "--progress-bar-pct": `${percentageValue}%`
35
+ }
36
+ }),
37
+ /*#__PURE__*/ jsx("span", {
38
+ className: `${classBase}-text`,
39
+ children: `${percentageValue.toFixed(2)} %`
40
+ })
41
+ ]
42
+ });
43
+ };
44
+ registerComponent("vuu.pct-progress", PctProgressCell_PctProgressCell, "cell-renderer", {
45
+ description: "Percentage formatter",
46
+ label: "Percentage formatter",
47
+ serverDataType: "double"
48
+ });
49
+ export { PctProgressCell_PctProgressCell as PctProgressCell };
@@ -0,0 +1 @@
1
+ export * from "./PctProgressCell.js";
@@ -0,0 +1,43 @@
1
+ const css = `
2
+ .vuuProgressCell {
3
+ align-items: center;
4
+ display: flex;
5
+ }
6
+
7
+ .vuuProgressCell-track {
8
+ flex: auto;
9
+ height: 4px;
10
+ display: inline-block;
11
+ position: relative;
12
+ overflow: hidden;
13
+ }
14
+
15
+ .vuuProgressCell-bg {
16
+ background-color: var(--salt-measured-background);
17
+ width: 100%;
18
+ height: 2px;
19
+ display: inline-block;
20
+ position: absolute;
21
+ top: 1px;
22
+ left: 0;
23
+ }
24
+
25
+ .vuuProgressCell-bar {
26
+ background-color: var(--salt-measured-fill);
27
+ height: 100%;
28
+ transform: translateX(var(--progress-bar-pct, -100%));
29
+ width: 100%;
30
+ display: inline-block;
31
+ position: absolute;
32
+ top: 0;
33
+ left: 0;
34
+ }
35
+
36
+ .vuuProgressCell-text {
37
+ text-align: right;
38
+ flex: 0 0 35px;
39
+ }
40
+
41
+
42
+ `;
43
+ export default css;
@@ -0,0 +1,74 @@
1
+ import { jsx, jsxs } from "react/jsx-runtime";
2
+ import { isColumnTypeRenderer, isTypeDescriptor, isValidNumber, registerComponent } from "@vuu-ui/vuu-utils";
3
+ import clsx from "clsx";
4
+ import { useComponentCssInjection } from "@salt-ds/styles";
5
+ import { useWindow } from "@salt-ds/window";
6
+ import ProgressCell from "./ProgressCell.css";
7
+ const classBase = "vuuProgressCell";
8
+ const ProgressCell_ProgressCell = ({ column, dataRow })=>{
9
+ const targetWindow = useWindow();
10
+ useComponentCssInjection({
11
+ testId: "vuu-progress-cell",
12
+ css: ProgressCell,
13
+ window: targetWindow
14
+ });
15
+ const { name, type } = column;
16
+ const value = dataRow[name];
17
+ let showProgress = false;
18
+ let percentage = 0;
19
+ if (isTypeDescriptor(type) && isColumnTypeRenderer(type.renderer)) {
20
+ const { associatedField } = type.renderer;
21
+ if (associatedField) {
22
+ const associatedValue = dataRow[associatedField];
23
+ if (isValidNumber(value) && isValidNumber(associatedValue)) {
24
+ percentage = Math.min(Math.round(value / associatedValue * 100), 100);
25
+ percentage = Math.min(Math.round(value / associatedValue * 100), 100);
26
+ showProgress = isFinite(percentage);
27
+ } else {
28
+ const floatValue = parseFloat(value);
29
+ if (Number.isFinite(floatValue)) {
30
+ const floatOtherValue = parseFloat(associatedValue);
31
+ if (Number.isFinite(floatOtherValue)) {
32
+ percentage = Math.min(Math.round(floatValue / floatOtherValue * 100), 100);
33
+ showProgress = isFinite(percentage);
34
+ }
35
+ }
36
+ }
37
+ } else throw Error("ProgressCell associatedField is required to render");
38
+ }
39
+ const className = clsx(classBase, {});
40
+ return /*#__PURE__*/ jsxs("div", {
41
+ className: className,
42
+ tabIndex: -1,
43
+ children: [
44
+ showProgress ? /*#__PURE__*/ jsxs("span", {
45
+ className: `${classBase}-track`,
46
+ children: [
47
+ /*#__PURE__*/ jsx("span", {
48
+ className: `${classBase}-bg`
49
+ }),
50
+ /*#__PURE__*/ jsx("span", {
51
+ className: `${classBase}-bar`,
52
+ style: {
53
+ "--progress-bar-pct": `-${100 - percentage}%`
54
+ }
55
+ })
56
+ ]
57
+ }) : null,
58
+ /*#__PURE__*/ jsx("span", {
59
+ className: `${classBase}-text`,
60
+ children: `${percentage} %`
61
+ })
62
+ ]
63
+ });
64
+ };
65
+ registerComponent("vuu.progress", ProgressCell_ProgressCell, "cell-renderer", {
66
+ description: "Progress formatter",
67
+ label: "Progress formatter",
68
+ serverDataType: [
69
+ "long",
70
+ "int",
71
+ "double"
72
+ ],
73
+ userCanAssign: false
74
+ });
@@ -0,0 +1 @@
1
+ export * from "./ProgressCell.js";