@hashicorp/design-system-components
Version:
Helios Design System Components
61 lines (60 loc) • 2.49 kB
TypeScript
/**
* Copyright IBM Corp. 2021, 2025
* SPDX-License-Identifier: MPL-2.0
*/
import Component from '@glimmer/component';
import type { WithBoundArgs } from '@glint/template';
import HdsAlert from '../../alert/index';
import HdsFormError from '../error/index';
import HdsFormHelperText from '../helper-text/index';
import HdsFormKeyValueInputsDeleteRowButton from './delete-row-button';
import HdsFormKeyValueInputsField from './field';
import HdsFormKeyValueInputsGeneric from './generic';
import HdsFormLegend from '../legend/index';
import HdsYield from '../../yield/index';
import HdsFormKeyValueInputsAddRowButton from './add-row-button';
export interface HdsFormKeyValueInputsSignature<T = unknown> {
Args: {
data: Array<T>;
extraAriaDescribedBy?: string;
isOptional?: boolean;
isRequired?: boolean;
};
Blocks: {
header?: [
{
Legend?: WithBoundArgs<typeof HdsFormLegend, 'contextualClass' | 'id' | 'isOptional' | 'isRequired'>;
HelperText?: WithBoundArgs<typeof HdsFormHelperText, 'contextualClass' | 'controlId' | 'onInsert'>;
Generic?: typeof HdsYield;
}
];
row: [
{
Field?: WithBoundArgs<typeof HdsFormKeyValueInputsField, 'onInsert' | 'onRemove' | 'rowIndex'>;
Generic?: WithBoundArgs<typeof HdsFormKeyValueInputsGeneric, 'onInsert' | 'onRemove'>;
DeleteRowButton?: WithBoundArgs<typeof HdsFormKeyValueInputsDeleteRowButton, 'onInsert' | 'onRemove' | 'returnFocusTo' | 'rowData' | 'rowIndex'>;
rowData?: T;
rowIndex?: number;
}
];
footer?: [
{
AddRowButton?: typeof HdsFormKeyValueInputsAddRowButton;
Alert?: WithBoundArgs<typeof HdsAlert, 'color' | 'type'>;
Error?: WithBoundArgs<typeof HdsFormError, 'contextualClass' | 'controlId' | 'onInsert' | 'onRemove'>;
}
];
};
Element: HTMLFieldSetElement;
}
export default class HdsFormKeyValueInputs<T = unknown> extends Component<HdsFormKeyValueInputsSignature<T>> {
private _element;
_gridTemplateColumns: string;
get glueId(): string;
_setUpColumn: () => void;
_removeColumn: () => void;
appendDescriptor: (element: HTMLElement) => void;
removeDescriptor: (element: HTMLElement) => void;
private _setUpKeyValueInputs;
private _updateColumns;
}