@deephaven/iris-grid 0.22.3-beta.18 → 0.22.3-beta.21
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/AdvancedFilterCreator.js +7 -65
- package/dist/AdvancedFilterCreator.js.map +1 -1
- package/dist/AdvancedFilterCreatorFilterItem.js +0 -23
- package/dist/AdvancedFilterCreatorFilterItem.js.map +1 -1
- package/dist/AdvancedFilterCreatorSelectValue.js +0 -52
- package/dist/AdvancedFilterCreatorSelectValue.js.map +1 -1
- package/dist/AdvancedFilterCreatorSelectValueList.js +2 -42
- package/dist/AdvancedFilterCreatorSelectValueList.js.map +1 -1
- package/dist/ColumnHeaderGroup.js +0 -11
- package/dist/ColumnHeaderGroup.js.map +1 -1
- package/dist/ColumnStatistics.js +1 -20
- package/dist/ColumnStatistics.js.map +1 -1
- package/dist/CrossColumnSearch.js +2 -23
- package/dist/CrossColumnSearch.js.map +1 -1
- package/dist/FilterInputField.js +2 -36
- package/dist/FilterInputField.js.map +1 -1
- package/dist/GotoRow.d.ts +1 -1
- package/dist/GotoRow.d.ts.map +1 -1
- package/dist/GotoRow.js +2 -7
- package/dist/GotoRow.js.map +1 -1
- package/dist/IrisGrid.d.ts +11 -5
- package/dist/IrisGrid.d.ts.map +1 -1
- package/dist/IrisGrid.js +77 -519
- package/dist/IrisGrid.js.map +1 -1
- package/dist/IrisGridBottomBar.d.ts +1 -1
- package/dist/IrisGridBottomBar.d.ts.map +1 -1
- package/dist/IrisGridBottomBar.js +2 -2
- package/dist/IrisGridBottomBar.js.map +1 -1
- package/dist/IrisGridCellOverflowModal.js +6 -21
- package/dist/IrisGridCellOverflowModal.js.map +1 -1
- package/dist/IrisGridCopyHandler.js +3 -50
- package/dist/IrisGridCopyHandler.js.map +1 -1
- package/dist/IrisGridMetricCalculator.js +2 -12
- package/dist/IrisGridMetricCalculator.js.map +1 -1
- package/dist/IrisGridModel.js +32 -58
- package/dist/IrisGridModel.js.map +1 -1
- package/dist/IrisGridModelFactory.js +0 -7
- package/dist/IrisGridModelFactory.js.map +1 -1
- package/dist/IrisGridModelUpdater.js +0 -4
- package/dist/IrisGridModelUpdater.js.map +1 -1
- package/dist/IrisGridPartitionSelector.js +0 -23
- package/dist/IrisGridPartitionSelector.js.map +1 -1
- package/dist/IrisGridProxyModel.js +9 -153
- package/dist/IrisGridProxyModel.js.map +1 -1
- package/dist/IrisGridRenderer.js +41 -183
- package/dist/IrisGridRenderer.js.map +1 -1
- package/dist/IrisGridShortcuts.js.map +1 -1
- package/dist/IrisGridTableModel.js +7 -86
- package/dist/IrisGridTableModel.js.map +1 -1
- package/dist/IrisGridTableModelTemplate.js +70 -461
- package/dist/IrisGridTableModelTemplate.js.map +1 -1
- package/dist/IrisGridTestUtils.js +0 -23
- package/dist/IrisGridTestUtils.js.map +1 -1
- package/dist/IrisGridTheme.js.map +1 -1
- package/dist/IrisGridTreeTableModel.js +3 -42
- package/dist/IrisGridTreeTableModel.js.map +1 -1
- package/dist/IrisGridUtils.d.ts +8 -2
- package/dist/IrisGridUtils.d.ts.map +1 -1
- package/dist/IrisGridUtils.js +97 -195
- package/dist/IrisGridUtils.js.map +1 -1
- package/dist/MissingKeyError.js +0 -7
- package/dist/MissingKeyError.js.map +1 -1
- package/dist/PartitionSelectorSearch.js +2 -48
- package/dist/PartitionSelectorSearch.js.map +1 -1
- package/dist/PendingDataBottomBar.d.ts +1 -1
- package/dist/PendingDataBottomBar.d.ts.map +1 -1
- package/dist/PendingDataBottomBar.js +2 -7
- package/dist/PendingDataBottomBar.js.map +1 -1
- package/dist/TableViewportUpdater.js +3 -29
- package/dist/TableViewportUpdater.js.map +1 -1
- package/dist/ToastBottomBar.d.ts +1 -1
- package/dist/ToastBottomBar.d.ts.map +1 -1
- package/dist/ToastBottomBar.js +2 -4
- package/dist/ToastBottomBar.js.map +1 -1
- package/dist/TreeTableViewportUpdater.js +0 -21
- package/dist/TreeTableViewportUpdater.js.map +1 -1
- package/dist/format-context-menus/CustomFormatAction.js +4 -25
- package/dist/format-context-menus/CustomFormatAction.js.map +1 -1
- package/dist/format-context-menus/DateTimeFormatContextMenu.js +0 -7
- package/dist/format-context-menus/DateTimeFormatContextMenu.js.map +1 -1
- package/dist/format-context-menus/DecimalFormatContextMenu.js +0 -9
- package/dist/format-context-menus/DecimalFormatContextMenu.js.map +1 -1
- package/dist/format-context-menus/FormatContextMenuUtils.js +3 -9
- package/dist/format-context-menus/FormatContextMenuUtils.js.map +1 -1
- package/dist/format-context-menus/IntegerFormatContextMenu.js +0 -8
- package/dist/format-context-menus/IntegerFormatContextMenu.js.map +1 -1
- package/dist/format-context-menus/index.js.map +1 -1
- package/dist/index.d.ts +3 -3
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +3 -3
- package/dist/index.js.map +1 -1
- package/dist/key-handlers/ClearFilterKeyHandler.js +0 -8
- package/dist/key-handlers/ClearFilterKeyHandler.js.map +1 -1
- package/dist/key-handlers/CopyKeyHandler.js +1 -10
- package/dist/key-handlers/CopyKeyHandler.js.map +1 -1
- package/dist/key-handlers/ReverseKeyHandler.js +0 -11
- package/dist/key-handlers/ReverseKeyHandler.js.map +1 -1
- package/dist/key-handlers/index.js.map +1 -1
- package/dist/mousehandlers/IrisGridCellOverflowMouseHandler.js +2 -32
- package/dist/mousehandlers/IrisGridCellOverflowMouseHandler.js.map +1 -1
- package/dist/mousehandlers/IrisGridColumnSelectMouseHandler.js +4 -34
- package/dist/mousehandlers/IrisGridColumnSelectMouseHandler.js.map +1 -1
- package/dist/mousehandlers/IrisGridColumnTooltipMouseHandler.js +0 -20
- package/dist/mousehandlers/IrisGridColumnTooltipMouseHandler.js.map +1 -1
- package/dist/mousehandlers/IrisGridContextMenuHandler.js +15 -105
- package/dist/mousehandlers/IrisGridContextMenuHandler.js.map +1 -1
- package/dist/mousehandlers/IrisGridDataSelectMouseHandler.js +0 -9
- package/dist/mousehandlers/IrisGridDataSelectMouseHandler.js.map +1 -1
- package/dist/mousehandlers/IrisGridFilterMouseHandler.js +0 -17
- package/dist/mousehandlers/IrisGridFilterMouseHandler.js.map +1 -1
- package/dist/mousehandlers/IrisGridSortMouseHandler.js +2 -15
- package/dist/mousehandlers/IrisGridSortMouseHandler.js.map +1 -1
- package/dist/mousehandlers/PendingMouseHandler.js +0 -6
- package/dist/mousehandlers/PendingMouseHandler.js.map +1 -1
- package/dist/mousehandlers/index.js.map +1 -1
- package/dist/sidebar/AdvancedSettings.js.map +1 -1
- package/dist/sidebar/AdvancedSettingsMenu.d.ts +4 -4
- package/dist/sidebar/AdvancedSettingsMenu.d.ts.map +1 -1
- package/dist/sidebar/AdvancedSettingsMenu.js +2 -6
- package/dist/sidebar/AdvancedSettingsMenu.js.map +1 -1
- package/dist/sidebar/AdvancedSettingsType.js +0 -2
- package/dist/sidebar/AdvancedSettingsType.js.map +1 -1
- package/dist/sidebar/ChartBuilder.js +2 -46
- package/dist/sidebar/ChartBuilder.js.map +1 -1
- package/dist/sidebar/CustomColumnBuilder.js +6 -58
- package/dist/sidebar/CustomColumnBuilder.js.map +1 -1
- package/dist/sidebar/CustomColumnInput.js +4 -15
- package/dist/sidebar/CustomColumnInput.js.map +1 -1
- package/dist/sidebar/InputEditor.js +5 -36
- package/dist/sidebar/InputEditor.js.map +1 -1
- package/dist/sidebar/OptionType.js +0 -2
- package/dist/sidebar/OptionType.js.map +1 -1
- package/dist/sidebar/RollupRows.js +9 -65
- package/dist/sidebar/RollupRows.js.map +1 -1
- package/dist/sidebar/SelectDistinctBuilder.js +0 -13
- package/dist/sidebar/SelectDistinctBuilder.js.map +1 -1
- package/dist/sidebar/TableCsvExporter.js +0 -52
- package/dist/sidebar/TableCsvExporter.js.map +1 -1
- package/dist/sidebar/TableSaver.js +10 -123
- package/dist/sidebar/TableSaver.js.map +1 -1
- package/dist/sidebar/VisibilityOrderingBuilder.js +37 -116
- package/dist/sidebar/VisibilityOrderingBuilder.js.map +1 -1
- package/dist/sidebar/aggregations/AggregationEdit.d.ts +1 -1
- package/dist/sidebar/aggregations/AggregationEdit.d.ts.map +1 -1
- package/dist/sidebar/aggregations/AggregationEdit.js +2 -14
- package/dist/sidebar/aggregations/AggregationEdit.js.map +1 -1
- package/dist/sidebar/aggregations/AggregationOperation.js +0 -2
- package/dist/sidebar/aggregations/AggregationOperation.js.map +1 -1
- package/dist/sidebar/aggregations/AggregationUtils.js +2 -5
- package/dist/sidebar/aggregations/AggregationUtils.js.map +1 -1
- package/dist/sidebar/aggregations/Aggregations.d.ts +1 -1
- package/dist/sidebar/aggregations/Aggregations.d.ts.map +1 -1
- package/dist/sidebar/aggregations/Aggregations.js +2 -12
- package/dist/sidebar/aggregations/Aggregations.js.map +1 -1
- package/dist/sidebar/conditional-formatting/ColumnFormatEditor.d.ts +1 -1
- package/dist/sidebar/conditional-formatting/ColumnFormatEditor.d.ts.map +1 -1
- package/dist/sidebar/conditional-formatting/ColumnFormatEditor.js +2 -16
- package/dist/sidebar/conditional-formatting/ColumnFormatEditor.js.map +1 -1
- package/dist/sidebar/conditional-formatting/ConditionEditor.d.ts +1 -1
- package/dist/sidebar/conditional-formatting/ConditionEditor.d.ts.map +1 -1
- package/dist/sidebar/conditional-formatting/ConditionEditor.js +2 -35
- package/dist/sidebar/conditional-formatting/ConditionEditor.js.map +1 -1
- package/dist/sidebar/conditional-formatting/ConditionalFormatEditor.d.ts +1 -1
- package/dist/sidebar/conditional-formatting/ConditionalFormatEditor.d.ts.map +1 -1
- package/dist/sidebar/conditional-formatting/ConditionalFormatEditor.js +2 -12
- package/dist/sidebar/conditional-formatting/ConditionalFormatEditor.js.map +1 -1
- package/dist/sidebar/conditional-formatting/ConditionalFormattingAPIUtils.js +0 -3
- package/dist/sidebar/conditional-formatting/ConditionalFormattingAPIUtils.js.map +1 -1
- package/dist/sidebar/conditional-formatting/ConditionalFormattingMenu.d.ts +1 -1
- package/dist/sidebar/conditional-formatting/ConditionalFormattingMenu.d.ts.map +1 -1
- package/dist/sidebar/conditional-formatting/ConditionalFormattingMenu.js +16 -26
- package/dist/sidebar/conditional-formatting/ConditionalFormattingMenu.js.map +1 -1
- package/dist/sidebar/conditional-formatting/ConditionalFormattingUtils.js +9 -172
- package/dist/sidebar/conditional-formatting/ConditionalFormattingUtils.js.map +1 -1
- package/dist/sidebar/conditional-formatting/RowFormatEditor.d.ts +1 -1
- package/dist/sidebar/conditional-formatting/RowFormatEditor.d.ts.map +1 -1
- package/dist/sidebar/conditional-formatting/RowFormatEditor.js +2 -16
- package/dist/sidebar/conditional-formatting/RowFormatEditor.js.map +1 -1
- package/dist/sidebar/conditional-formatting/StyleEditor.d.ts +1 -1
- package/dist/sidebar/conditional-formatting/StyleEditor.d.ts.map +1 -1
- package/dist/sidebar/conditional-formatting/StyleEditor.js +2 -12
- package/dist/sidebar/conditional-formatting/StyleEditor.js.map +1 -1
- package/dist/sidebar/icons/BarIcon.js +0 -3
- package/dist/sidebar/icons/BarIcon.js.map +1 -1
- package/dist/sidebar/icons/FormatColumnWhereIcon.js +2 -5
- package/dist/sidebar/icons/FormatColumnWhereIcon.js.map +1 -1
- package/dist/sidebar/icons/FormatRowWhereIcon.js +2 -5
- package/dist/sidebar/icons/FormatRowWhereIcon.js.map +1 -1
- package/dist/sidebar/icons/HistogramIcon.js +0 -3
- package/dist/sidebar/icons/HistogramIcon.js.map +1 -1
- package/dist/sidebar/icons/LineIcon.js +0 -3
- package/dist/sidebar/icons/LineIcon.js.map +1 -1
- package/dist/sidebar/icons/PieIcon.js +0 -3
- package/dist/sidebar/icons/PieIcon.js.map +1 -1
- package/dist/sidebar/icons/ScatterIcon.js +0 -3
- package/dist/sidebar/icons/ScatterIcon.js.map +1 -1
- package/dist/sidebar/icons/index.js.map +1 -1
- package/dist/sidebar/index.js.map +1 -1
- package/package.json +15 -15
|
@@ -8,34 +8,26 @@ import RowFormatEditor from "./RowFormatEditor.js";
|
|
|
8
8
|
import { FormatterType, isSupportedColumn } from "./ConditionalFormattingUtils.js";
|
|
9
9
|
import "./ConditionalFormatEditor.css";
|
|
10
10
|
var log = Log.module('ConditionalFormatEditor');
|
|
11
|
-
|
|
12
11
|
var DEFAULT_CALLBACK = () => undefined;
|
|
13
|
-
|
|
14
12
|
function getFormatterTypeIcon(option) {
|
|
15
13
|
switch (option) {
|
|
16
14
|
case FormatterType.CONDITIONAL:
|
|
17
15
|
return /*#__PURE__*/React.createElement(FormatColumnWhereIcon, null);
|
|
18
|
-
|
|
19
16
|
case FormatterType.ROWS:
|
|
20
17
|
return /*#__PURE__*/React.createElement(FormatRowWhereIcon, null);
|
|
21
18
|
}
|
|
22
19
|
}
|
|
23
|
-
|
|
24
20
|
function getFormatterTypeLabel(option) {
|
|
25
21
|
switch (option) {
|
|
26
22
|
case FormatterType.CONDITIONAL:
|
|
27
23
|
return 'Conditional';
|
|
28
|
-
|
|
29
24
|
case FormatterType.ROWS:
|
|
30
25
|
return 'Rows';
|
|
31
26
|
}
|
|
32
27
|
}
|
|
33
|
-
|
|
34
28
|
var formatterTypes = [FormatterType.CONDITIONAL, FormatterType.ROWS];
|
|
35
|
-
|
|
36
|
-
var ConditionalFormatEditor = props => {
|
|
29
|
+
function ConditionalFormatEditor(props) {
|
|
37
30
|
var _defaultRule$type;
|
|
38
|
-
|
|
39
31
|
var {
|
|
40
32
|
columns: originalColumns,
|
|
41
33
|
onSave = DEFAULT_CALLBACK,
|
|
@@ -55,7 +47,6 @@ var ConditionalFormatEditor = props => {
|
|
|
55
47
|
log.error('Rule is not defined.');
|
|
56
48
|
return;
|
|
57
49
|
}
|
|
58
|
-
|
|
59
50
|
onSave(rule);
|
|
60
51
|
}, [onSave, rule]);
|
|
61
52
|
var handleFormatterChange = useCallback(value => {
|
|
@@ -110,7 +101,6 @@ var ConditionalFormatEditor = props => {
|
|
|
110
101
|
onClick: handleSave,
|
|
111
102
|
disabled: rule === undefined || !isValid
|
|
112
103
|
}, "Done")));
|
|
113
|
-
}
|
|
114
|
-
|
|
104
|
+
}
|
|
115
105
|
export default ConditionalFormatEditor;
|
|
116
106
|
//# sourceMappingURL=ConditionalFormatEditor.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ConditionalFormatEditor.js","names":["React","useCallback","useState","classNames","Button","Log","FormatColumnWhereIcon","FormatRowWhereIcon","ColumnFormatEditor","RowFormatEditor","FormatterType","isSupportedColumn","log","module","DEFAULT_CALLBACK","undefined","getFormatterTypeIcon","option","CONDITIONAL","ROWS","getFormatterTypeLabel","formatterTypes","ConditionalFormatEditor","props","columns","originalColumns","onSave","onUpdate","onCancel","rule","defaultRule","filter","selectedFormatter","setFormatter","type","setRule","isValid","setIsValid","handleCancel","handleSave","error","handleFormatterChange","value","debug","handleRuleChange","ruleConfig","isRuleValid","updatedRule","config","map","index","active"],"sources":["../../../src/sidebar/conditional-formatting/ConditionalFormatEditor.tsx"],"sourcesContent":["import React, { useCallback, useState } from 'react';\nimport classNames from 'classnames';\nimport { Button } from '@deephaven/components';\nimport Log from '@deephaven/log';\nimport { FormatColumnWhereIcon, FormatRowWhereIcon } from '../icons';\nimport ColumnFormatEditor from './ColumnFormatEditor';\nimport RowFormatEditor from './RowFormatEditor';\nimport {\n BaseFormatConfig,\n FormatterType,\n FormattingRule,\n isSupportedColumn,\n ModelColumn,\n} from './ConditionalFormattingUtils';\nimport './ConditionalFormatEditor.scss';\n\nconst log = Log.module('ConditionalFormatEditor');\n\nexport type SaveCallback = (rule: FormattingRule) => void;\n\nexport type UpdateCallback = (rule?: FormattingRule) => void;\n\nexport type CancelCallback = () => void;\n\nexport interface ConditionalFormatEditorProps {\n columns: ModelColumn[];\n rule?: FormattingRule;\n onCancel?: CancelCallback;\n onSave?: SaveCallback;\n onUpdate?: UpdateCallback;\n}\n\nconst DEFAULT_CALLBACK = () => undefined;\n\nfunction getFormatterTypeIcon(option: FormatterType): JSX.Element | undefined {\n switch (option) {\n case FormatterType.CONDITIONAL:\n return <FormatColumnWhereIcon />;\n case FormatterType.ROWS:\n return <FormatRowWhereIcon />;\n }\n}\n\nfunction getFormatterTypeLabel(option: FormatterType): string {\n switch (option) {\n case FormatterType.CONDITIONAL:\n return 'Conditional';\n case FormatterType.ROWS:\n return 'Rows';\n }\n}\n\nconst formatterTypes = [FormatterType.CONDITIONAL, FormatterType.ROWS];\n\
|
|
1
|
+
{"version":3,"file":"ConditionalFormatEditor.js","names":["React","useCallback","useState","classNames","Button","Log","FormatColumnWhereIcon","FormatRowWhereIcon","ColumnFormatEditor","RowFormatEditor","FormatterType","isSupportedColumn","log","module","DEFAULT_CALLBACK","undefined","getFormatterTypeIcon","option","CONDITIONAL","ROWS","getFormatterTypeLabel","formatterTypes","ConditionalFormatEditor","props","columns","originalColumns","onSave","onUpdate","onCancel","rule","defaultRule","filter","selectedFormatter","setFormatter","type","setRule","isValid","setIsValid","handleCancel","handleSave","error","handleFormatterChange","value","debug","handleRuleChange","ruleConfig","isRuleValid","updatedRule","config","map","index","active"],"sources":["../../../src/sidebar/conditional-formatting/ConditionalFormatEditor.tsx"],"sourcesContent":["import React, { useCallback, useState } from 'react';\nimport classNames from 'classnames';\nimport { Button } from '@deephaven/components';\nimport Log from '@deephaven/log';\nimport { FormatColumnWhereIcon, FormatRowWhereIcon } from '../icons';\nimport ColumnFormatEditor from './ColumnFormatEditor';\nimport RowFormatEditor from './RowFormatEditor';\nimport {\n BaseFormatConfig,\n FormatterType,\n FormattingRule,\n isSupportedColumn,\n ModelColumn,\n} from './ConditionalFormattingUtils';\nimport './ConditionalFormatEditor.scss';\n\nconst log = Log.module('ConditionalFormatEditor');\n\nexport type SaveCallback = (rule: FormattingRule) => void;\n\nexport type UpdateCallback = (rule?: FormattingRule) => void;\n\nexport type CancelCallback = () => void;\n\nexport interface ConditionalFormatEditorProps {\n columns: ModelColumn[];\n rule?: FormattingRule;\n onCancel?: CancelCallback;\n onSave?: SaveCallback;\n onUpdate?: UpdateCallback;\n}\n\nconst DEFAULT_CALLBACK = () => undefined;\n\nfunction getFormatterTypeIcon(option: FormatterType): JSX.Element | undefined {\n switch (option) {\n case FormatterType.CONDITIONAL:\n return <FormatColumnWhereIcon />;\n case FormatterType.ROWS:\n return <FormatRowWhereIcon />;\n }\n}\n\nfunction getFormatterTypeLabel(option: FormatterType): string {\n switch (option) {\n case FormatterType.CONDITIONAL:\n return 'Conditional';\n case FormatterType.ROWS:\n return 'Rows';\n }\n}\n\nconst formatterTypes = [FormatterType.CONDITIONAL, FormatterType.ROWS];\n\nfunction ConditionalFormatEditor(\n props: ConditionalFormatEditorProps\n): JSX.Element {\n const {\n columns: originalColumns,\n onSave = DEFAULT_CALLBACK,\n onUpdate = DEFAULT_CALLBACK,\n onCancel = DEFAULT_CALLBACK,\n rule: defaultRule,\n } = props;\n\n const columns = originalColumns.filter(isSupportedColumn);\n\n const [selectedFormatter, setFormatter] = useState(\n defaultRule?.type ?? formatterTypes[0]\n );\n const [rule, setRule] = useState(defaultRule);\n const [isValid, setIsValid] = useState(false);\n\n const handleCancel = useCallback(() => {\n onCancel();\n }, [onCancel]);\n\n const handleSave = useCallback(() => {\n if (rule === undefined) {\n log.error('Rule is not defined.');\n return;\n }\n onSave(rule);\n }, [onSave, rule]);\n\n const handleFormatterChange = useCallback(value => {\n log.debug('handleFormatterChange', value);\n setFormatter(value);\n }, []);\n\n const handleRuleChange = useCallback(\n (ruleConfig, isRuleValid: boolean) => {\n log.debug('handleRuleChange', ruleConfig, isRuleValid, selectedFormatter);\n const updatedRule = {\n type: selectedFormatter,\n config: ruleConfig as BaseFormatConfig,\n };\n setRule(updatedRule);\n setIsValid(isRuleValid);\n onUpdate(isRuleValid ? updatedRule : undefined);\n },\n [onUpdate, selectedFormatter]\n );\n\n return (\n <div className=\"conditional-format-editor form\">\n <div className=\"mb-2\">\n <label className=\"mb-0\" htmlFor=\"formatter-select\">\n Select Formatter\n </label>\n\n <div className=\"formatter-list\">\n {formatterTypes.map((type, index) => (\n <div key={type} className=\"formatter-type\">\n <button\n type=\"button\"\n className={classNames('btn', 'btn-icon', 'btn-formatter-type', {\n active: type === selectedFormatter,\n })}\n data-index={index}\n onClick={() => handleFormatterChange(type)}\n >\n {getFormatterTypeIcon(type)}\n {getFormatterTypeLabel(type)}\n </button>\n </div>\n ))}\n </div>\n </div>\n {selectedFormatter === FormatterType.CONDITIONAL && (\n <ColumnFormatEditor\n columns={columns}\n config={rule?.config}\n onChange={handleRuleChange}\n />\n )}\n {selectedFormatter === FormatterType.ROWS && (\n <RowFormatEditor\n columns={columns}\n config={rule?.config}\n onChange={handleRuleChange}\n />\n )}\n <hr />\n <div className=\"d-flex justify-content-end my-3\">\n <Button kind=\"secondary\" onClick={handleCancel} className=\"mr-2\">\n Cancel\n </Button>\n <Button\n kind=\"primary\"\n onClick={handleSave}\n disabled={rule === undefined || !isValid}\n >\n Done\n </Button>\n </div>\n </div>\n );\n}\n\nexport default ConditionalFormatEditor;\n"],"mappings":"AAAA,OAAOA,KAAK,IAAIC,WAAW,EAAEC,QAAQ,QAAQ,OAAO;AACpD,OAAOC,UAAU,MAAM,YAAY;AACnC,SAASC,MAAM,QAAQ,uBAAuB;AAC9C,OAAOC,GAAG,MAAM,gBAAgB;AAAC,SACxBC,qBAAqB,EAAEC,kBAAkB;AAAA,OAC3CC,kBAAkB;AAAA,OAClBC,eAAe;AAAA,SAGpBC,aAAa,EAEbC,iBAAiB;AAAA;AAKnB,IAAMC,GAAG,GAAGP,GAAG,CAACQ,MAAM,CAAC,yBAAyB,CAAC;AAgBjD,IAAMC,gBAAgB,GAAG,MAAMC,SAAS;AAExC,SAASC,oBAAoB,CAACC,MAAqB,EAA2B;EAC5E,QAAQA,MAAM;IACZ,KAAKP,aAAa,CAACQ,WAAW;MAC5B,oBAAO,oBAAC,qBAAqB,OAAG;IAClC,KAAKR,aAAa,CAACS,IAAI;MACrB,oBAAO,oBAAC,kBAAkB,OAAG;EAAC;AAEpC;AAEA,SAASC,qBAAqB,CAACH,MAAqB,EAAU;EAC5D,QAAQA,MAAM;IACZ,KAAKP,aAAa,CAACQ,WAAW;MAC5B,OAAO,aAAa;IACtB,KAAKR,aAAa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,QAAQ,EAAEJ;EAAiB,EAE9B,EACAZ,iBAAiB,KAAKtB,aAAa,CAACS,IAAI,iBACvC,oBAAC,eAAe;IACd,OAAO,EAAEK,OAAQ;IACjB,MAAM,EAAEK,IAAI,aAAJA,IAAI,uBAAJA,IAAI,CAAEmB,MAAO;IACrB,QAAQ,EAAEJ;EAAiB,EAE9B,eACD,+BAAM,eACN;IAAK,SAAS,EAAC;EAAiC,gBAC9C,oBAAC,MAAM;IAAC,IAAI,EAAC,WAAW;IAAC,OAAO,EAAEN,YAAa;IAAC,SAAS,EAAC;EAAM,YAEvD,eACT,oBAAC,MAAM;IACL,IAAI,EAAC,SAAS;IACd,OAAO,EAAEC,UAAW;IACpB,QAAQ,EAAEV,IAAI,KAAKd,SAAS,IAAI,CAACqB;EAAQ,UAGlC,CACL,CACF;AAEV;AAEA,eAAed,uBAAuB"}
|
|
@@ -1,14 +1,11 @@
|
|
|
1
1
|
import { getConditionDBString, getStyleDBString } from "./ConditionalFormattingUtils.js"; // Conditional formatting API utils in a separate file
|
|
2
2
|
// to make ConditionalFormattingUtils.ts easier to test.
|
|
3
3
|
// https://github.com/facebook/jest/issues/936#issuecomment-545080082
|
|
4
|
-
|
|
5
4
|
export function makeTernaryFormatRule(config, prevRule) {
|
|
6
5
|
var styleDBString = getStyleDBString(config);
|
|
7
|
-
|
|
8
6
|
if (styleDBString === undefined) {
|
|
9
7
|
return undefined;
|
|
10
8
|
}
|
|
11
|
-
|
|
12
9
|
var conditionDBString = getConditionDBString(config);
|
|
13
10
|
return "".concat(conditionDBString, " ? ").concat(styleDBString, " : ").concat(prevRule);
|
|
14
11
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ConditionalFormattingAPIUtils.js","names":["getConditionDBString","getStyleDBString","makeTernaryFormatRule","config","prevRule","styleDBString","undefined","conditionDBString","makeRowFormatColumn","rule","dh","Column","formatRowColor","makeColumnFormatColumn","col","formatColor"],"sources":["../../../src/sidebar/conditional-formatting/ConditionalFormattingAPIUtils.ts"],"sourcesContent":["import { Column, CustomColumn } from '@deephaven/jsapi-shim';\nimport {\n BaseFormatConfig,\n getConditionDBString,\n getStyleDBString,\n} from './ConditionalFormattingUtils';\n\n// Conditional formatting API utils in a separate file\n// to make ConditionalFormattingUtils.ts easier to test.\n// https://github.com/facebook/jest/issues/936#issuecomment-545080082\n\nexport function makeTernaryFormatRule(\n config: BaseFormatConfig,\n prevRule: string\n): string | undefined {\n const styleDBString = getStyleDBString(config);\n if (styleDBString === undefined) {\n return undefined;\n }\n const conditionDBString = getConditionDBString(config);\n return `${conditionDBString} ? ${styleDBString} : ${prevRule}`;\n}\n\nexport function makeRowFormatColumn(rule: string): CustomColumn {\n return dh.Column.formatRowColor(rule);\n}\n\nexport function makeColumnFormatColumn(\n col: Column,\n rule: string\n): CustomColumn {\n return col.formatColor(rule);\n}\n"],"mappings":"SAGEA,
|
|
1
|
+
{"version":3,"file":"ConditionalFormattingAPIUtils.js","names":["getConditionDBString","getStyleDBString","makeTernaryFormatRule","config","prevRule","styleDBString","undefined","conditionDBString","makeRowFormatColumn","rule","dh","Column","formatRowColor","makeColumnFormatColumn","col","formatColor"],"sources":["../../../src/sidebar/conditional-formatting/ConditionalFormattingAPIUtils.ts"],"sourcesContent":["import { Column, CustomColumn } from '@deephaven/jsapi-shim';\nimport {\n BaseFormatConfig,\n getConditionDBString,\n getStyleDBString,\n} from './ConditionalFormattingUtils';\n\n// Conditional formatting API utils in a separate file\n// to make ConditionalFormattingUtils.ts easier to test.\n// https://github.com/facebook/jest/issues/936#issuecomment-545080082\n\nexport function makeTernaryFormatRule(\n config: BaseFormatConfig,\n prevRule: string\n): string | undefined {\n const styleDBString = getStyleDBString(config);\n if (styleDBString === undefined) {\n return undefined;\n }\n const conditionDBString = getConditionDBString(config);\n return `${conditionDBString} ? ${styleDBString} : ${prevRule}`;\n}\n\nexport function makeRowFormatColumn(rule: string): CustomColumn {\n return dh.Column.formatRowColor(rule);\n}\n\nexport function makeColumnFormatColumn(\n col: Column,\n rule: string\n): CustomColumn {\n return col.formatColor(rule);\n}\n"],"mappings":"SAGEA,oBAAoB,EACpBC,gBAAgB,2CAGlB;AACA;AACA;AAEA,OAAO,SAASC,qBAAqB,CACnCC,MAAwB,EACxBC,QAAgB,EACI;EACpB,IAAMC,aAAa,GAAGJ,gBAAgB,CAACE,MAAM,CAAC;EAC9C,IAAIE,aAAa,KAAKC,SAAS,EAAE;IAC/B,OAAOA,SAAS;EAClB;EACA,IAAMC,iBAAiB,GAAGP,oBAAoB,CAACG,MAAM,CAAC;EACtD,iBAAUI,iBAAiB,gBAAMF,aAAa,gBAAMD,QAAQ;AAC9D;AAEA,OAAO,SAASI,mBAAmB,CAACC,IAAY,EAAgB;EAC9D,OAAOC,EAAE,CAACC,MAAM,CAACC,cAAc,CAACH,IAAI,CAAC;AACvC;AAEA,OAAO,SAASI,sBAAsB,CACpCC,GAAW,EACXL,IAAY,EACE;EACd,OAAOK,GAAG,CAACC,WAAW,CAACN,IAAI,CAAC;AAC9B"}
|
|
@@ -12,6 +12,6 @@ export declare type ConditionalFormattingMenuProps = {
|
|
|
12
12
|
onCreate?: CreateCallback;
|
|
13
13
|
onSelect?: SelectCallback;
|
|
14
14
|
};
|
|
15
|
-
declare
|
|
15
|
+
declare function ConditionalFormattingMenu(props: ConditionalFormattingMenuProps): JSX.Element;
|
|
16
16
|
export default ConditionalFormattingMenu;
|
|
17
17
|
//# sourceMappingURL=ConditionalFormattingMenu.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ConditionalFormattingMenu.d.ts","sourceRoot":"","sources":["../../../src/sidebar/conditional-formatting/ConditionalFormattingMenu.tsx"],"names":[],"mappings":";AAaA,OAAO,kCAAkC,CAAC;AAC1C,OAAO,EAEL,cAAc,EAQf,MAAM,8BAA8B,CAAC;AACtC,OAAO,EAAE,UAAU,EAAE,MAAM,mBAAmB,CAAC;AAI/C,oBAAY,cAAc,GAAG,CAAC,KAAK,EAAE,cAAc,EAAE,KAAK,IAAI,CAAC;AAE/D,oBAAY,cAAc,GAAG,CAAC,KAAK,EAAE,MAAM,KAAK,IAAI,CAAC;AAErD,oBAAY,cAAc,GAAG,MAAM,IAAI,CAAC;AAExC,oBAAY,8BAA8B,GAAG;IAC3C,KAAK,EAAE,cAAc,EAAE,CAAC;IACxB,cAAc,CAAC,EAAE,UAAU,CAAC;IAC5B,QAAQ,CAAC,EAAE,cAAc,CAAC;IAC1B,QAAQ,CAAC,EAAE,cAAc,CAAC;IAC1B,QAAQ,CAAC,EAAE,cAAc,CAAC;CAC3B,CAAC;AAoDF,
|
|
1
|
+
{"version":3,"file":"ConditionalFormattingMenu.d.ts","sourceRoot":"","sources":["../../../src/sidebar/conditional-formatting/ConditionalFormattingMenu.tsx"],"names":[],"mappings":";AAaA,OAAO,kCAAkC,CAAC;AAC1C,OAAO,EAEL,cAAc,EAQf,MAAM,8BAA8B,CAAC;AACtC,OAAO,EAAE,UAAU,EAAE,MAAM,mBAAmB,CAAC;AAI/C,oBAAY,cAAc,GAAG,CAAC,KAAK,EAAE,cAAc,EAAE,KAAK,IAAI,CAAC;AAE/D,oBAAY,cAAc,GAAG,CAAC,KAAK,EAAE,MAAM,KAAK,IAAI,CAAC;AAErD,oBAAY,cAAc,GAAG,MAAM,IAAI,CAAC;AAExC,oBAAY,8BAA8B,GAAG;IAC3C,KAAK,EAAE,cAAc,EAAE,CAAC;IACxB,cAAc,CAAC,EAAE,UAAU,CAAC;IAC5B,QAAQ,CAAC,EAAE,cAAc,CAAC;IAC1B,QAAQ,CAAC,EAAE,cAAc,CAAC;IAC1B,QAAQ,CAAC,EAAE,cAAc,CAAC;CAC3B,CAAC;AAoDF,iBAAS,yBAAyB,CAChC,KAAK,EAAE,8BAA8B,GACpC,GAAG,CAAC,OAAO,CAwJb;AAED,eAAe,yBAAyB,CAAC"}
|
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
function _extends() { _extends = Object.assign ? Object.assign.bind() : function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }
|
|
2
|
-
|
|
3
2
|
import React, { useCallback } from 'react';
|
|
4
3
|
import { DragDropContext, Draggable, Droppable } from 'react-beautiful-dnd';
|
|
5
4
|
import classNames from 'classnames';
|
|
@@ -11,48 +10,37 @@ import Log from '@deephaven/log';
|
|
|
11
10
|
import "./ConditionalFormattingMenu.css";
|
|
12
11
|
import { FormatterType, getBackgroundForStyleConfig, getColorForStyleConfig, getShortLabelForConditionType, NumberCondition, StringCondition, DateCondition } from "./ConditionalFormattingUtils.js";
|
|
13
12
|
var log = Log.module('ConditionalFormattingMenu');
|
|
14
|
-
|
|
15
13
|
var DEFAULT_CALLBACK = () => undefined;
|
|
16
|
-
|
|
17
14
|
function getRuleValue(config) {
|
|
18
15
|
var {
|
|
19
16
|
column: {
|
|
20
17
|
type
|
|
21
18
|
}
|
|
22
19
|
} = config;
|
|
23
|
-
|
|
24
20
|
if (TableUtils.isNumberType(type)) {
|
|
25
21
|
return config.condition === NumberCondition.IS_NULL || config.condition === NumberCondition.IS_NOT_NULL ? '' : "".concat(config.value);
|
|
26
22
|
}
|
|
27
|
-
|
|
28
23
|
if (TableUtils.isCharType(type)) {
|
|
29
24
|
return config.condition === DateCondition.IS_NULL || config.condition === DateCondition.IS_NOT_NULL ? '' : "".concat(config.value);
|
|
30
25
|
}
|
|
31
|
-
|
|
32
26
|
if (TableUtils.isStringType(type)) {
|
|
33
27
|
return config.condition === StringCondition.IS_NULL || config.condition === StringCondition.IS_NOT_NULL ? '' : "\"".concat(config.value, "\"");
|
|
34
28
|
}
|
|
35
|
-
|
|
36
29
|
if (TableUtils.isDateType(type)) {
|
|
37
30
|
return config.condition === DateCondition.IS_NULL || config.condition === DateCondition.IS_NOT_NULL ? '' : "".concat(config.value);
|
|
38
31
|
}
|
|
39
|
-
|
|
40
32
|
if (TableUtils.isBooleanType(type)) {
|
|
41
33
|
return '';
|
|
42
34
|
}
|
|
43
|
-
|
|
44
35
|
throw new Error("Invalid column type ".concat(type, " in getRuleValue"));
|
|
45
36
|
}
|
|
46
|
-
|
|
47
37
|
function getRuleTitle(config) {
|
|
48
38
|
if (TableUtils.isNumberType(config.column.type) && config.condition === NumberCondition.IS_BETWEEN) {
|
|
49
39
|
return "".concat(config.start, " < ").concat(config.column.name, " < ").concat(config.end);
|
|
50
40
|
}
|
|
51
|
-
|
|
52
41
|
return "".concat(config.column.name, " ").concat(getShortLabelForConditionType(config.column.type, config.condition), " \n ").concat(getRuleValue(config));
|
|
53
42
|
}
|
|
54
|
-
|
|
55
|
-
var ConditionalFormattingMenu = props => {
|
|
43
|
+
function ConditionalFormattingMenu(props) {
|
|
56
44
|
var {
|
|
57
45
|
rules = [],
|
|
58
46
|
onChange = DEFAULT_CALLBACK,
|
|
@@ -75,12 +63,12 @@ var ConditionalFormattingMenu = props => {
|
|
|
75
63
|
e.stopPropagation();
|
|
76
64
|
}, []);
|
|
77
65
|
var handleDragEnd = useCallback(result => {
|
|
78
|
-
DragUtils.stopDragging();
|
|
66
|
+
DragUtils.stopDragging();
|
|
79
67
|
|
|
68
|
+
// if dropped outside the list
|
|
80
69
|
if (result.destination == null) {
|
|
81
70
|
return;
|
|
82
71
|
}
|
|
83
|
-
|
|
84
72
|
var sourceIndex = result.source.index;
|
|
85
73
|
var destinationIndex = result.destination.index;
|
|
86
74
|
var updatedRules = [...rules];
|
|
@@ -88,8 +76,9 @@ var ConditionalFormattingMenu = props => {
|
|
|
88
76
|
updatedRules.splice(sourceIndex, 1);
|
|
89
77
|
updatedRules.splice(destinationIndex, 0, sourceInput);
|
|
90
78
|
onChange(updatedRules);
|
|
91
|
-
}, [onChange, rules]);
|
|
79
|
+
}, [onChange, rules]);
|
|
92
80
|
|
|
81
|
+
// Display list of rules
|
|
93
82
|
return /*#__PURE__*/React.createElement("div", {
|
|
94
83
|
className: "conditional-formatting-rules"
|
|
95
84
|
}, /*#__PURE__*/React.createElement(DragDropContext, {
|
|
@@ -98,21 +87,23 @@ var ConditionalFormattingMenu = props => {
|
|
|
98
87
|
}, /*#__PURE__*/React.createElement(Droppable, {
|
|
99
88
|
droppableId: "droppable-custom-columns"
|
|
100
89
|
}, (provided, snapshot) => /*#__PURE__*/React.createElement("div", _extends({
|
|
101
|
-
ref: provided.innerRef
|
|
102
|
-
|
|
90
|
+
ref: provided.innerRef
|
|
91
|
+
// eslint-disable-next-line react/jsx-props-no-spreading
|
|
103
92
|
}, provided.droppableProps, {
|
|
104
93
|
className: classNames('droppable-container', {
|
|
105
94
|
dragging: snapshot.draggingFromThisWith
|
|
106
95
|
})
|
|
107
96
|
}), rules.length === 0 && /*#__PURE__*/React.createElement("div", {
|
|
108
97
|
className: "text-muted pl-2"
|
|
109
|
-
}, "No formats defined"), rules.map((rule, index) => /*#__PURE__*/React.createElement(Draggable
|
|
98
|
+
}, "No formats defined"), rules.map((rule, index) => /*#__PURE__*/React.createElement(Draggable
|
|
99
|
+
// eslint-disable-next-line react/no-array-index-key
|
|
110
100
|
, {
|
|
111
101
|
key: "".concat(index, "-").concat(rule.type),
|
|
112
102
|
draggableId: "".concat(index, "-").concat(rule.type),
|
|
113
103
|
index: index,
|
|
114
104
|
disableInteractiveElementBlocking: true
|
|
115
|
-
},
|
|
105
|
+
},
|
|
106
|
+
// eslint-disable-next-line @typescript-eslint/no-shadow
|
|
116
107
|
(provided, snapshot) => /*#__PURE__*/React.createElement("div", _extends({
|
|
117
108
|
role: "menuitem",
|
|
118
109
|
tabIndex: 0,
|
|
@@ -120,8 +111,8 @@ var ConditionalFormattingMenu = props => {
|
|
|
120
111
|
className: classNames('draggable-container', {
|
|
121
112
|
dragging: snapshot.isDragging
|
|
122
113
|
}),
|
|
123
|
-
ref: provided.innerRef
|
|
124
|
-
|
|
114
|
+
ref: provided.innerRef
|
|
115
|
+
// eslint-disable-next-line react/jsx-props-no-spreading
|
|
125
116
|
}, provided.draggableProps), /*#__PURE__*/React.createElement("div", {
|
|
126
117
|
className: "conditional-formatting-list-item"
|
|
127
118
|
}, /*#__PURE__*/React.createElement("div", {
|
|
@@ -145,8 +136,8 @@ var ConditionalFormattingMenu = props => {
|
|
|
145
136
|
}), /*#__PURE__*/React.createElement("button", _extends({
|
|
146
137
|
type: "button",
|
|
147
138
|
className: "btn btn-link btn-link-icon px-2 btn-drag-handle",
|
|
148
|
-
onClick: handleDragHandlerClick
|
|
149
|
-
|
|
139
|
+
onClick: handleDragHandlerClick
|
|
140
|
+
// eslint-disable-next-line react/jsx-props-no-spreading
|
|
150
141
|
}, provided.dragHandleProps), /*#__PURE__*/React.createElement(Tooltip, null, "Drag to re-order"), /*#__PURE__*/React.createElement(FontAwesomeIcon, {
|
|
151
142
|
icon: vsGripper
|
|
152
143
|
}))))))), provided.placeholder))), /*#__PURE__*/React.createElement("hr", null), /*#__PURE__*/React.createElement(Button, {
|
|
@@ -154,7 +145,6 @@ var ConditionalFormattingMenu = props => {
|
|
|
154
145
|
onClick: onCreate,
|
|
155
146
|
icon: dhNewCircleLargeFilled
|
|
156
147
|
}, "Add New Rule"));
|
|
157
|
-
}
|
|
158
|
-
|
|
148
|
+
}
|
|
159
149
|
export default ConditionalFormattingMenu;
|
|
160
150
|
//# sourceMappingURL=ConditionalFormattingMenu.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ConditionalFormattingMenu.js","names":["React","useCallback","DragDropContext","Draggable","Droppable","classNames","FontAwesomeIcon","dhNewCircleLargeFilled","vsGripper","vsTrash","Button","DragUtils","Tooltip","TableUtils","Log","FormatterType","getBackgroundForStyleConfig","getColorForStyleConfig","getShortLabelForConditionType","NumberCondition","StringCondition","DateCondition","log","module","DEFAULT_CALLBACK","undefined","getRuleValue","config","column","type","isNumberType","condition","IS_NULL","IS_NOT_NULL","value","isCharType","isStringType","isDateType","isBooleanType","Error","getRuleTitle","IS_BETWEEN","start","name","end","ConditionalFormattingMenu","props","rules","onChange","onCreate","onSelect","handleRuleClick","e","rule","index","stopPropagation","debug","handleDeleteClick","updatedRules","splice","handleDragHandlerClick","handleDragEnd","result","stopDragging","destination","sourceIndex","source","destinationIndex","sourceInput","startDragging","provided","snapshot","innerRef","droppableProps","dragging","draggingFromThisWith","length","map","isDragging","draggableProps","backgroundColor","style","color","ROWS","dragHandleProps","placeholder"],"sources":["../../../src/sidebar/conditional-formatting/ConditionalFormattingMenu.tsx"],"sourcesContent":["import React, { useCallback } from 'react';\nimport {\n DragDropContext,\n Draggable,\n Droppable,\n DropResult,\n} from 'react-beautiful-dnd';\nimport classNames from 'classnames';\nimport { FontAwesomeIcon } from '@fortawesome/react-fontawesome';\nimport { dhNewCircleLargeFilled, vsGripper, vsTrash } from '@deephaven/icons';\nimport { Button, DragUtils, Tooltip } from '@deephaven/components';\nimport { TableUtils } from '@deephaven/jsapi-utils';\nimport Log from '@deephaven/log';\nimport './ConditionalFormattingMenu.scss';\nimport {\n BaseFormatConfig,\n FormattingRule,\n FormatterType,\n getBackgroundForStyleConfig,\n getColorForStyleConfig,\n getShortLabelForConditionType,\n NumberCondition,\n StringCondition,\n DateCondition,\n} from './ConditionalFormattingUtils';\nimport { ColumnName } from '../../CommonTypes';\n\nconst log = Log.module('ConditionalFormattingMenu');\n\nexport type ChangeCallback = (rules: FormattingRule[]) => void;\n\nexport type SelectCallback = (index: number) => void;\n\nexport type CreateCallback = () => void;\n\nexport type ConditionalFormattingMenuProps = {\n rules: FormattingRule[];\n selectedColumn?: ColumnName;\n onChange?: ChangeCallback;\n onCreate?: CreateCallback;\n onSelect?: SelectCallback;\n};\n\nconst DEFAULT_CALLBACK = () => undefined;\n\nfunction getRuleValue(config: BaseFormatConfig): string {\n const {\n column: { type },\n } = config;\n if (TableUtils.isNumberType(type)) {\n return config.condition === NumberCondition.IS_NULL ||\n config.condition === NumberCondition.IS_NOT_NULL\n ? ''\n : `${config.value}`;\n }\n if (TableUtils.isCharType(type)) {\n return config.condition === DateCondition.IS_NULL ||\n config.condition === DateCondition.IS_NOT_NULL\n ? ''\n : `${config.value}`;\n }\n if (TableUtils.isStringType(type)) {\n return config.condition === StringCondition.IS_NULL ||\n config.condition === StringCondition.IS_NOT_NULL\n ? ''\n : `\"${config.value}\"`;\n }\n if (TableUtils.isDateType(type)) {\n return config.condition === DateCondition.IS_NULL ||\n config.condition === DateCondition.IS_NOT_NULL\n ? ''\n : `${config.value}`;\n }\n if (TableUtils.isBooleanType(type)) {\n return '';\n }\n throw new Error(`Invalid column type ${type} in getRuleValue`);\n}\n\nfunction getRuleTitle(config: BaseFormatConfig): string {\n if (\n TableUtils.isNumberType(config.column.type) &&\n config.condition === NumberCondition.IS_BETWEEN\n ) {\n return `${config.start} < ${config.column.name} < ${config.end}`;\n }\n return `${config.column.name} ${getShortLabelForConditionType(\n (config as BaseFormatConfig).column.type,\n (config as BaseFormatConfig).condition\n )} \n ${getRuleValue(config as BaseFormatConfig)}`;\n}\n\nconst ConditionalFormattingMenu = (\n props: ConditionalFormattingMenuProps\n): JSX.Element => {\n const {\n rules = [],\n onChange = DEFAULT_CALLBACK,\n onCreate = DEFAULT_CALLBACK,\n onSelect = DEFAULT_CALLBACK,\n } = props;\n\n const handleRuleClick = useCallback(\n (e, rule, index) => {\n e.stopPropagation();\n log.debug('Rule clicked', rule, index);\n onSelect(index);\n },\n [onSelect]\n );\n\n const handleDeleteClick = useCallback(\n (e, rule, index) => {\n e.stopPropagation();\n log.debug('Delete button clicked', rule, index);\n const updatedRules = [...rules];\n updatedRules.splice(index, 1);\n onChange(updatedRules);\n },\n [onChange, rules]\n );\n\n const handleDragHandlerClick = useCallback(e => {\n e.stopPropagation();\n }, []);\n\n const handleDragEnd = useCallback(\n (result: DropResult) => {\n DragUtils.stopDragging();\n\n // if dropped outside the list\n if (result.destination == null) {\n return;\n }\n const sourceIndex = result.source.index;\n const destinationIndex = result.destination.index;\n const updatedRules = [...rules];\n const sourceInput = rules[sourceIndex];\n\n updatedRules.splice(sourceIndex, 1);\n updatedRules.splice(destinationIndex, 0, sourceInput);\n\n onChange(updatedRules);\n },\n [onChange, rules]\n );\n\n // Display list of rules\n return (\n <div className=\"conditional-formatting-rules\">\n <DragDropContext\n onDragStart={DragUtils.startDragging}\n onDragEnd={handleDragEnd}\n >\n <Droppable droppableId=\"droppable-custom-columns\">\n {(provided, snapshot) => (\n <div\n ref={provided.innerRef}\n // eslint-disable-next-line react/jsx-props-no-spreading\n {...provided.droppableProps}\n className={classNames('droppable-container', {\n dragging: snapshot.draggingFromThisWith,\n })}\n >\n {rules.length === 0 && (\n <div className=\"text-muted pl-2\">No formats defined</div>\n )}\n {rules.map((rule, index) => (\n <Draggable\n // eslint-disable-next-line react/no-array-index-key\n key={`${index}-${rule.type}`}\n draggableId={`${index}-${rule.type}`}\n index={index}\n disableInteractiveElementBlocking\n >\n {\n // eslint-disable-next-line @typescript-eslint/no-shadow\n (provided, snapshot) => (\n <div\n role=\"menuitem\"\n tabIndex={0}\n onClick={e => handleRuleClick(e, rule, index)}\n className={classNames('draggable-container', {\n dragging: snapshot.isDragging,\n })}\n ref={provided.innerRef}\n // eslint-disable-next-line react/jsx-props-no-spreading\n {...provided.draggableProps}\n >\n <div className=\"conditional-formatting-list-item\">\n <div className=\"formatting-item\">\n <div className=\"rule-icon\">\n <span\n className=\"rule-icon-bg\"\n style={{\n backgroundColor: getBackgroundForStyleConfig(\n (rule.config as BaseFormatConfig).style\n ),\n color: getColorForStyleConfig(\n (rule.config as BaseFormatConfig).style\n ),\n }}\n >\n {rule.type === FormatterType.ROWS\n ? 'row'\n : 'col'}\n </span>\n </div>\n <div className=\"rule-title\">\n {getRuleTitle(rule.config as BaseFormatConfig)}\n </div>\n <Button\n kind=\"ghost\"\n className=\"ml-1 px-2\"\n onClick={e => handleDeleteClick(e, rule, index)}\n icon={vsTrash}\n tooltip=\"Delete rule\"\n />\n <button\n type=\"button\"\n className=\"btn btn-link btn-link-icon px-2 btn-drag-handle\"\n onClick={handleDragHandlerClick}\n // eslint-disable-next-line react/jsx-props-no-spreading\n {...provided.dragHandleProps}\n >\n <Tooltip>Drag to re-order</Tooltip>\n <FontAwesomeIcon icon={vsGripper} />\n </button>\n </div>\n </div>\n </div>\n )\n }\n </Draggable>\n ))}\n {provided.placeholder}\n </div>\n )}\n </Droppable>\n </DragDropContext>\n <hr />\n <Button kind=\"ghost\" onClick={onCreate} icon={dhNewCircleLargeFilled}>\n Add New Rule\n </Button>\n </div>\n );\n};\n\nexport default ConditionalFormattingMenu;\n"],"mappings":";;AAAA,OAAOA,KAAP,IAAgBC,WAAhB,QAAmC,OAAnC;AACA,SACEC,eADF,EAEEC,SAFF,EAGEC,SAHF,QAKO,qBALP;AAMA,OAAOC,UAAP,MAAuB,YAAvB;AACA,SAASC,eAAT,QAAgC,gCAAhC;AACA,SAASC,sBAAT,EAAiCC,SAAjC,EAA4CC,OAA5C,QAA2D,kBAA3D;AACA,SAASC,MAAT,EAAiBC,SAAjB,EAA4BC,OAA5B,QAA2C,uBAA3C;AACA,SAASC,UAAT,QAA2B,wBAA3B;AACA,OAAOC,GAAP,MAAgB,gBAAhB;;SAKEC,a,EACAC,2B,EACAC,sB,EACAC,6B,EACAC,e,EACAC,e,EACAC,a;AAIF,IAAMC,GAAG,GAAGR,GAAG,CAACS,MAAJ,CAAW,2BAAX,CAAZ;;AAgBA,IAAMC,gBAAgB,GAAG,MAAMC,SAA/B;;AAEA,SAASC,YAAT,CAAsBC,MAAtB,EAAwD;EACtD,IAAM;IACJC,MAAM,EAAE;MAAEC;IAAF;EADJ,IAEFF,MAFJ;;EAGA,IAAId,UAAU,CAACiB,YAAX,CAAwBD,IAAxB,CAAJ,EAAmC;IACjC,OAAOF,MAAM,CAACI,SAAP,KAAqBZ,eAAe,CAACa,OAArC,IACLL,MAAM,CAACI,SAAP,KAAqBZ,eAAe,CAACc,WADhC,GAEH,EAFG,aAGAN,MAAM,CAACO,KAHP,CAAP;EAID;;EACD,IAAIrB,UAAU,CAACsB,UAAX,CAAsBN,IAAt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,QAA9B;IAAwC,IAAI,EAAE1C;EAA9C,kBA5FF,CADF;AAkGD,CA1JD;;AA4JA,eAAesC,yBAAf"}
|
|
1
|
+
{"version":3,"file":"ConditionalFormattingMenu.js","names":["React","useCallback","DragDropContext","Draggable","Droppable","classNames","FontAwesomeIcon","dhNewCircleLargeFilled","vsGripper","vsTrash","Button","DragUtils","Tooltip","TableUtils","Log","FormatterType","getBackgroundForStyleConfig","getColorForStyleConfig","getShortLabelForConditionType","NumberCondition","StringCondition","DateCondition","log","module","DEFAULT_CALLBACK","undefined","getRuleValue","config","column","type","isNumberType","condition","IS_NULL","IS_NOT_NULL","value","isCharType","isStringType","isDateType","isBooleanType","Error","getRuleTitle","IS_BETWEEN","start","name","end","ConditionalFormattingMenu","props","rules","onChange","onCreate","onSelect","handleRuleClick","e","rule","index","stopPropagation","debug","handleDeleteClick","updatedRules","splice","handleDragHandlerClick","handleDragEnd","result","stopDragging","destination","sourceIndex","source","destinationIndex","sourceInput","startDragging","provided","snapshot","innerRef","droppableProps","dragging","draggingFromThisWith","length","map","isDragging","draggableProps","backgroundColor","style","color","ROWS","dragHandleProps","placeholder"],"sources":["../../../src/sidebar/conditional-formatting/ConditionalFormattingMenu.tsx"],"sourcesContent":["import React, { useCallback } from 'react';\nimport {\n DragDropContext,\n Draggable,\n Droppable,\n DropResult,\n} from 'react-beautiful-dnd';\nimport classNames from 'classnames';\nimport { FontAwesomeIcon } from '@fortawesome/react-fontawesome';\nimport { dhNewCircleLargeFilled, vsGripper, vsTrash } from '@deephaven/icons';\nimport { Button, DragUtils, Tooltip } from '@deephaven/components';\nimport { TableUtils } from '@deephaven/jsapi-utils';\nimport Log from '@deephaven/log';\nimport './ConditionalFormattingMenu.scss';\nimport {\n BaseFormatConfig,\n FormattingRule,\n FormatterType,\n getBackgroundForStyleConfig,\n getColorForStyleConfig,\n getShortLabelForConditionType,\n NumberCondition,\n StringCondition,\n DateCondition,\n} from './ConditionalFormattingUtils';\nimport { ColumnName } from '../../CommonTypes';\n\nconst log = Log.module('ConditionalFormattingMenu');\n\nexport type ChangeCallback = (rules: FormattingRule[]) => void;\n\nexport type SelectCallback = (index: number) => void;\n\nexport type CreateCallback = () => void;\n\nexport type ConditionalFormattingMenuProps = {\n rules: FormattingRule[];\n selectedColumn?: ColumnName;\n onChange?: ChangeCallback;\n onCreate?: CreateCallback;\n onSelect?: SelectCallback;\n};\n\nconst DEFAULT_CALLBACK = () => undefined;\n\nfunction getRuleValue(config: BaseFormatConfig): string {\n const {\n column: { type },\n } = config;\n if (TableUtils.isNumberType(type)) {\n return config.condition === NumberCondition.IS_NULL ||\n config.condition === NumberCondition.IS_NOT_NULL\n ? ''\n : `${config.value}`;\n }\n if (TableUtils.isCharType(type)) {\n return config.condition === DateCondition.IS_NULL ||\n config.condition === DateCondition.IS_NOT_NULL\n ? ''\n : `${config.value}`;\n }\n if (TableUtils.isStringType(type)) {\n return config.condition === StringCondition.IS_NULL ||\n config.condition === StringCondition.IS_NOT_NULL\n ? ''\n : `\"${config.value}\"`;\n }\n if (TableUtils.isDateType(type)) {\n return config.condition === DateCondition.IS_NULL ||\n config.condition === DateCondition.IS_NOT_NULL\n ? ''\n : `${config.value}`;\n }\n if (TableUtils.isBooleanType(type)) {\n return '';\n }\n throw new Error(`Invalid column type ${type} in getRuleValue`);\n}\n\nfunction getRuleTitle(config: BaseFormatConfig): string {\n if (\n TableUtils.isNumberType(config.column.type) &&\n config.condition === NumberCondition.IS_BETWEEN\n ) {\n return `${config.start} < ${config.column.name} < ${config.end}`;\n }\n return `${config.column.name} ${getShortLabelForConditionType(\n (config as BaseFormatConfig).column.type,\n (config as BaseFormatConfig).condition\n )} \n ${getRuleValue(config as BaseFormatConfig)}`;\n}\n\nfunction ConditionalFormattingMenu(\n props: ConditionalFormattingMenuProps\n): JSX.Element {\n const {\n rules = [],\n onChange = DEFAULT_CALLBACK,\n onCreate = DEFAULT_CALLBACK,\n onSelect = DEFAULT_CALLBACK,\n } = props;\n\n const handleRuleClick = useCallback(\n (e, rule, index) => {\n e.stopPropagation();\n log.debug('Rule clicked', rule, index);\n onSelect(index);\n },\n [onSelect]\n );\n\n const handleDeleteClick = useCallback(\n (e, rule, index) => {\n e.stopPropagation();\n log.debug('Delete button clicked', rule, index);\n const updatedRules = [...rules];\n updatedRules.splice(index, 1);\n onChange(updatedRules);\n },\n [onChange, rules]\n );\n\n const handleDragHandlerClick = useCallback(e => {\n e.stopPropagation();\n }, []);\n\n const handleDragEnd = useCallback(\n (result: DropResult) => {\n DragUtils.stopDragging();\n\n // if dropped outside the list\n if (result.destination == null) {\n return;\n }\n const sourceIndex = result.source.index;\n const destinationIndex = result.destination.index;\n const updatedRules = [...rules];\n const sourceInput = rules[sourceIndex];\n\n updatedRules.splice(sourceIndex, 1);\n updatedRules.splice(destinationIndex, 0, sourceInput);\n\n onChange(updatedRules);\n },\n [onChange, rules]\n );\n\n // Display list of rules\n return (\n <div className=\"conditional-formatting-rules\">\n <DragDropContext\n onDragStart={DragUtils.startDragging}\n onDragEnd={handleDragEnd}\n >\n <Droppable droppableId=\"droppable-custom-columns\">\n {(provided, snapshot) => (\n <div\n ref={provided.innerRef}\n // eslint-disable-next-line react/jsx-props-no-spreading\n {...provided.droppableProps}\n className={classNames('droppable-container', {\n dragging: snapshot.draggingFromThisWith,\n })}\n >\n {rules.length === 0 && (\n <div className=\"text-muted pl-2\">No formats defined</div>\n )}\n {rules.map((rule, index) => (\n <Draggable\n // eslint-disable-next-line react/no-array-index-key\n key={`${index}-${rule.type}`}\n draggableId={`${index}-${rule.type}`}\n index={index}\n disableInteractiveElementBlocking\n >\n {\n // eslint-disable-next-line @typescript-eslint/no-shadow\n (provided, snapshot) => (\n <div\n role=\"menuitem\"\n tabIndex={0}\n onClick={e => handleRuleClick(e, rule, index)}\n className={classNames('draggable-container', {\n dragging: snapshot.isDragging,\n })}\n ref={provided.innerRef}\n // eslint-disable-next-line react/jsx-props-no-spreading\n {...provided.draggableProps}\n >\n <div className=\"conditional-formatting-list-item\">\n <div className=\"formatting-item\">\n <div className=\"rule-icon\">\n <span\n className=\"rule-icon-bg\"\n style={{\n backgroundColor: getBackgroundForStyleConfig(\n (rule.config as BaseFormatConfig).style\n ),\n color: getColorForStyleConfig(\n (rule.config as BaseFormatConfig).style\n ),\n }}\n >\n {rule.type === FormatterType.ROWS\n ? 'row'\n : 'col'}\n </span>\n </div>\n <div className=\"rule-title\">\n {getRuleTitle(rule.config as BaseFormatConfig)}\n </div>\n <Button\n kind=\"ghost\"\n className=\"ml-1 px-2\"\n onClick={e => handleDeleteClick(e, rule, index)}\n icon={vsTrash}\n tooltip=\"Delete rule\"\n />\n <button\n type=\"button\"\n className=\"btn btn-link btn-link-icon px-2 btn-drag-handle\"\n onClick={handleDragHandlerClick}\n // eslint-disable-next-line react/jsx-props-no-spreading\n {...provided.dragHandleProps}\n >\n <Tooltip>Drag to re-order</Tooltip>\n <FontAwesomeIcon icon={vsGripper} />\n </button>\n </div>\n </div>\n </div>\n )\n }\n </Draggable>\n ))}\n {provided.placeholder}\n </div>\n )}\n </Droppable>\n </DragDropContext>\n <hr />\n <Button kind=\"ghost\" onClick={onCreate} icon={dhNewCircleLargeFilled}>\n Add New Rule\n </Button>\n </div>\n );\n}\n\nexport default ConditionalFormattingMenu;\n"],"mappings":";AAAA,OAAOA,KAAK,IAAIC,WAAW,QAAQ,OAAO;AAC1C,SACEC,eAAe,EACfC,SAAS,EACTC,SAAS,QAEJ,qBAAqB;AAC5B,OAAOC,UAAU,MAAM,YAAY;AACnC,SAASC,eAAe,QAAQ,gCAAgC;AAChE,SAASC,sBAAsB,EAAEC,SAAS,EAAEC,OAAO,QAAQ,kBAAkB;AAC7E,SAASC,MAAM,EAAEC,SAAS,EAAEC,OAAO,QAAQ,uBAAuB;AAClE,SAASC,UAAU,QAAQ,wBAAwB;AACnD,OAAOC,GAAG,MAAM,gBAAgB;AAAC;AAAA,SAK/BC,aAAa,EACbC,2BAA2B,EAC3BC,sBAAsB,EACtBC,6BAA6B,EAC7B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