29 lines
643 B
JavaScript
29 lines
643 B
JavaScript
/**
|
|
* Copyright IBM Corp. 2021, 2026
|
|
* SPDX-License-Identifier: BUSL-1.1
|
|
*/
|
|
|
|
import Component from '@glimmer/component';
|
|
|
|
export default class FormFieldKeyValueComponent extends Component {
|
|
/**
|
|
* Determines if the delete button should be shown.
|
|
*/
|
|
get canDelete() {
|
|
const rows = this.args.data || [];
|
|
|
|
// Always show delete for multiple rows
|
|
if (rows.length > 1) {
|
|
return true;
|
|
}
|
|
|
|
// For a single row, only show if it has any non-empty values
|
|
if (rows.length === 1) {
|
|
return Object.values(rows[0]).some((value) => value);
|
|
}
|
|
|
|
// Return false if there are no rows
|
|
return false;
|
|
}
|
|
}
|