@tailng-ui/primitives 0.49.0 → 0.51.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tailng-ui/primitives",
3
- "version": "0.49.0",
3
+ "version": "0.51.0",
4
4
  "license": "MIT",
5
5
  "repository": {
6
6
  "type": "git",
@@ -17,7 +17,7 @@
17
17
  },
18
18
  "peerDependencies": {
19
19
  "@angular/core": "^21.1.0",
20
- "@tailng-ui/cdk": "^0.35.0",
20
+ "@tailng-ui/cdk": "^0.37.0",
21
21
  "tslib": "^2.3.0"
22
22
  },
23
23
  "sideEffects": false
@@ -9,6 +9,8 @@ export declare class TngInput {
9
9
  private readonly initialAriaLabel;
10
10
  private readonly initialAriaLabelledby;
11
11
  private readonly initialAriaDescribedBy;
12
+ private readonly initialAriaInvalid;
13
+ private readonly initialAriaRequired;
12
14
  private readonly generatedId;
13
15
  /** Canonical API for aria-describedby (whitespace normalized). */
14
16
  readonly ariaDescribedBy: import("@angular/core").InputSignal<string | null>;
@@ -33,7 +35,7 @@ export declare class TngInput {
33
35
  * Omit `aria-invalid` unless invalid. (Avoids noisy aria-invalid="false" and
34
36
  * makes unit tests + bindings more stable.)
35
37
  */
36
- protected get ariaInvalidAttr(): 'true' | null;
38
+ protected get ariaInvalidAttr(): 'false' | 'grammar' | 'spelling' | 'true' | null;
37
39
  protected get ariaRequiredAttr(): 'false' | 'true' | null;
38
40
  protected get dataDisabledAttr(): '' | null;
39
41
  protected get dataInvalidAttr(): '' | null;
@@ -1 +1 @@
1
- {"version":3,"file":"tng-input.d.ts","sourceRoot":"","sources":["../../../../../../../../libs/tailng-ui/primitives/src/lib/form/input/tng-input.ts"],"names":[],"mappings":";AAWA,KAAK,oBAAoB,GAAG,OAAO,GAAG,IAAI,GAAG,MAAM,GAAG,SAAS,CAAC;AAEhE,MAAM,MAAM,YAAY,GAAG,OAAO,GAAG,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A0E;IAC1E,SAAgB,WAAW,yFAExB;IAEH,SAAgB,YAAY,yFAEzB;IAEH,SAAgB,QAAQ,8EAA4E;IACpG,SAAgB,QAAQ,8EAA4E;IACpG,SAAgB,QAAQ,8EAA4E;IAGpG,SAAS,CAAC,QAAQ,CAAC,QAAQ,EAAG,OAAO,CAAU;IAG/C,SAAS,KAAK,MAAM,IAAI,MAAM,CAG7B;IAGD,SAAS,KAAK,aAAa,IAAI,MAAM,GAAG,IAAI,CAK3C;IAGD,SAAS,KAAK,kBAAkB,IAAI,MAAM,GAAG,IAAI,CAKhD;IAED;;;OAGG;IAEH,SAAS,KAAK,mBAAmB,IAAI,MAAM,GAAG,IAAI,CAKjD;IAED;;;OAGG;IAEH,SAAS,KAAK,eAAe,IAAI,OAAO,GAAG,SAAS,GAAG,UAAU,GAAG,MAAM,GAAG,IAAI,CAOhF;IAGD,SAAS,KAAK,gBAAgB,IAAI,OAAO,GAAG,MAAM,GAAG,IAAI,CAMxD;IAGD,SAAS,KAAK,gBAAgB,IAAI,EAAE,GAAG,IAAI,CAE1C;IAGD,SAAS,KAAK,eAAe,IAAI,EAAE,GAAG,IAAI,CAEzC;IAGD,SAAS,KAAK,gBAAgB,IAAI,EAAE,GAAG,IAAI,CAE1C;IAGD,SAAS,KAAK,YAAY,IAAI,EAAE,GAAG,IAAI,CAEtC;IAGD,SAAS,KAAK,YAAY,IAAI,EAAE,GAAG,IAAI,CAEtC;IAGD,SAAS,KAAK,YAAY,IAAI,EAAE,GAAG,IAAI,CAEtC;IAEM,SAAS,IAAI,OAAO;yCAhIhB,QAAQ;2CAAR,QAAQ;CAyIpB"}
@@ -21,6 +21,18 @@ function toAriaBoolean(value) {
21
21
  return null;
22
22
  return value ? 'true' : 'false';
23
23
  }
24
+ function normalizeAriaInvalidValue(value) {
25
+ const normalized = normalizeStringValue(value);
26
+ if (normalized === null)
27
+ return null;
28
+ if (normalized === 'false' ||
29
+ normalized === 'grammar' ||
30
+ normalized === 'spelling' ||
31
+ normalized === 'true') {
32
+ return normalized;
33
+ }
34
+ return 'true';
35
+ }
24
36
  export class TngInput {
25
37
  elementRef = inject((ElementRef));
26
38
  idService = inject(TngUniqueIdService);
@@ -28,6 +40,8 @@ export class TngInput {
28
40
  initialAriaLabel = normalizeStringValue(this.hostElement.getAttribute('aria-label'));
29
41
  initialAriaLabelledby = normalizeStringValue(this.hostElement.getAttribute('aria-labelledby'));
30
42
  initialAriaDescribedBy = normalizeStringValue(this.hostElement.getAttribute('aria-describedby'));
43
+ initialAriaInvalid = normalizeAriaInvalidValue(this.hostElement.getAttribute('aria-invalid'));
44
+ initialAriaRequired = coerceTngInputNullableBoolean(this.hostElement.getAttribute('aria-required'));
31
45
  generatedId = this.idService.nextId('tng-input');
32
46
  /** Canonical API for aria-describedby (whitespace normalized). */
33
47
  ariaDescribedBy = input(null, ...(ngDevMode ? [{ debugName: "ariaDescribedBy" }] : []));
@@ -71,12 +85,20 @@ export class TngInput {
71
85
  * makes unit tests + bindings more stable.)
72
86
  */
73
87
  get ariaInvalidAttr() {
74
- return this.isInvalid() ? 'true' : null;
88
+ const override = this.ariaInvalid();
89
+ if (override !== null)
90
+ return override ? 'true' : null;
91
+ if (this.initialAriaInvalid !== null)
92
+ return this.initialAriaInvalid;
93
+ return this.hostElement.matches(':invalid') ? 'true' : null;
75
94
  }
76
95
  get ariaRequiredAttr() {
77
96
  if (this.required())
78
97
  return 'true';
79
- return toAriaBoolean(this.ariaRequired());
98
+ const provided = toAriaBoolean(this.ariaRequired());
99
+ if (provided !== null)
100
+ return provided;
101
+ return toAriaBoolean(this.initialAriaRequired);
80
102
  }
81
103
  get dataDisabledAttr() {
82
104
  return this.disabled() ? '' : null;
@@ -100,6 +122,8 @@ export class TngInput {
100
122
  const override = this.ariaInvalid();
101
123
  if (override !== null)
102
124
  return override;
125
+ if (this.initialAriaInvalid !== null)
126
+ return this.initialAriaInvalid !== 'false';
103
127
  // jsdom may not fully implement validity; this is still correct for browsers.
104
128
  return this.hostElement.matches(':invalid');
105
129
  }
@@ -1 +1 @@
1
- {"version":3,"file":"tng-input.js","sourceRoot":"","sources":["../../../../../../../../libs/tailng-ui/primitives/src/lib/form/input/tng-input.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,SAAS,EACT,UAAU,EACV,WAAW,EACX,gBAAgB,EAChB,MAAM,EACN,KAAK,GACN,MAAM,eAAe,CAAC;AAEvB,OAAO,EAAE,kBAAkB,EAAE,MAAM,eAAe,CAAC;;AAMnD,MAAM,UAAU,6BAA6B,CAAC,KAA2B;IACvE,IAAI,KAAK,KAAK,SAAS,IAAI,KAAK,KAAK,IAAI;QAAE,OAAO,IAAI,CAAC;IAEvD,IAAI,KAAK,KAAK,EAAE,IAAI,KAAK,KAAK,IAAI,IAAI,KAAK,KAAK,MAAM;QAAE,OAAO,IAAI,CAAC;IAEpE,IAAI,KAAK,KAAK,KAAK,IAAI,KAAK,KAAK,OAAO;QAAE,OAAO,KAAK,CAAC;IAEvD,OAAO,IAAI,CAAC;AACd,CAAC;AAED,SAAS,oBAAoB,CAAC,KAAgC;IAC5D,IAAI,KAAK,KAAK,SAAS,IAAI,KAAK,KAAK,IAAI;QAAE,OAAO,IAAI,CAAC;IAEvD,MAAM,UAAU,GAAG,KAAK,CAAC,IAAI,EAAE,CAAC;IAChC,OAAO,UAAU,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC,CAAC,UAAU,CAAC,CAAC,CAAC,IAAI,CAAC;AACnD,CAAC;AAED,SAAS,aAAa,CAAC,KAAqB;IAC1C,IAAI,KAAK,KAAK,IAAI;QAAE,OAAO,IAAI,CAAC;IAChC,OAAO,KAAK,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,OAAO,CAAC;AAClC,CAAC;AAMD,MAAM,OAAO,QAAQ;IACF,UAAU,GAAG,MAAM,CAAC,CAAA,UAAkD,CAAA,CAAC,CAAC;IACxE,SAAS,GAAG,MAAM,CAAC,kBAAkB,CAAC,CAAC;IAExC,WAAW,GAAG,IAAI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ED,IACc,YAAY;QACxB,OAAO,IAAI,CAAC,QAAQ,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,IAAI,CAAC;IACrC,CAAC;IAED,IACc,YAAY;QACxB,OAAO,IAAI,CAAC,QAAQ,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,IAAI,CAAC;IACrC,CAAC;IAED,IACc,YAAY;QACxB,OAAO,IAAI,CAAC,QAAQ,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,IAAI,CAAC;IACrC,CAAC;IAEM,SAAS;QACd,MAAM,QAAQ,GAAG,IAAI,CAAC,WAAW,EAAE,CAAC;QACpC,IAAI,QAAQ,KAAK,IAAI;YAAE,OAAO,QAAQ,CAAC;QAEvC,8EAA8E;QAC9E,OAAO,IAAI,CAAC,WAAW,CAAC,OAAO,CAAC,UAAU,CAAC,CAAC;IAC9C,CAAC;uGAxHU,QAAQ;2FAAR,QAAQ;;2FAAR,QAAQ;kBAJpB,SAAS;mBAAC;oBACT,QAAQ,EAAE,qCAAqC;oBAC/C,QAAQ,EAAE,UAAU;iBACrB;;sBAiCE,WAAW;uBAAC,gBAAgB;;sBAG5B,WAAW;uBAAC,SAAS;;sBAMrB,WAAW;uBAAC,iBAAiB;;sBAQ7B,WAAW;uBAAC,sBAAsB;;sBAYlC,WAAW;uBAAC,uBAAuB;;sBAYnC,WAAW;uBAAC,mBAAmB;;sBAK/B,WAAW;uBAAC,oBAAoB;;sBAMhC,WAAW;uBAAC,oBAAoB;;sBAKhC,WAAW;uBAAC,mBAAmB;;sBAK/B,WAAW;uBAAC,oBAAoB;;sBAKhC,WAAW;uBAAC,eAAe;;sBAK3B,WAAW;uBAAC,eAAe;;sBAK3B,WAAW;uBAAC,eAAe","sourcesContent":["import {\n Directive,\n ElementRef,\n HostBinding,\n booleanAttribute,\n inject,\n input,\n} from '@angular/core';\n\nimport { TngUniqueIdService } from '../_shared/id';\n\ntype NullableBooleanInput = boolean | null | string | undefined;\n\nexport type TngInputType = 'email' | 'number' | 'password' | 'search' | 'tel' | 'text' | 'url';\n\nexport function coerceTngInputNullableBoolean(value: NullableBooleanInput): boolean | null {\n if (value === undefined || value === null) return null;\n\n if (value === '' || value === true || value === 'true') return true;\n\n if (value === false || value === 'false') return false;\n\n return null;\n}\n\nfunction normalizeStringValue(value: string | null | undefined): string | null {\n if (value === undefined || value === null) return null;\n\n const normalized = value.trim();\n return normalized.length > 0 ? normalized : null;\n}\n\nfunction toAriaBoolean(value: boolean | null): 'false' | 'true' | null {\n if (value === null) return null;\n return value ? 'true' : 'false';\n}\n\n@Directive({\n selector: 'input[tngInput], textarea[tngInput]',\n exportAs: 'tngInput',\n})\nexport class TngInput {\n private readonly elementRef = inject(ElementRef<HTMLInputElement | HTMLTextAreaElement>);\n private readonly idService = inject(TngUniqueIdService);\n\n public readonly hostElement = this.elementRef.nativeElement;\n private readonly initialAriaLabel = normalizeStringValue(this.hostElement.getAttribute('aria-label'));\n private readonly initialAriaLabelledby = normalizeStringValue(this.hostElement.getAttribute('aria-labelledby'));\n private readonly initialAriaDescribedBy = normalizeStringValue(\n this.hostElement.getAttribute('aria-describedby'),\n );\n\n private readonly generatedId = this.idService.nextId('tng-input');\n\n /** Canonical API for aria-describedby (whitespace normalized). */\n public readonly ariaDescribedBy = input<string | null>(null);\n\n public readonly ariaLabel = input<string | null>(null);\n public readonly ariaLabelledby = input<string | null>(null);\n\n /** If non-null, this value overrides native validity in `isInvalid()`. */\n public readonly ariaInvalid = input<boolean | null, NullableBooleanInput>(null, {\n transform: coerceTngInputNullableBoolean,\n });\n\n public readonly ariaRequired = input<boolean | null, NullableBooleanInput>(null, {\n transform: coerceTngInputNullableBoolean,\n });\n\n public readonly disabled = input<boolean, boolean | string>(false, { transform: booleanAttribute });\n public readonly readonly = input<boolean, boolean | string>(false, { transform: booleanAttribute });\n public readonly required = input<boolean, boolean | string>(false, { transform: booleanAttribute });\n\n @HostBinding('attr.data-slot')\n protected readonly dataSlot = 'input' as const;\n\n @HostBinding('attr.id')\n protected get idAttr(): string {\n const nativeId = normalizeStringValue(this.hostElement.getAttribute('id'));\n return nativeId ?? this.generatedId;\n }\n\n @HostBinding('attr.aria-label')\n protected get ariaLabelAttr(): string | null {\n const provided = normalizeStringValue(this.ariaLabel());\n if (provided !== null) return provided;\n\n return this.initialAriaLabel;\n }\n\n @HostBinding('attr.aria-labelledby')\n protected get ariaLabelledbyAttr(): string | null {\n const provided = normalizeStringValue(this.ariaLabelledby());\n if (provided !== null) return provided;\n\n return this.initialAriaLabelledby;\n }\n\n /**\n * If the consumer provided a native `aria-describedby` and the input is not set,\n * preserve it (do not clobber).\n */\n @HostBinding('attr.aria-describedby')\n protected get ariaDescribedByAttr(): string | null {\n const provided = normalizeStringValue(this.ariaDescribedBy());\n if (provided !== null) return provided;\n\n return this.initialAriaDescribedBy;\n }\n\n /**\n * Omit `aria-invalid` unless invalid. (Avoids noisy aria-invalid=\"false\" and\n * makes unit tests + bindings more stable.)\n */\n @HostBinding('attr.aria-invalid')\n protected get ariaInvalidAttr(): 'true' | null {\n return this.isInvalid() ? 'true' : null;\n }\n\n @HostBinding('attr.aria-required')\n protected get ariaRequiredAttr(): 'false' | 'true' | null {\n if (this.required()) return 'true';\n return toAriaBoolean(this.ariaRequired());\n }\n\n @HostBinding('attr.data-disabled')\n protected get dataDisabledAttr(): '' | null {\n return this.disabled() ? '' : null;\n }\n\n @HostBinding('attr.data-invalid')\n protected get dataInvalidAttr(): '' | null {\n return this.isInvalid() ? '' : null;\n }\n\n @HostBinding('attr.data-readonly')\n protected get dataReadonlyAttr(): '' | null {\n return this.readonly() ? '' : null;\n }\n\n @HostBinding('attr.disabled')\n protected get disabledAttr(): '' | null {\n return this.disabled() ? '' : null;\n }\n\n @HostBinding('attr.readonly')\n protected get readonlyAttr(): '' | null {\n return this.readonly() ? '' : null;\n }\n\n @HostBinding('attr.required')\n protected get requiredAttr(): '' | null {\n return this.required() ? '' : null;\n }\n\n public isInvalid(): boolean {\n const override = this.ariaInvalid();\n if (override !== null) return override;\n\n // jsdom may not fully implement validity; this is still correct for browsers.\n return this.hostElement.matches(':invalid');\n }\n}\n\n"]}
1
+ {"version":3,"file":"tng-input.js","sourceRoot":"","sources":["../../../../../../../../libs/tailng-ui/primitives/src/lib/form/input/tng-input.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,SAAS,EACT,UAAU,EACV,WAAW,EACX,gBAAgB,EAChB,MAAM,EACN,KAAK,GACN,MAAM,eAAe,CAAC;AAEvB,OAAO,EAAE,kBAAkB,EAAE,MAAM,eAAe,CAAC;;AAMnD,MAAM,UAAU,6BAA6B,CAAC,KAA2B;IACvE,IAAI,KAAK,KAAK,SAAS,IAAI,KAAK,KAAK,IAAI;QAAE,OAAO,IAAI,CAAC;IAEvD,IAAI,KAAK,KAAK,EAAE,IAAI,KAAK,KAAK,IAAI,IAAI,KAAK,KAAK,MAAM;QAAE,OAAO,IAAI,CAAC;IAEpE,IAAI,KAAK,KAAK,KAAK,IAAI,KAAK,KAAK,OAAO;QAAE,OAAO,KAAK,CAAC;IAEvD,OAAO,IAAI,CAAC;AACd,CAAC;AAED,SAAS,oBAAoB,CAAC,KAAgC;IAC5D,IAAI,KAAK,KAAK,SAAS,IAAI,KAAK,KAAK,IAAI;QAAE,OAAO,IAAI,CAAC;IAEvD,MAAM,UAAU,GAAG,KAAK,CAAC,IAAI,EAAE,CAAC;IAChC,OAAO,UAAU,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC,CAAC,UAAU,CAAC,CAAC,CAAC,IAAI,CAAC;AACnD,CAAC;AAED,SAAS,aAAa,CAAC,KAAqB;IAC1C,IAAI,KAAK,KAAK,IAAI;QAAE,OAAO,IAAI,CAAC;IAChC,OAAO,KAAK,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,OAAO,CAAC;AAClC,CAAC;AAED,SAAS,yBAAyB,CAAC,KAAgC;IACjE,MAAM,UAAU,GAAG,oBAAoB,CAAC,KAAK,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AED,IACc,YAAY;QACxB,OAAO,IAAI,CAAC,QAAQ,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,IAAI,CAAC;IACrC,CAAC;IAEM,SAAS;QACd,MAAM,QAAQ,GAAG,IAAI,CAAC,WAAW,EAAE,CAAC;QACpC,IAAI,QAAQ,KAAK,IAAI;YAAE,OAAO,QAAQ,CAAC;QAEvC,IAAI,IAAI,CAAC,kBAAkB,KAAK,IAAI;YAAE,OAAO,IAAI,CAAC,kBAAkB,KAAK,OAAO,CAAC;QAEjF,8EAA8E;QAC9E,OAAO,IAAI,CAAC,WAAW,CAAC,OAAO,CAAC,UAAU,CAAC,CAAC;IAC9C,CAAC;uGAxIU,QAAQ;2FAAR,QAAQ;;2FAAR,QAAQ;kBAJpB,SAAS;mBAAC;oBACT,QAAQ,EAAE,qCAAqC;oBAC/C,QAAQ,EAAE,UAAU;iBACrB;;sBAuCE,WAAW;uBAAC,gBAAgB;;sBAG5B,WAAW;uBAAC,SAAS;;sBAMrB,WAAW;uBAAC,iBAAiB;;sBAQ7B,WAAW;uBAAC,sBAAsB;;sBAYlC,WAAW;uBAAC,uBAAuB;;sBAYnC,WAAW;uBAAC,mBAAmB;;sBAU/B,WAAW;uBAAC,oBAAoB;;sBAShC,WAAW;uBAAC,oBAAoB;;sBAKhC,WAAW;uBAAC,mBAAmB;;sBAK/B,WAAW;uBAAC,oBAAoB;;sBAKhC,WAAW;uBAAC,eAAe;;sBAK3B,WAAW;uBAAC,eAAe;;sBAK3B,WAAW;uBAAC,eAAe","sourcesContent":["import {\n Directive,\n ElementRef,\n HostBinding,\n booleanAttribute,\n inject,\n input,\n} from '@angular/core';\n\nimport { TngUniqueIdService } from '../_shared/id';\n\ntype NullableBooleanInput = boolean | null | string | undefined;\n\nexport type TngInputType = 'email' | 'number' | 'password' | 'search' | 'tel' | 'text' | 'url';\n\nexport function coerceTngInputNullableBoolean(value: NullableBooleanInput): boolean | null {\n if (value === undefined || value === null) return null;\n\n if (value === '' || value === true || value === 'true') return true;\n\n if (value === false || value === 'false') return false;\n\n return null;\n}\n\nfunction normalizeStringValue(value: string | null | undefined): string | null {\n if (value === undefined || value === null) return null;\n\n const normalized = value.trim();\n return normalized.length > 0 ? normalized : null;\n}\n\nfunction toAriaBoolean(value: boolean | null): 'false' | 'true' | null {\n if (value === null) return null;\n return value ? 'true' : 'false';\n}\n\nfunction normalizeAriaInvalidValue(value: string | null | undefined): 'false' | 'grammar' | 'spelling' | 'true' | null {\n const normalized = normalizeStringValue(value);\n if (normalized === null) return null;\n\n if (\n normalized === 'false' ||\n normalized === 'grammar' ||\n normalized === 'spelling' ||\n normalized === 'true'\n ) {\n return normalized;\n }\n\n return 'true';\n}\n\n@Directive({\n selector: 'input[tngInput], textarea[tngInput]',\n exportAs: 'tngInput',\n})\nexport class TngInput {\n private readonly elementRef = inject(ElementRef<HTMLInputElement | HTMLTextAreaElement>);\n private readonly idService = inject(TngUniqueIdService);\n\n public readonly hostElement = this.elementRef.nativeElement;\n private readonly initialAriaLabel = normalizeStringValue(this.hostElement.getAttribute('aria-label'));\n private readonly initialAriaLabelledby = normalizeStringValue(this.hostElement.getAttribute('aria-labelledby'));\n private readonly initialAriaDescribedBy = normalizeStringValue(\n this.hostElement.getAttribute('aria-describedby'),\n );\n private readonly initialAriaInvalid = normalizeAriaInvalidValue(\n this.hostElement.getAttribute('aria-invalid'),\n );\n private readonly initialAriaRequired = coerceTngInputNullableBoolean(\n this.hostElement.getAttribute('aria-required'),\n );\n\n private readonly generatedId = this.idService.nextId('tng-input');\n\n /** Canonical API for aria-describedby (whitespace normalized). */\n public readonly ariaDescribedBy = input<string | null>(null);\n\n public readonly ariaLabel = input<string | null>(null);\n public readonly ariaLabelledby = input<string | null>(null);\n\n /** If non-null, this value overrides native validity in `isInvalid()`. */\n public readonly ariaInvalid = input<boolean | null, NullableBooleanInput>(null, {\n transform: coerceTngInputNullableBoolean,\n });\n\n public readonly ariaRequired = input<boolean | null, NullableBooleanInput>(null, {\n transform: coerceTngInputNullableBoolean,\n });\n\n public readonly disabled = input<boolean, boolean | string>(false, { transform: booleanAttribute });\n public readonly readonly = input<boolean, boolean | string>(false, { transform: booleanAttribute });\n public readonly required = input<boolean, boolean | string>(false, { transform: booleanAttribute });\n\n @HostBinding('attr.data-slot')\n protected readonly dataSlot = 'input' as const;\n\n @HostBinding('attr.id')\n protected get idAttr(): string {\n const nativeId = normalizeStringValue(this.hostElement.getAttribute('id'));\n return nativeId ?? this.generatedId;\n }\n\n @HostBinding('attr.aria-label')\n protected get ariaLabelAttr(): string | null {\n const provided = normalizeStringValue(this.ariaLabel());\n if (provided !== null) return provided;\n\n return this.initialAriaLabel;\n }\n\n @HostBinding('attr.aria-labelledby')\n protected get ariaLabelledbyAttr(): string | null {\n const provided = normalizeStringValue(this.ariaLabelledby());\n if (provided !== null) return provided;\n\n return this.initialAriaLabelledby;\n }\n\n /**\n * If the consumer provided a native `aria-describedby` and the input is not set,\n * preserve it (do not clobber).\n */\n @HostBinding('attr.aria-describedby')\n protected get ariaDescribedByAttr(): string | null {\n const provided = normalizeStringValue(this.ariaDescribedBy());\n if (provided !== null) return provided;\n\n return this.initialAriaDescribedBy;\n }\n\n /**\n * Omit `aria-invalid` unless invalid. (Avoids noisy aria-invalid=\"false\" and\n * makes unit tests + bindings more stable.)\n */\n @HostBinding('attr.aria-invalid')\n protected get ariaInvalidAttr(): 'false' | 'grammar' | 'spelling' | 'true' | null {\n const override = this.ariaInvalid();\n if (override !== null) return override ? 'true' : null;\n\n if (this.initialAriaInvalid !== null) return this.initialAriaInvalid;\n\n return this.hostElement.matches(':invalid') ? 'true' : null;\n }\n\n @HostBinding('attr.aria-required')\n protected get ariaRequiredAttr(): 'false' | 'true' | null {\n if (this.required()) return 'true';\n const provided = toAriaBoolean(this.ariaRequired());\n if (provided !== null) return provided;\n\n return toAriaBoolean(this.initialAriaRequired);\n }\n\n @HostBinding('attr.data-disabled')\n protected get dataDisabledAttr(): '' | null {\n return this.disabled() ? '' : null;\n }\n\n @HostBinding('attr.data-invalid')\n protected get dataInvalidAttr(): '' | null {\n return this.isInvalid() ? '' : null;\n }\n\n @HostBinding('attr.data-readonly')\n protected get dataReadonlyAttr(): '' | null {\n return this.readonly() ? '' : null;\n }\n\n @HostBinding('attr.disabled')\n protected get disabledAttr(): '' | null {\n return this.disabled() ? '' : null;\n }\n\n @HostBinding('attr.readonly')\n protected get readonlyAttr(): '' | null {\n return this.readonly() ? '' : null;\n }\n\n @HostBinding('attr.required')\n protected get requiredAttr(): '' | null {\n return this.required() ? '' : null;\n }\n\n public isInvalid(): boolean {\n const override = this.ariaInvalid();\n if (override !== null) return override;\n\n if (this.initialAriaInvalid !== null) return this.initialAriaInvalid !== 'false';\n\n // jsdom may not fully implement validity; this is still correct for browsers.\n return this.hostElement.matches(':invalid');\n }\n}\n"]}