@spartan-ng/brain 1.8.3 → 1.9.0-beta.1

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.
@@ -1,69 +1,98 @@
1
1
  import * as i0 from '@angular/core';
2
- import { signal, computed, Directive, contentChild, ChangeDetectionStrategy, Component, Pipe } from '@angular/core';
2
+ import { signal, Directive, inject, computed, ElementRef, DestroyRef, input, Pipe } from '@angular/core';
3
3
 
4
- class BrnAvatarImage {
5
- _loaded = signal(false, ...(ngDevMode ? [{ debugName: "_loaded" }] : /* istanbul ignore next */ []));
6
- _onError() {
7
- this._loaded.set(false);
8
- }
9
- _onLoad() {
10
- this._loaded.set(true);
4
+ /**
5
+ * Avatar container. Provides the positioning context for the absolutely positioned image and
6
+ * intentionally does not set `display`.
7
+ */
8
+ class BrnAvatar {
9
+ _status = signal('idle', ...(ngDevMode ? [{ debugName: "_status" }] : /* istanbul ignore next */ []));
10
+ status = this._status.asReadonly();
11
+ /** @internal */
12
+ setStatus(status) {
13
+ this._status.set(status);
11
14
  }
12
- canShow = computed(() => this._loaded(), ...(ngDevMode ? [{ debugName: "canShow" }] : /* istanbul ignore next */ []));
13
- /** @nocollapse */ static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.2.16", ngImport: i0, type: BrnAvatarImage, deps: [], target: i0.ɵɵFactoryTarget.Directive });
14
- /** @nocollapse */ static ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "21.2.16", type: BrnAvatarImage, isStandalone: true, selector: "img[brnAvatarImage]", host: { listeners: { "load": "_onLoad()", "error": "_onError()" } }, exportAs: ["brnAvatarImage"], ngImport: i0 });
15
+ /** @nocollapse */ static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.2.16", ngImport: i0, type: BrnAvatar, deps: [], target: i0.ɵɵFactoryTarget.Directive });
16
+ /** @nocollapse */ static ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "21.2.16", type: BrnAvatar, isStandalone: true, selector: "[brnAvatar],brn-avatar", host: { properties: { "style.position": "'relative'", "attr.data-status": "status()" } }, exportAs: ["brnAvatar"], ngImport: i0 });
15
17
  }
16
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.16", ngImport: i0, type: BrnAvatarImage, decorators: [{
18
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.16", ngImport: i0, type: BrnAvatar, decorators: [{
17
19
  type: Directive,
18
20
  args: [{
19
- selector: 'img[brnAvatarImage]',
20
- exportAs: 'brnAvatarImage',
21
+ selector: '[brnAvatar],brn-avatar',
22
+ exportAs: 'brnAvatar',
21
23
  host: {
22
- '(load)': '_onLoad()',
23
- '(error)': '_onError()',
24
+ '[style.position]': "'relative'",
25
+ '[attr.data-status]': 'status()',
24
26
  },
25
27
  }]
26
28
  }] });
27
29
 
28
- class BrnAvatar {
29
- _image = contentChild(BrnAvatarImage, ...(ngDevMode ? [{ debugName: "_image" }] : /* istanbul ignore next */ []));
30
- /** @nocollapse */ static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.2.16", ngImport: i0, type: BrnAvatar, deps: [], target: i0.ɵɵFactoryTarget.Component });
31
- /** @nocollapse */ static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "21.2.16", type: BrnAvatar, isStandalone: true, selector: "brn-avatar", queries: [{ propertyName: "_image", first: true, predicate: BrnAvatarImage, descendants: true, isSignal: true }], exportAs: ["brnAvatar"], ngImport: i0, template: `
32
- @if (_image()?.canShow()) {
33
- <ng-content select="[brnAvatarImage]" />
34
- } @else {
35
- <ng-content select="[brnAvatarFallback]" />
36
- }
37
- `, isInline: true, changeDetection: i0.ChangeDetectionStrategy.OnPush });
38
- }
39
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.16", ngImport: i0, type: BrnAvatar, decorators: [{
40
- type: Component,
41
- args: [{
42
- selector: 'brn-avatar',
43
- exportAs: 'brnAvatar',
44
- changeDetection: ChangeDetectionStrategy.OnPush,
45
- template: `
46
- @if (_image()?.canShow()) {
47
- <ng-content select="[brnAvatarImage]" />
48
- } @else {
49
- <ng-content select="[brnAvatarFallback]" />
50
- }
51
- `,
52
- }]
53
- }], propDecorators: { _image: [{ type: i0.ContentChild, args: [i0.forwardRef(() => BrnAvatarImage), { isSignal: true }] }] } });
54
-
55
30
  class BrnAvatarFallback {
31
+ _avatar = inject(BrnAvatar);
32
+ _hidden = computed(() => this._avatar.status() === 'loaded', ...(ngDevMode ? [{ debugName: "_hidden" }] : /* istanbul ignore next */ []));
56
33
  /** @nocollapse */ static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.2.16", ngImport: i0, type: BrnAvatarFallback, deps: [], target: i0.ɵɵFactoryTarget.Directive });
57
- /** @nocollapse */ static ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "21.2.16", type: BrnAvatarFallback, isStandalone: true, selector: "[brnAvatarFallback]", exportAs: ["brnAvatarFallback"], ngImport: i0 });
34
+ /** @nocollapse */ static ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "21.2.16", type: BrnAvatarFallback, isStandalone: true, selector: "[brnAvatarFallback]", host: { properties: { "style.visibility": "_hidden() ? 'hidden' : null" } }, exportAs: ["brnAvatarFallback"], ngImport: i0 });
58
35
  }
59
36
  i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.16", ngImport: i0, type: BrnAvatarFallback, decorators: [{
60
37
  type: Directive,
61
38
  args: [{
62
39
  selector: '[brnAvatarFallback]',
63
40
  exportAs: 'brnAvatarFallback',
41
+ host: {
42
+ '[style.visibility]': "_hidden() ? 'hidden' : null",
43
+ },
64
44
  }]
65
45
  }] });
66
46
 
47
+ class BrnAvatarImage {
48
+ _avatar = inject(BrnAvatar);
49
+ _image = inject(ElementRef).nativeElement;
50
+ _destroyRef = inject(DestroyRef);
51
+ /**
52
+ * Styles applied to the host element. Bound via `[style]` so they apply through the CSSOM and are
53
+ * not blocked by a strict Content-Security-Policy.
54
+ */
55
+ hostStyles = input('position: absolute; inset: 0; width: 100%; height: 100%', ...(ngDevMode ? [{ debugName: "hostStyles" }] : /* istanbul ignore next */ []));
56
+ canShow = computed(() => this._avatar.status() === 'loaded', ...(ngDevMode ? [{ debugName: "canShow" }] : /* istanbul ignore next */ []));
57
+ constructor() {
58
+ // The image may already be loaded before this directive is created, e.g. during hydration
59
+ // or when a cached image is reused. In that case the load event will never fire.
60
+ if (this._image.complete && this._image.naturalWidth > 0) {
61
+ this._onLoad();
62
+ }
63
+ else {
64
+ this._avatar.setStatus('loading');
65
+ }
66
+ // If the image is removed, the fallback should become visible again.
67
+ this._destroyRef.onDestroy(() => {
68
+ if (this._avatar.status() !== 'idle') {
69
+ this._avatar.setStatus('idle');
70
+ }
71
+ });
72
+ }
73
+ _onError() {
74
+ this._avatar.setStatus('error');
75
+ }
76
+ _onLoad() {
77
+ this._avatar.setStatus('loaded');
78
+ }
79
+ /** @nocollapse */ static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.2.16", ngImport: i0, type: BrnAvatarImage, deps: [], target: i0.ɵɵFactoryTarget.Directive });
80
+ /** @nocollapse */ static ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "17.1.0", version: "21.2.16", type: BrnAvatarImage, isStandalone: true, selector: "img[brnAvatarImage]", inputs: { hostStyles: { classPropertyName: "hostStyles", publicName: "hostStyles", isSignal: true, isRequired: false, transformFunction: null } }, host: { listeners: { "load": "_onLoad()", "error": "_onError()" }, properties: { "style": "hostStyles()", "style.visibility": "canShow() ? null : 'hidden'" } }, exportAs: ["brnAvatarImage"], ngImport: i0 });
81
+ }
82
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.16", ngImport: i0, type: BrnAvatarImage, decorators: [{
83
+ type: Directive,
84
+ args: [{
85
+ selector: 'img[brnAvatarImage]',
86
+ exportAs: 'brnAvatarImage',
87
+ host: {
88
+ '[style]': 'hostStyles()',
89
+ '[style.visibility]': "canShow() ? null : 'hidden'",
90
+ '(load)': '_onLoad()',
91
+ '(error)': '_onError()',
92
+ },
93
+ }]
94
+ }], ctorParameters: () => [], propDecorators: { hostStyles: [{ type: i0.Input, args: [{ isSignal: true, alias: "hostStyles", required: false }] }] } });
95
+
67
96
  function hashString(str) {
68
97
  let h;
69
98
  for (let i = 0; i < str.length; i++)
@@ -1 +1 @@
1
- {"version":3,"file":"spartan-ng-brain-avatar.mjs","sources":["../../../../libs/brain/avatar/src/lib/image/brn-avatar-image.ts","../../../../libs/brain/avatar/src/lib/brn-avatar.ts","../../../../libs/brain/avatar/src/lib/fallback/brn-avatar-fallback.ts","../../../../libs/brain/avatar/src/lib/util/hex-color-for.ts","../../../../libs/brain/avatar/src/lib/util/initials.pipe.ts","../../../../libs/brain/avatar/src/lib/util/is-bright.ts","../../../../libs/brain/avatar/src/index.ts","../../../../libs/brain/avatar/src/spartan-ng-brain-avatar.ts"],"sourcesContent":["import { Directive, computed, signal } from '@angular/core';\n\n@Directive({\n\tselector: 'img[brnAvatarImage]',\n\texportAs: 'brnAvatarImage',\n\thost: {\n\t\t'(load)': '_onLoad()',\n\t\t'(error)': '_onError()',\n\t},\n})\nexport class BrnAvatarImage {\n\tprivate readonly _loaded = signal(false);\n\n\tprotected _onError() {\n\t\tthis._loaded.set(false);\n\t}\n\n\tprotected _onLoad() {\n\t\tthis._loaded.set(true);\n\t}\n\n\tpublic readonly canShow = computed(() => this._loaded());\n}\n","import { ChangeDetectionStrategy, Component, contentChild } from '@angular/core';\nimport { BrnAvatarImage } from './image';\n\n@Component({\n\tselector: 'brn-avatar',\n\texportAs: 'brnAvatar',\n\tchangeDetection: ChangeDetectionStrategy.OnPush,\n\ttemplate: `\n\t\t@if (_image()?.canShow()) {\n\t\t\t<ng-content select=\"[brnAvatarImage]\" />\n\t\t} @else {\n\t\t\t<ng-content select=\"[brnAvatarFallback]\" />\n\t\t}\n\t`,\n})\nexport class BrnAvatar {\n\tprotected readonly _image = contentChild(BrnAvatarImage);\n}\n","import { Directive } from '@angular/core';\n\n@Directive({\n\tselector: '[brnAvatarFallback]',\n\texportAs: 'brnAvatarFallback',\n})\nexport class BrnAvatarFallback {}\n","function hashString(str: string) {\n\tlet h;\n\tfor (let i = 0; i < str.length; i++) h = (Math.imul(31, h || 0) + str.charCodeAt(i)) | 0;\n\n\treturn h || 0;\n}\n\nfunction hashManyTimes(times: number, str: string) {\n\tlet h = hashString(str);\n\n\tfor (let i = 0; i < times; i++) h = hashString(String(h));\n\n\treturn h;\n}\n\nexport function hexColorFor(str: string) {\n\tconst hash = str.length <= 2 ? hashManyTimes(5, str) : hashString(str);\n\n\tlet color = '#';\n\n\tfor (let i = 0; i < 3; i += 1) {\n\t\tconst value = (hash >> (i * 8)) & 0xff;\n\t\tcolor += `00${value.toString(16)}`.slice(-2);\n\t}\n\n\treturn color;\n}\n","import { Pipe, type PipeTransform } from '@angular/core';\n\nconst toInitial =\n\t(capitalize = true) =>\n\t(word: string) => {\n\t\tconst initial = word.charAt(0);\n\t\treturn capitalize ? initial.toLocaleUpperCase() : initial;\n\t};\n\nconst firstAndLast = (initials: string[]) => `${initials[0]}${initials[initials.length - 1]}`;\n\n@Pipe({\n\tname: 'initials',\n})\nexport class InitialsPipe implements PipeTransform {\n\ttransform(name: string, capitalize = true, firstAndLastOnly = true, delimiter = ' '): string {\n\t\tif (!name) return '';\n\n\t\tconst initials = name.trim().split(delimiter).filter(Boolean).map(toInitial(capitalize));\n\n\t\tif (firstAndLastOnly && initials.length > 1) return firstAndLast(initials);\n\n\t\treturn initials.join('');\n\t}\n}\n","const isShortHand = (hex: string) => hex.length === 3;\n\nconst cleanup = (hex: string) => {\n\tconst noHash = hex.replace('#', '').trim().toLowerCase();\n\n\tif (!isShortHand(noHash)) return noHash;\n\n\treturn noHash\n\t\t.split('')\n\t\t.map((char) => char + char)\n\t\t.join('');\n};\n\nexport const isBright = (hex: string) => Number.parseInt(cleanup(hex), 16) > 0xffffff / 1.25;\n","import { BrnAvatar } from './lib/brn-avatar';\nimport { BrnAvatarFallback } from './lib/fallback';\nimport { BrnAvatarImage } from './lib/image';\n\nexport * from './lib/brn-avatar';\nexport * from './lib/fallback';\nexport * from './lib/image';\nexport * from './lib/util';\n\nexport const BrnAvatarImports = [BrnAvatar, BrnAvatarFallback, BrnAvatarImage] as const;\n","/**\n * Generated bundle index. Do not edit.\n */\n\nexport * from './index';\n"],"names":[],"mappings":";;;MAUa,cAAc,CAAA;AACT,IAAA,OAAO,GAAG,MAAM,CAAC,KAAK,8EAAC;IAE9B,QAAQ,GAAA;AACjB,QAAA,IAAI,CAAC,OAAO,CAAC,GAAG,CAAC,KAAK,CAAC;IACxB;IAEU,OAAO,GAAA;AAChB,QAAA,IAAI,CAAC,OAAO,CAAC,GAAG,CAAC,IAAI,CAAC;IACvB;IAEgB,OAAO,GAAG,QAAQ,CAAC,MAAM,IAAI,CAAC,OAAO,EAAE,EAAA,IAAA,SAAA,GAAA,CAAA,EAAA,SAAA,EAAA,SAAA,EAAA,CAAA,8BAAA,EAAA,CAAA,CAAC;2HAX5C,cAAc,EAAA,IAAA,EAAA,EAAA,EAAA,MAAA,EAAA,EAAA,CAAA,eAAA,CAAA,SAAA,EAAA,CAAA;+GAAd,cAAc,EAAA,YAAA,EAAA,IAAA,EAAA,QAAA,EAAA,qBAAA,EAAA,IAAA,EAAA,EAAA,SAAA,EAAA,EAAA,MAAA,EAAA,WAAA,EAAA,OAAA,EAAA,YAAA,EAAA,EAAA,EAAA,QAAA,EAAA,CAAA,gBAAA,CAAA,EAAA,QAAA,EAAA,EAAA,EAAA,CAAA;;4FAAd,cAAc,EAAA,UAAA,EAAA,CAAA;kBAR1B,SAAS;AAAC,YAAA,IAAA,EAAA,CAAA;AACV,oBAAA,QAAQ,EAAE,qBAAqB;AAC/B,oBAAA,QAAQ,EAAE,gBAAgB;AAC1B,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;kBAHxB,IAAI;AAAC,YAAA,IAAA,EAAA,CAAA;AACL,oBAAA,IAAI,EAAE,UAAU;AAChB,iBAAA;;;ACbD,MAAM,WAAW,GAAG,CAAC,GAAW,KAAK,GAAG,CAAC,MAAM,KAAK,CAAC;AAErD,MAAM,OAAO,GAAG,CAAC,GAAW,KAAI;AAC/B,IAAA,MAAM,MAAM,GAAG,GAAG,CAAC,OAAO,CAAC,GAAG,EAAE,EAAE,CAAC,CAAC,IAAI,EAAE,CAAC,WAAW,EAAE;AAExD,IAAA,IAAI,CAAC,WAAW,CAAC,MAAM,CAAC;AAAE,QAAA,OAAO,MAAM;AAEvC,IAAA,OAAO;SACL,KAAK,CAAC,EAAE;SACR,GAAG,CAAC,CAAC,IAAI,KAAK,IAAI,GAAG,IAAI;SACzB,IAAI,CAAC,EAAE,CAAC;AACX,CAAC;AAEM,MAAM,QAAQ,GAAG,CAAC,GAAW,KAAK,MAAM,CAAC,QAAQ,CAAC,OAAO,CAAC,GAAG,CAAC,EAAE,EAAE,CAAC,GAAG,QAAQ,GAAG;;ACJjF,MAAM,gBAAgB,GAAG,CAAC,SAAS,EAAE,iBAAiB,EAAE,cAAc;;ACT7E;;AAEG;;;;"}
1
+ {"version":3,"file":"spartan-ng-brain-avatar.mjs","sources":["../../../../libs/brain/avatar/src/lib/brn-avatar.ts","../../../../libs/brain/avatar/src/lib/fallback/brn-avatar-fallback.ts","../../../../libs/brain/avatar/src/lib/image/brn-avatar-image.ts","../../../../libs/brain/avatar/src/lib/util/hex-color-for.ts","../../../../libs/brain/avatar/src/lib/util/initials.pipe.ts","../../../../libs/brain/avatar/src/lib/util/is-bright.ts","../../../../libs/brain/avatar/src/index.ts","../../../../libs/brain/avatar/src/spartan-ng-brain-avatar.ts"],"sourcesContent":["import { Directive, signal } from '@angular/core';\n\nexport type BrnAvatarStatus = 'idle' | 'loading' | 'loaded' | 'error';\n\n/**\n * Avatar container. Provides the positioning context for the absolutely positioned image and\n * intentionally does not set `display`.\n */\n@Directive({\n\tselector: '[brnAvatar],brn-avatar',\n\texportAs: 'brnAvatar',\n\thost: {\n\t\t'[style.position]': \"'relative'\",\n\t\t'[attr.data-status]': 'status()',\n\t},\n})\nexport class BrnAvatar {\n\tprivate readonly _status = signal<BrnAvatarStatus>('idle');\n\tpublic readonly status = this._status.asReadonly();\n\n\t/** @internal */\n\tpublic setStatus(status: BrnAvatarStatus): void {\n\t\tthis._status.set(status);\n\t}\n}\n","import { computed, Directive, inject } from '@angular/core';\nimport { BrnAvatar } from '../brn-avatar';\n\n@Directive({\n\tselector: '[brnAvatarFallback]',\n\texportAs: 'brnAvatarFallback',\n\thost: {\n\t\t'[style.visibility]': \"_hidden() ? 'hidden' : null\",\n\t},\n})\nexport class BrnAvatarFallback {\n\tprivate readonly _avatar = inject(BrnAvatar);\n\tprotected readonly _hidden = computed(() => this._avatar.status() === 'loaded');\n}\n","import { DestroyRef, Directive, ElementRef, computed, inject, input } from '@angular/core';\nimport { BrnAvatar } from '../brn-avatar';\n\n@Directive({\n\tselector: 'img[brnAvatarImage]',\n\texportAs: 'brnAvatarImage',\n\thost: {\n\t\t'[style]': 'hostStyles()',\n\t\t'[style.visibility]': \"canShow() ? null : 'hidden'\",\n\t\t'(load)': '_onLoad()',\n\t\t'(error)': '_onError()',\n\t},\n})\nexport class BrnAvatarImage {\n\tprivate readonly _avatar = inject(BrnAvatar);\n\tprivate readonly _image = inject<ElementRef<HTMLImageElement>>(ElementRef).nativeElement;\n\tprivate readonly _destroyRef = inject(DestroyRef);\n\n\t/**\n\t * Styles applied to the host element. Bound via `[style]` so they apply through the CSSOM and are\n\t * not blocked by a strict Content-Security-Policy.\n\t */\n\tpublic readonly hostStyles = input<string>('position: absolute; inset: 0; width: 100%; height: 100%');\n\n\tpublic readonly canShow = computed(() => this._avatar.status() === 'loaded');\n\n\tconstructor() {\n\t\t// The image may already be loaded before this directive is created, e.g. during hydration\n\t\t// or when a cached image is reused. In that case the load event will never fire.\n\t\tif (this._image.complete && this._image.naturalWidth > 0) {\n\t\t\tthis._onLoad();\n\t\t} else {\n\t\t\tthis._avatar.setStatus('loading');\n\t\t}\n\n\t\t// If the image is removed, the fallback should become visible again.\n\t\tthis._destroyRef.onDestroy(() => {\n\t\t\tif (this._avatar.status() !== 'idle') {\n\t\t\t\tthis._avatar.setStatus('idle');\n\t\t\t}\n\t\t});\n\t}\n\n\tprotected _onError(): void {\n\t\tthis._avatar.setStatus('error');\n\t}\n\n\tprotected _onLoad(): void {\n\t\tthis._avatar.setStatus('loaded');\n\t}\n}\n","function hashString(str: string) {\n\tlet h;\n\tfor (let i = 0; i < str.length; i++) h = (Math.imul(31, h || 0) + str.charCodeAt(i)) | 0;\n\n\treturn h || 0;\n}\n\nfunction hashManyTimes(times: number, str: string) {\n\tlet h = hashString(str);\n\n\tfor (let i = 0; i < times; i++) h = hashString(String(h));\n\n\treturn h;\n}\n\nexport function hexColorFor(str: string) {\n\tconst hash = str.length <= 2 ? hashManyTimes(5, str) : hashString(str);\n\n\tlet color = '#';\n\n\tfor (let i = 0; i < 3; i += 1) {\n\t\tconst value = (hash >> (i * 8)) & 0xff;\n\t\tcolor += `00${value.toString(16)}`.slice(-2);\n\t}\n\n\treturn color;\n}\n","import { Pipe, type PipeTransform } from '@angular/core';\n\nconst toInitial =\n\t(capitalize = true) =>\n\t(word: string) => {\n\t\tconst initial = word.charAt(0);\n\t\treturn capitalize ? initial.toLocaleUpperCase() : initial;\n\t};\n\nconst firstAndLast = (initials: string[]) => `${initials[0]}${initials[initials.length - 1]}`;\n\n@Pipe({\n\tname: 'initials',\n})\nexport class InitialsPipe implements PipeTransform {\n\ttransform(name: string, capitalize = true, firstAndLastOnly = true, delimiter = ' '): string {\n\t\tif (!name) return '';\n\n\t\tconst initials = name.trim().split(delimiter).filter(Boolean).map(toInitial(capitalize));\n\n\t\tif (firstAndLastOnly && initials.length > 1) return firstAndLast(initials);\n\n\t\treturn initials.join('');\n\t}\n}\n","const isShortHand = (hex: string) => hex.length === 3;\n\nconst cleanup = (hex: string) => {\n\tconst noHash = hex.replace('#', '').trim().toLowerCase();\n\n\tif (!isShortHand(noHash)) return noHash;\n\n\treturn noHash\n\t\t.split('')\n\t\t.map((char) => char + char)\n\t\t.join('');\n};\n\nexport const isBright = (hex: string) => Number.parseInt(cleanup(hex), 16) > 0xffffff / 1.25;\n","import { BrnAvatar } from './lib/brn-avatar';\nimport { BrnAvatarFallback } from './lib/fallback';\nimport { BrnAvatarImage } from './lib/image';\n\nexport * from './lib/brn-avatar';\nexport * from './lib/fallback';\nexport * from './lib/image';\nexport * from './lib/util';\n\nexport const BrnAvatarImports = [BrnAvatar, BrnAvatarFallback, BrnAvatarImage] as const;\n","/**\n * Generated bundle index. Do not edit.\n */\n\nexport * from './index';\n"],"names":[],"mappings":";;;AAIA;;;AAGG;MASU,SAAS,CAAA;AACJ,IAAA,OAAO,GAAG,MAAM,CAAkB,MAAM,8EAAC;AAC1C,IAAA,MAAM,GAAG,IAAI,CAAC,OAAO,CAAC,UAAU,EAAE;;AAG3C,IAAA,SAAS,CAAC,MAAuB,EAAA;AACvC,QAAA,IAAI,CAAC,OAAO,CAAC,GAAG,CAAC,MAAM,CAAC;IACzB;2HAPY,SAAS,EAAA,IAAA,EAAA,EAAA,EAAA,MAAA,EAAA,EAAA,CAAA,eAAA,CAAA,SAAA,EAAA,CAAA;+GAAT,SAAS,EAAA,YAAA,EAAA,IAAA,EAAA,QAAA,EAAA,wBAAA,EAAA,IAAA,EAAA,EAAA,UAAA,EAAA,EAAA,gBAAA,EAAA,YAAA,EAAA,kBAAA,EAAA,UAAA,EAAA,EAAA,EAAA,QAAA,EAAA,CAAA,WAAA,CAAA,EAAA,QAAA,EAAA,EAAA,EAAA,CAAA;;4FAAT,SAAS,EAAA,UAAA,EAAA,CAAA;kBARrB,SAAS;AAAC,YAAA,IAAA,EAAA,CAAA;AACV,oBAAA,QAAQ,EAAE,wBAAwB;AAClC,oBAAA,QAAQ,EAAE,WAAW;AACrB,oBAAA,IAAI,E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AA,EAAA,CAAA;kBAHxB,IAAI;AAAC,YAAA,IAAA,EAAA,CAAA;AACL,oBAAA,IAAI,EAAE,UAAU;AAChB,iBAAA;;;ACbD,MAAM,WAAW,GAAG,CAAC,GAAW,KAAK,GAAG,CAAC,MAAM,KAAK,CAAC;AAErD,MAAM,OAAO,GAAG,CAAC,GAAW,KAAI;AAC/B,IAAA,MAAM,MAAM,GAAG,GAAG,CAAC,OAAO,CAAC,GAAG,EAAE,EAAE,CAAC,CAAC,IAAI,EAAE,CAAC,WAAW,EAAE;AAExD,IAAA,IAAI,CAAC,WAAW,CAAC,MAAM,CAAC;AAAE,QAAA,OAAO,MAAM;AAEvC,IAAA,OAAO;SACL,KAAK,CAAC,EAAE;SACR,GAAG,CAAC,CAAC,IAAI,KAAK,IAAI,GAAG,IAAI;SACzB,IAAI,CAAC,EAAE,CAAC;AACX,CAAC;AAEM,MAAM,QAAQ,GAAG,CAAC,GAAW,KAAK,MAAM,CAAC,QAAQ,CAAC,OAAO,CAAC,GAAG,CAAC,EAAE,EAAE,CAAC,GAAG,QAAQ,GAAG;;ACJjF,MAAM,gBAAgB,GAAG,CAAC,SAAS,EAAE,iBAAiB,EAAE,cAAc;;ACT7E;;AAEG;;;;"}
@@ -1,5 +1,5 @@
1
1
  import * as i0 from '@angular/core';
2
- import { InjectionToken, inject, forwardRef, signal, input, booleanAttribute, linkedSignal, numberAttribute, output, computed, viewChild, afterNextRender, ChangeDetectionStrategy, Component } from '@angular/core';
2
+ import { InjectionToken, inject, forwardRef, signal, input, booleanAttribute, linkedSignal, numberAttribute, untracked, output, computed, afterNextRender, Directive, DestroyRef, ElementRef, ChangeDetectionStrategy, Component } from '@angular/core';
3
3
  import { NG_VALUE_ACCESSOR } from '@angular/forms';
4
4
  import * as i1 from '@spartan-ng/brain/field';
5
5
  import { BrnFieldControl, provideBrnLabelable } from '@spartan-ng/brain/field';
@@ -31,20 +31,24 @@ class BrnInputOtp {
31
31
  /** Custom id applied to the input element */
32
32
  inputId = input(`brn-input-otp-${++BrnInputOtp._id}`, ...(ngDevMode ? [{ debugName: "inputId" }] : /* istanbul ignore next */ []));
33
33
  labelableId = this.inputId;
34
- /** Custom autocomplete attribute applied to the input element */
35
- inputAutocomplete = input('one-time-code', ...(ngDevMode ? [{ debugName: "inputAutocomplete" }] : /* istanbul ignore next */ []));
36
- /** Styles applied to the input element to make it invisible and clickable. */
37
- inputStyles = input('position: absolute; inset: 0; width: 100%; height: 100%; display: flex; textAlign: left; opacity: 1; color: transparent; pointerEvents: all; background: transparent; caret-color: transparent; border: 0px solid transparent; outline: transparent solid 0px; box-shadow: none; line-height: 1; letter-spacing: -0.5em; font-family: monospace; font-variant-numeric: tabular-nums;', ...(ngDevMode ? [{ debugName: "inputStyles" }] : /* istanbul ignore next */ []));
38
- /** Styles applied to the container element. */
39
- containerStyles = input('position: absolute; inset: 0; pointer-events: none;', ...(ngDevMode ? [{ debugName: "containerStyles" }] : /* istanbul ignore next */ []));
40
- /** Determine if the date picker is disabled. */
34
+ /** Determine if the input is disabled. */
41
35
  disabled = input(false, { ...(ngDevMode ? { debugName: "disabled" } : /* istanbul ignore next */ {}), transform: booleanAttribute });
42
36
  _disabled = linkedSignal(this.disabled, ...(ngDevMode ? [{ debugName: "_disabled" }] : /* istanbul ignore next */ []));
37
+ /** @internal The disabled state as a readonly signal */
38
+ disabledState = this._disabled.asReadonly();
43
39
  /** The number of slots. */
44
40
  length = input.required({ ...(ngDevMode ? { debugName: "length" } : /* istanbul ignore next */ {}), transform: numberAttribute });
45
- /** Virtual keyboard appearance on mobile */
46
- inputMode = input('numeric', ...(ngDevMode ? [{ debugName: "inputMode" }] : /* istanbul ignore next */ []));
47
- inputClass = input('', ...(ngDevMode ? [{ debugName: "inputClass" }] : /* istanbul ignore next */ []));
41
+ /**
42
+ * Optional per-character pattern. Each typed or pasted character must match this
43
+ * pattern. Strings are treated as a single-character regular expression.
44
+ *
45
+ * Examples: '[0-9]', '[A-Za-z0-9]'
46
+ */
47
+ slotPattern = input(null, ...(ngDevMode ? [{ debugName: "slotPattern" }] : /* istanbul ignore next */ []));
48
+ /** Whether entered characters should be visually masked. */
49
+ mask = input(false, { ...(ngDevMode ? { debugName: "mask" } : /* istanbul ignore next */ {}), transform: booleanAttribute });
50
+ /** The character used to mask entered characters. */
51
+ maskChar = input('•', ...(ngDevMode ? [{ debugName: "maskChar" }] : /* istanbul ignore next */ []));
48
52
  /** If true, the element is focused automatically on init **/
49
53
  autofocus = input(false, { ...(ngDevMode ? { debugName: "autofocus" } : /* istanbul ignore next */ {}), transform: booleanAttribute });
50
54
  /**
@@ -57,18 +61,25 @@ class BrnInputOtp {
57
61
  transformPaste = input((text) => text, ...(ngDevMode ? [{ debugName: "transformPaste" }] : /* istanbul ignore next */ []));
58
62
  /** The value controlling the input */
59
63
  valueInput = input(null, { ...(ngDevMode ? { debugName: "valueInput" } : /* istanbul ignore next */ {}), alias: 'value' });
60
- value = linkedSignal(this.valueInput, ...(ngDevMode ? [{ debugName: "value" }] : /* istanbul ignore next */ []));
64
+ value = linkedSignal(() => {
65
+ const valueInput = this.valueInput();
66
+ // Keep configuration changes from resetting the current value.
67
+ return untracked(() => this.sanitizeValue(valueInput));
68
+ }, ...(ngDevMode ? [{ debugName: "value" }] : /* istanbul ignore next */ []));
61
69
  /** Emits when the value changes. */
62
70
  valueChange = output();
63
71
  context = computed(() => {
64
72
  const value = this.value() ?? '';
65
73
  const focused = this._focused();
66
74
  const length = this.length();
75
+ const mask = this.mask();
76
+ const maskChar = this.maskChar();
67
77
  const slots = Array.from({ length: this.length() }).map((_, slotIndex) => {
68
78
  const char = value[slotIndex] !== undefined ? value[slotIndex] : null;
69
79
  const isActive = focused && (value.length === slotIndex || (value.length === length && slotIndex === length - 1));
70
80
  return {
71
81
  char,
82
+ displayChar: char !== null && mask ? maskChar : char,
72
83
  isActive,
73
84
  hasFakeCaret: isActive && value.length === slotIndex,
74
85
  };
@@ -79,40 +90,57 @@ class BrnInputOtp {
79
90
  completed = output();
80
91
  _onChange;
81
92
  _onTouched;
82
- _inputComponentRef = viewChild.required('otpInput');
93
+ /** The registered hidden input element. */
94
+ _input = signal(null, ...(ngDevMode ? [{ debugName: "_input" }] : /* istanbul ignore next */ []));
83
95
  constructor() {
84
96
  afterNextRender(() => {
85
97
  if (this.autofocus()) {
86
- this._inputComponentRef().nativeElement.focus();
98
+ this.focus();
87
99
  }
88
100
  });
89
101
  }
90
- onBlur() {
91
- this._focused.set(false);
92
- this._onTouched?.();
93
- }
94
- onInputChange(event) {
95
- let newValue = event.target.value;
102
+ /** @internal */
103
+ sanitizeValue(value, clamp = true) {
96
104
  const length = this.length();
97
- if (newValue.length > length) {
98
- // Replace the last character when length is exceeded
99
- newValue = newValue.slice(0, length - 1) + newValue.slice(-1);
105
+ const text = value ?? '';
106
+ const pattern = this.slotPattern();
107
+ const regex = pattern ? toCharRegex(pattern) : null;
108
+ const filtered = regex
109
+ ? Array.from(text)
110
+ .filter((char) => regex.test(char))
111
+ .join('')
112
+ : text;
113
+ return clamp ? filtered.slice(0, length) : filtered;
114
+ }
115
+ /** Focus the underlying input element. */
116
+ focus() {
117
+ this._input()?.focus();
118
+ }
119
+ /** @internal */
120
+ registerInput(input) {
121
+ this._input.set(input);
122
+ }
123
+ /** @internal */
124
+ unregisterInput(input) {
125
+ if (this._input() === input) {
126
+ this._input.set(null);
100
127
  }
101
- this.updateValue(newValue, length);
102
128
  }
103
- onPaste(event) {
104
- event.preventDefault();
105
- const clipboardData = event.clipboardData?.getData('text/plain') || '';
106
- const length = this.length();
107
- const content = this.transformPaste()(clipboardData, length);
108
- const newValue = content.slice(0, length);
109
- this.updateValue(newValue, length);
129
+ /** @internal */
130
+ onFocus() {
131
+ this._focused.set(true);
132
+ }
133
+ /** @internal */
134
+ onBlur() {
135
+ this._focused.set(false);
136
+ this._onTouched?.();
110
137
  }
111
138
  /** CONTROL VALUE ACCESSOR */
112
139
  writeValue(value) {
113
- this.value.set(value);
114
- if (value?.length === this.length()) {
115
- this.completed.emit(value ?? '');
140
+ const sanitizedValue = this.sanitizeValue(value);
141
+ this.value.set(sanitizedValue);
142
+ if (sanitizedValue.length === this.length()) {
143
+ this.completed.emit(sanitizedValue);
116
144
  }
117
145
  }
118
146
  registerOnChange(fn) {
@@ -127,71 +155,120 @@ class BrnInputOtp {
127
155
  isCompleted(newValue, previousValue, length) {
128
156
  return newValue !== previousValue && previousValue.length < length && newValue.length === length;
129
157
  }
130
- updateValue(newValue, length) {
158
+ /** @internal */
159
+ updateValue(newValue) {
131
160
  const previousValue = this.value() ?? '';
132
- this.value.set(newValue);
133
- this.valueChange.emit(newValue);
134
- this._onChange?.(newValue);
135
- if (this.isCompleted(newValue, previousValue, length)) {
136
- this.completed.emit(newValue);
161
+ const length = this.length();
162
+ const sanitizedValue = this.sanitizeValue(newValue);
163
+ this.value.set(sanitizedValue);
164
+ this.valueChange.emit(sanitizedValue);
165
+ this._onChange?.(sanitizedValue);
166
+ if (this.isCompleted(sanitizedValue, previousValue, length)) {
167
+ this.completed.emit(sanitizedValue);
137
168
  }
138
169
  }
139
- /** @nocollapse */ static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.2.16", ngImport: i0, type: BrnInputOtp, deps: [], target: i0.ɵɵFactoryTarget.Component });
140
- /** @nocollapse */ static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.2.0", version: "21.2.16", type: BrnInputOtp, isStandalone: true, selector: "brn-input-otp", inputs: { hostStyles: { classPropertyName: "hostStyles", publicName: "hostStyles", isSignal: true, isRequired: false, transformFunction: null }, inputId: { classPropertyName: "inputId", publicName: "inputId", isSignal: true, isRequired: false, transformFunction: null }, inputAutocomplete: { classPropertyName: "inputAutocomplete", publicName: "inputAutocomplete", isSignal: true, isRequired: false, transformFunction: null }, inputStyles: { classPropertyName: "inputStyles", publicName: "inputStyles", isSignal: true, isRequired: false, transformFunction: null }, containerStyles: { classPropertyName: "containerStyles", publicName: "containerStyles", isSignal: true, isRequired: false, transformFunction: null }, disabled: { classPropertyName: "disabled", publicName: "disabled", isSignal: true, isRequired: false, transformFunction: null }, length: { classPropertyName: "length", publicName: "length", isSignal: true, isRequired: true, transformFunction: null }, inputMode: { classPropertyName: "inputMode", publicName: "inputMode", isSignal: true, isRequired: false, transformFunction: null }, inputClass: { classPropertyName: "inputClass", publicName: "inputClass", isSignal: true, isRequired: false, transformFunction: null }, autofocus: { classPropertyName: "autofocus", publicName: "autofocus", isSignal: true, isRequired: false, transformFunction: null }, transformPaste: { classPropertyName: "transformPaste", publicName: "transformPaste", isSignal: true, isRequired: false, transformFunction: null }, valueInput: { classPropertyName: "valueInput", publicName: "value", isSignal: true, isRequired: false, transformFunction: null } }, outputs: { valueChange: "valueChange", completed: "completed" }, host: { attributes: { "data-input-otp-container": "true" }, properties: { "style": "hostStyles()" } }, providers: [BRN_INPUT_OTP_VALUE_ACCESSOR, provideBrnInputOtp(BrnInputOtp), provideBrnLabelable(BrnInputOtp)], viewQueries: [{ propertyName: "_inputComponentRef", first: true, predicate: ["otpInput"], descendants: true, isSignal: true }], exportAs: ["brnInputOtp"], hostDirectives: [{ directive: i1.BrnFieldControl }], ngImport: i0, template: `
141
- <ng-content />
142
- <div [style]="containerStyles()">
143
- <input
144
- #otpInput
145
- data-slot="input-otp"
146
- [id]="inputId()"
147
- [class]="inputClass()"
148
- [autocomplete]="inputAutocomplete()"
149
- [style]="inputStyles()"
150
- [disabled]="_disabled()"
151
- [inputMode]="inputMode()"
152
- [value]="value() ?? ''"
153
- (input)="onInputChange($event)"
154
- (paste)="onPaste($event)"
155
- (focus)="_focused.set(true)"
156
- (blur)="onBlur()"
157
- />
158
- </div>
159
- `, isInline: true, changeDetection: i0.ChangeDetectionStrategy.OnPush });
170
+ /** @nocollapse */ static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.2.16", ngImport: i0, type: BrnInputOtp, deps: [], target: i0.ɵɵFactoryTarget.Directive });
171
+ /** @nocollapse */ static ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "17.1.0", version: "21.2.16", type: BrnInputOtp, isStandalone: true, selector: "brn-input-otp, [brnInputOtp]", inputs: { hostStyles: { classPropertyName: "hostStyles", publicName: "hostStyles", isSignal: true, isRequired: false, transformFunction: null }, inputId: { classPropertyName: "inputId", publicName: "inputId", isSignal: true, isRequired: false, transformFunction: null }, disabled: { classPropertyName: "disabled", publicName: "disabled", isSignal: true, isRequired: false, transformFunction: null }, length: { classPropertyName: "length", publicName: "length", isSignal: true, isRequired: true, transformFunction: null }, slotPattern: { classPropertyName: "slotPattern", publicName: "slotPattern", isSignal: true, isRequired: false, transformFunction: null }, mask: { classPropertyName: "mask", publicName: "mask", isSignal: true, isRequired: false, transformFunction: null }, maskChar: { classPropertyName: "maskChar", publicName: "maskChar", isSignal: true, isRequired: false, transformFunction: null }, autofocus: { classPropertyName: "autofocus", publicName: "autofocus", isSignal: true, isRequired: false, transformFunction: null }, transformPaste: { classPropertyName: "transformPaste", publicName: "transformPaste", isSignal: true, isRequired: false, transformFunction: null }, valueInput: { classPropertyName: "valueInput", publicName: "value", isSignal: true, isRequired: false, transformFunction: null } }, outputs: { valueChange: "valueChange", completed: "completed" }, host: { attributes: { "data-input-otp-container": "true" }, properties: { "style": "hostStyles()" } }, providers: [BRN_INPUT_OTP_VALUE_ACCESSOR, provideBrnInputOtp(BrnInputOtp), provideBrnLabelable(BrnInputOtp)], exportAs: ["brnInputOtp"], hostDirectives: [{ directive: i1.BrnFieldControl }], ngImport: i0 });
160
172
  }
161
173
  i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.16", ngImport: i0, type: BrnInputOtp, decorators: [{
162
- type: Component,
174
+ type: Directive,
163
175
  args: [{
164
- selector: 'brn-input-otp',
176
+ selector: 'brn-input-otp, [brnInputOtp]',
165
177
  exportAs: 'brnInputOtp',
166
178
  providers: [BRN_INPUT_OTP_VALUE_ACCESSOR, provideBrnInputOtp(BrnInputOtp), provideBrnLabelable(BrnInputOtp)],
167
- changeDetection: ChangeDetectionStrategy.OnPush,
168
179
  hostDirectives: [BrnFieldControl],
169
180
  host: {
170
181
  '[style]': 'hostStyles()',
171
182
  'data-input-otp-container': 'true',
172
183
  },
173
- template: `
174
- <ng-content />
175
- <div [style]="containerStyles()">
176
- <input
177
- #otpInput
178
- data-slot="input-otp"
179
- [id]="inputId()"
180
- [class]="inputClass()"
181
- [autocomplete]="inputAutocomplete()"
182
- [style]="inputStyles()"
183
- [disabled]="_disabled()"
184
- [inputMode]="inputMode()"
185
- [value]="value() ?? ''"
186
- (input)="onInputChange($event)"
187
- (paste)="onPaste($event)"
188
- (focus)="_focused.set(true)"
189
- (blur)="onBlur()"
190
- />
191
- </div>
192
- `,
193
184
  }]
194
- }], ctorParameters: () => [], propDecorators: { hostStyles: [{ type: i0.Input, args: [{ isSignal: true, alias: "hostStyles", required: false }] }], inputId: [{ type: i0.Input, args: [{ isSignal: true, alias: "inputId", required: false }] }], inputAutocomplete: [{ type: i0.Input, args: [{ isSignal: true, alias: "inputAutocomplete", required: false }] }], inputStyles: [{ type: i0.Input, args: [{ isSignal: true, alias: "inputStyles", required: false }] }], containerStyles: [{ type: i0.Input, args: [{ isSignal: true, alias: "containerStyles", required: false }] }], disabled: [{ type: i0.Input, args: [{ isSignal: true, alias: "disabled", required: false }] }], length: [{ type: i0.Input, args: [{ isSignal: true, alias: "length", required: true }] }], inputMode: [{ type: i0.Input, args: [{ isSignal: true, alias: "inputMode", required: false }] }], inputClass: [{ type: i0.Input, args: [{ isSignal: true, alias: "inputClass", required: false }] }], autofocus: [{ type: i0.Input, args: [{ isSignal: true, alias: "autofocus", required: false }] }], transformPaste: [{ type: i0.Input, args: [{ isSignal: true, alias: "transformPaste", required: false }] }], valueInput: [{ type: i0.Input, args: [{ isSignal: true, alias: "value", required: false }] }], valueChange: [{ type: i0.Output, args: ["valueChange"] }], completed: [{ type: i0.Output, args: ["completed"] }], _inputComponentRef: [{ type: i0.ViewChild, args: ['otpInput', { isSignal: true }] }] } });
185
+ }], ctorParameters: () => [], propDecorators: { hostStyles: [{ type: i0.Input, args: [{ isSignal: true, alias: "hostStyles", required: false }] }], inputId: [{ type: i0.Input, args: [{ isSignal: true, alias: "inputId", required: false }] }], disabled: [{ type: i0.Input, args: [{ isSignal: true, alias: "disabled", required: false }] }], length: [{ type: i0.Input, args: [{ isSignal: true, alias: "length", required: true }] }], slotPattern: [{ type: i0.Input, args: [{ isSignal: true, alias: "slotPattern", required: false }] }], mask: [{ type: i0.Input, args: [{ isSignal: true, alias: "mask", required: false }] }], maskChar: [{ type: i0.Input, args: [{ isSignal: true, alias: "maskChar", required: false }] }], autofocus: [{ type: i0.Input, args: [{ isSignal: true, alias: "autofocus", required: false }] }], transformPaste: [{ type: i0.Input, args: [{ isSignal: true, alias: "transformPaste", required: false }] }], valueInput: [{ type: i0.Input, args: [{ isSignal: true, alias: "value", required: false }] }], valueChange: [{ type: i0.Output, args: ["valueChange"] }], completed: [{ type: i0.Output, args: ["completed"] }] } });
186
+ function toCharRegex(pattern) {
187
+ if (pattern instanceof RegExp) {
188
+ // Strip stateful flags so repeated .test() calls remain deterministic.
189
+ return new RegExp(`^(?:${pattern.source})$`, pattern.flags.replace(/[gy]/g, ''));
190
+ }
191
+ return new RegExp(`^(?:${pattern})$`);
192
+ }
193
+
194
+ const DEFAULT_INPUT_STYLES = 'position: absolute; inset: 0; width: 100%; height: 100%; display: flex; textAlign: left; opacity: 1; color: transparent; pointerEvents: all; background: transparent; caret-color: transparent; border: 0px solid transparent; outline: transparent solid 0px; box-shadow: none; line-height: 1; letter-spacing: -0.5em; font-family: monospace; font-variant-numeric: tabular-nums;';
195
+ class BrnInputOtpInput {
196
+ _destroyRef = inject(DestroyRef);
197
+ _elementRef = inject(ElementRef);
198
+ _otp = injectBrnInputOtp();
199
+ /** Custom autocomplete attribute applied to the input element */
200
+ autocomplete = input('one-time-code', ...(ngDevMode ? [{ debugName: "autocomplete" }] : /* istanbul ignore next */ []));
201
+ /** Virtual keyboard appearance on mobile */
202
+ inputMode = input('numeric', ...(ngDevMode ? [{ debugName: "inputMode" }] : /* istanbul ignore next */ []));
203
+ /** Styles applied to the input element to make it invisible and clickable. */
204
+ inputStyles = input(undefined, ...(ngDevMode ? [{ debugName: "inputStyles" }] : /* istanbul ignore next */ []));
205
+ _inputStyles = computed(() => this.inputStyles() ?? DEFAULT_INPUT_STYLES, ...(ngDevMode ? [{ debugName: "_inputStyles" }] : /* istanbul ignore next */ []));
206
+ constructor() {
207
+ this._otp.registerInput(this);
208
+ this._destroyRef.onDestroy(() => this._otp.unregisterInput(this));
209
+ }
210
+ /** Focus the underlying input element. */
211
+ focus() {
212
+ this._elementRef.nativeElement.focus();
213
+ }
214
+ onInputChange() {
215
+ const input = this._elementRef.nativeElement;
216
+ const length = this._otp.length();
217
+ // Do not clamp here so that typing when the input is full replaces the
218
+ // last character instead of dropping the newly typed character.
219
+ let sanitized = this._otp.sanitizeValue(input.value, false);
220
+ if (sanitized.length > length) {
221
+ sanitized = sanitized.slice(0, length - 1) + sanitized.slice(-1);
222
+ }
223
+ sanitized = sanitized.slice(0, length);
224
+ if (input.value !== sanitized) {
225
+ input.value = sanitized;
226
+ this.setSelectionRange(sanitized.length, sanitized.length);
227
+ }
228
+ this._otp.updateValue(sanitized);
229
+ }
230
+ onPaste(event) {
231
+ event.preventDefault();
232
+ const input = this._elementRef.nativeElement;
233
+ const clipboardData = event.clipboardData?.getData('text/plain') || '';
234
+ const length = this._otp.length();
235
+ const content = this._otp.transformPaste()(clipboardData, length);
236
+ const sanitized = this._otp.sanitizeValue(content);
237
+ input.value = sanitized;
238
+ this.setSelectionRange(sanitized.length, sanitized.length);
239
+ this._otp.updateValue(sanitized);
240
+ }
241
+ setSelectionRange(start, end) {
242
+ const input = this._elementRef.nativeElement;
243
+ // Number/date/email inputs throw when setSelectionRange is called.
244
+ if (!['text', 'search', 'url', 'tel', 'password'].includes(input.type)) {
245
+ return;
246
+ }
247
+ input.setSelectionRange(start, end);
248
+ }
249
+ /** @nocollapse */ static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.2.16", ngImport: i0, type: BrnInputOtpInput, deps: [], target: i0.ɵɵFactoryTarget.Directive });
250
+ /** @nocollapse */ static ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "17.1.0", version: "21.2.16", type: BrnInputOtpInput, isStandalone: true, selector: "input[brnInputOtpInput]", inputs: { autocomplete: { classPropertyName: "autocomplete", publicName: "autocomplete", isSignal: true, isRequired: false, transformFunction: null }, inputMode: { classPropertyName: "inputMode", publicName: "inputMode", isSignal: true, isRequired: false, transformFunction: null }, inputStyles: { classPropertyName: "inputStyles", publicName: "inputStyles", isSignal: true, isRequired: false, transformFunction: null } }, host: { attributes: { "data-slot": "input-otp" }, listeners: { "input": "onInputChange()", "paste": "onPaste($event)", "focus": "_otp.onFocus()", "blur": "_otp.onBlur()" }, properties: { "id": "_otp.inputId()", "attr.autocomplete": "autocomplete()", "attr.inputmode": "inputMode()", "disabled": "_otp.disabledState()", "value": "_otp.value() ?? \"\"", "style": "_inputStyles()" } }, exportAs: ["brnInputOtpInput"], ngImport: i0 });
251
+ }
252
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.16", ngImport: i0, type: BrnInputOtpInput, decorators: [{
253
+ type: Directive,
254
+ args: [{
255
+ selector: 'input[brnInputOtpInput]',
256
+ exportAs: 'brnInputOtpInput',
257
+ host: {
258
+ 'data-slot': 'input-otp',
259
+ '[id]': '_otp.inputId()',
260
+ '[attr.autocomplete]': 'autocomplete()',
261
+ '[attr.inputmode]': 'inputMode()',
262
+ '[disabled]': '_otp.disabledState()',
263
+ '[value]': '_otp.value() ?? ""',
264
+ '[style]': '_inputStyles()',
265
+ '(input)': 'onInputChange()',
266
+ '(paste)': 'onPaste($event)',
267
+ '(focus)': '_otp.onFocus()',
268
+ '(blur)': '_otp.onBlur()',
269
+ },
270
+ }]
271
+ }], ctorParameters: () => [], propDecorators: { autocomplete: [{ type: i0.Input, args: [{ isSignal: true, alias: "autocomplete", required: false }] }], inputMode: [{ type: i0.Input, args: [{ isSignal: true, alias: "inputMode", required: false }] }], inputStyles: [{ type: i0.Input, args: [{ isSignal: true, alias: "inputStyles", required: false }] }] } });
195
272
 
196
273
  class BrnInputOtpSlot {
197
274
  /** Access the input-otp component */
@@ -200,14 +277,19 @@ class BrnInputOtpSlot {
200
277
  index = input.required({ ...(ngDevMode ? { debugName: "index" } : /* istanbul ignore next */ {}), transform: numberAttribute });
201
278
  /** Whether to force the input into an invalid state. */
202
279
  forceInvalid = input(false, { ...(ngDevMode ? { debugName: "forceInvalid" } : /* istanbul ignore next */ {}), transform: booleanAttribute });
203
- _slot = computed(() => this._inputOtp.context()[this.index()], ...(ngDevMode ? [{ debugName: "_slot" }] : /* istanbul ignore next */ []));
280
+ _slot = computed(() => this._inputOtp.context()[this.index()] ?? {
281
+ char: null,
282
+ displayChar: null,
283
+ isActive: false,
284
+ hasFakeCaret: false,
285
+ }, ...(ngDevMode ? [{ debugName: "_slot" }] : /* istanbul ignore next */ []));
204
286
  _ariaInvalid = this._inputOtp.invalid;
205
287
  _touched = this._inputOtp.touched;
206
288
  _dirty = this._inputOtp.dirty;
207
289
  _spartanInvalid = computed(() => this.forceInvalid() || this._inputOtp.spartanInvalid?.(), ...(ngDevMode ? [{ debugName: "_spartanInvalid" }] : /* istanbul ignore next */ []));
208
290
  /** @nocollapse */ static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.2.16", ngImport: i0, type: BrnInputOtpSlot, deps: [], target: i0.ɵɵFactoryTarget.Component });
209
291
  /** @nocollapse */ static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "21.2.16", type: BrnInputOtpSlot, isStandalone: true, selector: "brn-input-otp-slot", inputs: { index: { classPropertyName: "index", publicName: "index", isSignal: true, isRequired: true, transformFunction: null }, forceInvalid: { classPropertyName: "forceInvalid", publicName: "forceInvalid", isSignal: true, isRequired: false, transformFunction: null } }, host: { properties: { "attr.data-active": "_slot().isActive", "attr.data-invalid": "_ariaInvalid?.() ? \"true\" : null", "attr.data-touched": "_touched?.() ? \"true\" : null", "attr.data-dirty": "_dirty?.() ? \"true\" : null", "attr.data-matches-spartan-invalid": "_spartanInvalid() ? \"true\" : null" } }, exportAs: ["brnInputOtpSlot"], ngImport: i0, template: `
210
- {{ _slot().char }}
292
+ {{ _slot().displayChar }}
211
293
 
212
294
  @if (_slot().hasFakeCaret) {
213
295
  <ng-content />
@@ -228,7 +310,7 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.16", ngImpo
228
310
  '[attr.data-matches-spartan-invalid]': '_spartanInvalid() ? "true" : null',
229
311
  },
230
312
  template: `
231
- {{ _slot().char }}
313
+ {{ _slot().displayChar }}
232
314
 
233
315
  @if (_slot().hasFakeCaret) {
234
316
  <ng-content />
@@ -237,11 +319,11 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.16", ngImpo
237
319
  }]
238
320
  }], propDecorators: { index: [{ type: i0.Input, args: [{ isSignal: true, alias: "index", required: true }] }], forceInvalid: [{ type: i0.Input, args: [{ isSignal: true, alias: "forceInvalid", required: false }] }] } });
239
321
 
240
- const BrnInputOtpImports = [BrnInputOtp, BrnInputOtpSlot];
322
+ const BrnInputOtpImports = [BrnInputOtp, BrnInputOtpInput, BrnInputOtpSlot];
241
323
 
242
324
  /**
243
325
  * Generated bundle index. Do not edit.
244
326
  */
245
327
 
246
- export { BRN_INPUT_OTP_VALUE_ACCESSOR, BrnInputOtp, BrnInputOtpImports, BrnInputOtpSlot };
328
+ export { BRN_INPUT_OTP_VALUE_ACCESSOR, BrnInputOtp, BrnInputOtpImports, BrnInputOtpInput, BrnInputOtpSlot };
247
329
  //# sourceMappingURL=spartan-ng-brain-input-otp.mjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"spartan-ng-brain-input-otp.mjs","sources":["../../../../libs/brain/input-otp/src/lib/brn-input-otp.token.ts","../../../../libs/brain/input-otp/src/lib/brn-input-otp.ts","../../../../libs/brain/input-otp/src/lib/brn-input-otp-slot.ts","../../../../libs/brain/input-otp/src/index.ts","../../../../libs/brain/input-otp/src/spartan-ng-brain-input-otp.ts"],"sourcesContent":["import { type ExistingProvider, inject, InjectionToken, type Type } from '@angular/core';\nimport type { BrnInputOtp } from './brn-input-otp';\n\nexport const BrnInputOtpToken = new InjectionToken<BrnInputOtp>('BrnInputOtpToken');\n\nexport function injectBrnInputOtp(): BrnInputOtp {\n\treturn inject(BrnInputOtpToken) as BrnInputOtp;\n}\n\nexport function provideBrnInputOtp(inputOtp: Type<BrnInputOtp>): ExistingProvider {\n\treturn { provide: BrnInputOtpToken, useExisting: inputOtp };\n}\n","import type { BooleanInput, NumberInput } from '@angular/cdk/coercion';\nimport {\n\tafterNextRender,\n\tbooleanAttribute,\n\tChangeDetectionStrategy,\n\tComponent,\n\tcomputed,\n\tElementRef,\n\tforwardRef,\n\tinject,\n\tinput,\n\tlinkedSignal,\n\tnumberAttribute,\n\toutput,\n\tsignal,\n\tviewChild,\n} from '@angular/core';\nimport { type ControlValueAccessor, NG_VALUE_ACCESSOR } from '@angular/forms';\nimport { BrnFieldControl, provideBrnLabelable } from '@spartan-ng/brain/field';\nimport type { ChangeFn, TouchFn } from '@spartan-ng/brain/forms';\nimport type { ClassValue } from 'clsx';\nimport { provideBrnInputOtp } from './brn-input-otp.token';\n\nexport const BRN_INPUT_OTP_VALUE_ACCESSOR = {\n\tprovide: NG_VALUE_ACCESSOR,\n\tuseExisting: forwardRef(() => BrnInputOtp),\n\tmulti: true,\n};\n\nexport type InputMode = 'text' | 'tel' | 'url' | 'email' | 'numeric' | 'decimal' | 'search';\n\n@Component({\n\tselector: 'brn-input-otp',\n\texportAs: 'brnInputOtp',\n\tproviders: [BRN_INPUT_OTP_VALUE_ACCESSOR, provideBrnInputOtp(BrnInputOtp), provideBrnLabelable(BrnInputOtp)],\n\tchangeDetection: ChangeDetectionStrategy.OnPush,\n\thostDirectives: [BrnFieldControl],\n\thost: {\n\t\t'[style]': 'hostStyles()',\n\t\t'data-input-otp-container': 'true',\n\t},\n\ttemplate: `\n\t\t<ng-content />\n\t\t<div [style]=\"containerStyles()\">\n\t\t\t<input\n\t\t\t\t#otpInput\n\t\t\t\tdata-slot=\"input-otp\"\n\t\t\t\t[id]=\"inputId()\"\n\t\t\t\t[class]=\"inputClass()\"\n\t\t\t\t[autocomplete]=\"inputAutocomplete()\"\n\t\t\t\t[style]=\"inputStyles()\"\n\t\t\t\t[disabled]=\"_disabled()\"\n\t\t\t\t[inputMode]=\"inputMode()\"\n\t\t\t\t[value]=\"value() ?? ''\"\n\t\t\t\t(input)=\"onInputChange($event)\"\n\t\t\t\t(paste)=\"onPaste($event)\"\n\t\t\t\t(focus)=\"_focused.set(true)\"\n\t\t\t\t(blur)=\"onBlur()\"\n\t\t\t/>\n\t\t</div>\n\t`,\n})\nexport class BrnInputOtp implements ControlValueAccessor {\n\tprivate static _id = 0;\n\n\tprivate readonly _fieldControl = inject(BrnFieldControl, { optional: true });\n\n\tpublic readonly invalid = this._fieldControl?.invalid;\n\tpublic readonly touched = this._fieldControl?.touched;\n\tpublic readonly dirty = this._fieldControl?.dirty;\n\tpublic readonly spartanInvalid = this._fieldControl?.spartanInvalid;\n\n\t/** Whether the input has focus. */\n\tprotected readonly _focused = signal<boolean>(false);\n\n\t/** Styles applied to the host element. */\n\tpublic readonly hostStyles = input<string>(\n\t\t'position: relative; cursor: text; user-select: none; pointer-events: none;',\n\t);\n\n\t/** Custom id applied to the input element */\n\tpublic readonly inputId = input<string>(`brn-input-otp-${++BrnInputOtp._id}`);\n\n\tpublic readonly labelableId = this.inputId;\n\n\t/** Custom autocomplete attribute applied to the input element */\n\tpublic readonly inputAutocomplete = input<'one-time-code' | 'off'>('one-time-code');\n\n\t/** Styles applied to the input element to make it invisible and clickable. */\n\tpublic readonly inputStyles = input<string>(\n\t\t'position: absolute; inset: 0; width: 100%; height: 100%; display: flex; textAlign: left; opacity: 1; color: transparent; pointerEvents: all; background: transparent; caret-color: transparent; border: 0px solid transparent; outline: transparent solid 0px; box-shadow: none; line-height: 1; letter-spacing: -0.5em; font-family: monospace; font-variant-numeric: tabular-nums;',\n\t);\n\n\t/** Styles applied to the container element. */\n\tpublic readonly containerStyles = input<string>('position: absolute; inset: 0; pointer-events: none;');\n\n\t/** Determine if the date picker is disabled. */\n\tpublic readonly disabled = input<boolean, BooleanInput>(false, {\n\t\ttransform: booleanAttribute,\n\t});\n\n\tprotected readonly _disabled = linkedSignal(this.disabled);\n\n\t/** The number of slots. */\n\tpublic readonly length = input.required<number, NumberInput>({ transform: numberAttribute });\n\n\t/** Virtual keyboard appearance on mobile */\n\tpublic readonly inputMode = input<InputMode>('numeric');\n\n\tpublic readonly inputClass = input<ClassValue>('');\n\n\t/** If true, the element is focused automatically on init **/\n\tpublic readonly autofocus = input<boolean, BooleanInput>(false, { transform: booleanAttribute });\n\n\t/**\n\t * Defines how the pasted text should be transformed before saving to model/form.\n\t * Allows pasting text which contains extra characters like spaces, dashes, etc. and are longer than the length.\n\t *\n\t * \"XXX-XXX\": (pastedText) => pastedText.replaceAll('-', '')\n\t * \"XXX XXX\": (pastedText) => pastedText.replaceAll(/\\s+/g, '')\n\t */\n\tpublic readonly transformPaste = input<(pastedText: string, length: number) => string>((text) => text);\n\n\t/** The value controlling the input */\n\tpublic readonly valueInput = input<string | null>(null, { alias: 'value' });\n\tpublic readonly value = linkedSignal(this.valueInput);\n\n\t/** Emits when the value changes. */\n\tpublic readonly valueChange = output<string>();\n\n\tpublic readonly context = computed(() => {\n\t\tconst value = this.value() ?? '';\n\t\tconst focused = this._focused();\n\t\tconst length = this.length();\n\t\tconst slots = Array.from({ length: this.length() }).map((_, slotIndex) => {\n\t\t\tconst char = value[slotIndex] !== undefined ? value[slotIndex] : null;\n\n\t\t\tconst isActive = focused && (value.length === slotIndex || (value.length === length && slotIndex === length - 1));\n\n\t\t\treturn {\n\t\t\t\tchar,\n\t\t\t\tisActive,\n\t\t\t\thasFakeCaret: isActive && value.length === slotIndex,\n\t\t\t};\n\t\t});\n\n\t\treturn slots;\n\t});\n\n\t/** Emitted when the input is complete, triggered through input or paste. */\n\tpublic readonly completed = output<string>();\n\n\tprotected _onChange?: ChangeFn<string>;\n\tprotected _onTouched?: TouchFn;\n\n\tprotected readonly _inputComponentRef = viewChild.required<ElementRef>('otpInput');\n\n\tconstructor() {\n\t\tafterNextRender(() => {\n\t\t\tif (this.autofocus()) {\n\t\t\t\tthis._inputComponentRef().nativeElement.focus();\n\t\t\t}\n\t\t});\n\t}\n\n\tprotected onBlur() {\n\t\tthis._focused.set(false);\n\t\tthis._onTouched?.();\n\t}\n\n\tprotected onInputChange(event: Event) {\n\t\tlet newValue = (event.target as HTMLInputElement).value;\n\t\tconst length = this.length();\n\n\t\tif (newValue.length > length) {\n\t\t\t// Replace the last character when length is exceeded\n\t\t\tnewValue = newValue.slice(0, length - 1) + newValue.slice(-1);\n\t\t}\n\n\t\tthis.updateValue(newValue, length);\n\t}\n\n\tprotected onPaste(event: ClipboardEvent) {\n\t\tevent.preventDefault();\n\t\tconst clipboardData = event.clipboardData?.getData('text/plain') || '';\n\n\t\tconst length = this.length();\n\n\t\tconst content = this.transformPaste()(clipboardData, length);\n\t\tconst newValue = content.slice(0, length);\n\n\t\tthis.updateValue(newValue, length);\n\t}\n\n\t/** CONTROL VALUE ACCESSOR */\n\twriteValue(value: string | null): void {\n\t\tthis.value.set(value);\n\t\tif (value?.length === this.length()) {\n\t\t\tthis.completed.emit(value ?? '');\n\t\t}\n\t}\n\n\tregisterOnChange(fn: ChangeFn<string>): void {\n\t\tthis._onChange = fn;\n\t}\n\n\tregisterOnTouched(fn: TouchFn): void {\n\t\tthis._onTouched = fn;\n\t}\n\n\tsetDisabledState(isDisabled: boolean): void {\n\t\tthis._disabled.set(isDisabled);\n\t}\n\n\tprivate isCompleted(newValue: string, previousValue: string, length: number) {\n\t\treturn newValue !== previousValue && previousValue.length < length && newValue.length === length;\n\t}\n\n\tprivate updateValue(newValue: string, length: number) {\n\t\tconst previousValue = this.value() ?? '';\n\n\t\tthis.value.set(newValue);\n\t\tthis.valueChange.emit(newValue);\n\t\tthis._onChange?.(newValue);\n\n\t\tif (this.isCompleted(newValue, previousValue, length)) {\n\t\t\tthis.completed.emit(newValue);\n\t\t}\n\t}\n}\n","import type { BooleanInput, NumberInput } from '@angular/cdk/coercion';\nimport { booleanAttribute, ChangeDetectionStrategy, Component, computed, input, numberAttribute } from '@angular/core';\nimport { injectBrnInputOtp } from './brn-input-otp.token';\n\n@Component({\n\tselector: 'brn-input-otp-slot',\n\texportAs: 'brnInputOtpSlot',\n\tchangeDetection: ChangeDetectionStrategy.OnPush,\n\thost: {\n\t\t'[attr.data-active]': '_slot().isActive',\n\t\t'[attr.data-invalid]': '_ariaInvalid?.() ? \"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\ttemplate: `\n\t\t{{ _slot().char }}\n\n\t\t@if (_slot().hasFakeCaret) {\n\t\t\t<ng-content />\n\t\t}\n\t`,\n})\nexport class BrnInputOtpSlot {\n\t/** Access the input-otp component */\n\tprotected readonly _inputOtp = injectBrnInputOtp();\n\n\t/** The index of the slot to render the char or a fake caret */\n\tpublic readonly index = input.required<number, NumberInput>({ transform: numberAttribute });\n\n\t/** Whether to force the input into an invalid state. */\n\tpublic readonly forceInvalid = input<boolean, BooleanInput>(false, { transform: booleanAttribute });\n\n\tprotected readonly _slot = computed(() => this._inputOtp.context()[this.index()]);\n\n\tprotected readonly _ariaInvalid = this._inputOtp.invalid;\n\tprotected readonly _touched = this._inputOtp.touched;\n\tprotected readonly _dirty = this._inputOtp.dirty;\n\tprotected readonly _spartanInvalid = computed(() => this.forceInvalid() || this._inputOtp.spartanInvalid?.());\n}\n","import { BrnInputOtp } from './lib/brn-input-otp';\nimport { BrnInputOtpSlot } from './lib/brn-input-otp-slot';\n\nexport * from './lib/brn-input-otp';\nexport * from './lib/brn-input-otp-slot';\n\nexport const BrnInputOtpImports = [BrnInputOtp, BrnInputOtpSlot] as const;\n","/**\n * Generated bundle index. Do not edit.\n */\n\nexport * from './index';\n"],"names":[],"mappings":";;;;;;AAGO,MAAM,gBAAgB,GAAG,IAAI,cAAc,CAAc,kBAAkB,CAAC;SAEnE,iBAAiB,GAAA;AAChC,IAAA,OAAO,MAAM,CAAC,gBAAgB,CAAgB;AAC/C;AAEM,SAAU,kBAAkB,CAAC,QAA2B,EAAA;IAC7D,OAAO,EAAE,OAAO,EAAE,gBAAgB,EAAE,WAAW,EAAE,QAAQ,EAAE;AAC5D;;ACYO,MAAM,4BAA4B,GAAG;AAC3C,IAAA,OAAO,EAAE,iBAAiB;AAC1B,IAAA,WAAW,EAAE,UAAU,CAAC,MAAM,WAAW,CAAC;AAC1C,IAAA,KAAK,EAAE,IAAI;;MAoCC,WAAW,CAAA;AACf,IAAA,OAAO,GAAG,GAAG,CAAC;IAEL,aAAa,GAAG,MAAM,CAAC,eAAe,EAAE,EAAE,QAAQ,EAAE,IAAI,EAAE,CAAC;AAE5D,IAAA,OAAO,GAAG,IAAI,CAAC,aAAa,EAAE,OAAO;AACrC,IAAA,OAAO,GAAG,IAAI,CAAC,aAAa,EAAE,OAAO;AACrC,IAAA,KAAK,GAAG,IAAI,CAAC,aAAa,EAAE,KAAK;AACjC,IAAA,cAAc,GAAG,IAAI,CAAC,aAAa,EAAE,cAAc;;AAGhD,IAAA,QAAQ,GAAG,MAAM,CAAU,KAAK,+EAAC;;AAGpC,IAAA,UAAU,GAAG,KAAK,CACjC,4EAA4E,iFAC5E;;IAGe,OAAO,GAAG,KAAK,CAAS,CAAA,cAAA,EAAiB,EAAE,WAAW,CAAC,GAAG,CAAA,CAAE,EAAA,IAAA,SAAA,GAAA,CAAA,EAAA,SAAA,EAAA,SAAA,EA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otp.token.ts","../../../../libs/brain/input-otp/src/lib/brn-input-otp.ts","../../../../libs/brain/input-otp/src/lib/brn-input-otp-input.ts","../../../../libs/brain/input-otp/src/lib/brn-input-otp-slot.ts","../../../../libs/brain/input-otp/src/index.ts","../../../../libs/brain/input-otp/src/spartan-ng-brain-input-otp.ts"],"sourcesContent":["import { type ExistingProvider, inject, InjectionToken, type Type } from '@angular/core';\nimport type { BrnInputOtp } from './brn-input-otp';\n\nexport const BrnInputOtpToken = new InjectionToken<BrnInputOtp>('BrnInputOtpToken');\n\nexport function injectBrnInputOtp(): BrnInputOtp {\n\treturn inject(BrnInputOtpToken) as BrnInputOtp;\n}\n\nexport function provideBrnInputOtp(inputOtp: Type<BrnInputOtp>): ExistingProvider {\n\treturn { provide: BrnInputOtpToken, useExisting: inputOtp };\n}\n","import type { BooleanInput, NumberInput } from '@angular/cdk/coercion';\nimport {\n\tafterNextRender,\n\tbooleanAttribute,\n\tcomputed,\n\tDirective,\n\tforwardRef,\n\tinject,\n\tinput,\n\tlinkedSignal,\n\tnumberAttribute,\n\toutput,\n\tsignal,\n\tuntracked,\n} from '@angular/core';\nimport { type ControlValueAccessor, NG_VALUE_ACCESSOR } from '@angular/forms';\nimport { BrnFieldControl, provideBrnLabelable } from '@spartan-ng/brain/field';\nimport type { ChangeFn, TouchFn } from '@spartan-ng/brain/forms';\nimport type { BrnInputOtpInput } from './brn-input-otp-input';\nimport { provideBrnInputOtp } from './brn-input-otp.token';\n\nexport type { InputMode } from './brn-input-otp-input';\n\nexport const BRN_INPUT_OTP_VALUE_ACCESSOR = {\n\tprovide: NG_VALUE_ACCESSOR,\n\tuseExisting: forwardRef(() => BrnInputOtp),\n\tmulti: true,\n};\n\n@Directive({\n\tselector: 'brn-input-otp, [brnInputOtp]',\n\texportAs: 'brnInputOtp',\n\tproviders: [BRN_INPUT_OTP_VALUE_ACCESSOR, provideBrnInputOtp(BrnInputOtp), provideBrnLabelable(BrnInputOtp)],\n\thostDirectives: [BrnFieldControl],\n\thost: {\n\t\t'[style]': 'hostStyles()',\n\t\t'data-input-otp-container': 'true',\n\t},\n})\nexport class BrnInputOtp implements ControlValueAccessor {\n\tprivate static _id = 0;\n\n\tprivate readonly _fieldControl = inject(BrnFieldControl, { optional: true });\n\n\tpublic readonly invalid = this._fieldControl?.invalid;\n\tpublic readonly touched = this._fieldControl?.touched;\n\tpublic readonly dirty = this._fieldControl?.dirty;\n\tpublic readonly spartanInvalid = this._fieldControl?.spartanInvalid;\n\n\t/** Whether the input has focus. */\n\tprotected readonly _focused = signal<boolean>(false);\n\n\t/** Styles applied to the host element. */\n\tpublic readonly hostStyles = input<string>(\n\t\t'position: relative; cursor: text; user-select: none; pointer-events: none;',\n\t);\n\n\t/** Custom id applied to the input element */\n\tpublic readonly inputId = input<string>(`brn-input-otp-${++BrnInputOtp._id}`);\n\n\tpublic readonly labelableId = this.inputId;\n\n\t/** Determine if the input is disabled. */\n\tpublic readonly disabled = input<boolean, BooleanInput>(false, {\n\t\ttransform: booleanAttribute,\n\t});\n\n\tprotected readonly _disabled = linkedSignal(this.disabled);\n\n\t/** @internal The disabled state as a readonly signal */\n\tpublic readonly disabledState = this._disabled.asReadonly();\n\n\t/** The number of slots. */\n\tpublic readonly length = input.required<number, NumberInput>({ transform: numberAttribute });\n\n\t/**\n\t * Optional per-character pattern. Each typed or pasted character must match this\n\t * pattern. Strings are treated as a single-character regular expression.\n\t *\n\t * Examples: '[0-9]', '[A-Za-z0-9]'\n\t */\n\tpublic readonly slotPattern = input<string | RegExp | null>(null);\n\n\t/** Whether entered characters should be visually masked. */\n\tpublic readonly mask = input<boolean, BooleanInput>(false, { transform: booleanAttribute });\n\n\t/** The character used to mask entered characters. */\n\tpublic readonly maskChar = input<string>('•');\n\n\t/** If true, the element is focused automatically on init **/\n\tpublic readonly autofocus = input<boolean, BooleanInput>(false, { transform: booleanAttribute });\n\n\t/**\n\t * Defines how the pasted text should be transformed before saving to model/form.\n\t * Allows pasting text which contains extra characters like spaces, dashes, etc. and are longer than the length.\n\t *\n\t * \"XXX-XXX\": (pastedText) => pastedText.replaceAll('-', '')\n\t * \"XXX XXX\": (pastedText) => pastedText.replaceAll(/\\s+/g, '')\n\t */\n\tpublic readonly transformPaste = input<(pastedText: string, length: number) => string>((text) => text);\n\n\t/** The value controlling the input */\n\tpublic readonly valueInput = input<string | null>(null, { alias: 'value' });\n\tpublic readonly value = linkedSignal(() => {\n\t\tconst valueInput = this.valueInput();\n\n\t\t// Keep configuration changes from resetting the current value.\n\t\treturn untracked(() => this.sanitizeValue(valueInput));\n\t});\n\n\t/** Emits when the value changes. */\n\tpublic readonly valueChange = output<string>();\n\n\tpublic readonly context = computed(() => {\n\t\tconst value = this.value() ?? '';\n\t\tconst focused = this._focused();\n\t\tconst length = this.length();\n\t\tconst mask = this.mask();\n\t\tconst maskChar = this.maskChar();\n\t\tconst slots = Array.from({ length: this.length() }).map((_, slotIndex) => {\n\t\t\tconst char = value[slotIndex] !== undefined ? value[slotIndex] : null;\n\n\t\t\tconst isActive = focused && (value.length === slotIndex || (value.length === length && slotIndex === length - 1));\n\n\t\t\treturn {\n\t\t\t\tchar,\n\t\t\t\tdisplayChar: char !== null && mask ? maskChar : char,\n\t\t\t\tisActive,\n\t\t\t\thasFakeCaret: isActive && value.length === slotIndex,\n\t\t\t};\n\t\t});\n\n\t\treturn slots;\n\t});\n\n\t/** Emitted when the input is complete, triggered through input or paste. */\n\tpublic readonly completed = output<string>();\n\n\tprotected _onChange?: ChangeFn<string>;\n\tprotected _onTouched?: TouchFn;\n\n\t/** The registered hidden input element. */\n\tprivate readonly _input = signal<BrnInputOtpInput | null>(null);\n\n\tconstructor() {\n\t\tafterNextRender(() => {\n\t\t\tif (this.autofocus()) {\n\t\t\t\tthis.focus();\n\t\t\t}\n\t\t});\n\t}\n\n\t/** @internal */\n\tpublic sanitizeValue(value: string | null | undefined, clamp = true): string {\n\t\tconst length = this.length();\n\t\tconst text = value ?? '';\n\t\tconst pattern = this.slotPattern();\n\t\tconst regex = pattern ? toCharRegex(pattern) : null;\n\t\tconst filtered = regex\n\t\t\t? Array.from(text)\n\t\t\t\t\t.filter((char) => regex.test(char))\n\t\t\t\t\t.join('')\n\t\t\t: text;\n\n\t\treturn clamp ? filtered.slice(0, length) : filtered;\n\t}\n\n\t/** Focus the underlying input element. */\n\tpublic focus(): void {\n\t\tthis._input()?.focus();\n\t}\n\n\t/** @internal */\n\tpublic registerInput(input: BrnInputOtpInput): void {\n\t\tthis._input.set(input);\n\t}\n\n\t/** @internal */\n\tpublic unregisterInput(input: BrnInputOtpInput): void {\n\t\tif (this._input() === input) {\n\t\t\tthis._input.set(null);\n\t\t}\n\t}\n\n\t/** @internal */\n\tpublic onFocus(): void {\n\t\tthis._focused.set(true);\n\t}\n\n\t/** @internal */\n\tpublic onBlur(): void {\n\t\tthis._focused.set(false);\n\t\tthis._onTouched?.();\n\t}\n\n\t/** CONTROL VALUE ACCESSOR */\n\twriteValue(value: string | null): void {\n\t\tconst sanitizedValue = this.sanitizeValue(value);\n\n\t\tthis.value.set(sanitizedValue);\n\n\t\tif (sanitizedValue.length === this.length()) {\n\t\t\tthis.completed.emit(sanitizedValue);\n\t\t}\n\t}\n\n\tregisterOnChange(fn: ChangeFn<string>): void {\n\t\tthis._onChange = fn;\n\t}\n\n\tregisterOnTouched(fn: TouchFn): void {\n\t\tthis._onTouched = fn;\n\t}\n\n\tsetDisabledState(isDisabled: boolean): void {\n\t\tthis._disabled.set(isDisabled);\n\t}\n\n\tprivate isCompleted(newValue: string, previousValue: string, length: number) {\n\t\treturn newValue !== previousValue && previousValue.length < length && newValue.length === length;\n\t}\n\n\t/** @internal */\n\tpublic updateValue(newValue: string): void {\n\t\tconst previousValue = this.value() ?? '';\n\t\tconst length = this.length();\n\t\tconst sanitizedValue = this.sanitizeValue(newValue);\n\n\t\tthis.value.set(sanitizedValue);\n\t\tthis.valueChange.emit(sanitizedValue);\n\t\tthis._onChange?.(sanitizedValue);\n\n\t\tif (this.isCompleted(sanitizedValue, previousValue, length)) {\n\t\t\tthis.completed.emit(sanitizedValue);\n\t\t}\n\t}\n}\n\nfunction toCharRegex(pattern: string | RegExp): RegExp {\n\tif (pattern instanceof RegExp) {\n\t\t// Strip stateful flags so repeated .test() calls remain deterministic.\n\t\treturn new RegExp(`^(?:${pattern.source})$`, pattern.flags.replace(/[gy]/g, ''));\n\t}\n\n\treturn new RegExp(`^(?:${pattern})$`);\n}\n","import { computed, DestroyRef, Directive, ElementRef, inject, input } from '@angular/core';\nimport { injectBrnInputOtp } from './brn-input-otp.token';\n\nexport type InputMode = 'text' | 'tel' | 'url' | 'email' | 'numeric' | 'decimal' | 'search';\n\nconst DEFAULT_INPUT_STYLES =\n\t'position: absolute; inset: 0; width: 100%; height: 100%; display: flex; textAlign: left; opacity: 1; color: transparent; pointerEvents: all; background: transparent; caret-color: transparent; border: 0px solid transparent; outline: transparent solid 0px; box-shadow: none; line-height: 1; letter-spacing: -0.5em; font-family: monospace; font-variant-numeric: tabular-nums;';\n\n@Directive({\n\tselector: 'input[brnInputOtpInput]',\n\texportAs: 'brnInputOtpInput',\n\thost: {\n\t\t'data-slot': 'input-otp',\n\t\t'[id]': '_otp.inputId()',\n\t\t'[attr.autocomplete]': 'autocomplete()',\n\t\t'[attr.inputmode]': 'inputMode()',\n\t\t'[disabled]': '_otp.disabledState()',\n\t\t'[value]': '_otp.value() ?? \"\"',\n\t\t'[style]': '_inputStyles()',\n\t\t'(input)': 'onInputChange()',\n\t\t'(paste)': 'onPaste($event)',\n\t\t'(focus)': '_otp.onFocus()',\n\t\t'(blur)': '_otp.onBlur()',\n\t},\n})\nexport class BrnInputOtpInput {\n\tprivate readonly _destroyRef = inject(DestroyRef);\n\tprivate readonly _elementRef = inject<ElementRef<HTMLInputElement>>(ElementRef);\n\n\tprotected readonly _otp = injectBrnInputOtp();\n\n\t/** Custom autocomplete attribute applied to the input element */\n\tpublic readonly autocomplete = input<'one-time-code' | 'off'>('one-time-code');\n\n\t/** Virtual keyboard appearance on mobile */\n\tpublic readonly inputMode = input<InputMode>('numeric');\n\n\t/** Styles applied to the input element to make it invisible and clickable. */\n\tpublic readonly inputStyles = input<string | undefined>(undefined);\n\n\tprotected readonly _inputStyles = computed(() => this.inputStyles() ?? DEFAULT_INPUT_STYLES);\n\n\tconstructor() {\n\t\tthis._otp.registerInput(this);\n\t\tthis._destroyRef.onDestroy(() => this._otp.unregisterInput(this));\n\t}\n\n\t/** Focus the underlying input element. */\n\tpublic focus(): void {\n\t\tthis._elementRef.nativeElement.focus();\n\t}\n\n\tprotected onInputChange(): void {\n\t\tconst input = this._elementRef.nativeElement;\n\t\tconst length = this._otp.length();\n\n\t\t// Do not clamp here so that typing when the input is full replaces the\n\t\t// last character instead of dropping the newly typed character.\n\t\tlet sanitized = this._otp.sanitizeValue(input.value, false);\n\n\t\tif (sanitized.length > length) {\n\t\t\tsanitized = sanitized.slice(0, length - 1) + sanitized.slice(-1);\n\t\t}\n\n\t\tsanitized = sanitized.slice(0, length);\n\n\t\tif (input.value !== sanitized) {\n\t\t\tinput.value = sanitized;\n\t\t\tthis.setSelectionRange(sanitized.length, sanitized.length);\n\t\t}\n\n\t\tthis._otp.updateValue(sanitized);\n\t}\n\n\tprotected onPaste(event: ClipboardEvent): void {\n\t\tevent.preventDefault();\n\t\tconst input = this._elementRef.nativeElement;\n\t\tconst clipboardData = event.clipboardData?.getData('text/plain') || '';\n\t\tconst length = this._otp.length();\n\n\t\tconst content = this._otp.transformPaste()(clipboardData, length);\n\t\tconst sanitized = this._otp.sanitizeValue(content);\n\n\t\tinput.value = sanitized;\n\t\tthis.setSelectionRange(sanitized.length, sanitized.length);\n\t\tthis._otp.updateValue(sanitized);\n\t}\n\n\tprivate setSelectionRange(start: number, end: number): void {\n\t\tconst input = this._elementRef.nativeElement;\n\n\t\t// Number/date/email inputs throw when setSelectionRange is called.\n\t\tif (!['text', 'search', 'url', 'tel', 'password'].includes(input.type)) {\n\t\t\treturn;\n\t\t}\n\n\t\tinput.setSelectionRange(start, end);\n\t}\n}\n","import type { BooleanInput, NumberInput } from '@angular/cdk/coercion';\nimport { booleanAttribute, ChangeDetectionStrategy, Component, computed, input, numberAttribute } from '@angular/core';\nimport { injectBrnInputOtp } from './brn-input-otp.token';\n\n@Component({\n\tselector: 'brn-input-otp-slot',\n\texportAs: 'brnInputOtpSlot',\n\tchangeDetection: ChangeDetectionStrategy.OnPush,\n\thost: {\n\t\t'[attr.data-active]': '_slot().isActive',\n\t\t'[attr.data-invalid]': '_ariaInvalid?.() ? \"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\ttemplate: `\n\t\t{{ _slot().displayChar }}\n\n\t\t@if (_slot().hasFakeCaret) {\n\t\t\t<ng-content />\n\t\t}\n\t`,\n})\nexport class BrnInputOtpSlot {\n\t/** Access the input-otp component */\n\tprotected readonly _inputOtp = injectBrnInputOtp();\n\n\t/** The index of the slot to render the char or a fake caret */\n\tpublic readonly index = input.required<number, NumberInput>({ transform: numberAttribute });\n\n\t/** Whether to force the input into an invalid state. */\n\tpublic readonly forceInvalid = input<boolean, BooleanInput>(false, { transform: booleanAttribute });\n\n\tprotected readonly _slot = computed(\n\t\t() =>\n\t\t\tthis._inputOtp.context()[this.index()] ?? {\n\t\t\t\tchar: null,\n\t\t\t\tdisplayChar: null,\n\t\t\t\tisActive: false,\n\t\t\t\thasFakeCaret: false,\n\t\t\t},\n\t);\n\n\tprotected readonly _ariaInvalid = this._inputOtp.invalid;\n\tprotected readonly _touched = this._inputOtp.touched;\n\tprotected readonly _dirty = this._inputOtp.dirty;\n\tprotected readonly _spartanInvalid = computed(() => this.forceInvalid() || this._inputOtp.spartanInvalid?.());\n}\n","import { BrnInputOtp } from './lib/brn-input-otp';\nimport { BrnInputOtpInput } from './lib/brn-input-otp-input';\nimport { BrnInputOtpSlot } from './lib/brn-input-otp-slot';\n\nexport * from './lib/brn-input-otp';\nexport * from './lib/brn-input-otp-input';\nexport * from './lib/brn-input-otp-slot';\n\nexport const BrnInputOtpImports = [BrnInputOtp, BrnInputOtpInput, BrnInputOtpSlot] as const;\n","/**\n * Generated bundle index. Do not edit.\n */\n\nexport * from './index';\n"],"names":[],"mappings":";;;;;;AAGO,MAAM,gBAAgB,GAAG,IAAI,cAAc,CAAc,kBAAkB,CAAC;SAEnE,iBAAiB,GAAA;AAChC,IAAA,OAAO,MAAM,CAAC,gBAAgB,CAAgB;AAC/C;AAEM,SAAU,kBAAkB,CAAC,QAA2B,EAAA;IAC7D,OAAO,EAAE,OAAO,EAAE,gBAAgB,EAAE,WAAW,EAAE,QAAQ,EAAE;AAC5D;;ACYO,MAAM,4BAA4B,GAAG;AAC3C,IAAA,OAAO,EAAE,iBAAiB;AAC1B,IAAA,WAAW,EAAE,UAAU,CAAC,MAAM,WAAW,CAAC;AAC1C,IAAA,KAAK,EAAE,IAAI;;MAaC,WAAW,CAAA;AACf,IAAA,OAAO,GAAG,GAAG,CAAC;IAEL,aAAa,GAAG,MAAM,CAAC,eAAe,EAAE,EAAE,QAAQ,EAAE,IAAI,EAAE,CAAC;AAE5D,IAAA,OAAO,GAAG,IAAI,CAAC,aAAa,EAAE,OAAO;AACrC,IAAA,OAAO,GAAG,IAAI,CAAC,aAAa,EAAE,OAAO;AACrC,IAAA,KAAK,GAAG,IAAI,CAAC,aAAa,EAAE,KAAK;AACjC,IAAA,cAAc,GAAG,IAAI,CAAC,aAAa,EAAE,cAAc;;AAGhD,IAAA,QAAQ,GAAG,MAAM,CAAU,KAAK,+EAAC;;AAGpC,IAAA,UAAU,GAAG,KAAK,CACjC,4EAA4E,iFAC5E;;IAGe,OAAO,GAAG,KAAK,CAAS,CAAA,cAAA,EAAiB,EAAE,WAAW,CAAC,GAAG,CAAA,CAAE,EAAA,IAAA,SAAA,GAAA,CAAA,EAAA,SAAA,EAAA,SAAA,EAAA,CAAA,8B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QAAA,EARjB;;;;;;AAMT,CAAA,CAAA,EAAA,QAAA,EAAA,IAAA,EAAA,eAAA,EAAA,EAAA,CAAA,uBAAA,CAAA,MAAA,EAAA,CAAA;;4FAEW,eAAe,EAAA,UAAA,EAAA,CAAA;kBAnB3B,SAAS;AAAC,YAAA,IAAA,EAAA,CAAA;AACV,oBAAA,QAAQ,EAAE,oBAAoB;AAC9B,oBAAA,QAAQ,EAAE,iBAAiB;oBAC3B,eAAe,EAAE,uBAAuB,CAAC,MAAM;AAC/C,oBAAA,IAAI,EAAE;AACL,wBAAA,oBAAoB,EAAE,kBAAkB;AACxC,wBAAA,qBAAqB,EAAE,kCAAkC;AACzD,wBAAA,qBAAqB,EAAE,8BAA8B;AACrD,wBAAA,mBAAmB,EAAE,4BAA4B;AACjD,wBAAA,qCAAqC,EAAE,mCAAmC;AAC1E,qBAAA;AACD,oBAAA,QAAQ,EAAE;;;;;;AAMT,CAAA,CAAA;AACD,iBAAA;;;ACdM,MAAM,kBAAkB,GAAG,CAAC,WAAW,EAAE,gBAAgB,EAAE,eAAe;;ACRjF;;AAEG;;;;"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@spartan-ng/brain",
3
- "version": "1.8.3",
3
+ "version": "1.9.0-beta.1",
4
4
  "repository": {
5
5
  "type": "git",
6
6
  "url": "https://github.com/spartan-ng/spartan.git"
@@ -1,26 +1,44 @@
1
1
  import * as i0 from '@angular/core';
2
2
  import { PipeTransform } from '@angular/core';
3
3
 
4
- declare class BrnAvatarImage {
5
- private readonly _loaded;
6
- protected _onError(): void;
7
- protected _onLoad(): void;
8
- readonly canShow: i0.Signal<boolean>;
9
- static ɵfac: i0.ɵɵFactoryDeclaration<BrnAvatarImage, never>;
10
- static ɵdir: i0.ɵɵDirectiveDeclaration<BrnAvatarImage, "img[brnAvatarImage]", ["brnAvatarImage"], {}, {}, never, never, true, never>;
11
- }
12
-
4
+ type BrnAvatarStatus = 'idle' | 'loading' | 'loaded' | 'error';
5
+ /**
6
+ * Avatar container. Provides the positioning context for the absolutely positioned image and
7
+ * intentionally does not set `display`.
8
+ */
13
9
  declare class BrnAvatar {
14
- protected readonly _image: i0.Signal<BrnAvatarImage | undefined>;
10
+ private readonly _status;
11
+ readonly status: i0.Signal<BrnAvatarStatus>;
12
+ /** @internal */
13
+ setStatus(status: BrnAvatarStatus): void;
15
14
  static ɵfac: i0.ɵɵFactoryDeclaration<BrnAvatar, never>;
16
- static ɵcmp: i0.ɵɵComponentDeclaration<BrnAvatar, "brn-avatar", ["brnAvatar"], {}, {}, ["_image"], ["[brnAvatarImage]", "[brnAvatarFallback]"], true, never>;
15
+ static ɵdir: i0.ɵɵDirectiveDeclaration<BrnAvatar, "[brnAvatar],brn-avatar", ["brnAvatar"], {}, {}, never, never, true, never>;
17
16
  }
18
17
 
19
18
  declare class BrnAvatarFallback {
19
+ private readonly _avatar;
20
+ protected readonly _hidden: i0.Signal<boolean>;
20
21
  static ɵfac: i0.ɵɵFactoryDeclaration<BrnAvatarFallback, never>;
21
22
  static ɵdir: i0.ɵɵDirectiveDeclaration<BrnAvatarFallback, "[brnAvatarFallback]", ["brnAvatarFallback"], {}, {}, never, never, true, never>;
22
23
  }
23
24
 
25
+ declare class BrnAvatarImage {
26
+ private readonly _avatar;
27
+ private readonly _image;
28
+ private readonly _destroyRef;
29
+ /**
30
+ * Styles applied to the host element. Bound via `[style]` so they apply through the CSSOM and are
31
+ * not blocked by a strict Content-Security-Policy.
32
+ */
33
+ readonly hostStyles: i0.InputSignal<string>;
34
+ readonly canShow: i0.Signal<boolean>;
35
+ constructor();
36
+ protected _onError(): void;
37
+ protected _onLoad(): void;
38
+ static ɵfac: i0.ɵɵFactoryDeclaration<BrnAvatarImage, never>;
39
+ static ɵdir: i0.ɵɵDirectiveDeclaration<BrnAvatarImage, "img[brnAvatarImage]", ["brnAvatarImage"], { "hostStyles": { "alias": "hostStyles"; "required": false; "isSignal": true; }; }, {}, never, never, true, never>;
40
+ }
41
+
24
42
  declare function hexColorFor(str: string): string;
25
43
 
26
44
  declare class InitialsPipe implements PipeTransform {
@@ -34,3 +52,4 @@ declare const isBright: (hex: string) => boolean;
34
52
  declare const BrnAvatarImports: readonly [typeof BrnAvatar, typeof BrnAvatarFallback, typeof BrnAvatarImage];
35
53
 
36
54
  export { BrnAvatar, BrnAvatarFallback, BrnAvatarImage, BrnAvatarImports, InitialsPipe, hexColorFor, isBright };
55
+ export type { BrnAvatarStatus };
@@ -1,18 +1,37 @@
1
1
  import * as _angular_core from '@angular/core';
2
- import { ElementRef } from '@angular/core';
3
2
  import { BooleanInput, NumberInput } from '@angular/cdk/coercion';
4
3
  import { ControlValueAccessor } from '@angular/forms';
5
4
  import { ChangeFn, TouchFn } from '@spartan-ng/brain/forms';
6
- import { ClassValue } from 'clsx';
7
- import * as i1 from '@spartan-ng/brain/field';
8
5
  import * as _spartan_ng_brain_input_otp from '@spartan-ng/brain/input-otp';
6
+ import * as i1 from '@spartan-ng/brain/field';
7
+
8
+ type InputMode = 'text' | 'tel' | 'url' | 'email' | 'numeric' | 'decimal' | 'search';
9
+ declare class BrnInputOtpInput {
10
+ private readonly _destroyRef;
11
+ private readonly _elementRef;
12
+ protected readonly _otp: _spartan_ng_brain_input_otp.BrnInputOtp;
13
+ /** Custom autocomplete attribute applied to the input element */
14
+ readonly autocomplete: _angular_core.InputSignal<"one-time-code" | "off">;
15
+ /** Virtual keyboard appearance on mobile */
16
+ readonly inputMode: _angular_core.InputSignal<InputMode>;
17
+ /** Styles applied to the input element to make it invisible and clickable. */
18
+ readonly inputStyles: _angular_core.InputSignal<string | undefined>;
19
+ protected readonly _inputStyles: _angular_core.Signal<string>;
20
+ constructor();
21
+ /** Focus the underlying input element. */
22
+ focus(): void;
23
+ protected onInputChange(): void;
24
+ protected onPaste(event: ClipboardEvent): void;
25
+ private setSelectionRange;
26
+ static ɵfac: _angular_core.ɵɵFactoryDeclaration<BrnInputOtpInput, never>;
27
+ static ɵdir: _angular_core.ɵɵDirectiveDeclaration<BrnInputOtpInput, "input[brnInputOtpInput]", ["brnInputOtpInput"], { "autocomplete": { "alias": "autocomplete"; "required": false; "isSignal": true; }; "inputMode": { "alias": "inputMode"; "required": false; "isSignal": true; }; "inputStyles": { "alias": "inputStyles"; "required": false; "isSignal": true; }; }, {}, never, never, true, never>;
28
+ }
9
29
 
10
30
  declare const BRN_INPUT_OTP_VALUE_ACCESSOR: {
11
31
  provide: _angular_core.InjectionToken<readonly ControlValueAccessor[]>;
12
32
  useExisting: _angular_core.Type<any>;
13
33
  multi: boolean;
14
34
  };
15
- type InputMode = 'text' | 'tel' | 'url' | 'email' | 'numeric' | 'decimal' | 'search';
16
35
  declare class BrnInputOtp implements ControlValueAccessor {
17
36
  private static _id;
18
37
  private readonly _fieldControl;
@@ -27,20 +46,24 @@ declare class BrnInputOtp implements ControlValueAccessor {
27
46
  /** Custom id applied to the input element */
28
47
  readonly inputId: _angular_core.InputSignal<string>;
29
48
  readonly labelableId: _angular_core.InputSignal<string>;
30
- /** Custom autocomplete attribute applied to the input element */
31
- readonly inputAutocomplete: _angular_core.InputSignal<"one-time-code" | "off">;
32
- /** Styles applied to the input element to make it invisible and clickable. */
33
- readonly inputStyles: _angular_core.InputSignal<string>;
34
- /** Styles applied to the container element. */
35
- readonly containerStyles: _angular_core.InputSignal<string>;
36
- /** Determine if the date picker is disabled. */
49
+ /** Determine if the input is disabled. */
37
50
  readonly disabled: _angular_core.InputSignalWithTransform<boolean, BooleanInput>;
38
51
  protected readonly _disabled: _angular_core.WritableSignal<boolean>;
52
+ /** @internal The disabled state as a readonly signal */
53
+ readonly disabledState: _angular_core.Signal<boolean>;
39
54
  /** The number of slots. */
40
55
  readonly length: _angular_core.InputSignalWithTransform<number, NumberInput>;
41
- /** Virtual keyboard appearance on mobile */
42
- readonly inputMode: _angular_core.InputSignal<InputMode>;
43
- readonly inputClass: _angular_core.InputSignal<ClassValue>;
56
+ /**
57
+ * Optional per-character pattern. Each typed or pasted character must match this
58
+ * pattern. Strings are treated as a single-character regular expression.
59
+ *
60
+ * Examples: '[0-9]', '[A-Za-z0-9]'
61
+ */
62
+ readonly slotPattern: _angular_core.InputSignal<string | RegExp | null>;
63
+ /** Whether entered characters should be visually masked. */
64
+ readonly mask: _angular_core.InputSignalWithTransform<boolean, BooleanInput>;
65
+ /** The character used to mask entered characters. */
66
+ readonly maskChar: _angular_core.InputSignal<string>;
44
67
  /** If true, the element is focused automatically on init **/
45
68
  readonly autofocus: _angular_core.InputSignalWithTransform<boolean, BooleanInput>;
46
69
  /**
@@ -53,11 +76,12 @@ declare class BrnInputOtp implements ControlValueAccessor {
53
76
  readonly transformPaste: _angular_core.InputSignal<(pastedText: string, length: number) => string>;
54
77
  /** The value controlling the input */
55
78
  readonly valueInput: _angular_core.InputSignal<string | null>;
56
- readonly value: _angular_core.WritableSignal<string | null>;
79
+ readonly value: _angular_core.WritableSignal<string>;
57
80
  /** Emits when the value changes. */
58
81
  readonly valueChange: _angular_core.OutputEmitterRef<string>;
59
82
  readonly context: _angular_core.Signal<{
60
83
  char: string | null;
84
+ displayChar: string | null;
61
85
  isActive: boolean;
62
86
  hasFakeCaret: boolean;
63
87
  }[]>;
@@ -65,20 +89,31 @@ declare class BrnInputOtp implements ControlValueAccessor {
65
89
  readonly completed: _angular_core.OutputEmitterRef<string>;
66
90
  protected _onChange?: ChangeFn<string>;
67
91
  protected _onTouched?: TouchFn;
68
- protected readonly _inputComponentRef: _angular_core.Signal<ElementRef<any>>;
92
+ /** The registered hidden input element. */
93
+ private readonly _input;
69
94
  constructor();
70
- protected onBlur(): void;
71
- protected onInputChange(event: Event): void;
72
- protected onPaste(event: ClipboardEvent): void;
95
+ /** @internal */
96
+ sanitizeValue(value: string | null | undefined, clamp?: boolean): string;
97
+ /** Focus the underlying input element. */
98
+ focus(): void;
99
+ /** @internal */
100
+ registerInput(input: BrnInputOtpInput): void;
101
+ /** @internal */
102
+ unregisterInput(input: BrnInputOtpInput): void;
103
+ /** @internal */
104
+ onFocus(): void;
105
+ /** @internal */
106
+ onBlur(): void;
73
107
  /** CONTROL VALUE ACCESSOR */
74
108
  writeValue(value: string | null): void;
75
109
  registerOnChange(fn: ChangeFn<string>): void;
76
110
  registerOnTouched(fn: TouchFn): void;
77
111
  setDisabledState(isDisabled: boolean): void;
78
112
  private isCompleted;
79
- private updateValue;
113
+ /** @internal */
114
+ updateValue(newValue: string): void;
80
115
  static ɵfac: _angular_core.ɵɵFactoryDeclaration<BrnInputOtp, never>;
81
- static ɵcmp: _angular_core.ɵɵComponentDeclaration<BrnInputOtp, "brn-input-otp", ["brnInputOtp"], { "hostStyles": { "alias": "hostStyles"; "required": false; "isSignal": true; }; "inputId": { "alias": "inputId"; "required": false; "isSignal": true; }; "inputAutocomplete": { "alias": "inputAutocomplete"; "required": false; "isSignal": true; }; "inputStyles": { "alias": "inputStyles"; "required": false; "isSignal": true; }; "containerStyles": { "alias": "containerStyles"; "required": false; "isSignal": true; }; "disabled": { "alias": "disabled"; "required": false; "isSignal": true; }; "length": { "alias": "length"; "required": true; "isSignal": true; }; "inputMode": { "alias": "inputMode"; "required": false; "isSignal": true; }; "inputClass": { "alias": "inputClass"; "required": false; "isSignal": true; }; "autofocus": { "alias": "autofocus"; "required": false; "isSignal": true; }; "transformPaste": { "alias": "transformPaste"; "required": false; "isSignal": true; }; "valueInput": { "alias": "value"; "required": false; "isSignal": true; }; }, { "valueChange": "valueChange"; "completed": "completed"; }, never, ["*"], true, [{ directive: typeof i1.BrnFieldControl; inputs: {}; outputs: {}; }]>;
116
+ static ɵdir: _angular_core.ɵɵDirectiveDeclaration<BrnInputOtp, "brn-input-otp, [brnInputOtp]", ["brnInputOtp"], { "hostStyles": { "alias": "hostStyles"; "required": false; "isSignal": true; }; "inputId": { "alias": "inputId"; "required": false; "isSignal": true; }; "disabled": { "alias": "disabled"; "required": false; "isSignal": true; }; "length": { "alias": "length"; "required": true; "isSignal": true; }; "slotPattern": { "alias": "slotPattern"; "required": false; "isSignal": true; }; "mask": { "alias": "mask"; "required": false; "isSignal": true; }; "maskChar": { "alias": "maskChar"; "required": false; "isSignal": true; }; "autofocus": { "alias": "autofocus"; "required": false; "isSignal": true; }; "transformPaste": { "alias": "transformPaste"; "required": false; "isSignal": true; }; "valueInput": { "alias": "value"; "required": false; "isSignal": true; }; }, { "valueChange": "valueChange"; "completed": "completed"; }, never, never, true, [{ directive: typeof i1.BrnFieldControl; inputs: {}; outputs: {}; }]>;
82
117
  }
83
118
 
84
119
  declare class BrnInputOtpSlot {
@@ -90,6 +125,7 @@ declare class BrnInputOtpSlot {
90
125
  readonly forceInvalid: _angular_core.InputSignalWithTransform<boolean, BooleanInput>;
91
126
  protected readonly _slot: _angular_core.Signal<{
92
127
  char: string | null;
128
+ displayChar: string | null;
93
129
  isActive: boolean;
94
130
  hasFakeCaret: boolean;
95
131
  }>;
@@ -101,7 +137,7 @@ declare class BrnInputOtpSlot {
101
137
  static ɵcmp: _angular_core.ɵɵComponentDeclaration<BrnInputOtpSlot, "brn-input-otp-slot", ["brnInputOtpSlot"], { "index": { "alias": "index"; "required": true; "isSignal": true; }; "forceInvalid": { "alias": "forceInvalid"; "required": false; "isSignal": true; }; }, {}, never, ["*"], true, never>;
102
138
  }
103
139
 
104
- declare const BrnInputOtpImports: readonly [typeof BrnInputOtp, typeof BrnInputOtpSlot];
140
+ declare const BrnInputOtpImports: readonly [typeof BrnInputOtp, typeof BrnInputOtpInput, typeof BrnInputOtpSlot];
105
141
 
106
- export { BRN_INPUT_OTP_VALUE_ACCESSOR, BrnInputOtp, BrnInputOtpImports, BrnInputOtpSlot };
142
+ export { BRN_INPUT_OTP_VALUE_ACCESSOR, BrnInputOtp, BrnInputOtpImports, BrnInputOtpInput, BrnInputOtpSlot };
107
143
  export type { InputMode };