@deephaven/iris-grid 0.9.4-plugins.9 → 0.10.1-beta.0

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 (86) hide show
  1. package/dist/IrisGrid.d.ts +23 -3
  2. package/dist/IrisGrid.d.ts.map +1 -1
  3. package/dist/IrisGrid.js +146 -8
  4. package/dist/IrisGrid.js.map +1 -1
  5. package/dist/IrisGridModel.d.ts +14 -2
  6. package/dist/IrisGridModel.d.ts.map +1 -1
  7. package/dist/IrisGridModel.js +8 -0
  8. package/dist/IrisGridModel.js.map +1 -1
  9. package/dist/IrisGridModelFactory.d.ts +1 -1
  10. package/dist/IrisGridModelFactory.d.ts.map +1 -1
  11. package/dist/IrisGridModelFactory.js +8 -1
  12. package/dist/IrisGridModelFactory.js.map +1 -1
  13. package/dist/IrisGridModelUpdater.d.ts +3 -2
  14. package/dist/IrisGridModelUpdater.d.ts.map +1 -1
  15. package/dist/IrisGridModelUpdater.js +7 -1
  16. package/dist/IrisGridModelUpdater.js.map +1 -1
  17. package/dist/IrisGridProxyModel.d.ts.map +1 -1
  18. package/dist/IrisGridProxyModel.js +12 -0
  19. package/dist/IrisGridProxyModel.js.map +1 -1
  20. package/dist/IrisGridTableModel.d.ts +2 -0
  21. package/dist/IrisGridTableModel.d.ts.map +1 -1
  22. package/dist/IrisGridTableModel.js +47 -5
  23. package/dist/IrisGridTableModel.js.map +1 -1
  24. package/dist/IrisGridUtils.d.ts +2 -0
  25. package/dist/IrisGridUtils.d.ts.map +1 -1
  26. package/dist/IrisGridUtils.js +4 -0
  27. package/dist/IrisGridUtils.js.map +1 -1
  28. package/dist/TableUtils.d.ts.map +1 -1
  29. package/dist/TableUtils.js +2 -0
  30. package/dist/TableUtils.js.map +1 -1
  31. package/dist/sidebar/ChartBuilder.js +1 -1
  32. package/dist/sidebar/ChartBuilder.js.map +1 -1
  33. package/dist/sidebar/OptionType.d.ts +3 -1
  34. package/dist/sidebar/OptionType.d.ts.map +1 -1
  35. package/dist/sidebar/OptionType.js +2 -0
  36. package/dist/sidebar/OptionType.js.map +1 -1
  37. package/dist/sidebar/conditional-formatting/ColumnFormatEditor.d.ts +9 -0
  38. package/dist/sidebar/conditional-formatting/ColumnFormatEditor.d.ts.map +1 -0
  39. package/dist/sidebar/conditional-formatting/ColumnFormatEditor.js +132 -0
  40. package/dist/sidebar/conditional-formatting/ColumnFormatEditor.js.map +1 -0
  41. package/dist/sidebar/conditional-formatting/ConditionEditor.d.ts +9 -0
  42. package/dist/sidebar/conditional-formatting/ConditionEditor.d.ts.map +1 -0
  43. package/dist/sidebar/conditional-formatting/ConditionEditor.js +273 -0
  44. package/dist/sidebar/conditional-formatting/ConditionEditor.js.map +1 -0
  45. package/dist/sidebar/conditional-formatting/ConditionalFormatEditor.css +21 -0
  46. package/dist/sidebar/conditional-formatting/ConditionalFormatEditor.css.map +1 -0
  47. package/dist/sidebar/conditional-formatting/ConditionalFormatEditor.d.ts +15 -0
  48. package/dist/sidebar/conditional-formatting/ConditionalFormatEditor.d.ts.map +1 -0
  49. package/dist/sidebar/conditional-formatting/ConditionalFormatEditor.js +115 -0
  50. package/dist/sidebar/conditional-formatting/ConditionalFormatEditor.js.map +1 -0
  51. package/dist/sidebar/conditional-formatting/ConditionalFormattingAPIUtils.d.ts +6 -0
  52. package/dist/sidebar/conditional-formatting/ConditionalFormattingAPIUtils.d.ts.map +1 -0
  53. package/dist/sidebar/conditional-formatting/ConditionalFormattingAPIUtils.js +21 -0
  54. package/dist/sidebar/conditional-formatting/ConditionalFormattingAPIUtils.js.map +1 -0
  55. package/dist/sidebar/conditional-formatting/ConditionalFormattingMenu.css +56 -0
  56. package/dist/sidebar/conditional-formatting/ConditionalFormattingMenu.css.map +1 -0
  57. package/dist/sidebar/conditional-formatting/ConditionalFormattingMenu.d.ts +15 -0
  58. package/dist/sidebar/conditional-formatting/ConditionalFormattingMenu.d.ts.map +1 -0
  59. package/dist/sidebar/conditional-formatting/ConditionalFormattingMenu.js +160 -0
  60. package/dist/sidebar/conditional-formatting/ConditionalFormattingMenu.js.map +1 -0
  61. package/dist/sidebar/conditional-formatting/ConditionalFormattingUtils.d.ts +119 -0
  62. package/dist/sidebar/conditional-formatting/ConditionalFormattingUtils.d.ts.map +1 -0
  63. package/dist/sidebar/conditional-formatting/ConditionalFormattingUtils.js +748 -0
  64. package/dist/sidebar/conditional-formatting/ConditionalFormattingUtils.js.map +1 -0
  65. package/dist/sidebar/conditional-formatting/RowFormatEditor.d.ts +9 -0
  66. package/dist/sidebar/conditional-formatting/RowFormatEditor.d.ts.map +1 -0
  67. package/dist/sidebar/conditional-formatting/RowFormatEditor.js +132 -0
  68. package/dist/sidebar/conditional-formatting/RowFormatEditor.js.map +1 -0
  69. package/dist/sidebar/conditional-formatting/StyleEditor.css +54 -0
  70. package/dist/sidebar/conditional-formatting/StyleEditor.css.map +1 -0
  71. package/dist/sidebar/conditional-formatting/StyleEditor.d.ts +9 -0
  72. package/dist/sidebar/conditional-formatting/StyleEditor.d.ts.map +1 -0
  73. package/dist/sidebar/conditional-formatting/StyleEditor.js +160 -0
  74. package/dist/sidebar/conditional-formatting/StyleEditor.js.map +1 -0
  75. package/dist/sidebar/icons/FormatColumnWhereIcon.d.ts +4 -0
  76. package/dist/sidebar/icons/FormatColumnWhereIcon.d.ts.map +1 -0
  77. package/dist/sidebar/icons/FormatColumnWhereIcon.js +45 -0
  78. package/dist/sidebar/icons/FormatColumnWhereIcon.js.map +1 -0
  79. package/dist/sidebar/icons/FormatRowWhereIcon.d.ts +4 -0
  80. package/dist/sidebar/icons/FormatRowWhereIcon.d.ts.map +1 -0
  81. package/dist/sidebar/icons/FormatRowWhereIcon.js +39 -0
  82. package/dist/sidebar/icons/FormatRowWhereIcon.js.map +1 -0
  83. package/dist/sidebar/icons/index.d.ts +2 -0
  84. package/dist/sidebar/icons/index.js +2 -0
  85. package/dist/sidebar/icons/index.js.map +1 -1
  86. package/package.json +11 -11
@@ -0,0 +1,132 @@
1
+ function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly) { symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); } keys.push.apply(keys, symbols); } return keys; }
2
+
3
+ function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { ownKeys(Object(source), true).forEach(function (key) { _defineProperty(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; }
4
+
5
+ function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
6
+
7
+ import React, { useCallback, useEffect, useState } from 'react';
8
+ import Log from '@deephaven/log';
9
+ import { ComboBox } from '@deephaven/components';
10
+ import { getDefaultConditionConfigForType, getConditionConfig, getDefaultStyleConfig } from "./ConditionalFormattingUtils.js";
11
+ import ConditionEditor from "./ConditionEditor.js";
12
+ import StyleEditor from "./StyleEditor.js";
13
+ var log = Log.module('ColumnFormatEditor');
14
+
15
+ var DEFAULT_CALLBACK = () => undefined;
16
+
17
+ function makeDefaultConfig(columns) {
18
+ var {
19
+ type,
20
+ name
21
+ } = columns[0];
22
+ var column = {
23
+ type,
24
+ name
25
+ };
26
+
27
+ var config = _objectSpread({
28
+ column,
29
+ style: getDefaultStyleConfig()
30
+ }, getDefaultConditionConfigForType(type));
31
+
32
+ return config;
33
+ }
34
+
35
+ var ColumnFormatEditor = props => {
36
+ var _columns$find;
37
+
38
+ var {
39
+ columns,
40
+ config = makeDefaultConfig(columns),
41
+ onChange = DEFAULT_CALLBACK
42
+ } = props;
43
+ var [selectedColumn, setColumn] = useState((_columns$find = columns.find(c => c.name === config.column.name && c.type === config.column.type)) !== null && _columns$find !== void 0 ? _columns$find : columns[0]);
44
+ var [conditionConfig, setConditionConfig] = useState(getConditionConfig(config));
45
+ var [conditionValid, setConditionValid] = useState(false);
46
+ var [selectedStyle, setStyle] = useState(config.style);
47
+ var handleColumnChange = useCallback(value => {
48
+ var newColumn = columns.find(_ref => {
49
+ var {
50
+ name
51
+ } = _ref;
52
+ return name === value;
53
+ });
54
+
55
+ if (newColumn !== undefined) {
56
+ setColumn(newColumn);
57
+
58
+ if (selectedColumn.type !== newColumn.type) {
59
+ setConditionConfig(getDefaultConditionConfigForType(newColumn.type));
60
+ setConditionValid(false);
61
+ }
62
+ } else {
63
+ log.error("Column ".concat(value, " not found."));
64
+ }
65
+ }, [columns, selectedColumn]);
66
+ var handleConditionChange = useCallback((updatedConditionConfig, isValid) => {
67
+ log.debug('handleConditionChange', updatedConditionConfig, isValid);
68
+ setConditionConfig(updatedConditionConfig);
69
+ setConditionValid(isValid);
70
+ }, []);
71
+ var handleStyleChange = useCallback(updatedStyleConfig => {
72
+ log.debug('handleStyleChange', updatedStyleConfig);
73
+ setStyle(updatedStyleConfig);
74
+ }, []);
75
+ useEffect(() => {
76
+ if (selectedColumn === undefined) {
77
+ log.debug('Column is not selected, skip update.');
78
+ return;
79
+ }
80
+
81
+ if (selectedStyle === undefined) {
82
+ log.debug('Style is not selected, skip update.');
83
+ return;
84
+ }
85
+
86
+ var {
87
+ type,
88
+ name
89
+ } = selectedColumn;
90
+ var column = {
91
+ type,
92
+ name
93
+ };
94
+ onChange(_objectSpread({
95
+ column,
96
+ style: selectedStyle
97
+ }, conditionConfig), conditionValid);
98
+ }, [onChange, selectedColumn, selectedStyle, conditionConfig, conditionValid]);
99
+ var columnInputOptions = columns.map(_ref2 => {
100
+ var {
101
+ name
102
+ } = _ref2;
103
+ return {
104
+ title: name,
105
+ value: name
106
+ };
107
+ });
108
+ return /*#__PURE__*/React.createElement("div", {
109
+ className: "conditional-rule-editor form"
110
+ }, /*#__PURE__*/React.createElement("div", {
111
+ className: "mb-2"
112
+ }, /*#__PURE__*/React.createElement("label", {
113
+ className: "mb-0"
114
+ }, "Format Cell If"), /*#__PURE__*/React.createElement(ComboBox, {
115
+ defaultValue: selectedColumn === null || selectedColumn === void 0 ? void 0 : selectedColumn.name,
116
+ options: columnInputOptions,
117
+ inputPlaceholder: "Select a column",
118
+ spellCheck: false,
119
+ onChange: handleColumnChange,
120
+ searchPlaceholder: "Filter columns"
121
+ })), selectedColumn !== undefined && /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement(ConditionEditor, {
122
+ column: selectedColumn,
123
+ config: conditionConfig,
124
+ onChange: handleConditionChange
125
+ }), /*#__PURE__*/React.createElement(StyleEditor, {
126
+ config: selectedStyle,
127
+ onChange: handleStyleChange
128
+ })));
129
+ };
130
+
131
+ export default ColumnFormatEditor;
132
+ //# sourceMappingURL=ColumnFormatEditor.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../../src/sidebar/conditional-formatting/ColumnFormatEditor.tsx"],"names":["React","useCallback","useEffect","useState","Log","ComboBox","getDefaultConditionConfigForType","getConditionConfig","getDefaultStyleConfig","ConditionEditor","StyleEditor","log","module","DEFAULT_CALLBACK","undefined","makeDefaultConfig","columns","type","name","column","config","style","ColumnFormatEditor","props","onChange","selectedColumn","setColumn","find","c","conditionConfig","setConditionConfig","conditionValid","setConditionValid","selectedStyle","setStyle","handleColumnChange","value","newColumn","error","handleConditionChange","updatedConditionConfig","isValid","debug","handleStyleChange","updatedStyleConfig","columnInputOptions","map","title"],"mappings":";;;;;;AAAA,OAAOA,KAAP,IAAgBC,WAAhB,EAA6BC,SAA7B,EAAwCC,QAAxC,QAAwD,OAAxD;AACA,OAAOC,GAAP,MAAgB,gBAAhB;AACA,SAASC,QAAT,QAAyB,uBAAzB;SAIEC,gC,EACAC,kB,EACAC,qB;OAGKC,e;OACAC,W;AAEP,IAAMC,GAAG,GAAGP,GAAG,CAACQ,MAAJ,C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Content":["import React, { useCallback, useEffect, useState } from 'react';\nimport Log from '@deephaven/log';\nimport { ComboBox } from '@deephaven/components';\nimport {\n BaseFormatConfig,\n ChangeCallback,\n getDefaultConditionConfigForType,\n getConditionConfig,\n getDefaultStyleConfig,\n ModelColumn,\n} from './ConditionalFormattingUtils';\nimport ConditionEditor from './ConditionEditor';\nimport StyleEditor from './StyleEditor';\n\nconst log = Log.module('ColumnFormatEditor');\n\nexport interface ColumnFormatEditorProps {\n columns: ModelColumn[];\n config?: BaseFormatConfig;\n onChange?: ChangeCallback;\n}\n\nconst DEFAULT_CALLBACK = () => undefined;\n\nfunction makeDefaultConfig(columns: ModelColumn[]): BaseFormatConfig {\n const { type, name } = columns[0];\n const column = { type, name };\n const config = {\n column,\n style: getDefaultStyleConfig(),\n ...getDefaultConditionConfigForType(type),\n };\n return config;\n}\n\nconst ColumnFormatEditor = (props: ColumnFormatEditorProps): JSX.Element => {\n const {\n columns,\n config = makeDefaultConfig(columns),\n onChange = DEFAULT_CALLBACK,\n } = props;\n\n const [selectedColumn, setColumn] = useState(\n columns.find(\n c => c.name === config.column.name && c.type === config.column.type\n ) ?? columns[0]\n );\n const [conditionConfig, setConditionConfig] = useState(\n getConditionConfig(config)\n );\n const [conditionValid, setConditionValid] = useState(false);\n const [selectedStyle, setStyle] = useState(config.style);\n\n const handleColumnChange = useCallback(\n value => {\n const newColumn = columns.find(({ name }) => name === value);\n if (newColumn !== undefined) {\n setColumn(newColumn);\n if (selectedColumn.type !== newColumn.type) {\n setConditionConfig(getDefaultConditionConfigForType(newColumn.type));\n setConditionValid(false);\n }\n } else {\n log.error(`Column ${value} not found.`);\n }\n },\n [columns, selectedColumn]\n );\n\n const handleConditionChange = useCallback(\n (updatedConditionConfig, isValid) => {\n log.debug('handleConditionChange', updatedConditionConfig, isValid);\n setConditionConfig(updatedConditionConfig);\n setConditionValid(isValid);\n },\n []\n );\n\n const handleStyleChange = useCallback(updatedStyleConfig => {\n log.debug('handleStyleChange', updatedStyleConfig);\n setStyle(updatedStyleConfig);\n }, []);\n\n useEffect(() => {\n if (selectedColumn === undefined) {\n log.debug('Column is not selected, skip update.');\n return;\n }\n if (selectedStyle === undefined) {\n log.debug('Style is not selected, skip update.');\n return;\n }\n const { type, name } = selectedColumn;\n const column = { type, name };\n onChange(\n {\n column,\n style: selectedStyle,\n ...conditionConfig,\n },\n conditionValid\n );\n }, [\n onChange,\n selectedColumn,\n selectedStyle,\n conditionConfig,\n conditionValid,\n ]);\n\n const columnInputOptions = columns.map(({ name }) => ({\n title: name,\n value: name,\n }));\n\n return (\n <div className=\"conditional-rule-editor form\">\n <div className=\"mb-2\">\n <label className=\"mb-0\">Format Cell If</label>\n <ComboBox\n defaultValue={selectedColumn?.name}\n options={columnInputOptions}\n inputPlaceholder=\"Select a column\"\n spellCheck={false}\n onChange={handleColumnChange}\n searchPlaceholder=\"Filter columns\"\n />\n </div>\n\n {selectedColumn !== undefined && (\n <>\n <ConditionEditor\n column={selectedColumn}\n config={conditionConfig}\n onChange={handleConditionChange}\n />\n <StyleEditor config={selectedStyle} onChange={handleStyleChange} />\n </>\n )}\n </div>\n );\n};\n\nexport default ColumnFormatEditor;\n"],"file":"ColumnFormatEditor.js"}
@@ -0,0 +1,9 @@
1
+ import { ModelColumn, ConditionConfig } from './ConditionalFormattingUtils';
2
+ export interface ConditionEditorProps {
3
+ column: ModelColumn;
4
+ config: ConditionConfig;
5
+ onChange?: (config: ConditionConfig, isValid: boolean) => void;
6
+ }
7
+ declare const ConditionEditor: (props: ConditionEditorProps) => JSX.Element;
8
+ export default ConditionEditor;
9
+ //# sourceMappingURL=ConditionEditor.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ConditionEditor.d.ts","sourceRoot":"","sources":["../../../src/sidebar/conditional-formatting/ConditionEditor.tsx"],"names":[],"mappings":"AAGA,OAAO,EAOL,WAAW,EACX,eAAe,EAMhB,MAAM,8BAA8B,CAAC;AAItC,MAAM,WAAW,oBAAoB;IACnC,MAAM,EAAE,WAAW,CAAC;IACpB,MAAM,EAAE,eAAe,CAAC;IACxB,QAAQ,CAAC,EAAE,CAAC,MAAM,EAAE,eAAe,EAAE,OAAO,EAAE,OAAO,KAAK,IAAI,CAAC;CAChE;AAgOD,QAAA,MAAM,eAAe,UAAW,oBAAoB,KAAG,WAwKtD,CAAC;AAEF,eAAe,eAAe,CAAC"}
@@ -0,0 +1,273 @@
1
+ import React, { useCallback, useEffect, useMemo, useState } from 'react';
2
+ import Log from '@deephaven/log';
3
+ import TableUtils from "../../TableUtils.js";
4
+ import { StringCondition, DateCondition, getLabelForNumberCondition, getLabelForDateCondition, getLabelForStringCondition, NumberCondition, getDefaultConditionForType, getLabelForBooleanCondition, BooleanCondition, CharCondition, getLabelForCharCondition } from "./ConditionalFormattingUtils.js";
5
+ var log = Log.module('ConditionEditor');
6
+
7
+ var DEFAULT_CALLBACK = () => undefined;
8
+
9
+ var numberConditionOptions = [NumberCondition.IS_EQUAL, NumberCondition.IS_NOT_EQUAL, NumberCondition.IS_BETWEEN, NumberCondition.GREATER_THAN, NumberCondition.GREATER_THAN_OR_EQUAL, NumberCondition.LESS_THAN, NumberCondition.LESS_THAN_OR_EQUAL, NumberCondition.IS_NULL, NumberCondition.IS_NOT_NULL].map(option => /*#__PURE__*/React.createElement("option", {
10
+ key: option,
11
+ value: option
12
+ }, getLabelForNumberCondition(option)));
13
+ var stringConditions = [StringCondition.IS_EXACTLY, StringCondition.IS_NOT_EXACTLY, StringCondition.CONTAINS, StringCondition.DOES_NOT_CONTAIN, StringCondition.STARTS_WITH, StringCondition.ENDS_WITH, StringCondition.IS_NULL, StringCondition.IS_NOT_NULL].map(option => /*#__PURE__*/React.createElement("option", {
14
+ key: option,
15
+ value: option
16
+ }, getLabelForStringCondition(option)));
17
+ var dateConditions = [DateCondition.IS_EXACTLY, DateCondition.IS_NOT_EXACTLY, DateCondition.IS_BEFORE, DateCondition.IS_BEFORE_OR_EQUAL, DateCondition.IS_AFTER, DateCondition.IS_AFTER_OR_EQUAL, DateCondition.IS_NULL, DateCondition.IS_NOT_NULL].map(option => /*#__PURE__*/React.createElement("option", {
18
+ key: option,
19
+ value: option
20
+ }, getLabelForDateCondition(option)));
21
+ var booleanConditions = [BooleanCondition.IS_TRUE, BooleanCondition.IS_FALSE, BooleanCondition.IS_NULL, BooleanCondition.IS_NOT_NULL].map(option => /*#__PURE__*/React.createElement("option", {
22
+ key: option,
23
+ value: option
24
+ }, getLabelForBooleanCondition(option)));
25
+ var charConditions = [CharCondition.IS_EQUAL, CharCondition.IS_NOT_EQUAL, CharCondition.IS_NULL, CharCondition.IS_NOT_NULL].map(option => /*#__PURE__*/React.createElement("option", {
26
+ key: option,
27
+ value: option
28
+ }, getLabelForCharCondition(option)));
29
+
30
+ function isNumberConditionValid(condition, value, startValue, endValue) {
31
+ if (condition === NumberCondition.IS_NULL || condition === NumberCondition.IS_NOT_NULL) {
32
+ return true;
33
+ }
34
+
35
+ if (condition === NumberCondition.IS_BETWEEN && startValue && !Number.isNaN(Number.parseFloat(startValue)) && endValue && !Number.isNaN(Number.parseFloat(endValue))) {
36
+ return true;
37
+ }
38
+
39
+ if (condition !== NumberCondition.IS_BETWEEN && value && !Number.isNaN(Number.parseFloat(value))) {
40
+ return true;
41
+ }
42
+
43
+ return false;
44
+ }
45
+
46
+ function getNumberInputs(selectedCondition, handleValueChange, handleStartValueChange, handleEndValueChange, conditionValue, startValue, endValue) {
47
+ switch (selectedCondition) {
48
+ case NumberCondition.IS_EQUAL:
49
+ case NumberCondition.IS_NOT_EQUAL:
50
+ case NumberCondition.GREATER_THAN:
51
+ case NumberCondition.GREATER_THAN_OR_EQUAL:
52
+ case NumberCondition.LESS_THAN:
53
+ case NumberCondition.LESS_THAN_OR_EQUAL:
54
+ return /*#__PURE__*/React.createElement("input", {
55
+ type: "number",
56
+ className: "form-control",
57
+ placeholder: "Enter value",
58
+ value: conditionValue !== null && conditionValue !== void 0 ? conditionValue : '',
59
+ onChange: handleValueChange
60
+ });
61
+
62
+ case NumberCondition.IS_BETWEEN:
63
+ return /*#__PURE__*/React.createElement("div", {
64
+ className: "d-flex flex-row"
65
+ }, /*#__PURE__*/React.createElement("input", {
66
+ type: "number",
67
+ className: "form-control d-flex mr-2",
68
+ placeholder: "Start value",
69
+ value: startValue !== null && startValue !== void 0 ? startValue : '',
70
+ onChange: handleStartValueChange
71
+ }), /*#__PURE__*/React.createElement("input", {
72
+ type: "number",
73
+ className: "form-control d-flex",
74
+ placeholder: "End value",
75
+ value: endValue !== null && endValue !== void 0 ? endValue : '',
76
+ onChange: handleEndValueChange
77
+ }));
78
+
79
+ case NumberCondition.IS_NULL:
80
+ case NumberCondition.IS_NOT_NULL:
81
+ return null;
82
+ }
83
+ }
84
+
85
+ function getStringInputs(selectedCondition, handleValueChange, conditionValue) {
86
+ switch (selectedCondition) {
87
+ case StringCondition.IS_NULL:
88
+ case StringCondition.IS_NOT_NULL:
89
+ return null;
90
+
91
+ default:
92
+ return /*#__PURE__*/React.createElement("input", {
93
+ type: "text",
94
+ className: "form-control",
95
+ placeholder: "Enter value",
96
+ value: conditionValue !== null && conditionValue !== void 0 ? conditionValue : '',
97
+ onChange: handleValueChange
98
+ });
99
+ }
100
+ }
101
+
102
+ function getDateInputs(selectedCondition, handleValueChange, conditionValue) {
103
+ switch (selectedCondition) {
104
+ case DateCondition.IS_NULL:
105
+ case DateCondition.IS_NOT_NULL:
106
+ return null;
107
+
108
+ default:
109
+ return /*#__PURE__*/React.createElement("input", {
110
+ type: "text",
111
+ className: "form-control",
112
+ placeholder: "Enter value",
113
+ value: conditionValue !== null && conditionValue !== void 0 ? conditionValue : '',
114
+ onChange: handleValueChange
115
+ });
116
+ }
117
+ }
118
+
119
+ function getBooleanInputs() {
120
+ return null;
121
+ }
122
+
123
+ function getCharInputs(selectedCondition, handleValueChange, conditionValue) {
124
+ switch (selectedCondition) {
125
+ case CharCondition.IS_NULL:
126
+ case CharCondition.IS_NOT_NULL:
127
+ return null;
128
+
129
+ default:
130
+ return /*#__PURE__*/React.createElement("input", {
131
+ type: "text",
132
+ className: "form-control",
133
+ maxLength: 1,
134
+ placeholder: "Enter value",
135
+ value: conditionValue !== null && conditionValue !== void 0 ? conditionValue : '',
136
+ onChange: handleValueChange
137
+ });
138
+ }
139
+ }
140
+
141
+ var ConditionEditor = props => {
142
+ var {
143
+ column,
144
+ config,
145
+ onChange = DEFAULT_CALLBACK
146
+ } = props;
147
+ var selectedColumnType = column.type;
148
+ var [prevColumnType, setPrevColumnType] = useState(selectedColumnType);
149
+ var [selectedCondition, setCondition] = useState(config.condition);
150
+ var [conditionValue, setValue] = useState(config.value);
151
+ var [startValue, setStartValue] = useState(config.start);
152
+ var [endValue, setEndValue] = useState(config.end);
153
+
154
+ if (selectedColumnType !== prevColumnType) {
155
+ // Column type changed, reset condition and value fields
156
+ setCondition(getDefaultConditionForType(selectedColumnType));
157
+ setValue(undefined);
158
+ setStartValue(undefined);
159
+ setEndValue(undefined);
160
+ setPrevColumnType(selectedColumnType);
161
+ }
162
+
163
+ var conditions = useMemo(() => {
164
+ if (selectedColumnType === undefined) {
165
+ return [];
166
+ }
167
+
168
+ if (TableUtils.isNumberType(selectedColumnType)) {
169
+ return numberConditionOptions;
170
+ }
171
+
172
+ if (TableUtils.isCharType(selectedColumnType)) {
173
+ return charConditions;
174
+ }
175
+
176
+ if (TableUtils.isTextType(selectedColumnType)) {
177
+ return stringConditions;
178
+ }
179
+
180
+ if (TableUtils.isDateType(selectedColumnType)) {
181
+ return dateConditions;
182
+ }
183
+
184
+ if (TableUtils.isBooleanType(selectedColumnType)) {
185
+ return booleanConditions;
186
+ }
187
+ }, [selectedColumnType]);
188
+ var handleConditionChange = useCallback(e => {
189
+ var {
190
+ value
191
+ } = e.target;
192
+ log.debug('handleConditionChange', value);
193
+ setCondition(value);
194
+ }, []);
195
+ var handleValueChange = useCallback(e => {
196
+ var {
197
+ value
198
+ } = e.target;
199
+ log.debug('handleValueChange', value);
200
+ setValue(value);
201
+ }, []);
202
+ var handleStartValueChange = useCallback(e => {
203
+ var {
204
+ value
205
+ } = e.target;
206
+ log.debug('handleStartValueChange', value);
207
+ setStartValue(value);
208
+ }, []);
209
+ var handleEndValueChange = useCallback(e => {
210
+ var {
211
+ value
212
+ } = e.target;
213
+ log.debug('handleEndValueChange', value);
214
+ setEndValue(value);
215
+ }, []);
216
+ useEffect(() => {
217
+ var isValid = true;
218
+
219
+ if (selectedCondition === undefined) {
220
+ log.debug('Unable to create formatting rule. Condition is not selected.');
221
+ isValid = false;
222
+ }
223
+
224
+ if (TableUtils.isNumberType(column.type) && !isNumberConditionValid(selectedCondition, conditionValue, startValue, endValue)) {
225
+ log.debug('Unable to create formatting rule. Invalid value', conditionValue);
226
+ isValid = false;
227
+ }
228
+
229
+ onChange({
230
+ condition: selectedCondition,
231
+ value: conditionValue,
232
+ start: startValue,
233
+ end: endValue
234
+ }, isValid);
235
+ }, [onChange, column.type, selectedCondition, conditionValue, startValue, endValue]);
236
+ var conditionInputs = useMemo(() => {
237
+ if (selectedColumnType === undefined) {
238
+ // Column not selected
239
+ return null;
240
+ }
241
+
242
+ if (TableUtils.isNumberType(selectedColumnType)) {
243
+ return getNumberInputs(selectedCondition, handleValueChange, handleStartValueChange, handleEndValueChange, conditionValue, startValue, endValue);
244
+ }
245
+
246
+ if (TableUtils.isCharType(selectedColumnType)) {
247
+ return getCharInputs(selectedCondition, handleValueChange, conditionValue);
248
+ }
249
+
250
+ if (TableUtils.isTextType(selectedColumnType)) {
251
+ return getStringInputs(selectedCondition, handleValueChange, conditionValue);
252
+ }
253
+
254
+ if (TableUtils.isDateType(selectedColumnType)) {
255
+ return getDateInputs(selectedCondition, handleValueChange, conditionValue);
256
+ }
257
+
258
+ if (TableUtils.isBooleanType(selectedColumnType)) {
259
+ return getBooleanInputs();
260
+ }
261
+ }, [selectedColumnType, selectedCondition, conditionValue, startValue, endValue, handleValueChange, handleStartValueChange, handleEndValueChange]);
262
+ return /*#__PURE__*/React.createElement("div", {
263
+ className: "condition-editor mb-2"
264
+ }, /*#__PURE__*/React.createElement("select", {
265
+ value: selectedCondition,
266
+ id: "condition-select",
267
+ className: "custom-select mb-2",
268
+ onChange: handleConditionChange
269
+ }, conditions), conditionInputs);
270
+ };
271
+
272
+ export default ConditionEditor;
273
+ //# sourceMappingURL=ConditionEditor.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../../src/sidebar/conditional-formatting/ConditionEditor.tsx"],"names":["React","useCallback","useEffect","useMemo","useState","Log","TableUtils","StringCondition","DateCondition","getLabelForNumberCondition","getLabelForDateCondition","getLabelForStringCondition","NumberCondition","getDefaultConditionForType","getLabelForBooleanCondition","BooleanCondition","CharCondition","getLabelForCharCondition","log","module","DEFAULT_CALLBACK","undefined","numberConditionOptions","IS_EQUAL","IS_NOT_EQUAL","IS_BETWEEN","GREATER_THAN","GREATER_THAN_OR_EQUAL","LESS_THAN","LESS_THAN_OR_EQUAL","IS_NULL","IS_NOT_NULL","map","option","stringConditions","IS_EXACTLY","IS_NOT_EXACTLY","CONTAINS","DOES_NOT_CONTAIN","STARTS_WITH","ENDS_WITH","dateConditions","IS_BEFORE","IS_BEFORE_OR_EQUAL","IS_AFTER","IS_AFTER_OR_EQUAL","booleanConditions","IS_TRUE","IS_FALSE","charConditions","isNumberConditionValid","condition","value","startValue","endValue","Number","isNaN","parseFloat","getNumberInputs","selectedCondition","handleValueChange","handleStartValueChange","handleEndValueChange","conditionValue","getStringInputs","getDateInputs","getBooleanInputs","getCharInputs","ConditionEditor","props","column","config","onChange","selectedColumnType","type","prevColumnType","setPrevColumnType","setCondition","setValue","setStartValue","start","setEndValue","end","conditions","isNumberType","isCharType","isTextType","isDateType","isBooleanType","handleConditionChange","e","target","debug","isValid","conditionInputs"],"mappings":"AAAA,OAAOA,KAAP,IAAgBC,WAAhB,EAA6BC,SAA7B,EAAwCC,OAAxC,EAAiDC,QAAjD,QAAiE,OAAjE;AACA,OAAOC,GAAP,MAAgB,gBAAhB;OACOC,U;SAELC,e,EACAC,a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AEpBC,iBAFoB,EAGpBC,sBAHoB,EAIpBC,oBAJoB,EAKpBC,cALoB,EAMpBV,UANoB,EAOpBC,QAPoB,CAAtB;AASD;;AACD,QAAIhD,UAAU,CAAC+E,UAAX,CAAsBZ,kBAAtB,CAAJ,EAA+C;AAC7C,aAAON,aAAa,CAClBR,iBADkB,EAElBC,iBAFkB,EAGlBG,cAHkB,CAApB;AAKD;;AACD,QAAIzD,UAAU,CAACgF,UAAX,CAAsBb,kBAAtB,CAAJ,EAA+C;AAC7C,aAAOT,eAAe,CACpBL,iBADoB,EAEpBC,iBAFoB,EAGpBG,cAHoB,CAAtB;AAKD;;AACD,QAAIzD,UAAU,CAACiF,UAAX,CAAsBd,kBAAtB,CAAJ,EAA+C;AAC7C,aAAOR,aAAa,CAClBN,iBADkB,EAElBC,iBAFkB,EAGlBG,cAHkB,CAApB;AAKD;;AACD,QAAIzD,UAAU,CAACkF,aAAX,CAAyBf,kBAAzB,CAAJ,EAAkD;AAChD,aAAOP,gBAAgB,EAAvB;AACD;AACF,GAxC8B,EAwC5B,CACDO,kBADC,EAEDd,iBAFC,EAGDI,cAHC,EAIDV,UAJC,EAKDC,QALC,EAMDM,iBANC,EAODC,sBAPC,EAQDC,oBARC,CAxC4B,CAA/B;AAmDA,sBACE;AAAK,IAAA,SAAS,EAAC;AAAf,kBACE;AACE,IAAA,KAAK,EAAEH,iBADT;AAEE,IAAA,EAAE,EAAC,kBAFL;AAGE,IAAA,SAAS,EAAC,oBAHZ;AAIE,IAAA,QAAQ,EAAE8B;AAJZ,KAMGN,UANH,CADF,EASGW,eATH,CADF;AAaD,CAxKD;;AA0KA,eAAe1B,eAAf","sourcesContent":["import React, { useCallback, useEffect, useMemo, useState } from 'react';\nimport Log from '@deephaven/log';\nimport TableUtils from '../../TableUtils';\nimport {\n StringCondition,\n DateCondition,\n getLabelForNumberCondition,\n getLabelForDateCondition,\n getLabelForStringCondition,\n NumberCondition,\n ModelColumn,\n ConditionConfig,\n getDefaultConditionForType,\n getLabelForBooleanCondition,\n BooleanCondition,\n CharCondition,\n getLabelForCharCondition,\n} from './ConditionalFormattingUtils';\n\nconst log = Log.module('ConditionEditor');\n\nexport interface ConditionEditorProps {\n column: ModelColumn;\n config: ConditionConfig;\n onChange?: (config: ConditionConfig, isValid: boolean) => void;\n}\n\nconst DEFAULT_CALLBACK = () => undefined;\n\nconst numberConditionOptions = [\n NumberCondition.IS_EQUAL,\n NumberCondition.IS_NOT_EQUAL,\n NumberCondition.IS_BETWEEN,\n NumberCondition.GREATER_THAN,\n NumberCondition.GREATER_THAN_OR_EQUAL,\n NumberCondition.LESS_THAN,\n NumberCondition.LESS_THAN_OR_EQUAL,\n NumberCondition.IS_NULL,\n NumberCondition.IS_NOT_NULL,\n].map(option => (\n <option key={option} value={option}>\n {getLabelForNumberCondition(option)}\n </option>\n));\n\nconst stringConditions = [\n StringCondition.IS_EXACTLY,\n StringCondition.IS_NOT_EXACTLY,\n StringCondition.CONTAINS,\n StringCondition.DOES_NOT_CONTAIN,\n StringCondition.STARTS_WITH,\n StringCondition.ENDS_WITH,\n StringCondition.IS_NULL,\n StringCondition.IS_NOT_NULL,\n].map(option => (\n <option key={option} value={option}>\n {getLabelForStringCondition(option)}\n </option>\n));\n\nconst dateConditions = [\n DateCondition.IS_EXACTLY,\n DateCondition.IS_NOT_EXACTLY,\n DateCondition.IS_BEFORE,\n DateCondition.IS_BEFORE_OR_EQUAL,\n DateCondition.IS_AFTER,\n DateCondition.IS_AFTER_OR_EQUAL,\n DateCondition.IS_NULL,\n DateCondition.IS_NOT_NULL,\n].map(option => (\n <option key={option} value={option}>\n {getLabelForDateCondition(option)}\n </option>\n));\n\nconst booleanConditions = [\n BooleanCondition.IS_TRUE,\n BooleanCondition.IS_FALSE,\n BooleanCondition.IS_NULL,\n BooleanCondition.IS_NOT_NULL,\n].map(option => (\n <option key={option} value={option}>\n {getLabelForBooleanCondition(option)}\n </option>\n));\n\nconst charConditions = [\n CharCondition.IS_EQUAL,\n CharCondition.IS_NOT_EQUAL,\n CharCondition.IS_NULL,\n CharCondition.IS_NOT_NULL,\n].map(option => (\n <option key={option} value={option}>\n {getLabelForCharCondition(option)}\n </option>\n));\n\nfunction isNumberConditionValid(\n condition: NumberCondition,\n value?: string,\n startValue?: string,\n endValue?: string\n) {\n if (\n condition === NumberCondition.IS_NULL ||\n condition === NumberCondition.IS_NOT_NULL\n ) {\n return true;\n }\n if (\n condition === NumberCondition.IS_BETWEEN &&\n startValue &&\n !Number.isNaN(Number.parseFloat(startValue)) &&\n endValue &&\n !Number.isNaN(Number.parseFloat(endValue))\n ) {\n return true;\n }\n if (\n condition !== NumberCondition.IS_BETWEEN &&\n value &&\n !Number.isNaN(Number.parseFloat(value))\n ) {\n return true;\n }\n return false;\n}\n\nfunction getNumberInputs(\n selectedCondition: NumberCondition,\n handleValueChange: (e: unknown) => void,\n handleStartValueChange: (e: unknown) => void,\n handleEndValueChange: (e: unknown) => void,\n conditionValue?: string,\n startValue?: string,\n endValue?: string\n) {\n switch (selectedCondition) {\n case NumberCondition.IS_EQUAL:\n case NumberCondition.IS_NOT_EQUAL:\n case NumberCondition.GREATER_THAN:\n case NumberCondition.GREATER_THAN_OR_EQUAL:\n case NumberCondition.LESS_THAN:\n case NumberCondition.LESS_THAN_OR_EQUAL:\n return (\n <input\n type=\"number\"\n className=\"form-control\"\n placeholder=\"Enter value\"\n value={conditionValue ?? ''}\n onChange={handleValueChange}\n />\n );\n case NumberCondition.IS_BETWEEN:\n return (\n <div className=\"d-flex flex-row\">\n <input\n type=\"number\"\n className=\"form-control d-flex mr-2\"\n placeholder=\"Start value\"\n value={startValue ?? ''}\n onChange={handleStartValueChange}\n />\n <input\n type=\"number\"\n className=\"form-control d-flex\"\n placeholder=\"End value\"\n value={endValue ?? ''}\n onChange={handleEndValueChange}\n />\n </div>\n );\n case NumberCondition.IS_NULL:\n case NumberCondition.IS_NOT_NULL:\n return null;\n }\n}\n\nfunction getStringInputs(\n selectedCondition: StringCondition,\n handleValueChange: (e: unknown) => void,\n conditionValue?: string\n) {\n switch (selectedCondition) {\n case StringCondition.IS_NULL:\n case StringCondition.IS_NOT_NULL:\n return null;\n default:\n return (\n <input\n type=\"text\"\n className=\"form-control\"\n placeholder=\"Enter value\"\n value={conditionValue ?? ''}\n onChange={handleValueChange}\n />\n );\n }\n}\n\nfunction getDateInputs(\n selectedCondition: DateCondition,\n handleValueChange: (e: unknown) => void,\n conditionValue?: string\n) {\n switch (selectedCondition) {\n case DateCondition.IS_NULL:\n case DateCondition.IS_NOT_NULL:\n return null;\n default:\n return (\n <input\n type=\"text\"\n className=\"form-control\"\n placeholder=\"Enter value\"\n value={conditionValue ?? ''}\n onChange={handleValueChange}\n />\n );\n }\n}\n\nfunction getBooleanInputs() {\n return null;\n}\n\nfunction getCharInputs(\n selectedCondition: CharCondition,\n handleValueChange: (e: unknown) => void,\n conditionValue?: string\n) {\n switch (selectedCondition) {\n case CharCondition.IS_NULL:\n case CharCondition.IS_NOT_NULL:\n return null;\n default:\n return (\n <input\n type=\"text\"\n className=\"form-control\"\n maxLength={1}\n placeholder=\"Enter value\"\n value={conditionValue ?? ''}\n onChange={handleValueChange}\n />\n );\n }\n}\n\nconst ConditionEditor = (props: ConditionEditorProps): JSX.Element => {\n const { column, config, onChange = DEFAULT_CALLBACK } = props;\n const selectedColumnType = column.type;\n const [prevColumnType, setPrevColumnType] = useState(selectedColumnType);\n const [selectedCondition, setCondition] = useState(config.condition);\n const [conditionValue, setValue] = useState(config.value);\n const [startValue, setStartValue] = useState(config.start);\n const [endValue, setEndValue] = useState(config.end);\n\n if (selectedColumnType !== prevColumnType) {\n // Column type changed, reset condition and value fields\n setCondition(getDefaultConditionForType(selectedColumnType));\n setValue(undefined);\n setStartValue(undefined);\n setEndValue(undefined);\n setPrevColumnType(selectedColumnType);\n }\n\n const conditions = useMemo(() => {\n if (selectedColumnType === undefined) {\n return [];\n }\n if (TableUtils.isNumberType(selectedColumnType)) {\n return numberConditionOptions;\n }\n if (TableUtils.isCharType(selectedColumnType)) {\n return charConditions;\n }\n if (TableUtils.isTextType(selectedColumnType)) {\n return stringConditions;\n }\n if (TableUtils.isDateType(selectedColumnType)) {\n return dateConditions;\n }\n if (TableUtils.isBooleanType(selectedColumnType)) {\n return booleanConditions;\n }\n }, [selectedColumnType]);\n\n const handleConditionChange = useCallback(e => {\n const { value } = e.target;\n log.debug('handleConditionChange', value);\n setCondition(value);\n }, []);\n\n const handleValueChange = useCallback(e => {\n const { value } = e.target;\n log.debug('handleValueChange', value);\n setValue(value);\n }, []);\n\n const handleStartValueChange = useCallback(e => {\n const { value } = e.target;\n log.debug('handleStartValueChange', value);\n setStartValue(value);\n }, []);\n\n const handleEndValueChange = useCallback(e => {\n const { value } = e.target;\n log.debug('handleEndValueChange', value);\n setEndValue(value);\n }, []);\n\n useEffect(() => {\n let isValid = true;\n\n if (selectedCondition === undefined) {\n log.debug('Unable to create formatting rule. Condition is not selected.');\n isValid = false;\n }\n\n if (\n TableUtils.isNumberType(column.type) &&\n !isNumberConditionValid(\n selectedCondition as NumberCondition,\n conditionValue,\n startValue,\n endValue\n )\n ) {\n log.debug(\n 'Unable to create formatting rule. Invalid value',\n conditionValue\n );\n isValid = false;\n }\n onChange(\n {\n condition: selectedCondition,\n value: conditionValue,\n start: startValue,\n end: endValue,\n },\n isValid\n );\n }, [\n onChange,\n column.type,\n selectedCondition,\n conditionValue,\n startValue,\n endValue,\n ]);\n\n const conditionInputs = useMemo(() => {\n if (selectedColumnType === undefined) {\n // Column not selected\n return null;\n }\n if (TableUtils.isNumberType(selectedColumnType)) {\n return getNumberInputs(\n selectedCondition as NumberCondition,\n handleValueChange,\n handleStartValueChange,\n handleEndValueChange,\n conditionValue,\n startValue,\n endValue\n );\n }\n if (TableUtils.isCharType(selectedColumnType)) {\n return getCharInputs(\n selectedCondition as CharCondition,\n handleValueChange,\n conditionValue\n );\n }\n if (TableUtils.isTextType(selectedColumnType)) {\n return getStringInputs(\n selectedCondition as StringCondition,\n handleValueChange,\n conditionValue\n );\n }\n if (TableUtils.isDateType(selectedColumnType)) {\n return getDateInputs(\n selectedCondition as DateCondition,\n handleValueChange,\n conditionValue\n );\n }\n if (TableUtils.isBooleanType(selectedColumnType)) {\n return getBooleanInputs();\n }\n }, [\n selectedColumnType,\n selectedCondition,\n conditionValue,\n startValue,\n endValue,\n handleValueChange,\n handleStartValueChange,\n handleEndValueChange,\n ]);\n\n return (\n <div className=\"condition-editor mb-2\">\n <select\n value={selectedCondition}\n id=\"condition-select\"\n className=\"custom-select mb-2\"\n onChange={handleConditionChange}\n >\n {conditions}\n </select>\n {conditionInputs}\n </div>\n );\n};\n\nexport default ConditionEditor;\n"],"file":"ConditionEditor.js"}
@@ -0,0 +1,21 @@
1
+ .conditional-format-editor {
2
+ padding: 1rem;
3
+ }
4
+ .conditional-format-editor .formatter-list {
5
+ display: flex;
6
+ justify-content: flex-start;
7
+ padding-top: 0.5rem;
8
+ }
9
+ .conditional-format-editor .formatter-type {
10
+ margin: 0 1rem 0 0;
11
+ display: flex;
12
+ }
13
+ .conditional-format-editor .btn-formatter-type {
14
+ font-size: smaller;
15
+ width: 100%;
16
+ }
17
+ .conditional-format-editor .color-select {
18
+ padding: 0 2em 0 0.25em;
19
+ }
20
+
21
+ /*# sourceMappingURL=ConditionalFormatEditor.css.map */
@@ -0,0 +1 @@
1
+ {"version":3,"sourceRoot":"","sources":["../../../src/sidebar/conditional-formatting/ConditionalFormatEditor.scss","../../../../components/scss/new_variables.scss"],"names":[],"mappings":"AAEA;EACE,SCCS;;ADCT;EACE;EACA;EACA,aCLO;;ADQT;EACE;EACA;;AAGF;EACE;EACA;;AAGF;EACE","file":"ConditionalFormatEditor.css"}
@@ -0,0 +1,15 @@
1
+ import { FormattingRule, ModelColumn } from './ConditionalFormattingUtils';
2
+ import './ConditionalFormatEditor.scss';
3
+ export declare type SaveCallback = (rule: FormattingRule) => void;
4
+ export declare type UpdateCallback = (rule?: FormattingRule) => void;
5
+ export declare type CancelCallback = () => void;
6
+ export interface ConditionalFormatEditorProps {
7
+ columns: ModelColumn[];
8
+ rule?: FormattingRule;
9
+ onCancel?: CancelCallback;
10
+ onSave?: SaveCallback;
11
+ onUpdate?: UpdateCallback;
12
+ }
13
+ declare const ConditionalFormatEditor: (props: ConditionalFormatEditorProps) => JSX.Element;
14
+ export default ConditionalFormatEditor;
15
+ //# sourceMappingURL=ConditionalFormatEditor.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ConditionalFormatEditor.d.ts","sourceRoot":"","sources":["../../../src/sidebar/conditional-formatting/ConditionalFormatEditor.tsx"],"names":[],"mappings":"AAOA,OAAO,EAGL,cAAc,EACd,WAAW,EACZ,MAAM,8BAA8B,CAAC;AACtC,OAAO,gCAAgC,CAAC;AAIxC,oBAAY,YAAY,GAAG,CAAC,IAAI,EAAE,cAAc,KAAK,IAAI,CAAC;AAE1D,oBAAY,cAAc,GAAG,CAAC,IAAI,CAAC,EAAE,cAAc,KAAK,IAAI,CAAC;AAE7D,oBAAY,cAAc,GAAG,MAAM,IAAI,CAAC;AAExC,MAAM,WAAW,4BAA4B;IAC3C,OAAO,EAAE,WAAW,EAAE,CAAC;IACvB,IAAI,CAAC,EAAE,cAAc,CAAC;IACtB,QAAQ,CAAC,EAAE,cAAc,CAAC;IAC1B,MAAM,CAAC,EAAE,YAAY,CAAC;IACtB,QAAQ,CAAC,EAAE,cAAc,CAAC;CAC3B;AAwBD,QAAA,MAAM,uBAAuB,UACpB,4BAA4B,KAClC,WAoGF,CAAC;AAEF,eAAe,uBAAuB,CAAC"}
@@ -0,0 +1,115 @@
1
+ import React, { useCallback, useState } from 'react';
2
+ import classNames from 'classnames';
3
+ import { Button } from '@deephaven/components';
4
+ import Log from '@deephaven/log';
5
+ import { FormatColumnWhereIcon, FormatRowWhereIcon } from "../icons/index.js";
6
+ import ColumnFormatEditor from "./ColumnFormatEditor.js";
7
+ import RowFormatEditor from "./RowFormatEditor.js";
8
+ import { FormatterType } from "./ConditionalFormattingUtils.js";
9
+ import "./ConditionalFormatEditor.css";
10
+ var log = Log.module('ConditionalFormatEditor');
11
+
12
+ var DEFAULT_CALLBACK = () => undefined;
13
+
14
+ function getFormatterTypeIcon(option) {
15
+ switch (option) {
16
+ case FormatterType.CONDITIONAL:
17
+ return /*#__PURE__*/React.createElement(FormatColumnWhereIcon, null);
18
+
19
+ case FormatterType.ROWS:
20
+ return /*#__PURE__*/React.createElement(FormatRowWhereIcon, null);
21
+ }
22
+ }
23
+
24
+ function getFormatterTypeLabel(option) {
25
+ switch (option) {
26
+ case FormatterType.CONDITIONAL:
27
+ return 'Conditional';
28
+
29
+ case FormatterType.ROWS:
30
+ return 'Rows';
31
+ }
32
+ }
33
+
34
+ var formatterTypes = [FormatterType.CONDITIONAL, FormatterType.ROWS];
35
+
36
+ var ConditionalFormatEditor = props => {
37
+ var _defaultRule$type;
38
+
39
+ var {
40
+ columns,
41
+ onSave = DEFAULT_CALLBACK,
42
+ onUpdate = DEFAULT_CALLBACK,
43
+ onCancel = DEFAULT_CALLBACK,
44
+ rule: defaultRule
45
+ } = props;
46
+ var [selectedFormatter, setFormatter] = useState((_defaultRule$type = defaultRule === null || defaultRule === void 0 ? void 0 : defaultRule.type) !== null && _defaultRule$type !== void 0 ? _defaultRule$type : formatterTypes[0]);
47
+ var [rule, setRule] = useState(defaultRule);
48
+ var [isValid, setIsValid] = useState(false);
49
+ var handleCancel = useCallback(() => {
50
+ onCancel();
51
+ }, [onCancel]);
52
+ var handleSave = useCallback(() => {
53
+ if (rule === undefined) {
54
+ log.error('Rule is not defined.');
55
+ return;
56
+ }
57
+
58
+ onSave(rule);
59
+ }, [onSave, rule]);
60
+ var handleFormatterChange = useCallback(value => {
61
+ log.debug('handleFormatterChange', value);
62
+ setFormatter(value);
63
+ }, []);
64
+ var handleRuleChange = useCallback((ruleConfig, isRuleValid) => {
65
+ log.debug('handleRuleChange', ruleConfig, isRuleValid, selectedFormatter);
66
+ var updatedRule = {
67
+ type: selectedFormatter,
68
+ config: ruleConfig
69
+ };
70
+ setRule(updatedRule);
71
+ setIsValid(isRuleValid);
72
+ onUpdate(isRuleValid ? updatedRule : undefined);
73
+ }, [onUpdate, selectedFormatter]);
74
+ return /*#__PURE__*/React.createElement("div", {
75
+ className: "conditional-format-editor form"
76
+ }, /*#__PURE__*/React.createElement("div", {
77
+ className: "mb-2"
78
+ }, /*#__PURE__*/React.createElement("label", {
79
+ className: "mb-0",
80
+ htmlFor: "formatter-select"
81
+ }, "Select Formatter"), /*#__PURE__*/React.createElement("div", {
82
+ className: "formatter-list"
83
+ }, formatterTypes.map((type, index) => /*#__PURE__*/React.createElement("div", {
84
+ key: type,
85
+ className: "formatter-type"
86
+ }, /*#__PURE__*/React.createElement("button", {
87
+ type: "button",
88
+ className: classNames('btn', 'btn-icon', 'btn-formatter-type', {
89
+ active: type === selectedFormatter
90
+ }),
91
+ "data-index": index,
92
+ onClick: () => handleFormatterChange(type)
93
+ }, getFormatterTypeIcon(type), getFormatterTypeLabel(type)))))), selectedFormatter === FormatterType.CONDITIONAL && /*#__PURE__*/React.createElement(ColumnFormatEditor, {
94
+ columns: columns,
95
+ config: rule === null || rule === void 0 ? void 0 : rule.config,
96
+ onChange: handleRuleChange
97
+ }), selectedFormatter === FormatterType.ROWS && /*#__PURE__*/React.createElement(RowFormatEditor, {
98
+ columns: columns,
99
+ config: rule === null || rule === void 0 ? void 0 : rule.config,
100
+ onChange: handleRuleChange
101
+ }), /*#__PURE__*/React.createElement("hr", null), /*#__PURE__*/React.createElement("div", {
102
+ className: "d-flex justify-content-end my-3"
103
+ }, /*#__PURE__*/React.createElement(Button, {
104
+ kind: "secondary",
105
+ onClick: handleCancel,
106
+ className: "mr-2"
107
+ }, "Cancel"), /*#__PURE__*/React.createElement(Button, {
108
+ kind: "primary",
109
+ onClick: handleSave,
110
+ disabled: rule === undefined || !isValid
111
+ }, "Done")));
112
+ };
113
+
114
+ export default ConditionalFormatEditor;
115
+ //# sourceMappingURL=ConditionalFormatEditor.js.map