Field.tsx 690 B

1234567891011121314151617181920212223
  1. import React from 'react';
  2. import { EditorField } from '@grafana/experimental';
  3. import { InlineField } from '@grafana/ui';
  4. import { Props as InlineFieldProps } from '@grafana/ui/src/components/Forms/InlineField';
  5. interface Props extends InlineFieldProps {
  6. label: string;
  7. inlineField?: boolean;
  8. labelWidth?: number;
  9. }
  10. const DEFAULT_LABEL_WIDTH = 18;
  11. export const Field = (props: Props) => {
  12. const { labelWidth, inlineField, ...remainingProps } = props;
  13. if (!inlineField) {
  14. return <EditorField width={labelWidth || DEFAULT_LABEL_WIDTH} {...remainingProps} />;
  15. } else {
  16. return <InlineField labelWidth={labelWidth || DEFAULT_LABEL_WIDTH} {...remainingProps} />;
  17. }
  18. };