primeng
Version:
PrimeNG is an open source UI library for Angular featuring a rich set of 80+ components, a theme designer, various theme alternatives such as Material, Bootstrap, Tailwind, premium templates and professional support. In addition, it integrates with PrimeB
146 lines (139 loc) • 6.46 kB
JavaScript
import * as i0 from '@angular/core';
import { Injectable, inject, input, booleanAttribute, computed, HostListener, Input, Directive, NgModule } from '@angular/core';
import { NgControl } from '@angular/forms';
import { BaseModelHolder } from 'primeng/basemodelholder';
import { Fluid } from 'primeng/fluid';
import { style } from '@primeuix/styles/inputtext';
import { BaseStyle } from 'primeng/base';
const theme = /*css*/ `
${style}
/* For PrimeNG */
.p-inputtext.ng-invalid.ng-dirty {
border-color: dt('inputtext.invalid.border.color');
}
.p-inputtext.ng-invalid.ng-dirty::placeholder {
color: dt('inputtext.invalid.placeholder.color');
}
`;
const classes = {
root: ({ instance }) => [
'p-inputtext p-component',
{
'p-filled': instance.$filled(),
'p-inputtext-sm': instance.pSize === 'small',
'p-inputtext-lg': instance.pSize === 'large',
'p-invalid': instance.invalid(),
'p-variant-filled': instance.$variant() === 'filled',
'p-inputtext-fluid': instance.hasFluid
}
]
};
class InputTextStyle extends BaseStyle {
name = 'inputtext';
theme = theme;
classes = classes;
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "20.1.3", ngImport: i0, type: InputTextStyle, deps: null, target: i0.ɵɵFactoryTarget.Injectable });
static ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "20.1.3", ngImport: i0, type: InputTextStyle });
}
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.1.3", ngImport: i0, type: InputTextStyle, decorators: [{
type: Injectable
}] });
/**
*
* InputText renders a text field to enter data.
*
* [Live Demo](https://www.primeng.org/inputtext/)
*
* @module inputtextstyle
*
*/
var InputTextClasses;
(function (InputTextClasses) {
/**
* The class of root element
*/
InputTextClasses["root"] = "p-inputtext";
})(InputTextClasses || (InputTextClasses = {}));
/**
* InputText directive is an extension to standard input element with theming.
* @group Components
*/
class InputText extends BaseModelHolder {
ngControl = inject(NgControl, { optional: true, self: true });
pcFluid = inject(Fluid, { optional: true, host: true, skipSelf: true });
/**
* Defines the size of the component.
* @group Props
*/
pSize;
/**
* Specifies the input variant of the component.
* @defaultValue undefined
* @group Props
*/
variant = input(...(ngDevMode ? [undefined, { debugName: "variant" }] : []));
/**
* Spans 100% width of the container when enabled.
* @defaultValue undefined
* @group Props
*/
fluid = input(undefined, ...(ngDevMode ? [{ debugName: "fluid", transform: booleanAttribute }] : [{ transform: booleanAttribute }]));
/**
* When present, it specifies that the component should have invalid state style.
* @defaultValue false
* @group Props
*/
invalid = input(undefined, ...(ngDevMode ? [{ debugName: "invalid", transform: booleanAttribute }] : [{ transform: booleanAttribute }]));
$variant = computed(() => this.variant() || this.config.inputStyle() || this.config.inputVariant(), ...(ngDevMode ? [{ debugName: "$variant" }] : []));
_componentStyle = inject(InputTextStyle);
ngAfterViewInit() {
super.ngAfterViewInit();
this.writeModelValue(this.ngControl?.value ?? this.el.nativeElement.value);
this.cd.detectChanges();
}
ngDoCheck() {
this.writeModelValue(this.ngControl?.value ?? this.el.nativeElement.value);
}
onInput() {
this.writeModelValue(this.ngControl?.value ?? this.el.nativeElement.value);
}
get hasFluid() {
return this.fluid() ?? !!this.pcFluid;
}
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "20.1.3", ngImport: i0, type: InputText, deps: null, target: i0.ɵɵFactoryTarget.Directive });
static ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "17.1.0", version: "20.1.3", type: InputText, isStandalone: true, selector: "[pInputText]", inputs: { pSize: { classPropertyName: "pSize", publicName: "pSize", isSignal: false, isRequired: false, transformFunction: null }, variant: { classPropertyName: "variant", publicName: "variant", isSignal: true, isRequired: false, transformFunction: null }, fluid: { classPropertyName: "fluid", publicName: "fluid", isSignal: true, isRequired: false, transformFunction: null }, invalid: { classPropertyName: "invalid", publicName: "invalid", isSignal: true, isRequired: false, transformFunction: null } }, host: { listeners: { "input": "onInput($event)" }, properties: { "class": "cx('root')" } }, providers: [InputTextStyle], usesInheritance: true, ngImport: i0 });
}
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.1.3", ngImport: i0, type: InputText, decorators: [{
type: Directive,
args: [{
selector: '[pInputText]',
standalone: true,
host: {
'[class]': "cx('root')"
},
providers: [InputTextStyle]
}]
}], propDecorators: { pSize: [{
type: Input,
args: ['pSize']
}], onInput: [{
type: HostListener,
args: ['input', ['$event']]
}] } });
class InputTextModule {
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "20.1.3", ngImport: i0, type: InputTextModule, deps: [], target: i0.ɵɵFactoryTarget.NgModule });
static ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "14.0.0", version: "20.1.3", ngImport: i0, type: InputTextModule, imports: [InputText], exports: [InputText] });
static ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "20.1.3", ngImport: i0, type: InputTextModule });
}
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.1.3", ngImport: i0, type: InputTextModule, decorators: [{
type: NgModule,
args: [{
imports: [InputText],
exports: [InputText]
}]
}] });
/**
* Generated bundle index. Do not edit.
*/
export { InputText, InputTextClasses, InputTextModule, InputTextStyle };
//# sourceMappingURL=primeng-inputtext.mjs.map