@hashicorp/design-system-components
Version:
Helios Design System Components
62 lines (59 loc) • 1.96 kB
JavaScript
import Component from '@glimmer/component';
import { modifier } from 'ember-modifier';
import { on } from '@ember/modifier';
import { service } from '@ember/service';
import HdsButton from '../../button/index.js';
import { precompileTemplate } from '@ember/template-compilation';
import { setComponentTemplate } from '@ember/component';
import { g, i } from 'decorator-transforms/runtime';
/**
* Copyright IBM Corp. 2021, 2025
* SPDX-License-Identifier: MPL-2.0
*/
class HdsFormKeyValueInputsDeleteRowButton extends Component {
static {
g(this.prototype, "hdsIntl", [service]);
}
#hdsIntl = (i(this, "hdsIntl"), void 0);
_onInsert = modifier(() => {
if (this.args.onInsert) {
this.args.onInsert();
}
return () => {
if (this.args.onRemove) {
this.args.onRemove();
}
const {
returnFocusTo
} = this.args;
if (returnFocusTo && returnFocusTo.isConnected) {
returnFocusTo.focus();
}
};
});
get text() {
return this.args.text ?? this.hdsIntl.t('hds.components.form.key-value-inputs.delete-row-button.text', {
default: 'Delete row {rowNumber}',
rowNumber: this.args.rowIndex + 1
});
}
onClick = () => {
const {
onClick
} = this.args;
if (typeof onClick === 'function') {
onClick(this.args.rowData, this.args.rowIndex);
}
};
static {
setComponentTemplate(precompileTemplate("<span class=\"hds-form-key-value-inputs__delete-row-button-container\" {{this._onInsert}}>\n <HdsButton @text={{this.text}} @size=\"medium\" @color=\"secondary\" @icon=\"trash\" @isIconOnly={{true}} class=\"hds-form-key-value-inputs__delete-row-button\" {{on \"click\" this.onClick}} ...attributes />\n</span>", {
strictMode: true,
scope: () => ({
HdsButton,
on
})
}), this);
}
}
export { HdsFormKeyValueInputsDeleteRowButton as default };
//# sourceMappingURL=delete-row-button.js.map