UNPKG

choerodon-ui

Version:

An enterprise-class UI design language and React-based implementation

73 lines (60 loc) 1.8 kB
import _toConsumableArray from "@babel/runtime/helpers/toConsumableArray"; import isNumber from 'lodash/isNumber'; import { LabelLayout } from './enum'; export var defaultLabelWidth = 100; export var defaultLabelLayout = LabelLayout.horizontal; export var defaultColumns = 1; export var FIELD_SUFFIX = 'field'; export function normalizeLabelWidth(labelWidth, columns) { if (isNumber(labelWidth) || labelWidth === 'auto') { return new Array(columns).fill(labelWidth); } var labelWidths = new Array(columns).fill(defaultLabelWidth); labelWidth.slice(0, columns).forEach(function (width, index) { return labelWidths[index] = width; }); return labelWidths; } export function getProperty(props, key, dataSet, record) { if (props[key]) { return props[key]; } var name = props.name; var field = record ? record.getField(name) : dataSet && dataSet.getField(name); if (field) { var fieldProperty = field.get(key); if (fieldProperty) { return fieldProperty; } } } export var defaultExcludeUseColonTag = ['div', 'button', 'Button']; function findFocusableElement(node) { if (node.children) { var found; _toConsumableArray(node.children).some(function (child) { if (child.tabIndex > -1) { found = child; } else { found = findFocusableElement(child); } return !!found; }); return found; } } export function findFirstInvalidElement(node) { if (node.children) { var found; _toConsumableArray(node.children).some(function (child) { if (child.className.includes('invalid')) { found = findFocusableElement(child); } else { found = findFirstInvalidElement(child); } return !!found; }); return found; } } //# sourceMappingURL=utils.js.map