UNPKG

@adaptabletools/adaptable

Version:

Powerful AG Grid extension which provides advanced, cutting-edge functionality to meet all DataGrid requirements

34 lines (33 loc) 2.54 kB
import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-runtime"; import { Box, Flex } from '../../../components/Flex'; import { getWizardTypeSelectionGridColumns, WizardTypeSelectionCard, WizardTypeSelectionPreviewFrame, WizardTypeSelectionSection, } from '../../Wizard/WizardTypeSelection'; const CALCULATED_COLUMN_TYPE_OPTIONS = [ { type: 'ScalarExpression', label: 'Standard', description: 'The calculated value is derived from other cells in the row', expressionExample: '[price] * [quantity]', }, { type: 'AggregatedScalarExpression', label: 'Aggregated', description: 'The calculated value is derived from other rows', expressionExample: 'SUM([pnl], GROUP_BY([desk]))', }, { type: 'CumulativeAggregatedExpression', label: 'Cumulative', description: 'The calculated value is derived cumulatively from other rows', expressionExample: 'CUMUL(SUM([pnl]), OVER([tradeDate]))', }, { type: 'QuantileAggregatedExpression', label: 'Quantile', description: 'The calculated value is derived from other rows using quantile aggregations', expressionExample: 'QUANT([pnl], 4)', }, ]; const CALCULATED_COLUMN_TYPE_COUNT = CALCULATED_COLUMN_TYPE_OPTIONS.length; export const CalculatedColumnTypeWizardSection = (props) => { return (_jsx(Flex, { flexDirection: "column", "data-name": "calculated-column-type", className: "twa:h-full twa:min-h-0 twa:p-2", children: _jsx(WizardTypeSelectionSection, { headingId: "calculated-column-type-heading", title: "Calculated Column Type", dataName: "calculated-column-type-grid", columns: getWizardTypeSelectionGridColumns(CALCULATED_COLUMN_TYPE_COUNT), intro: _jsxs(_Fragment, { children: ["Click a card to choose one of ", CALCULATED_COLUMN_TYPE_COUNT, " calculated column types"] }), children: CALCULATED_COLUMN_TYPE_OPTIONS.map((option) => (_jsx(WizardTypeSelectionCard, { label: option.label, description: option.description, selected: props.type === option.type, dataName: `calculated-column-type-${option.type}`, minHeightClassName: "twa:min-h-[148px]", onSelect: () => props.onTypeChange(option.type), footer: _jsx(WizardTypeSelectionPreviewFrame, { children: _jsx(Box, { as: "code", className: "ab-CodeBlock twa:block twa:w-full twa:truncate twa:bg-transparent twa:p-0 twa:font-mono twa:text-2 twa:leading-snug twa:text-foreground twa:opacity-90", children: option.expressionExample }) }) }, option.type))) }) })); };