{"version":3,"file":"spartan-ng-brain-input.mjs","sources":["../../../../libs/brain/input/src/lib/brn-input.ts","../../../../libs/brain/input/src/index.ts","../../../../libs/brain/input/src/spartan-ng-brain-input.ts"],"sourcesContent":["import { BooleanInput } from '@angular/cdk/coercion';\nimport { booleanAttribute, computed, Directive, inject, input } from '@angular/core';\nimport { BrnFieldControl, provideBrnLabelable } from '@spartan-ng/brain/field';\n\n@Directive({\n\tselector: '[brnInput]',\n\texportAs: 'brnInput',\n\tproviders: [provideBrnLabelable(BrnInput)],\n\thostDirectives: [BrnFieldControl],\n\thost: {\n\t\t'[id]': 'id()',\n\t\t'[attr.aria-invalid]': '_ariaInvalid() ? \"true\" : null',\n\t\t'[attr.data-invalid]': '_invalid?.() ? \"true\" : null',\n\t\t'[attr.data-touched]': '_touched?.() ? \"true\" : null',\n\t\t'[attr.data-dirty]': '_dirty?.() ? \"true\" : null',\n\t\t'[attr.data-matches-spartan-invalid]': '_spartanInvalid() ? \"true\" : null',\n\t},\n})\nexport class BrnInput {\n\tprivate static _id = 0;\n\n\tprivate readonly _fieldControl = inject(BrnFieldControl, { optional: true });\n\n\t/** The id of the input. */\n\tpublic readonly id = input<string | undefined>(`brn-input-${++BrnInput._id}`);\n\n\t/** Whether to force the input into an invalid state. */\n\tpublic readonly forceInvalid = input<boolean, BooleanInput>(false, { transform: booleanAttribute });\n\n\t/**\n\t * Manual override for aria-invalid, e.g. for server-side validation errors.\n\t * When not set, it follows the error state matcher (and `forceInvalid`).\n\t */\n\tpublic readonly ariaInvalidInput = input<boolean | undefined, BooleanInput>(undefined, {\n\t\ttransform: (v: BooleanInput) => (v === '' || v === undefined ? undefined : booleanAttribute(v)),\n\t\talias: 'aria-invalid',\n\t});\n\n\tpublic readonly labelableId = this.id;\n\n\tprotected readonly _invalid = this._fieldControl?.invalid;\n\tprotected readonly _touched = this._fieldControl?.touched;\n\tprotected readonly _dirty = this._fieldControl?.dirty;\n\tprotected readonly _spartanInvalid = computed(() => this.forceInvalid() || this._fieldControl?.spartanInvalid());\n\n\t/** aria-invalid follows the same state that drives the visible error: the consumer override, else the matcher result. */\n\tprotected readonly _ariaInvalid = computed(() => this.ariaInvalidInput() ?? this._spartanInvalid());\n}\n","import { BrnInput } from './lib/brn-input';\n\nexport * from './lib/brn-input';\n\nexport const BrnInputImports = [BrnInput] as const;\n","/**\n * Generated bundle index. Do not edit.\n */\n\nexport * from './index';\n"],"names":[],"mappings":";;;;;MAkBa,QAAQ,CAAA;AACZ,IAAA,OAAO,GAAG,GAAG,CAAC;IAEL,aAAa,GAAG,MAAM,CAAC,eAAe,EAAE,EAAE,QAAQ,EAAE,IAAI,EAAE,CAAC;;IAG5D,EAAE,GAAG,KAAK,CAAqB,CAAA,UAAA,EAAa,EAAE,QAAQ,CAAC,GAAG,CAAA,CAAE,EAAA,IAAA,SAAA,GAAA,CAAA,EAAA,SAAA,EAAA,IAAA,EAAA,CAAA,8BAAA,EAAA,CAAA,CAAC;;IAG7D,YAAY,GAAG,KAAK,CAAwB,KAAK,oFAAI,SAAS,EAAE,gBAAgB,EAAA,CAAG;AAEnG;;;AAGG;AACa,IAAA,gBAAgB,GAAG,KAAK,CAAoC,SAAS,EAAA,EAAA,IAAA,SAAA,GAAA,EAAA,SAAA,EAAA,kBAAA,EAAA,8BAAA,EAAA,CAAA,EACpF,SAAS,EAAE,CAAC,CAAe,MAAM,CAAC,KAAK,EAAE,IAAI,CAAC,KAAK,SAAS,GAAG,SAAS,GAAG,gBAAgB,CAAC,CAAC,CAAC,CAAC;QAC/F,KAAK,EAAE,cAAc,EAAA,CACpB;AAEc,IAAA,WAAW,GAAG,IAAI,CAAC,EAAE;AAElB,IAAA,QAAQ,GAAG,IAAI,CAAC,aAAa,EAAE,OAAO;AACtC,IAAA,QAAQ,GAAG,IAAI,CAAC,aAAa,EAAE,OAAO;AACtC,IAAA,MAAM,GAAG,IAAI,CAAC,aAAa,EAAE,KAAK;AAClC,IAAA,eAAe,GAAG,QAAQ,CAAC,MAAM,IAAI,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