Icard/angular-clarity-master(work.../node_modules/primeng/esm2022/tristatecheckbox/tristatecheckbox.mjs

338 lines
34 KiB
JavaScript
Raw Permalink Normal View History

2024-07-16 14:55:36 +00:00
import { CommonModule } from '@angular/common';
import { ChangeDetectionStrategy, Component, ContentChildren, EventEmitter, Input, NgModule, Output, ViewEncapsulation, booleanAttribute, forwardRef, numberAttribute } from '@angular/core';
import { NG_VALUE_ACCESSOR } from '@angular/forms';
import { PrimeTemplate, SharedModule } from 'primeng/api';
import { CheckIcon } from 'primeng/icons/check';
import { TimesIcon } from 'primeng/icons/times';
import { AutoFocusModule } from 'primeng/autofocus';
import * as i0 from "@angular/core";
import * as i1 from "primeng/api";
import * as i2 from "@angular/common";
import * as i3 from "primeng/autofocus";
export const TRISTATECHECKBOX_VALUE_ACCESSOR = {
provide: NG_VALUE_ACCESSOR,
useExisting: forwardRef(() => TriStateCheckbox),
multi: true
};
/**
* TriStateCheckbox is used to select either 'true', 'false' or 'null' as the value.
* @group Components
*/
export class TriStateCheckbox {
cd;
config;
constructor(cd, config) {
this.cd = cd;
this.config = config;
}
/**
* When present, it specifies that the element should be disabled.
* @group Props
*/
disabled;
/**
* Name of the component.
* @group Props
*/
name;
/**
* Defines a string that labels the input for accessibility.
* @group Props
*/
ariaLabel;
/**
* Establishes relationships between the component and label(s) where its value should be one or more element IDs.
* @group Props
*/
ariaLabelledBy;
/**
* Specifies the input variant of the component.
* @group Props
*/
variant = 'outlined';
/**
* Index of the element in tabbing order.
* @group Props
*/
tabindex;
/**
* Identifier of the focus input to match a label defined for the component.
* @group Props
*/
inputId;
/**
* Inline style of the component.
* @group Props
*/
style;
/**
* Style class of the component.
* @group Props
*/
styleClass;
/**
* Label of the checkbox.
* @group Props
*/
label;
/**
* When present, it specifies that the component cannot be edited.
* @group Props
*/
readonly;
/**
* Specifies the icon for checkbox true value.
* @group Props
*/
checkboxTrueIcon;
/**
* Specifies the icon for checkbox false value.
* @group Props
*/
checkboxFalseIcon;
/**
* When present, it specifies that the component should automatically get focus on load.
* @group Props
*/
autofocus;
/**
* Callback to invoke on value change.
* @param {TriStateCheckboxChangeEvent} event - Custom change event.
* @group Emits
*/
onChange = new EventEmitter();
templates;
checkIconTemplate;
uncheckIconTemplate;
focused;
value;
onModelChange = () => { };
onModelTouched = () => { };
onClick(event, input) {
if (!this.disabled && !this.readonly) {
this.toggle(event);
this.focused = true;
input.focus();
}
}
onKeyDown(event) {
if (event.key === 'Enter') {
this.toggle(event);
event.preventDefault();
}
}
toggle(event) {
if (this.value == null || this.value == undefined)
this.value = true;
else if (this.value == true)
this.value = false;
else if (this.value == false)
this.value = null;
this.onModelChange(this.value);
this.onChange.emit({
originalEvent: event,
value: this.value
});
}
ngAfterContentInit() {
this.templates.forEach((item) => {
switch (item.getType()) {
case 'checkicon':
this.checkIconTemplate = item.template;
break;
case 'uncheckicon':
this.uncheckIconTemplate = item.template;
break;
}
});
}
onFocus() {
this.focused = true;
}
onBlur() {
this.focused = false;
this.onModelTouched();
}
registerOnChange(fn) {
this.onModelChange = fn;
}
registerOnTouched(fn) {
this.onModelTouched = fn;
}
writeValue(value) {
this.value = value;
this.cd.markForCheck();
}
setDisabledState(disabled) {
this.disabled = disabled;
this.cd.markForCheck();
}
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "17.3.7", ngImport: i0, type: TriStateCheckbox, deps: [{ token: i0.ChangeDetectorRef }, { token: i1.PrimeNGConfig }], target: i0.ɵɵFactoryTarget.Component });
static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "16.1.0", version: "17.3.7", type: TriStateCheckbox, selector: "p-triStateCheckbox", inputs: { disabled: ["disabled", "disabled", booleanAttribute], name: "name", ariaLabel: "ariaLabel", ariaLabelledBy: "ariaLabelledBy", variant: "variant", tabindex: ["tabindex", "tabindex", numberAttribute], inputId: "inputId", style: "style", styleClass: "styleClass", label: "label", readonly: ["readonly", "readonly", booleanAttribute], checkboxTrueIcon: "checkboxTrueIcon", checkboxFalseIcon: "checkboxFalseIcon", autofocus: ["autofocus", "autofocus", booleanAttribute] }, outputs: { onChange: "onChange" }, host: { classAttribute: "p-element" }, providers: [TRISTATECHECKBOX_VALUE_ACCESSOR], queries: [{ propertyName: "templates", predicate: PrimeTemplate }], ngImport: i0, template: `
<div
[ngStyle]="style"
[ngClass]="{ 'p-checkbox p-component': true, 'p-checkbox-disabled': disabled, 'p-checkbox-focused': focused, 'p-variant-filled': variant === 'filled' || config.inputStyle() === 'filled' }"
[class]="styleClass"
(click)="onClick($event, input)"
[attr.data-pc-name]="'tristatecheckbox'"
[attr.data-pc-section]="'root'"
>
<div class="p-hidden-accessible">
<input
#input
[attr.id]="inputId"
type="checkbox"
[name]="name"
[attr.tabindex]="tabindex"
[readonly]="readonly"
[disabled]="disabled"
(keydown)="onKeyDown($event)"
(focus)="onFocus()"
(blur)="onBlur()"
[attr.aria-labelledby]="ariaLabelledBy"
[attr.aria-label]="ariaLabel"
inputmode="none"
[attr.data-pc-section]="'hiddenInput'"
pAutoFocus
[autofocus]="autofocus"
/>
</div>
<div class="p-checkbox-box" role="checkbox" [attr.aria-checked]="value === true" [ngClass]="{ 'p-highlight': value != null, 'p-disabled': disabled, 'p-focus': focused }">
<ng-container *ngIf="value === true">
<span *ngIf="checkboxTrueIcon" [ngClass]="checkboxTrueIcon" class="p-checkbox-icon" [attr.data-pc-section]="'checkIcon'"></span>
<ng-container *ngIf="!checkboxTrueIcon">
<CheckIcon [styleClass]="'p-checkbox-icon'" *ngIf="!checkIconTemplate" [attr.data-pc-section]="'checkIcon'" />
<span *ngIf="checkIconTemplate" class="p-checkbox-icon" [attr.data-pc-section]="'checkIcon'">
<ng-template *ngTemplateOutlet="checkIconTemplate"></ng-template>
</span>
</ng-container>
</ng-container>
<ng-container *ngIf="value === false">
<span *ngIf="checkboxFalseIcon" [ngClass]="checkboxFalseIcon" class="p-checkbox-icon" [attr.data-pc-section]="'uncheckIcon'"></span>
<ng-container *ngIf="!checkboxFalseIcon">
<TimesIcon [styleClass]="'p-checkbox-icon'" *ngIf="!uncheckIconTemplate" [attr.data-pc-section]="'uncheckIcon'" />
<span class="p-checkbox-icon" *ngIf="uncheckIconTemplate" [attr.data-pc-section]="'uncheckIcon'">
<ng-template *ngTemplateOutlet="uncheckIconTemplate"></ng-template>
</span>
</ng-container>
</ng-container>
</div>
</div>
<label class="p-checkbox-label" (click)="onClick($event, input)" [ngClass]="{ 'p-checkbox-label-active': value != null, 'p-disabled': disabled, 'p-checkbox-label-focus': focused }" *ngIf="label" [attr.for]="inputId">{{ label }}</label>
`, isInline: true, dependencies: [{ kind: "directive", type: i0.forwardRef(() => i2.NgClass), selector: "[ngClass]", inputs: ["class", "ngClass"] }, { kind: "directive", type: i0.forwardRef(() => i2.NgIf), selector: "[ngIf]", inputs: ["ngIf", "ngIfThen", "ngIfElse"] }, { kind: "directive", type: i0.forwardRef(() => i2.NgTemplateOutlet), selector: "[ngTemplateOutlet]", inputs: ["ngTemplateOutletContext", "ngTemplateOutlet", "ngTemplateOutletInjector"] }, { kind: "directive", type: i0.forwardRef(() => i2.NgStyle), selector: "[ngStyle]", inputs: ["ngStyle"] }, { kind: "directive", type: i0.forwardRef(() => i3.AutoFocus), selector: "[pAutoFocus]", inputs: ["autofocus"] }, { kind: "component", type: i0.forwardRef(() => CheckIcon), selector: "CheckIcon" }, { kind: "component", type: i0.forwardRef(() => TimesIcon), selector: "TimesIcon" }], changeDetection: i0.ChangeDetectionStrategy.OnPush, encapsulation: i0.ViewEncapsulation.None });
}
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.3.7", ngImport: i0, type: TriStateCheckbox, decorators: [{
type: Component,
args: [{
selector: 'p-triStateCheckbox',
template: `
<div
[ngStyle]="style"
[ngClass]="{ 'p-checkbox p-component': true, 'p-checkbox-disabled': disabled, 'p-checkbox-focused': focused, 'p-variant-filled': variant === 'filled' || config.inputStyle() === 'filled' }"
[class]="styleClass"
(click)="onClick($event, input)"
[attr.data-pc-name]="'tristatecheckbox'"
[attr.data-pc-section]="'root'"
>
<div class="p-hidden-accessible">
<input
#input
[attr.id]="inputId"
type="checkbox"
[name]="name"
[attr.tabindex]="tabindex"
[readonly]="readonly"
[disabled]="disabled"
(keydown)="onKeyDown($event)"
(focus)="onFocus()"
(blur)="onBlur()"
[attr.aria-labelledby]="ariaLabelledBy"
[attr.aria-label]="ariaLabel"
inputmode="none"
[attr.data-pc-section]="'hiddenInput'"
pAutoFocus
[autofocus]="autofocus"
/>
</div>
<div class="p-checkbox-box" role="checkbox" [attr.aria-checked]="value === true" [ngClass]="{ 'p-highlight': value != null, 'p-disabled': disabled, 'p-focus': focused }">
<ng-container *ngIf="value === true">
<span *ngIf="checkboxTrueIcon" [ngClass]="checkboxTrueIcon" class="p-checkbox-icon" [attr.data-pc-section]="'checkIcon'"></span>
<ng-container *ngIf="!checkboxTrueIcon">
<CheckIcon [styleClass]="'p-checkbox-icon'" *ngIf="!checkIconTemplate" [attr.data-pc-section]="'checkIcon'" />
<span *ngIf="checkIconTemplate" class="p-checkbox-icon" [attr.data-pc-section]="'checkIcon'">
<ng-template *ngTemplateOutlet="checkIconTemplate"></ng-template>
</span>
</ng-container>
</ng-container>
<ng-container *ngIf="value === false">
<span *ngIf="checkboxFalseIcon" [ngClass]="checkboxFalseIcon" class="p-checkbox-icon" [attr.data-pc-section]="'uncheckIcon'"></span>
<ng-container *ngIf="!checkboxFalseIcon">
<TimesIcon [styleClass]="'p-checkbox-icon'" *ngIf="!uncheckIconTemplate" [attr.data-pc-section]="'uncheckIcon'" />
<span class="p-checkbox-icon" *ngIf="uncheckIconTemplate" [attr.data-pc-section]="'uncheckIcon'">
<ng-template *ngTemplateOutlet="uncheckIconTemplate"></ng-template>
</span>
</ng-container>
</ng-container>
</div>
</div>
<label class="p-checkbox-label" (click)="onClick($event, input)" [ngClass]="{ 'p-checkbox-label-active': value != null, 'p-disabled': disabled, 'p-checkbox-label-focus': focused }" *ngIf="label" [attr.for]="inputId">{{ label }}</label>
`,
providers: [TRISTATECHECKBOX_VALUE_ACCESSOR],
changeDetection: ChangeDetectionStrategy.OnPush,
encapsulation: ViewEncapsulation.None,
host: {
class: 'p-element'
}
}]
}], ctorParameters: () => [{ type: i0.ChangeDetectorRef }, { type: i1.PrimeNGConfig }], propDecorators: { disabled: [{
type: Input,
args: [{ transform: booleanAttribute }]
}], name: [{
type: Input
}], ariaLabel: [{
type: Input
}], ariaLabelledBy: [{
type: Input
}], variant: [{
type: Input
}], tabindex: [{
type: Input,
args: [{ transform: numberAttribute }]
}], inputId: [{
type: Input
}], style: [{
type: Input
}], styleClass: [{
type: Input
}], label: [{
type: Input
}], readonly: [{
type: Input,
args: [{ transform: booleanAttribute }]
}], checkboxTrueIcon: [{
type: Input
}], checkboxFalseIcon: [{
type: Input
}], autofocus: [{
type: Input,
args: [{ transform: booleanAttribute }]
}], onChange: [{
type: Output
}], templates: [{
type: ContentChildren,
args: [PrimeTemplate]
}] } });
export class TriStateCheckboxModule {
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "17.3.7", ngImport: i0, type: TriStateCheckboxModule, deps: [], target: i0.ɵɵFactoryTarget.NgModule });
static ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "14.0.0", version: "17.3.7", ngImport: i0, type: TriStateCheckboxModule, declarations: [TriStateCheckbox], imports: [CommonModule, SharedModule, AutoFocusModule, CheckIcon, TimesIcon], exports: [TriStateCheckbox, SharedModule] });
static ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "17.3.7", ngImport: i0, type: TriStateCheckboxModule, imports: [CommonModule, SharedModule, AutoFocusModule, CheckIcon, TimesIcon, SharedModule] });
}
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.3.7", ngImport: i0, type: TriStateCheckboxModule, decorators: [{
type: NgModule,
args: [{
imports: [CommonModule, SharedModule, AutoFocusModule, CheckIcon, TimesIcon],
exports: [TriStateCheckbox, SharedModule],
declarations: [TriStateCheckbox]
}]
}] });
//# sour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