UNPKG

@adaptabletools/adaptable-cjs

Version:

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

46 lines (45 loc) 2.36 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.FormatColumnStyleWizardSection = exports.renderFormatColumnStyleSummary = exports.renderFormatColumnStyleWizardSummary = exports.isFormatColumnStyleValid = void 0; const tslib_1 = require("tslib"); const React = tslib_1.__importStar(require("react")); const rebass_1 = require("rebass"); const StyleHelper_1 = require("../../../Utilities/Helpers/StyleHelper"); const StyleComponent_1 = require("../../Components/StyleComponent"); const OnePageAdaptableWizard_1 = require("../../Wizard/OnePageAdaptableWizard"); const UIHelper_1 = tslib_1.__importDefault(require("../../UIHelper")); const isFormatColumnStyleValid = (data, api) => { if (data.Style && UIHelper_1.default.IsEmptyStyle(data.Style) && data.DisplayFormat === undefined && data.CellAlignment === undefined && !api.columnScopeApi.isSingleBooleanColumnScope(data.Scope)) { return 'No format applied'; } return true; }; exports.isFormatColumnStyleValid = isFormatColumnStyleValid; const toStyle = (data) => { return { ...(0, StyleHelper_1.convertAdaptableStyleToCSS)(data.Style ?? {}), borderWidth: data.Style?.BorderColor ? 2 : 0, borderStyle: 'solid', textAlign: data.CellAlignment ? data.CellAlignment.toLowerCase() : undefined, }; }; const renderFormatColumnStyleWizardSummary = (data) => { const { api } = (0, OnePageAdaptableWizard_1.useOnePageAdaptableWizardContext)(); return (0, exports.renderFormatColumnStyleSummary)(data, api); }; exports.renderFormatColumnStyleWizardSummary = renderFormatColumnStyleWizardSummary; const renderFormatColumnStyleSummary = (data, api) => { return (React.createElement(rebass_1.Text, { className: "ab-FormatPreview", padding: 2, style: toStyle(data) }, "Preview result")); }; exports.renderFormatColumnStyleSummary = renderFormatColumnStyleSummary; function FormatColumnStyleWizardSection(props) { const { data, api } = (0, OnePageAdaptableWizard_1.useOnePageAdaptableWizardContext)(); return (React.createElement(StyleComponent_1.StyleComponent, { headless: true, api: api, Style: data.Style ?? {}, UpdateStyle: (Style) => { props.onChange({ ...data, Style }); } })); } exports.FormatColumnStyleWizardSection = FormatColumnStyleWizardSection;