UNPKG

devextreme

Version:

JavaScript/TypeScript Component Suite for Responsive Web Development

77 lines (76 loc) 2.55 kB
/** * DevExtreme (esm/__internal/ui/form/form.ai.utils.js) * Version: 25.2.7 * Build date: Tue May 05 2026 * * Copyright (c) 2012 - 2026 Developer Express Inc. ALL RIGHTS RESERVED * Read about DevExtreme licensing here: https://js.devexpress.com/Licensing/ */ import { isObject } from "../../../core/utils/type"; const getEditorTypeInfo = editorType => { switch (editorType) { case "dxDateBox": case "dxCalendar": return "date in ISO format"; case "dxDateRangeBox": return "date range in ISO format, use pattern {start}:::{end}"; case "dxColorBox": return "color in hex format"; case "dxCheckBox": case "dxSwitch": return "boolean value, true or false"; case "dxNumberBox": case "dxSlider": return "numeric value"; case "dxRangeSlider": return "numeric range, use pattern {start}:::{end}"; default: return "text" } }; export const getFieldType = editorType => { switch (editorType) { case "dxDateBox": case "dxCalendar": return "date"; case "dxDateRangeBox": return "dateRange"; case "dxCheckBox": case "dxSwitch": return "boolean"; case "dxNumberBox": case "dxSlider": return "number"; case "dxRangeSlider": return "numberRange"; case "dxColorBox": return "color"; default: return "string" } }; const getItemsAcceptedValuesInfo = editorOptions => { if (!(null !== editorOptions && void 0 !== editorOptions && editorOptions.items)) { return "" } const items = editorOptions.items.map(item => { if (isObject(item)) { return item.text } return item }); const acceptedValues = `, accepted values: ${items.join(", ")}, split values with :::`; const customItemsAllowed = null !== editorOptions && void 0 !== editorOptions && editorOptions.acceptCustomValue ? " (custom values are allowed)" : ""; return `${acceptedValues}${customItemsAllowed}` }; export const getItemFormatInfo = _ref => { let { editorType: editorType, editorOptions: editorOptions } = _ref; const dataType = getEditorTypeInfo(editorType); const acceptedValues = getItemsAcceptedValuesInfo(editorOptions); return `${dataType}${acceptedValues}` };