@adaptabletools/adaptable-cjs 18.0.12 → 18.1.0-canary.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.
- package/agGrid.d.ts +4 -3
- package/agGrid.js +6 -1
- package/base.css +7 -2
- package/base.css.map +1 -1
- package/index.css +11 -2
- package/index.css.map +1 -1
- package/package.json +2 -2
- package/src/AdaptableOptions/ActionColumnOptions.d.ts +1 -1
- package/src/AdaptableOptions/ColumnFilterOptions.d.ts +27 -1
- package/src/AdaptableOptions/ExportOptions.d.ts +20 -7
- package/src/AdaptableOptions/ExpressionOptions.d.ts +12 -2
- package/src/AdaptableOptions/Fdc3Options.d.ts +48 -43
- package/src/Api/ColumnApi.d.ts +1 -1
- package/src/Api/Events/Fdc3MessageInfo.d.ts +5 -7
- package/src/Api/ExpressionApi.d.ts +2 -2
- package/src/Api/Fdc3Api.d.ts +14 -19
- package/src/Api/Implementation/ConfigApiImpl.js +3 -0
- package/src/Api/Implementation/Fdc3ApiImpl.d.ts +14 -16
- package/src/Api/Implementation/Fdc3ApiImpl.js +35 -11
- package/src/Api/Internal/AlertInternalApi.d.ts +17 -2
- package/src/Api/Internal/AlertInternalApi.js +196 -25
- package/src/Api/Internal/ColumnFilterInternalApi.d.ts +2 -0
- package/src/Api/Internal/ColumnFilterInternalApi.js +20 -0
- package/src/Api/Internal/ExportInternalApi.d.ts +3 -3
- package/src/Api/Internal/ExportInternalApi.js +31 -17
- package/src/Api/Internal/ExpressionInternalApi.d.ts +5 -1
- package/src/Api/Internal/ExpressionInternalApi.js +80 -0
- package/src/Api/Internal/Fdc3InternalApi.d.ts +8 -10
- package/src/Api/Internal/Fdc3InternalApi.js +5 -9
- package/src/PredefinedConfig/Common/AdaptableField.d.ts +18 -0
- package/src/PredefinedConfig/Common/AdaptableField.js +2 -0
- package/src/PredefinedConfig/Common/AdaptableIcon.d.ts +1 -1
- package/src/PredefinedConfig/Common/AdaptablePredicate.js +18 -1
- package/src/PredefinedConfig/Common/Fdc3Context.d.ts +7 -226
- package/src/PredefinedConfig/Common/Fdc3Context.js +44 -32
- package/src/PredefinedConfig/Common/Fdc3Intent.d.ts +6 -89
- package/src/PredefinedConfig/Common/Fdc3Intent.js +27 -74
- package/src/PredefinedConfig/Common/RowSummary.d.ts +2 -1
- package/src/PredefinedConfig/StyledColumnState.d.ts +1 -1
- package/src/Redux/ActionsReducers/FormatColumnRedux.js +0 -3
- package/src/Strategy/AdaptableModuleBase.js +1 -3
- package/src/Strategy/AlertModule.d.ts +1 -1
- package/src/Strategy/AlertModule.js +8 -8
- package/src/Utilities/ExpressionFunctions/aggregatedScalarExpressionFunctions.d.ts +3 -1
- package/src/Utilities/ExpressionFunctions/aggregatedScalarExpressionFunctions.js +14 -13
- package/src/Utilities/Services/Fdc3Service.d.ts +1 -1
- package/src/Utilities/Services/QueryLanguageService.d.ts +8 -4
- package/src/Utilities/Services/QueryLanguageService.js +105 -6
- package/src/Utilities/Services/ReportService.js +8 -5
- package/src/Utilities/Services/RowSummaryService.js +3 -1
- package/src/Utilities/divideBy100.d.ts +1 -0
- package/src/Utilities/divideBy100.js +34 -0
- package/src/Utilities/times100.d.ts +1 -0
- package/src/Utilities/times100.js +27 -0
- package/src/View/Alert/Wizard/AlertMessageWizardSection.js +1 -1
- package/src/View/Alert/Wizard/AlertNotificationWizardSection.js +2 -2
- package/src/View/Alert/Wizard/AlertScopeWizardSection.js +2 -1
- package/src/View/CalculatedColumn/Wizard/CalculatedColumnExpressionWizardSection.js +1 -1
- package/src/View/Components/EntityRulesEditor/index.d.ts +1 -0
- package/src/View/Components/EntityRulesEditor/index.js +11 -7
- package/src/View/Components/ExpressionWizard.js +1 -1
- package/src/View/Components/FilterForm/QuickFilterValues.js +28 -4
- package/src/View/Components/Popups/AdaptablePopup/AdaptablePopupModuleView.js +6 -2
- package/src/View/Components/Selectors/FieldSelector.d.ts +13 -0
- package/src/View/Components/Selectors/FieldSelector.js +26 -0
- package/src/View/Components/Selectors/PermittedValuesSelector.js +8 -4
- package/src/View/Export/Wizard/ReportRowsWizardSection.js +1 -1
- package/src/View/FormatColumn/Wizard/FormatColumnRuleWizardSection.js +1 -1
- package/src/View/GridFilter/GridFilterExpressionEditor.js +1 -1
- package/src/View/Layout/Wizard/sections/GridFilterSection.js +4 -2
- package/src/View/Layout/Wizard/sections/RowSummarySection.js +7 -1
- package/src/View/NamedQuery/Wizard/NamedQueryExpressionWizardSection.js +1 -1
- package/src/View/Wizard/OnePageAdaptableWizard.js +3 -2
- package/src/agGrid/AdaptableAgGrid.d.ts +1 -2
- package/src/agGrid/AdaptableAgGrid.js +63 -32
- package/src/agGrid/AgGridColumnAdapter.d.ts +3 -0
- package/src/agGrid/AgGridColumnAdapter.js +24 -1
- package/src/agGrid/AgGridMenuAdapter.js +1 -1
- package/src/agGrid/editors/AdaptableDateEditor/InternalAdaptableDateEditor.d.ts +0 -1
- package/src/agGrid/editors/AdaptableDateEditor/InternalAdaptableDateEditor.js +0 -2
- package/src/agGrid/editors/AdaptableDateEditor/index.d.ts +4 -16
- package/src/agGrid/editors/AdaptableDateEditor/index.js +6 -19
- package/src/agGrid/editors/AdaptableNumberEditor/InternalAdaptableNumberEditor.js +6 -1
- package/src/agGrid/editors/AdaptableNumberEditor/index.d.ts +4 -3
- package/src/agGrid/editors/AdaptableNumberEditor/index.js +6 -2
- package/src/agGrid/editors/AdaptablePercentageEditor/InternalAdaptablePercentageEditor.d.ts +23 -0
- package/src/agGrid/editors/AdaptablePercentageEditor/InternalAdaptablePercentageEditor.js +84 -0
- package/src/agGrid/editors/AdaptablePercentageEditor/index.d.ts +47 -0
- package/src/agGrid/editors/AdaptablePercentageEditor/index.js +153 -0
- package/src/components/Accordion.js +1 -1
- package/src/components/Datepicker/DatepickerContext.d.ts +0 -2
- package/src/components/Datepicker/index.js +3 -4
- package/src/components/ExpressionEditor/DataTableEditor.d.ts +17 -0
- package/src/components/ExpressionEditor/DataTableEditor.js +68 -0
- package/src/components/ExpressionEditor/EditorInput.js +21 -8
- package/src/components/ExpressionEditor/NamedQueryEditor.d.ts +5 -0
- package/src/components/ExpressionEditor/NamedQueryEditor.js +35 -0
- package/src/components/ExpressionEditor/QueryBuilder/QueryBuilder.d.ts +10 -0
- package/src/components/ExpressionEditor/QueryBuilder/QueryBuilder.js +7 -4
- package/src/components/ExpressionEditor/QueryBuilder/QueryBuilderInputs.d.ts +3 -2
- package/src/components/ExpressionEditor/QueryBuilder/QueryBuilderInputs.js +72 -14
- package/src/components/ExpressionEditor/QueryBuilder/QueryPredicateBuilder.js +27 -19
- package/src/components/ExpressionEditor/QueryBuilder/utils.d.ts +9 -1
- package/src/components/ExpressionEditor/QueryBuilder/utils.js +46 -4
- package/src/components/ExpressionEditor/index.d.ts +3 -1
- package/src/components/ExpressionEditor/index.js +67 -92
- package/src/components/Input/NumberInput.d.ts +2 -1
- package/src/components/Input/NumberInput.js +6 -5
- package/src/components/OverlayTrigger/index.js +10 -6
- package/src/components/icons/column-outline.d.ts +3 -0
- package/src/components/icons/column-outline.js +7 -0
- package/src/components/icons/index.js +5 -1
- package/src/components/icons/sync.d.ts +3 -0
- package/src/components/icons/sync.js +7 -0
- package/src/env.js +2 -2
- package/src/metamodel/adaptable.metamodel.d.ts +78 -200
- package/src/metamodel/adaptable.metamodel.js +1 -1
- package/src/parser/src/predicate/mapExpressionToQlPredicate.d.ts +1 -0
- package/src/parser/src/predicate/mapExpressionToQlPredicate.js +13 -3
- package/src/parser/src/predicate/mapQlPredicateToExpression.js +4 -1
- package/src/parser/src/types.d.ts +101 -1
- package/src/types.d.ts +9 -7
- package/tsconfig.cjs.tsbuildinfo +1 -1
|
@@ -32,6 +32,6 @@ const NamedQueryExpressionWizardSection = (props) => {
|
|
|
32
32
|
const initialData = (0, react_1.useMemo)(() => api.internalApi.getQueryPreviewData(), []);
|
|
33
33
|
return (React.createElement(ExpressionEditor_1.ExpressionEditor, { allowSaveNamedQuery: false, showQueryBuilder: true, type: 'boolean', module: moduleInfo.ModuleName, value: data.BooleanExpression, onChange: (BooleanExpression) => {
|
|
34
34
|
props.onChange(Object.assign(Object.assign({}, data), { BooleanExpression }));
|
|
35
|
-
}, initialData: initialData, columns: api.columnApi.getQueryableColumns(), namedQueries: api.namedQueryApi.getNamedQueries(), api: api }));
|
|
35
|
+
}, initialData: initialData, columns: api.columnApi.getQueryableColumns(), fields: api.expressionApi.internalApi.getAvailableFields(), namedQueries: api.namedQueryApi.getNamedQueries(), api: api }));
|
|
36
36
|
};
|
|
37
37
|
exports.NamedQueryExpressionWizardSection = NamedQueryExpressionWizardSection;
|
|
@@ -75,7 +75,8 @@ const OnePageAdaptableWizard = (props) => {
|
|
|
75
75
|
};
|
|
76
76
|
exports.OnePageAdaptableWizard = OnePageAdaptableWizard;
|
|
77
77
|
const OnePageWizardSummary = () => {
|
|
78
|
-
const {
|
|
78
|
+
const { sections, data, api } = useOnePageAdaptableWizardContext();
|
|
79
|
+
const { setCurrentSection } = (0, OnePageWizards_1.useOnePageWizardContext)();
|
|
79
80
|
const renderEdit = (index) => (React.createElement(SimpleButton_1.default, { px: 1, variant: "text", style: {
|
|
80
81
|
textDecoration: 'underline',
|
|
81
82
|
display: 'inline-block',
|
|
@@ -96,7 +97,7 @@ const OnePageWizardSummary = () => {
|
|
|
96
97
|
section.title,
|
|
97
98
|
" ",
|
|
98
99
|
renderEdit(index)),
|
|
99
|
-
React.createElement(Tabs_1.Tabs.Content, null, section.renderSummary(data))));
|
|
100
|
+
React.createElement(Tabs_1.Tabs.Content, null, section.renderSummary(data, api))));
|
|
100
101
|
})
|
|
101
102
|
.filter(Boolean)));
|
|
102
103
|
};
|
|
@@ -25,9 +25,8 @@ import { AgGridMenuAdapter } from './AgGridMenuAdapter';
|
|
|
25
25
|
import { AdaptableColumn, AdaptableTheme, ChartDefinition, ColumnSort, DataUpdateConfig, GridCell, Layout, ReportData, SelectedCellInfo, SelectedRowInfo } from '../types';
|
|
26
26
|
import { RenderReactRootFn } from '../renderReactRoot';
|
|
27
27
|
import { AgGridOptionsService } from './AgGridOptionsService';
|
|
28
|
-
import { AgGridColumnAdapter } from './AgGridColumnAdapter';
|
|
28
|
+
import { AdaptableVariant, AgGridColumnAdapter } from './AgGridColumnAdapter';
|
|
29
29
|
import { RowEditService } from '../Utilities/Services/RowEditService';
|
|
30
|
-
export type AdaptableVariant = 'vanilla' | 'react' | 'angular';
|
|
31
30
|
export type AdaptableLifecycleState = 'initial' | 'preprocessOptions' | 'initAdaptableState' | 'setupAgGrid' | 'initAgGrid' | 'available' | 'ready' | 'preDestroyed';
|
|
32
31
|
type RenderAgGridFrameworkComponentResult = false | GridApi;
|
|
33
32
|
interface AdaptableInitInternalConfig<TData = any> {
|
|
@@ -69,8 +69,6 @@ const Fdc3Module_1 = require("../Strategy/Fdc3Module");
|
|
|
69
69
|
const GridFilterModule_1 = require("../Strategy/GridFilterModule");
|
|
70
70
|
const NamedQueryModule_1 = require("../Strategy/NamedQueryModule");
|
|
71
71
|
const CommentModule_1 = require("../Strategy/CommentModule");
|
|
72
|
-
const AdaptableNumberEditor_1 = require("./editors/AdaptableNumberEditor");
|
|
73
|
-
const AdaptableDateEditor_1 = require("./editors/AdaptableDateEditor");
|
|
74
72
|
const Helper_1 = require("../Utilities/Helpers/Helper");
|
|
75
73
|
const uuid_1 = require("../components/utils/uuid");
|
|
76
74
|
const UIHelper_1 = tslib_1.__importDefault(require("../View/UIHelper"));
|
|
@@ -93,7 +91,7 @@ const RowEditService_1 = require("../Utilities/Services/RowEditService");
|
|
|
93
91
|
const weightedAverage_1 = require("./weightedAverage");
|
|
94
92
|
const sortWithOrder_1 = require("../Utilities/sortWithOrder");
|
|
95
93
|
const Enums_1 = require("../PredefinedConfig/Common/Enums");
|
|
96
|
-
const ObjectFactory_1 = tslib_1.
|
|
94
|
+
const ObjectFactory_1 = tslib_1.__importStar(require("../Utilities/ObjectFactory"));
|
|
97
95
|
const EnvVars_1 = require("../EnvVars");
|
|
98
96
|
const AdaptableUpgradeHelper_1 = require("../migration/AdaptableUpgradeHelper");
|
|
99
97
|
const Modal_1 = require("../components/Modal");
|
|
@@ -402,9 +400,16 @@ class AdaptableAgGrid {
|
|
|
402
400
|
}
|
|
403
401
|
this.lifecycleState = 'ready';
|
|
404
402
|
this.forPlugins((plugin) => plugin.onAdaptableReady(this, this.adaptableOptions));
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
|
|
403
|
+
setTimeout(() => {
|
|
404
|
+
// without the setTimeout, calling autoSizeAllColumns immediately in the onAdaptableReady
|
|
405
|
+
// does not work. (I prefer setTimeout to rAF, as raf is not running when you switch tabs)
|
|
406
|
+
//
|
|
407
|
+
// it also makes it possible to listen to CALCULATED_COLUMN_READY, DASHBOARD_READY, etc.
|
|
408
|
+
// in onAdaptableReady - without this those event listeners are not triggered
|
|
409
|
+
this.api.eventApi.emit('AdaptableReady', {
|
|
410
|
+
adaptableApi: this.api,
|
|
411
|
+
agGridApi: this.agGridAdapter.getAgGridApi(),
|
|
412
|
+
});
|
|
408
413
|
});
|
|
409
414
|
perfInitAdaptableAgGrid.end();
|
|
410
415
|
return Promise.resolve(this.api);
|
|
@@ -673,10 +678,15 @@ class AdaptableAgGrid {
|
|
|
673
678
|
const columnFilters = this.api.columnFilterApi.getActiveColumnFilters();
|
|
674
679
|
try {
|
|
675
680
|
if (columnFilters.length > 0) {
|
|
681
|
+
const isRowFiltrable = this.api.optionsApi.getColumnFilterOptions().isRowFilterable;
|
|
676
682
|
for (const columnFilter of columnFilters) {
|
|
677
683
|
const evaluateFilterOnClient = this.api.expressionApi.internalApi.evaluatePredicatesInAdaptableQL('ColumnFilter', columnFilter, [columnFilter.Predicate]);
|
|
678
684
|
if (evaluateFilterOnClient) {
|
|
679
685
|
// we then assess filters (if running locally)
|
|
686
|
+
if (typeof isRowFiltrable === 'function' &&
|
|
687
|
+
!isRowFiltrable(Object.assign(Object.assign({}, (0, ObjectFactory_1.createBaseContext)(this.api)), { rowNode: node, data: node.data }))) {
|
|
688
|
+
return true;
|
|
689
|
+
}
|
|
680
690
|
if (!this.api.columnFilterApi.internalApi.evaluateColumnFilter(columnFilter, node)) {
|
|
681
691
|
return false;
|
|
682
692
|
}
|
|
@@ -935,37 +945,46 @@ class AdaptableAgGrid {
|
|
|
935
945
|
*/
|
|
936
946
|
// this will have to go/be heavily extended with https://github.com/AdaptableTools/adaptable/issues/2230
|
|
937
947
|
this.agGridOptionsService.setGridOptionsProperty(gridOptions, 'columnTypes', (original_columnTypes) => {
|
|
938
|
-
var _a
|
|
948
|
+
var _a;
|
|
939
949
|
const providedColumnTypes = original_columnTypes || {};
|
|
940
950
|
const gridOptionsColumnTypes = gridOptions.columnTypes || {};
|
|
941
|
-
const patchedColumnTypes = Object.assign(providedColumnTypes, {
|
|
951
|
+
const patchedColumnTypes = Object.assign({}, providedColumnTypes, {
|
|
942
952
|
[GeneralConstants_1.AB_SPECIAL_COLUMN]: {},
|
|
943
953
|
[GeneralConstants_1.AB_FDC3_COLUMN]: {},
|
|
944
|
-
abColDefNumber: (
|
|
945
|
-
abColDefString: (
|
|
946
|
-
abColDefBoolean: (
|
|
947
|
-
abColDefDate: (
|
|
948
|
-
abColDefObject: (
|
|
949
|
-
abColDefCustom: (
|
|
950
|
-
abColDefStringArray: (
|
|
951
|
-
abColDefNumberArray: (
|
|
952
|
-
abColDefTupleNumberArray: (
|
|
953
|
-
abColDefObjectNumberArray: (
|
|
954
|
+
abColDefNumber: Object.assign({}, gridOptionsColumnTypes.abColDefNumber),
|
|
955
|
+
abColDefString: Object.assign({}, gridOptionsColumnTypes.abColDefString),
|
|
956
|
+
abColDefBoolean: Object.assign({}, gridOptionsColumnTypes.abColDefBoolean),
|
|
957
|
+
abColDefDate: Object.assign({}, gridOptionsColumnTypes.abColDefDate),
|
|
958
|
+
abColDefObject: Object.assign({}, gridOptionsColumnTypes.abColDefObject),
|
|
959
|
+
abColDefCustom: Object.assign({}, gridOptionsColumnTypes.abColDefCustom),
|
|
960
|
+
abColDefStringArray: Object.assign({}, gridOptionsColumnTypes.abColDefStringArray),
|
|
961
|
+
abColDefNumberArray: Object.assign({}, gridOptionsColumnTypes.abColDefNumberArray),
|
|
962
|
+
abColDefTupleNumberArray: Object.assign({}, gridOptionsColumnTypes.abColDefTupleNumberArray),
|
|
963
|
+
abColDefObjectNumberArray: Object.assign({}, gridOptionsColumnTypes.abColDefObjectNumberArray),
|
|
954
964
|
});
|
|
955
|
-
const customColumnTypes = (
|
|
965
|
+
const customColumnTypes = (_a = this.api.columnApi.getColumnTypes()) !== null && _a !== void 0 ? _a : [];
|
|
956
966
|
for (const customColumnType of customColumnTypes) {
|
|
957
967
|
if (!patchedColumnTypes[customColumnType]) {
|
|
958
968
|
patchedColumnTypes[customColumnType] = {};
|
|
959
969
|
}
|
|
960
970
|
}
|
|
961
|
-
|
|
962
|
-
|
|
963
|
-
|
|
964
|
-
|
|
965
|
-
|
|
966
|
-
|
|
967
|
-
|
|
968
|
-
|
|
971
|
+
const colTypesToEditors = (0, AgGridColumnAdapter_1.getEditorsForColumnTypes)(this.variant);
|
|
972
|
+
// we used to patch here the column types
|
|
973
|
+
// and have the editors for abColDefNumber and abColDefDate set here
|
|
974
|
+
// but AG Grid seems to have a bug where if we have a custom editor
|
|
975
|
+
// for a specific number column, it's applied to all abColDefNumber columns, because they
|
|
976
|
+
// share the same column type
|
|
977
|
+
// so we're now doing this logic in AgGridColumnAdaptapter.setupColumnCellEditor
|
|
978
|
+
// and instead, here we're just assigning the editor to null
|
|
979
|
+
// because if we don't assign to null, the default that AG Grid provides
|
|
980
|
+
// will be used instead, and we don't want that for those column types
|
|
981
|
+
Object.keys(colTypesToEditors).forEach((colType) => {
|
|
982
|
+
if (patchedColumnTypes[colType].cellEditor == undefined) {
|
|
983
|
+
patchedColumnTypes[colType].cellEditor = null; // colTypesToEditors[colType];
|
|
984
|
+
// if you dont believe me, just put colTypesToEditors[colType] in the line above instead of the null value
|
|
985
|
+
// and see the editing/percentage-editor.spec.ts test fail as it wont be using the correct editor
|
|
986
|
+
}
|
|
987
|
+
});
|
|
969
988
|
return patchedColumnTypes;
|
|
970
989
|
});
|
|
971
990
|
/**
|
|
@@ -2685,6 +2704,16 @@ class AdaptableAgGrid {
|
|
|
2685
2704
|
return 'ag-theme-balham';
|
|
2686
2705
|
}
|
|
2687
2706
|
applyAdaptableTheme(theme) {
|
|
2707
|
+
const container = this.getAgGridContainerElement();
|
|
2708
|
+
if (container != null) {
|
|
2709
|
+
container.classList.add('ab-Grid');
|
|
2710
|
+
if (this.adaptableOptions.columnFilterOptions.indicateFilteredColumns) {
|
|
2711
|
+
container.classList.add('ab-Grid--indicate-filtered-columns');
|
|
2712
|
+
}
|
|
2713
|
+
}
|
|
2714
|
+
if (this._isDetailGrid) {
|
|
2715
|
+
return;
|
|
2716
|
+
}
|
|
2688
2717
|
theme = this.ThemeService.mapOsTheme(theme);
|
|
2689
2718
|
const themeName = typeof theme === 'string' ? theme : theme.Name;
|
|
2690
2719
|
const isSystemTheme = this.api.themeApi.internalApi.isSystemTheme(themeName);
|
|
@@ -2739,7 +2768,6 @@ class AdaptableAgGrid {
|
|
|
2739
2768
|
el.classList.add(`infinite-${variantTheme}`);
|
|
2740
2769
|
}
|
|
2741
2770
|
// AG THEME CLASS NAME
|
|
2742
|
-
const container = this.getAgGridContainerElement();
|
|
2743
2771
|
const getAgGridLightThemeName = () => this.getAgGridLightThemeName();
|
|
2744
2772
|
const getAgGridDarkThemeName = () => getAgGridLightThemeName() + '-dark';
|
|
2745
2773
|
if (newTheme && (isSystemTheme || variantTheme)) {
|
|
@@ -2773,10 +2801,6 @@ class AdaptableAgGrid {
|
|
|
2773
2801
|
if (newTheme && newTheme.AgGridClassName) {
|
|
2774
2802
|
container.classList.add(newTheme.AgGridClassName);
|
|
2775
2803
|
}
|
|
2776
|
-
container.classList.add('ab-Grid');
|
|
2777
|
-
if (this.adaptableOptions.columnFilterOptions.indicateFilteredColumns) {
|
|
2778
|
-
container.classList.add('ab-Grid--indicate-filtered-columns');
|
|
2779
|
-
}
|
|
2780
2804
|
}
|
|
2781
2805
|
// MAC LIKE SCROLLBARS
|
|
2782
2806
|
if (this.adaptableOptions.userInterfaceOptions &&
|
|
@@ -3946,12 +3970,19 @@ class AdaptableAgGrid {
|
|
|
3946
3970
|
const gridOptionsService = agGridApi.gos;
|
|
3947
3971
|
const self = this;
|
|
3948
3972
|
gridOptionsService.updateGridOptions = function ({ options, force, source = 'api', }) {
|
|
3973
|
+
// `columnDefs`
|
|
3949
3974
|
const passedColumnDefs = options.columnDefs;
|
|
3950
3975
|
if (passedColumnDefs) {
|
|
3951
3976
|
const colDefsWithSpecialColumns = self.getColumnDefinitionsInclSpecialColumns(passedColumnDefs);
|
|
3952
3977
|
options['columnDefs'] = colDefsWithSpecialColumns;
|
|
3953
3978
|
self.logger.info(`Added SpecialColumns on GridOptions.columnDefs update (source=${source})`);
|
|
3954
3979
|
}
|
|
3980
|
+
// `context`
|
|
3981
|
+
const passedContext = options.context;
|
|
3982
|
+
if (passedContext) {
|
|
3983
|
+
passedContext['__adaptable'] = self;
|
|
3984
|
+
passedContext['adaptableApi'] = self.api;
|
|
3985
|
+
}
|
|
3955
3986
|
// we mutated the options array, so it's OK to use the 'arguments' object
|
|
3956
3987
|
GridOptionsService_updateGridOptions.apply(this, arguments);
|
|
3957
3988
|
};
|
|
@@ -1,10 +1,13 @@
|
|
|
1
1
|
import { AdaptableAgGrid } from './AdaptableAgGrid';
|
|
2
2
|
import { ColumnSetupInfo } from './ColumnSetupInfo';
|
|
3
3
|
import { ColDef, Column } from '@ag-grid-community/core';
|
|
4
|
+
export type AdaptableVariant = 'vanilla' | 'react' | 'angular';
|
|
5
|
+
export declare function getEditorsForColumnTypes(variant: AdaptableVariant): Record<string, ColDef['cellEditor']>;
|
|
4
6
|
export declare class AgGridColumnAdapter {
|
|
5
7
|
private adaptableInstance;
|
|
6
8
|
private colDefPropertyCache;
|
|
7
9
|
constructor(adaptableInstance: AdaptableAgGrid);
|
|
10
|
+
private getVariant;
|
|
8
11
|
destroy(): void;
|
|
9
12
|
private get adaptableApi();
|
|
10
13
|
private get adaptableOptions();
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.AgGridColumnAdapter = void 0;
|
|
3
|
+
exports.AgGridColumnAdapter = exports.getEditorsForColumnTypes = void 0;
|
|
4
4
|
const tslib_1 = require("tslib");
|
|
5
5
|
const core_1 = require("ag-grid-community");
|
|
6
6
|
const merge_1 = tslib_1.__importDefault(require("lodash/merge"));
|
|
@@ -14,11 +14,23 @@ const UIHelper_1 = tslib_1.__importDefault(require("../View/UIHelper"));
|
|
|
14
14
|
const PercentBarRenderer_1 = require("./PercentBarRenderer");
|
|
15
15
|
const BadgeRenderer_1 = require("./BadgeRenderer");
|
|
16
16
|
const Helper_1 = tslib_1.__importDefault(require("../Utilities/Helpers/Helper"));
|
|
17
|
+
const AdaptableNumberEditor_1 = require("./editors/AdaptableNumberEditor");
|
|
18
|
+
const AdaptableDateEditor_1 = require("./editors/AdaptableDateEditor");
|
|
19
|
+
function getEditorsForColumnTypes(variant) {
|
|
20
|
+
return {
|
|
21
|
+
abColDefNumber: variant === 'react' ? AdaptableNumberEditor_1.AdaptableReactNumberEditor : AdaptableNumberEditor_1.AdaptableNumberEditor,
|
|
22
|
+
abColDefDate: variant === 'react' ? AdaptableDateEditor_1.AdaptableReactDateEditor : AdaptableDateEditor_1.AdaptableDateEditor,
|
|
23
|
+
};
|
|
24
|
+
}
|
|
25
|
+
exports.getEditorsForColumnTypes = getEditorsForColumnTypes;
|
|
17
26
|
class AgGridColumnAdapter {
|
|
18
27
|
constructor(adaptableInstance) {
|
|
19
28
|
this.adaptableInstance = adaptableInstance;
|
|
20
29
|
this.colDefPropertyCache = new Map();
|
|
21
30
|
}
|
|
31
|
+
getVariant() {
|
|
32
|
+
return this.adaptableInstance.variant;
|
|
33
|
+
}
|
|
22
34
|
destroy() {
|
|
23
35
|
this.adaptableInstance = null;
|
|
24
36
|
this.colDefPropertyCache.clear();
|
|
@@ -183,6 +195,17 @@ class AgGridColumnAdapter {
|
|
|
183
195
|
if (editLookUpItem) {
|
|
184
196
|
return hasRichSelectCellEditor ? 'agRichSelectCellEditor' : 'agSelectCellEditor';
|
|
185
197
|
}
|
|
198
|
+
else {
|
|
199
|
+
const colDef = col.getColDef();
|
|
200
|
+
if (colDef.cellEditor) {
|
|
201
|
+
return colDef.cellEditor;
|
|
202
|
+
}
|
|
203
|
+
const columnTypeToCellEditor = getEditorsForColumnTypes(this.getVariant());
|
|
204
|
+
return (adaptableColumn.columnTypes || []).reduce((cellEditor, colType) => {
|
|
205
|
+
var _a;
|
|
206
|
+
return (_a = columnTypeToCellEditor[colType]) !== null && _a !== void 0 ? _a : cellEditor;
|
|
207
|
+
}, undefined);
|
|
208
|
+
}
|
|
186
209
|
});
|
|
187
210
|
this.setColDefProperty(col, 'cellEditorPopup', () => {
|
|
188
211
|
// as specified in https://www.ag-grid.com/react-data-grid/provided-cell-editors/#rich-select-cell-editor
|
|
@@ -8,6 +8,5 @@ export type InternalAdaptableDateEditorProps = {
|
|
|
8
8
|
dateFormat: string;
|
|
9
9
|
onValueChange?: (value: Date | null) => void;
|
|
10
10
|
onStopEdit?: (keyboardEventKey?: string) => void;
|
|
11
|
-
showClearButton?: boolean;
|
|
12
11
|
};
|
|
13
12
|
export declare const InternalAdaptableDateEditor: React.ForwardRefExoticComponent<InternalAdaptableDateEditorProps & React.RefAttributes<InternalAdaptableDateEditorApi>>;
|
|
@@ -26,7 +26,6 @@ const inputStyle = {
|
|
|
26
26
|
border: 'none',
|
|
27
27
|
};
|
|
28
28
|
exports.InternalAdaptableDateEditor = React.forwardRef((props, ref) => {
|
|
29
|
-
var _a;
|
|
30
29
|
const inputRef = React.useRef(null);
|
|
31
30
|
const focus = () => {
|
|
32
31
|
var _a;
|
|
@@ -60,7 +59,6 @@ exports.InternalAdaptableDateEditor = React.forwardRef((props, ref) => {
|
|
|
60
59
|
(_a = props.onStopEdit) === null || _a === void 0 ? void 0 : _a.call(props, keyboardEventKey);
|
|
61
60
|
},
|
|
62
61
|
onShow: () => { },
|
|
63
|
-
showClearButton: (_a = props.showClearButton) !== null && _a !== void 0 ? _a : true,
|
|
64
62
|
} },
|
|
65
63
|
React.createElement(AdaptableInput_1.default, { type: 'date', value: stringValue, onChange: onChange, style: inputStyle, ref: inputRef }))));
|
|
66
64
|
});
|
|
@@ -1,25 +1,13 @@
|
|
|
1
1
|
import * as React from 'react';
|
|
2
2
|
import { ICellEditorComp, ICellEditorParams } from '@ag-grid-community/core';
|
|
3
3
|
import { IAdaptable } from '../../../AdaptableInterfaces/IAdaptable';
|
|
4
|
-
export
|
|
5
|
-
|
|
6
|
-
}
|
|
4
|
+
export interface AdaptableDateEditorParams extends ICellEditorParams {
|
|
5
|
+
onValueChange?: (value: any) => void;
|
|
6
|
+
}
|
|
7
|
+
export declare const AdaptableReactDateEditor: React.ForwardRefExoticComponent<AdaptableDateEditorParams & React.RefAttributes<unknown>>;
|
|
7
8
|
/**
|
|
8
9
|
* Used by default for all `abColDefDate` columns.
|
|
9
10
|
*
|
|
10
|
-
* You can configure it by specifying `cellEditorParams` in the colDef:
|
|
11
|
-
*
|
|
12
|
-
* colDef {
|
|
13
|
-
* field: 'tradeDate',
|
|
14
|
-
* type: 'abColDefDate',
|
|
15
|
-
* cellEditorParams: {
|
|
16
|
-
* showClearButton: true
|
|
17
|
-
* }
|
|
18
|
-
* }
|
|
19
|
-
*
|
|
20
|
-
* For now, there is just 1 editor param you can configure:
|
|
21
|
-
*
|
|
22
|
-
* cellEditorParams.showClearButton - defaults to `true` - whether to show the clear button.
|
|
23
11
|
*
|
|
24
12
|
* When the colDef has a `valueParser` provided as a function, it will be used before setting the value for the cell.
|
|
25
13
|
* This is useful because dates can be stored as strings, numbers or Date instances - the value parser will be called with a `Date` instance,
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.AdaptableDateEditor = exports.
|
|
3
|
+
exports.AdaptableDateEditor = exports.AdaptableReactDateEditor = void 0;
|
|
4
4
|
const tslib_1 = require("tslib");
|
|
5
5
|
const React = tslib_1.__importStar(require("react"));
|
|
6
6
|
const renderWithAdaptableContext_1 = require("../../../View/renderWithAdaptableContext");
|
|
@@ -27,8 +27,7 @@ const defaultDateValueParser = ({ newValue, oldValue, defaultParser }) => {
|
|
|
27
27
|
}
|
|
28
28
|
return newValue;
|
|
29
29
|
};
|
|
30
|
-
exports.
|
|
31
|
-
var _a;
|
|
30
|
+
exports.AdaptableReactDateEditor = (0, react_1.forwardRef)((props, ref) => {
|
|
32
31
|
const [initialValue] = (0, react_1.useState)(() => getStartValue(props));
|
|
33
32
|
const valueRef = (0, react_1.useRef)(initialValue);
|
|
34
33
|
const colValueParser = props.column.getColDef().valueParser;
|
|
@@ -48,6 +47,7 @@ exports.ReactAdaptableDateEditor = (0, react_1.forwardRef)((props, ref) => {
|
|
|
48
47
|
};
|
|
49
48
|
});
|
|
50
49
|
const editorElement = (React.createElement(InternalAdaptableDateEditor_1.InternalAdaptableDateEditor, { defaultValue: initialValue, dateFormat: adaptable.adaptableOptions.userInterfaceOptions.dateInputOptions.dateFormat, onValueChange: (value) => {
|
|
50
|
+
var _a;
|
|
51
51
|
const invalid = isNaN(+value);
|
|
52
52
|
if (valueParser) {
|
|
53
53
|
const params = Object.assign(Object.assign({}, props), { oldValue: props.value, newValue: value, defaultParser: (value) => {
|
|
@@ -62,6 +62,7 @@ exports.ReactAdaptableDateEditor = (0, react_1.forwardRef)((props, ref) => {
|
|
|
62
62
|
} });
|
|
63
63
|
// @ts-ignore it will be fixed with https://github.com/AdaptableTools/adaptable/issues/2230
|
|
64
64
|
valueRef.current = valueParser(params);
|
|
65
|
+
(_a = props.onValueChange) === null || _a === void 0 ? void 0 : _a.call(props, valueRef.current);
|
|
65
66
|
}
|
|
66
67
|
else {
|
|
67
68
|
valueRef.current = invalid ? null : value;
|
|
@@ -71,7 +72,7 @@ exports.ReactAdaptableDateEditor = (0, react_1.forwardRef)((props, ref) => {
|
|
|
71
72
|
props.stopEditing();
|
|
72
73
|
});
|
|
73
74
|
}
|
|
74
|
-
},
|
|
75
|
+
}, onStopEdit: (keyboardEventKey) => {
|
|
75
76
|
if (keyboardEventKey === 'Escape') {
|
|
76
77
|
props.api.stopEditing(true);
|
|
77
78
|
}
|
|
@@ -87,19 +88,6 @@ exports.ReactAdaptableDateEditor = (0, react_1.forwardRef)((props, ref) => {
|
|
|
87
88
|
/**
|
|
88
89
|
* Used by default for all `abColDefDate` columns.
|
|
89
90
|
*
|
|
90
|
-
* You can configure it by specifying `cellEditorParams` in the colDef:
|
|
91
|
-
*
|
|
92
|
-
* colDef {
|
|
93
|
-
* field: 'tradeDate',
|
|
94
|
-
* type: 'abColDefDate',
|
|
95
|
-
* cellEditorParams: {
|
|
96
|
-
* showClearButton: true
|
|
97
|
-
* }
|
|
98
|
-
* }
|
|
99
|
-
*
|
|
100
|
-
* For now, there is just 1 editor param you can configure:
|
|
101
|
-
*
|
|
102
|
-
* cellEditorParams.showClearButton - defaults to `true` - whether to show the clear button.
|
|
103
91
|
*
|
|
104
92
|
* When the colDef has a `valueParser` provided as a function, it will be used before setting the value for the cell.
|
|
105
93
|
* This is useful because dates can be stored as strings, numbers or Date instances - the value parser will be called with a `Date` instance,
|
|
@@ -144,7 +132,6 @@ class AdaptableDateEditor {
|
|
|
144
132
|
}
|
|
145
133
|
// after this component has been created and inserted into the grid
|
|
146
134
|
afterGuiAttached() {
|
|
147
|
-
var _a;
|
|
148
135
|
const adaptable = this.getAdaptableInstance(this.params);
|
|
149
136
|
const defaultValue = shouldClearExistingValue(this.params) ? '' : this.params.value;
|
|
150
137
|
const editorElement = (React.createElement(InternalAdaptableDateEditor_1.InternalAdaptableDateEditor, { defaultValue: defaultValue, dateFormat: adaptable.adaptableOptions.userInterfaceOptions.dateInputOptions.dateFormat, onValueChange: (value) => {
|
|
@@ -171,7 +158,7 @@ class AdaptableDateEditor {
|
|
|
171
158
|
this.params.stopEditing();
|
|
172
159
|
});
|
|
173
160
|
}
|
|
174
|
-
},
|
|
161
|
+
}, onStopEdit: (keyboardEventKey) => {
|
|
175
162
|
if (keyboardEventKey === 'Escape') {
|
|
176
163
|
this.params.api.stopEditing(true);
|
|
177
164
|
}
|
|
@@ -38,6 +38,11 @@ exports.InternalAdaptableNumberEditor = React.forwardRef(function InternalAdapta
|
|
|
38
38
|
(_a = props.onValueChange) === null || _a === void 0 ? void 0 : _a.call(props, value);
|
|
39
39
|
},
|
|
40
40
|
});
|
|
41
|
+
React.useEffect(() => {
|
|
42
|
+
// When the editor is opened by typing, the value is not set, even if the user
|
|
43
|
+
// dismisses the editing by pressing enter or clicking outside, this forces the value to be set.
|
|
44
|
+
setValue(props.defaultValue);
|
|
45
|
+
}, []);
|
|
41
46
|
React.useImperativeHandle(ref, () => {
|
|
42
47
|
return {
|
|
43
48
|
focus,
|
|
@@ -50,7 +55,7 @@ exports.InternalAdaptableNumberEditor = React.forwardRef(function InternalAdapta
|
|
|
50
55
|
e.stopPropagation();
|
|
51
56
|
}
|
|
52
57
|
} },
|
|
53
|
-
React.createElement("input", { type: (_a = props.type) !== null && _a !== void 0 ? _a : 'number', value: value, onChange: React.useCallback((event) => {
|
|
58
|
+
React.createElement("input", { "data-name": "AdaptableNumberEditorInput", type: (_a = props.type) !== null && _a !== void 0 ? _a : 'number', value: value, onChange: React.useCallback((event) => {
|
|
54
59
|
setValue(event.target.value);
|
|
55
60
|
}, []), style: inputStyle, ref: inputRef }),
|
|
56
61
|
showClear ? (React.createElement("div", { style: {
|
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
import * as React from 'react';
|
|
2
2
|
import { ICellEditorComp, ICellEditorParams } from '@ag-grid-community/core';
|
|
3
|
+
export declare function getStartValue(params: ICellEditorParams): any;
|
|
3
4
|
/**
|
|
4
5
|
* Adaptable number editor parameters extending the AG Grid {@link ICellEditorParams}.
|
|
5
6
|
*/
|
|
6
|
-
interface AdaptableNumberCellEditorParams extends ICellEditorParams {
|
|
7
|
+
export interface AdaptableNumberCellEditorParams extends ICellEditorParams {
|
|
7
8
|
/**
|
|
8
9
|
* Whether to show the clear button. If `true`, it works together with `cellEditorParams.emptyValue`
|
|
9
10
|
* @defaultValue true
|
|
@@ -14,8 +15,9 @@ interface AdaptableNumberCellEditorParams extends ICellEditorParams {
|
|
|
14
15
|
* @defaultValue '' (empty string)
|
|
15
16
|
*/
|
|
16
17
|
emptyValue: string;
|
|
18
|
+
onValueChange: (value: any) => void;
|
|
17
19
|
}
|
|
18
|
-
export declare const
|
|
20
|
+
export declare const AdaptableReactNumberEditor: React.ForwardRefExoticComponent<AdaptableNumberCellEditorParams & React.RefAttributes<unknown>>;
|
|
19
21
|
/**
|
|
20
22
|
* Used by default for all `abColDefNumber` columns.
|
|
21
23
|
*
|
|
@@ -54,4 +56,3 @@ export declare class AdaptableNumberEditor implements ICellEditorComp {
|
|
|
54
56
|
destroy(): void;
|
|
55
57
|
private onValueChange;
|
|
56
58
|
}
|
|
57
|
-
export {};
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.AdaptableNumberEditor = exports.
|
|
3
|
+
exports.AdaptableNumberEditor = exports.AdaptableReactNumberEditor = exports.getStartValue = void 0;
|
|
4
4
|
const tslib_1 = require("tslib");
|
|
5
5
|
const React = tslib_1.__importStar(require("react"));
|
|
6
6
|
const renderWithAdaptableContext_1 = require("../../../View/renderWithAdaptableContext");
|
|
@@ -24,6 +24,7 @@ function getStartValue(params) {
|
|
|
24
24
|
}
|
|
25
25
|
return params.value;
|
|
26
26
|
}
|
|
27
|
+
exports.getStartValue = getStartValue;
|
|
27
28
|
const defaultValueParser = ({ newValue, oldValue: _ }) => {
|
|
28
29
|
return newValue;
|
|
29
30
|
};
|
|
@@ -34,7 +35,7 @@ const style = {
|
|
|
34
35
|
right: '0px',
|
|
35
36
|
bottom: '0px',
|
|
36
37
|
};
|
|
37
|
-
exports.
|
|
38
|
+
exports.AdaptableReactNumberEditor = (0, react_1.forwardRef)((props, ref) => {
|
|
38
39
|
var _a, _b;
|
|
39
40
|
const [initialValue] = (0, react_1.useState)(() => getStartValue(props));
|
|
40
41
|
const valueRef = (0, react_1.useRef)(initialValue);
|
|
@@ -43,10 +44,12 @@ exports.ReactAdaptableNumberEditor = (0, react_1.forwardRef)((props, ref) => {
|
|
|
43
44
|
const colValueParser = props.column.getColDef().valueParser;
|
|
44
45
|
const valueParser = typeof colValueParser === 'function' ? colValueParser : defaultValueParser;
|
|
45
46
|
function onValueChange(value) {
|
|
47
|
+
var _a;
|
|
46
48
|
value = valueParser
|
|
47
49
|
? valueParser(Object.assign(Object.assign({}, props), { oldValue: props.value, newValue: value }))
|
|
48
50
|
: value;
|
|
49
51
|
valueRef.current = value;
|
|
52
|
+
(_a = props.onValueChange) === null || _a === void 0 ? void 0 : _a.call(props, value);
|
|
50
53
|
}
|
|
51
54
|
const editorRef = (0, react_1.useRef)(null);
|
|
52
55
|
(0, react_1.useImperativeHandle)(ref, () => {
|
|
@@ -77,6 +80,7 @@ exports.ReactAdaptableNumberEditor = (0, react_1.forwardRef)((props, ref) => {
|
|
|
77
80
|
}
|
|
78
81
|
return (React.createElement("div", { style: style, onKeyDown: onKeyDown }, (0, renderWithAdaptableContext_1.renderWithAdaptableContext)(editorElement, adaptable)));
|
|
79
82
|
});
|
|
83
|
+
exports.AdaptableReactNumberEditor.displayName = 'AdaptableReactNumberEditor';
|
|
80
84
|
/**
|
|
81
85
|
* Used by default for all `abColDefNumber` columns.
|
|
82
86
|
*
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
export type InternalAdaptablePercentageEditorApi = {
|
|
3
|
+
focus: VoidFunction;
|
|
4
|
+
setValue: (value: any) => void;
|
|
5
|
+
};
|
|
6
|
+
export type InternalAdaptablePercentageEditorProps = {
|
|
7
|
+
/**
|
|
8
|
+
* Value to set when the x (when showClear: true) is pressed
|
|
9
|
+
*/
|
|
10
|
+
emptyValue?: string | number;
|
|
11
|
+
defaultValue?: string | number;
|
|
12
|
+
value?: string | number;
|
|
13
|
+
/**
|
|
14
|
+
* The input type. Defaults to 'number'
|
|
15
|
+
*/
|
|
16
|
+
type?: string;
|
|
17
|
+
/**
|
|
18
|
+
* Whether to show the clear button. Defaults to false
|
|
19
|
+
*/
|
|
20
|
+
showClearButton?: boolean;
|
|
21
|
+
onValueChange?: (value: string | number) => void;
|
|
22
|
+
};
|
|
23
|
+
export declare const InternalAdaptablePercentageEditor: React.ForwardRefExoticComponent<InternalAdaptablePercentageEditorProps & React.RefAttributes<InternalAdaptablePercentageEditorApi>>;
|
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.InternalAdaptablePercentageEditor = void 0;
|
|
4
|
+
const tslib_1 = require("tslib");
|
|
5
|
+
const React = tslib_1.__importStar(require("react"));
|
|
6
|
+
const icons_1 = require("../../../components/icons");
|
|
7
|
+
const useProperty_1 = tslib_1.__importDefault(require("../../../components/utils/useProperty"));
|
|
8
|
+
const NumberInput_1 = require("../../../components/Input/NumberInput");
|
|
9
|
+
const fillStyle = {
|
|
10
|
+
position: 'absolute',
|
|
11
|
+
left: 0,
|
|
12
|
+
top: 0,
|
|
13
|
+
right: 0,
|
|
14
|
+
bottom: 0,
|
|
15
|
+
};
|
|
16
|
+
const hostStyle = Object.assign(Object.assign({}, fillStyle), { boxSizing: 'border-box', display: 'flex', flexDirection: 'row', alignItems: 'center' });
|
|
17
|
+
const inputStyle = {
|
|
18
|
+
position: 'relative',
|
|
19
|
+
background: 'transparent',
|
|
20
|
+
boxSizing: 'border-box',
|
|
21
|
+
color: 'currentcolor',
|
|
22
|
+
minWidth: 0,
|
|
23
|
+
outline: 'none',
|
|
24
|
+
textAlign: 'right',
|
|
25
|
+
width: '100%',
|
|
26
|
+
border: 'none',
|
|
27
|
+
boxShadow: 'none',
|
|
28
|
+
paddingRight: '3ch',
|
|
29
|
+
};
|
|
30
|
+
exports.InternalAdaptablePercentageEditor = React.forwardRef(function InternalAdaptablePercentageEditorFn(props, ref) {
|
|
31
|
+
var _a;
|
|
32
|
+
const inputRef = React.useRef(null);
|
|
33
|
+
const focus = () => {
|
|
34
|
+
var _a;
|
|
35
|
+
(_a = inputRef.current) === null || _a === void 0 ? void 0 : _a.focus();
|
|
36
|
+
};
|
|
37
|
+
const [value, setValue] = (0, useProperty_1.default)(props, 'value', props.defaultValue, {
|
|
38
|
+
onChange: (value) => {
|
|
39
|
+
var _a;
|
|
40
|
+
if (value !== '' && value == Number(value)) {
|
|
41
|
+
value = Number(value);
|
|
42
|
+
}
|
|
43
|
+
(_a = props.onValueChange) === null || _a === void 0 ? void 0 : _a.call(props, value);
|
|
44
|
+
},
|
|
45
|
+
});
|
|
46
|
+
React.useImperativeHandle(ref, () => {
|
|
47
|
+
return {
|
|
48
|
+
focus,
|
|
49
|
+
setValue,
|
|
50
|
+
};
|
|
51
|
+
});
|
|
52
|
+
const showClear = props.showClearButton && props.emptyValue != null && value != props.emptyValue;
|
|
53
|
+
return (React.createElement("div", { style: hostStyle, className: "ab-PercentageEditor", onKeyDown: (e) => {
|
|
54
|
+
if (e.key === 'Tab' && showClear && document.activeElement === inputRef.current) {
|
|
55
|
+
e.stopPropagation();
|
|
56
|
+
}
|
|
57
|
+
} },
|
|
58
|
+
React.createElement(NumberInput_1.NumberInput, { type: (_a = props.type) !== null && _a !== void 0 ? _a : 'number', className: "ab-PercentageEditor-Input", value: value, noArrows: true, autoFocus: true, onChange: React.useCallback((value) => {
|
|
59
|
+
setValue(value);
|
|
60
|
+
}, []), style: inputStyle, ref: inputRef }),
|
|
61
|
+
showClear ? (React.createElement("div", { style: {
|
|
62
|
+
display: 'inline-block',
|
|
63
|
+
marginRight: 'var(--ab-space-1)',
|
|
64
|
+
marginLeft: 'var(--ab-space-1)',
|
|
65
|
+
}, onClick: (e) => {
|
|
66
|
+
if (props.emptyValue != null) {
|
|
67
|
+
setValue(props.emptyValue);
|
|
68
|
+
e.stopPropagation();
|
|
69
|
+
focus();
|
|
70
|
+
}
|
|
71
|
+
}, onKeyDown: (e) => {
|
|
72
|
+
if (props.emptyValue != null && e.key === 'Enter') {
|
|
73
|
+
setValue(props.emptyValue);
|
|
74
|
+
e.stopPropagation();
|
|
75
|
+
focus();
|
|
76
|
+
}
|
|
77
|
+
} },
|
|
78
|
+
React.createElement(icons_1.Icon, { size: 18, name: "close", tabIndex: 0 }))) : null,
|
|
79
|
+
React.createElement("div", { style: {
|
|
80
|
+
position: 'absolute',
|
|
81
|
+
right: showClear ? 20 : 0,
|
|
82
|
+
paddingInlineEnd: '0.5ch',
|
|
83
|
+
} }, "%")));
|
|
84
|
+
});
|