Files
decky-frontend-lib/src/deck-components/Field.tsx

32 lines
1.3 KiB
TypeScript
Raw Normal View History

import { FC, ReactNode, RefAttributes } from 'react';
2022-10-24 20:33:40 -04:00
2022-06-22 21:44:41 -04:00
import { findModuleChild } from '../webpack';
import { FooterLegendProps } from './FooterLegend';
2022-06-22 21:44:41 -04:00
export interface FieldProps extends FooterLegendProps {
label?: ReactNode;
bottomSeparator?: 'standard' | 'thick' | 'none';
description?: ReactNode;
2022-06-22 21:44:41 -04:00
disabled?: boolean;
icon?: ReactNode;
inlineWrap?: 'keep-inline' | 'shift-children-below'; // If label is too long it will move shildren below before starting to wrap label
childrenLayout?: 'below' | 'inline';
childrenContainerWidth?: 'min' | 'max' | 'fixed'; // Does not work with childrenLayout==='below'
2022-10-24 20:33:40 -04:00
spacingBetweenLabelAndChild?: 'none'; // This applies only when childrenLayout==='below'
padding?: 'none' | 'standard' | 'compact';
className?: string;
2022-06-22 21:44:41 -04:00
highlightOnFocus?: boolean;
indentLevel?: number;
verticalAlignment?: 'center' | 'none'; // Alligns inline label with children
focusable?: boolean; // Allows to get focus without any focusable children or on* callbacks
onActivate?: (e: CustomEvent | MouseEvent) => void;
onClick?: (e: CustomEvent | MouseEvent) => void;
2022-06-22 21:44:41 -04:00
}
export const Field = findModuleChild((m) => {
2022-10-24 20:33:40 -04:00
if (typeof m !== 'object') return undefined;
for (let prop in m) {
if (m[prop]?.render?.toString().includes('"shift-children-below"')) return m[prop];
}
2022-06-22 21:44:41 -04:00
}) as FC<FieldProps & RefAttributes<HTMLDivElement>>;