@gavant/ember-validations
Version:
A form validator library using ember-changeset and ember-changeset-validations
50 lines (41 loc) • 1.74 kB
JavaScript
import { _ as _initializerDefineProperty } from '../../../initializerDefineProperty-b6f88891.js';
import { _ as _applyDecoratedDescriptor } from '../../../applyDecoratedDescriptor-e87190e7.js';
import { setComponentTemplate } from '@ember/component';
import { hbs } from 'ember-cli-htmlbars';
import { assert } from '@ember/debug';
import Component from '@glimmer/component';
import { tracked } from '@glimmer/tracking';
var TEMPLATE = hbs("{{yield\n @changeset\n (hash input=(component \"input-validator\" parent=this) showAllValidationFields=this.showAllValidationFields)\n}}");
var _class, _descriptor;
let FormValidatorChild = (_class = class FormValidatorChild extends Component {
/**
* Creates an instance of FormValidatorChild.
* @param {unknown} owner
* @param {FormValidatorChildArgs<T>} args
* @memberof FormValidatorChild
*/
constructor(owner, args) {
super(owner, args);
_initializerDefineProperty(this, "showAllValidationFields", _descriptor, this);
assert('child form validators must be inside a form-validator block and pass it to this component in the "parent" attribute', this.args.parent?.constructor.name === 'FormValidator');
this.args.parent.registerChild(this);
}
/**
* Deregister the child from the parent
*
* @memberof FormValidatorChild
*/
willDestroy() {
super.willDestroy();
this.args.parent?.deregisterChild(this);
}
}, (_descriptor = _applyDecoratedDescriptor(_class.prototype, "showAllValidationFields", [tracked], {
configurable: true,
enumerable: true,
writable: true,
initializer: function () {
return false;
}
})), _class);
setComponentTemplate(TEMPLATE, FormValidatorChild);
export { FormValidatorChild as default };