@spartan-ng/brain 0.0.1-alpha.454 → 0.0.1-alpha.456

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,61 +1,156 @@
1
+ import { BooleanInput } from '@angular/cdk/coercion';
1
2
  import { type AfterContentInit, ElementRef, type OnDestroy } from '@angular/core';
3
+ import { ControlValueAccessor } from '@angular/forms';
2
4
  import { ChangeFn, TouchFn } from '@spartan-ng/brain/forms';
3
5
  import * as i0 from "@angular/core";
4
6
  export declare const BRN_CHECKBOX_VALUE_ACCESSOR: {
5
- provide: import("@angular/core").InjectionToken<readonly import("@angular/forms").ControlValueAccessor[]>;
7
+ provide: import("@angular/core").InjectionToken<readonly ControlValueAccessor[]>;
6
8
  useExisting: import("@angular/core").Type<any>;
7
9
  multi: boolean;
8
10
  };
9
- export declare function indeterminateBooleanAttribute(value: unknown): boolean | 'indeterminate';
10
- export declare class BrnCheckboxComponent implements AfterContentInit, OnDestroy {
11
+ export declare class BrnCheckboxComponent implements ControlValueAccessor, AfterContentInit, OnDestroy {
12
+ private readonly _destroyRef;
11
13
  private readonly _renderer;
12
14
  private readonly _elementRef;
13
15
  private readonly _focusMonitor;
16
+ private readonly _cdr;
17
+ private readonly _document;
14
18
  private readonly _isBrowser;
15
- private readonly _focusVisible;
16
- readonly focusVisible: import("@angular/core").Signal<boolean>;
17
- private readonly _focused;
18
- readonly focused: import("@angular/core").Signal<boolean>;
19
+ protected readonly focusVisible: import("@angular/core").WritableSignal<boolean>;
20
+ protected readonly focused: import("@angular/core").WritableSignal<boolean>;
21
+ /**
22
+ * Current checked state of checkbox.
23
+ * Can be boolean (true/false) or 'indeterminate'.
24
+ * Can be bound with [(checked)] for two-way binding.
25
+ */
19
26
  readonly checked: import("@angular/core").ModelSignal<BrnCheckboxValue>;
27
+ /**
28
+ * Read-only signal of current checkbox state.
29
+ * Use this when you only need to read state without changing it.
30
+ */
20
31
  readonly isChecked: import("@angular/core").Signal<BrnCheckboxValue>;
32
+ /**
33
+ * Computed data-state attribute value based on checked state.
34
+ * Returns 'checked', 'unchecked', or 'indeterminate'.
35
+ */
21
36
  protected readonly _dataState: import("@angular/core").Signal<"indeterminate" | "checked" | "unchecked">;
37
+ /**
38
+ * Computed aria-checked attribute value for accessibility.
39
+ * Returns 'true', 'false', or 'mixed' (for indeterminate).
40
+ */
22
41
  protected readonly _ariaChecked: import("@angular/core").Signal<"mixed" | "true" | "false">;
23
- protected readonly _value: import("@angular/core").Signal<"" | "on" | "off">;
24
- /** Used to set the id on the underlying input element. */
42
+ /**
43
+ * Unique identifier for checkbox component.
44
+ * When provided, inner button gets ID without '-checkbox' suffix.
45
+ * Auto-generates ID if not provided.
46
+ */
25
47
  readonly id: import("@angular/core").InputSignal<string | null>;
26
- protected readonly hostId: import("@angular/core").Signal<string | null>;
27
- /** Used to set the name attribute on the underlying input element. */
48
+ /**
49
+ * Form control name for checkbox.
50
+ * When provided, inner button gets name without '-checkbox' suffix.
51
+ */
28
52
  readonly name: import("@angular/core").InputSignal<string | null>;
29
- protected readonly hostName: import("@angular/core").Signal<string | null>;
30
- /** Used to set the aria-label attribute on the underlying input element. */
53
+ /**
54
+ * CSS classes applied to inner button element.
55
+ */
56
+ readonly class: import("@angular/core").InputSignal<string | null>;
57
+ /**
58
+ * Accessibility label for screen readers.
59
+ * Use when no visible label exists.
60
+ */
31
61
  readonly ariaLabel: import("@angular/core").InputSignal<string | null>;
32
- /** Used to set the aria-labelledby attribute on the underlying input element. */
62
+ /**
63
+ * ID of element that labels this checkbox for accessibility.
64
+ * Auto-set when checkbox is inside label element.
65
+ */
33
66
  readonly ariaLabelledby: import("@angular/core").InputSignal<string | null>;
67
+ readonly mutableAriaLabelledby: import("@angular/core").WritableSignal<string | null>;
68
+ /**
69
+ * ID of element that describes this checkbox for accessibility.
70
+ */
34
71
  readonly ariaDescribedby: import("@angular/core").InputSignal<string | null>;
35
- readonly required: import("@angular/core").InputSignalWithTransform<boolean, unknown>;
36
- readonly disabled: import("@angular/core").InputSignalWithTransform<boolean, unknown>;
72
+ /**
73
+ * Whether checkbox is required in a form.
74
+ */
75
+ readonly required: import("@angular/core").InputSignalWithTransform<boolean, BooleanInput>;
76
+ /**
77
+ * Whether checkbox is disabled.
78
+ * Disabled checkboxes cannot be toggled and indicate disabled state through data-disabled attribute.
79
+ */
80
+ readonly disabled: import("@angular/core").InputSignalWithTransform<boolean, BooleanInput>;
81
+ /**
82
+ * Computed state for checkbox container and accessibility.
83
+ * Manages ID, name, and disabled state.
84
+ */
37
85
  protected readonly state: import("@angular/core").Signal<{
38
86
  disabled: import("@angular/core").WritableSignal<boolean>;
87
+ name: string | null;
88
+ id: string | null;
39
89
  }>;
40
90
  protected _onChange: ChangeFn<BrnCheckboxValue>;
41
91
  private _onTouched;
42
- readonly checkbox: import("@angular/core").Signal<ElementRef<HTMLInputElement>>;
92
+ /**
93
+ * Reference to the checkbox button element in the template.
94
+ */
95
+ readonly checkbox: import("@angular/core").Signal<ElementRef<HTMLButtonElement>>;
96
+ /**
97
+ * Event emitted when checkbox value changes.
98
+ * Emits new checked state (true/false/'indeterminate').
99
+ */
43
100
  readonly changed: import("@angular/core").OutputEmitterRef<BrnCheckboxValue>;
101
+ /**
102
+ * Event emitted when checkbox is blurred (loses focus).
103
+ * Used for form validation.
104
+ */
105
+ readonly touched: import("@angular/core").OutputEmitterRef<void>;
44
106
  constructor();
45
- toggle(event: Event): void;
107
+ /**
108
+ * Toggles checkbox between checked/unchecked states.
109
+ * If checkbox is indeterminate, sets to checked.
110
+ * Does nothing if checkbox is disabled.
111
+ */
112
+ toggle(): void;
46
113
  ngAfterContentInit(): void;
47
114
  ngOnDestroy(): void;
115
+ /**
116
+ * Gets proper ID for inner button element.
117
+ * Removes '-checkbox' suffix if present in container ID.
118
+ *
119
+ * @param idPassedToContainer - ID applied to container element
120
+ * @returns ID to use for inner button or null
121
+ */
122
+ protected getCheckboxButtonId(idPassedToContainer: string | null | undefined): string | null;
123
+ /**
124
+ * Updates internal state when control value changes from outside.
125
+ * Handles boolean and 'indeterminate' values.
126
+ * Part of ControlValueAccessor interface.
127
+ *
128
+ * @param value - New checkbox state (true/false/'indeterminate')
129
+ */
48
130
  writeValue(value: BrnCheckboxValue): void;
131
+ /**
132
+ * Registers callback for value changes.
133
+ * Part of ControlValueAccessor interface.
134
+ *
135
+ * @param fn - Function to call when value changes
136
+ */
49
137
  registerOnChange(fn: ChangeFn<BrnCheckboxValue>): void;
138
+ /**
139
+ * Registers callback for touched events.
140
+ * Part of ControlValueAccessor interface.
141
+ *
142
+ * @param fn - Function to call when control is touched
143
+ */
50
144
  registerOnTouched(fn: TouchFn): void;
51
- /** Implemented as a part of ControlValueAccessor. */
52
- setDisabledState(isDisabled: boolean): void;
53
145
  /**
54
- * If the space key is pressed, prevent the default action to stop the page from scrolling.
146
+ * Updates disabled state from form control.
147
+ * Part of ControlValueAccessor interface.
148
+ *
149
+ * @param isDisabled - Whether checkbox should be disabled
55
150
  */
56
- protected preventScrolling(event: KeyboardEvent): void;
151
+ setDisabledState(isDisabled: boolean): void;
57
152
  static ɵfac: i0.ɵɵFactoryDeclaration<BrnCheckboxComponent, never>;
58
- static ɵcmp: i0.ɵɵComponentDeclaration<BrnCheckboxComponent, "brn-checkbox", never, { "checked": { "alias": "checked"; "required": false; "isSignal": true; }; "id": { "alias": "id"; "required": false; "isSignal": true; }; "name": { "alias": "name"; "required": false; "isSignal": true; }; "ariaLabel": { "alias": "aria-label"; "required": false; "isSignal": true; }; "ariaLabelledby": { "alias": "aria-labelledby"; "required": false; "isSignal": true; }; "ariaDescribedby": { "alias": "aria-describedby"; "required": false; "isSignal": true; }; "required": { "alias": "required"; "required": false; "isSignal": true; }; "disabled": { "alias": "disabled"; "required": false; "isSignal": true; }; }, { "checked": "checkedChange"; "changed": "changed"; }, never, ["*"], true, never>;
153
+ static ɵcmp: i0.ɵɵComponentDeclaration<BrnCheckboxComponent, "brn-checkbox", never, { "checked": { "alias": "checked"; "required": false; "isSignal": true; }; "id": { "alias": "id"; "required": false; "isSignal": true; }; "name": { "alias": "name"; "required": false; "isSignal": true; }; "class": { "alias": "class"; "required": false; "isSignal": true; }; "ariaLabel": { "alias": "aria-label"; "required": false; "isSignal": true; }; "ariaLabelledby": { "alias": "aria-labelledby"; "required": false; "isSignal": true; }; "ariaDescribedby": { "alias": "aria-describedby"; "required": false; "isSignal": true; }; "required": { "alias": "required"; "required": false; "isSignal": true; }; "disabled": { "alias": "disabled"; "required": false; "isSignal": true; }; }, { "checked": "checkedChange"; "changed": "changed"; "touched": "touched"; }, never, ["*"], true, never>;
59
154
  }
60
155
  type BrnCheckboxValue = boolean | 'indeterminate';
61
156
  export {};
@@ -1,7 +1,8 @@
1
1
  import * as i0 from '@angular/core';
2
- import { forwardRef, booleanAttribute, inject, Renderer2, ElementRef, PLATFORM_ID, signal, model, computed, input, viewChild, output, effect, HostListener, ViewEncapsulation, ChangeDetectionStrategy, Component, NgModule } from '@angular/core';
2
+ import { forwardRef, inject, DestroyRef, Renderer2, ElementRef, ChangeDetectorRef, PLATFORM_ID, signal, model, computed, input, linkedSignal, booleanAttribute, viewChild, output, effect, ChangeDetectionStrategy, Component, NgModule } from '@angular/core';
3
3
  import { FocusMonitor } from '@angular/cdk/a11y';
4
- import { isPlatformBrowser, NgStyle } from '@angular/common';
4
+ import { DOCUMENT, isPlatformBrowser } from '@angular/common';
5
+ import { takeUntilDestroyed } from '@angular/core/rxjs-interop';
5
6
  import { NG_VALUE_ACCESSOR } from '@angular/forms';
6
7
 
7
8
  const BRN_CHECKBOX_VALUE_ACCESSOR = {
@@ -9,96 +10,164 @@ const BRN_CHECKBOX_VALUE_ACCESSOR = {
9
10
  useExisting: forwardRef(() => BrnCheckboxComponent),
10
11
  multi: true,
11
12
  };
12
- function indeterminateBooleanAttribute(value) {
13
- if (value === 'indeterminate')
14
- return 'indeterminate';
15
- return booleanAttribute(value);
16
- }
13
+ let uniqueIdCounter = 0;
17
14
  const CONTAINER_POST_FIX = '-checkbox';
18
15
  class BrnCheckboxComponent {
16
+ _destroyRef = inject(DestroyRef);
19
17
  _renderer = inject(Renderer2);
20
18
  _elementRef = inject(ElementRef);
21
19
  _focusMonitor = inject(FocusMonitor);
20
+ _cdr = inject(ChangeDetectorRef);
21
+ _document = inject(DOCUMENT);
22
22
  _isBrowser = isPlatformBrowser(inject(PLATFORM_ID));
23
- _focusVisible = signal(false);
24
- focusVisible = this._focusVisible.asReadonly();
25
- _focused = signal(false);
26
- focused = this._focused.asReadonly();
23
+ focusVisible = signal(false);
24
+ focused = signal(false);
25
+ /**
26
+ * Current checked state of checkbox.
27
+ * Can be boolean (true/false) or 'indeterminate'.
28
+ * Can be bound with [(checked)] for two-way binding.
29
+ */
27
30
  checked = model(false);
31
+ /**
32
+ * Read-only signal of current checkbox state.
33
+ * Use this when you only need to read state without changing it.
34
+ */
28
35
  isChecked = this.checked.asReadonly();
36
+ /**
37
+ * Computed data-state attribute value based on checked state.
38
+ * Returns 'checked', 'unchecked', or 'indeterminate'.
39
+ */
29
40
  _dataState = computed(() => {
30
41
  const checked = this.checked();
31
42
  if (checked === 'indeterminate')
32
43
  return 'indeterminate';
33
44
  return checked ? 'checked' : 'unchecked';
34
45
  });
46
+ /**
47
+ * Computed aria-checked attribute value for accessibility.
48
+ * Returns 'true', 'false', or 'mixed' (for indeterminate).
49
+ */
35
50
  _ariaChecked = computed(() => {
36
51
  const checked = this.checked();
37
52
  if (checked === 'indeterminate')
38
53
  return 'mixed';
39
54
  return checked ? 'true' : 'false';
40
55
  });
41
- _value = computed(() => {
42
- const checked = this.checked();
43
- if (checked === 'indeterminate')
44
- return '';
45
- return checked ? 'on' : 'off';
46
- });
47
- /** Used to set the id on the underlying input element. */
48
- id = input(null);
49
- hostId = computed(() => (this.id() ? this.id() + CONTAINER_POST_FIX : null));
50
- /** Used to set the name attribute on the underlying input element. */
56
+ /**
57
+ * Unique identifier for checkbox component.
58
+ * When provided, inner button gets ID without '-checkbox' suffix.
59
+ * Auto-generates ID if not provided.
60
+ */
61
+ id = input(uniqueIdCounter++ + '');
62
+ /**
63
+ * Form control name for checkbox.
64
+ * When provided, inner button gets name without '-checkbox' suffix.
65
+ */
51
66
  name = input(null);
52
- hostName = computed(() => (this.name() ? this.name() + CONTAINER_POST_FIX : null));
53
- /** Used to set the aria-label attribute on the underlying input element. */
67
+ /**
68
+ * CSS classes applied to inner button element.
69
+ */
70
+ class = input(null);
71
+ /**
72
+ * Accessibility label for screen readers.
73
+ * Use when no visible label exists.
74
+ */
54
75
  ariaLabel = input(null, { alias: 'aria-label' });
55
- /** Used to set the aria-labelledby attribute on the underlying input element. */
76
+ /**
77
+ * ID of element that labels this checkbox for accessibility.
78
+ * Auto-set when checkbox is inside label element.
79
+ */
56
80
  ariaLabelledby = input(null, { alias: 'aria-labelledby' });
81
+ mutableAriaLabelledby = linkedSignal(() => this.ariaLabelledby());
82
+ /**
83
+ * ID of element that describes this checkbox for accessibility.
84
+ */
57
85
  ariaDescribedby = input(null, { alias: 'aria-describedby' });
86
+ /**
87
+ * Whether checkbox is required in a form.
88
+ */
58
89
  required = input(false, { transform: booleanAttribute });
90
+ /**
91
+ * Whether checkbox is disabled.
92
+ * Disabled checkboxes cannot be toggled and indicate disabled state through data-disabled attribute.
93
+ */
59
94
  disabled = input(false, { transform: booleanAttribute });
60
- state = computed(() => ({
61
- disabled: signal(this.disabled()),
62
- }));
95
+ /**
96
+ * Computed state for checkbox container and accessibility.
97
+ * Manages ID, name, and disabled state.
98
+ */
99
+ state = computed(() => {
100
+ const name = this.name();
101
+ const id = this.id();
102
+ return {
103
+ disabled: signal(this.disabled()),
104
+ name: name ? name + CONTAINER_POST_FIX : null,
105
+ id: id ? id + CONTAINER_POST_FIX : null,
106
+ };
107
+ });
63
108
  // eslint-disable-next-line @typescript-eslint/no-empty-function
64
109
  _onChange = () => { };
65
110
  // eslint-disable-next-line @typescript-eslint/no-empty-function
66
111
  _onTouched = () => { };
112
+ /**
113
+ * Reference to the checkbox button element in the template.
114
+ */
67
115
  checkbox = viewChild.required('checkBox');
116
+ /**
117
+ * Event emitted when checkbox value changes.
118
+ * Emits new checked state (true/false/'indeterminate').
119
+ */
68
120
  changed = output();
121
+ /**
122
+ * Event emitted when checkbox is blurred (loses focus).
123
+ * Used for form validation.
124
+ */
125
+ touched = output();
69
126
  constructor() {
70
127
  effect(() => {
71
- const parent = this._renderer.parentNode(this._elementRef.nativeElement);
72
- if (!parent)
128
+ const state = this.state();
129
+ const isDisabled = state.disabled();
130
+ if (!this._elementRef.nativeElement || !this._isBrowser)
73
131
  return;
74
- // check if parent is a label and assume it is for this checkbox
75
- if (parent?.tagName === 'LABEL') {
76
- this._renderer.setAttribute(parent, 'data-disabled', this.state().disabled() ? 'true' : 'false');
132
+ const newLabelId = state.id + '-label';
133
+ const checkboxButtonId = this.getCheckboxButtonId(state.id);
134
+ const labelElement = this._elementRef.nativeElement.closest('label') ??
135
+ this._document.querySelector(`label[for="${checkboxButtonId}"]`);
136
+ if (!labelElement)
77
137
  return;
138
+ const existingLabelId = labelElement.id;
139
+ this._renderer.setAttribute(labelElement, 'data-disabled', isDisabled ? 'true' : 'false');
140
+ this.mutableAriaLabelledby.set(existingLabelId || newLabelId);
141
+ if (!existingLabelId || existingLabelId.length === 0) {
142
+ this._renderer.setAttribute(labelElement, 'id', newLabelId);
78
143
  }
79
- if (!this._isBrowser)
80
- return;
81
- const label = parent?.querySelector(`label[for="${this.id()}"]`);
82
- if (!label)
83
- return;
84
- this._renderer.setAttribute(label, 'data-disabled', this.state().disabled() ? 'true' : 'false');
85
144
  });
86
145
  }
87
- toggle(event) {
146
+ /**
147
+ * Toggles checkbox between checked/unchecked states.
148
+ * If checkbox is indeterminate, sets to checked.
149
+ * Does nothing if checkbox is disabled.
150
+ */
151
+ toggle() {
88
152
  if (this.state().disabled())
89
153
  return;
90
- event.preventDefault();
154
+ this._onTouched();
155
+ this.touched.emit();
91
156
  const previousChecked = this.checked();
92
157
  this.checked.set(previousChecked === 'indeterminate' ? true : !previousChecked);
93
- this._onChange(!previousChecked);
94
- this.changed.emit(!previousChecked);
158
+ this._onChange(this.checked());
159
+ this.changed.emit(this.checked());
95
160
  }
96
161
  ngAfterContentInit() {
97
- this._focusMonitor.monitor(this._elementRef, true).subscribe((focusOrigin) => {
162
+ this._focusMonitor
163
+ .monitor(this._elementRef, true)
164
+ .pipe(takeUntilDestroyed(this._destroyRef))
165
+ .subscribe((focusOrigin) => {
98
166
  if (focusOrigin)
99
- this._focused.set(true);
167
+ this.focused.set(true);
100
168
  if (focusOrigin === 'keyboard' || focusOrigin === 'program') {
101
- this._focusVisible.set(true);
169
+ this.focusVisible.set(true);
170
+ this._cdr.markForCheck();
102
171
  }
103
172
  if (!focusOrigin) {
104
173
  // When a focused element becomes disabled, the browser *immediately* fires a blur event.
@@ -107,144 +176,139 @@ class BrnCheckboxComponent {
107
176
  // See https://github.com/angular/angular/issues/17793. To work around this, we defer
108
177
  // telling the form control it has been touched until the next tick.
109
178
  Promise.resolve().then(() => {
110
- this._focusVisible.set(false);
111
- this._focused.set(false);
179
+ this.focusVisible.set(false);
180
+ this.focused.set(false);
112
181
  this._onTouched();
182
+ this.touched.emit();
183
+ this._cdr.markForCheck();
113
184
  });
114
185
  }
115
186
  });
116
- this.checkbox().nativeElement.indeterminate = this.checked() === 'indeterminate';
117
- if (this.checkbox().nativeElement.indeterminate) {
118
- this.checkbox().nativeElement.value = 'indeterminate';
119
- }
120
- else {
121
- this.checkbox().nativeElement.value = this.checked() ? 'on' : 'off';
122
- }
123
- this.checkbox().nativeElement.dispatchEvent(new Event('change'));
124
187
  }
125
188
  ngOnDestroy() {
126
189
  this._focusMonitor.stopMonitoring(this._elementRef);
127
190
  }
191
+ /**
192
+ * Gets proper ID for inner button element.
193
+ * Removes '-checkbox' suffix if present in container ID.
194
+ *
195
+ * @param idPassedToContainer - ID applied to container element
196
+ * @returns ID to use for inner button or null
197
+ */
198
+ getCheckboxButtonId(idPassedToContainer) {
199
+ return idPassedToContainer ? idPassedToContainer.replace(CONTAINER_POST_FIX, '') : null;
200
+ }
201
+ /**
202
+ * Updates internal state when control value changes from outside.
203
+ * Handles boolean and 'indeterminate' values.
204
+ * Part of ControlValueAccessor interface.
205
+ *
206
+ * @param value - New checkbox state (true/false/'indeterminate')
207
+ */
128
208
  writeValue(value) {
129
209
  if (value === 'indeterminate') {
130
210
  this.checked.set('indeterminate');
131
211
  }
132
212
  else {
133
- this.checked.set(!!value);
213
+ this.checked.set(value);
134
214
  }
135
215
  }
216
+ /**
217
+ * Registers callback for value changes.
218
+ * Part of ControlValueAccessor interface.
219
+ *
220
+ * @param fn - Function to call when value changes
221
+ */
136
222
  registerOnChange(fn) {
137
223
  this._onChange = fn;
138
224
  }
225
+ /**
226
+ * Registers callback for touched events.
227
+ * Part of ControlValueAccessor interface.
228
+ *
229
+ * @param fn - Function to call when control is touched
230
+ */
139
231
  registerOnTouched(fn) {
140
232
  this._onTouched = fn;
141
233
  }
142
- /** Implemented as a part of ControlValueAccessor. */
143
- setDisabledState(isDisabled) {
144
- this.state().disabled.set(isDisabled);
145
- }
146
234
  /**
147
- * If the space key is pressed, prevent the default action to stop the page from scrolling.
235
+ * Updates disabled state from form control.
236
+ * Part of ControlValueAccessor interface.
237
+ *
238
+ * @param isDisabled - Whether checkbox should be disabled
148
239
  */
149
- preventScrolling(event) {
150
- event.preventDefault();
240
+ setDisabledState(isDisabled) {
241
+ this.state().disabled.set(isDisabled);
242
+ this._cdr.markForCheck();
151
243
  }
152
244
  /** @nocollapse */ static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.2.8", ngImport: i0, type: BrnCheckboxComponent, deps: [], target: i0.ɵɵFactoryTarget.Component });
153
- /** @nocollapse */ static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.2.0", version: "19.2.8", type: BrnCheckboxComponent, isStandalone: true, selector: "brn-checkbox", inputs: { checked: { classPropertyName: "checked", publicName: "checked", isSignal: true, isRequired: false, transformFunction: null }, id: { classPropertyName: "id", publicName: "id", isSignal: true, isRequired: false, transformFunction: null }, name: { classPropertyName: "name", publicName: "name", isSignal: true, isRequired: false, transformFunction: null }, ariaLabel: { classPropertyName: "ariaLabel", publicName: "aria-label", isSignal: true, isRequired: false, transformFunction: null }, ariaLabelledby: { classPropertyName: "ariaLabelledby", publicName: "aria-labelledby", isSignal: true, isRequired: false, transformFunction: null }, ariaDescribedby: { classPropertyName: "ariaDescribedby", publicName: "aria-describedby", isSignal: true, isRequired: false, transformFunction: null }, required: { classPropertyName: "required", publicName: "required", isSignal: true, isRequired: false, transformFunction: null }, disabled: { classPropertyName: "disabled", publicName: "disabled", isSignal: true, isRequired: false, transformFunction: null } }, outputs: { checked: "checkedChange", changed: "changed" }, host: { listeners: { "click": "toggle($event)", "keyup.space": "toggle($event)", "keyup.enter": "toggle($event)", "keydown.space": "preventScrolling($event)" }, properties: { "attr.tabindex": "state().disabled() ? \"-1\" : \"0\"", "attr.data-state": "_dataState()", "attr.data-focus-visible": "focusVisible()", "attr.data-focus": "focused()", "attr.data-disabled": "state().disabled()", "attr.aria-labelledby": "null", "attr.aria-label": "null", "attr.aria-describedby": "null", "attr.id": "hostId()", "attr.name": "hostName()" } }, providers: [BRN_CHECKBOX_VALUE_ACCESSOR], viewQueries: [{ propertyName: "checkbox", first: true, predicate: ["checkBox"], descendants: true, isSignal: true }], ngImport: i0, template: `
154
- <input
245
+ /** @nocollapse */ static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.2.0", version: "19.2.8", type: BrnCheckboxComponent, isStandalone: true, selector: "brn-checkbox", inputs: { checked: { classPropertyName: "checked", publicName: "checked", isSignal: true, isRequired: false, transformFunction: null }, id: { classPropertyName: "id", publicName: "id", isSignal: true, isRequired: false, transformFunction: null }, name: { classPropertyName: "name", publicName: "name", isSignal: true, isRequired: false, transformFunction: null }, class: { classPropertyName: "class", publicName: "class", isSignal: true, isRequired: false, transformFunction: null }, ariaLabel: { classPropertyName: "ariaLabel", publicName: "aria-label", isSignal: true, isRequired: false, transformFunction: null }, ariaLabelledby: { classPropertyName: "ariaLabelledby", publicName: "aria-labelledby", isSignal: true, isRequired: false, transformFunction: null }, ariaDescribedby: { classPropertyName: "ariaDescribedby", publicName: "aria-describedby", isSignal: true, isRequired: false, transformFunction: null }, required: { classPropertyName: "required", publicName: "required", isSignal: true, isRequired: false, transformFunction: null }, disabled: { classPropertyName: "disabled", publicName: "disabled", isSignal: true, isRequired: false, transformFunction: null } }, outputs: { checked: "checkedChange", changed: "changed", touched: "touched" }, host: { properties: { "style": "{display: \"contents\"}", "attr.id": "state().id", "attr.name": "state().name", "attr.aria-labelledby": "null", "attr.aria-label": "null", "attr.aria-describedby": "null", "attr.data-state": "_dataState()", "attr.data-focus-visible": "focusVisible()", "attr.data-focus": "focused()", "attr.data-disabled": "state().disabled()" } }, providers: [BRN_CHECKBOX_VALUE_ACCESSOR], viewQueries: [{ propertyName: "checkbox", first: true, predicate: ["checkBox"], descendants: true, isSignal: true }], ngImport: i0, template: `
246
+ <button
155
247
  #checkBox
156
- tabindex="-1"
157
- type="checkbox"
158
248
  role="checkbox"
159
- [ngStyle]="{
160
- position: 'absolute',
161
- width: '1px',
162
- height: '1px',
163
- padding: '0',
164
- margin: '-1px',
165
- overflow: 'hidden',
166
- clip: 'rect(0, 0, 0, 0)',
167
- whiteSpace: 'nowrap',
168
- borderWidth: '0',
169
- }"
170
- [id]="id() ?? ''"
171
- [name]="name() ?? ''"
172
- [value]="_value()"
173
- [checked]="isChecked()"
174
- [required]="required()"
175
- [attr.aria-label]="ariaLabel()"
176
- [attr.aria-labelledby]="ariaLabelledby()"
177
- [attr.aria-describedby]="ariaDescribedby()"
178
- [attr.aria-required]="required() || null"
249
+ type="button"
250
+ [id]="getCheckboxButtonId(state().id) ?? ''"
251
+ [name]="getCheckboxButtonId(state().name) ?? ''"
252
+ [class]="class()"
179
253
  [attr.aria-checked]="_ariaChecked()"
180
- />
181
- <ng-content />
182
- `, isInline: true, dependencies: [{ kind: "directive", type: NgStyle, selector: "[ngStyle]", inputs: ["ngStyle"] }], changeDetection: i0.ChangeDetectionStrategy.OnPush, encapsulation: i0.ViewEncapsulation.None });
254
+ [attr.aria-label]="ariaLabel() || null"
255
+ [attr.aria-labelledby]="mutableAriaLabelledby() || null"
256
+ [attr.aria-describedby]="ariaDescribedby() || null"
257
+ [attr.data-state]="_dataState()"
258
+ [attr.data-focus-visible]="focusVisible()"
259
+ [attr.data-focus]="focused()"
260
+ [attr.data-disabled]="state().disabled()"
261
+ [disabled]="state().disabled()"
262
+ [tabIndex]="state().disabled() ? -1 : 0"
263
+ (click)="$event.preventDefault(); toggle()"
264
+ >
265
+ <ng-content />
266
+ </button>
267
+ `, isInline: true, changeDetection: i0.ChangeDetectionStrategy.OnPush });
183
268
  }
184
269
  i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.2.8", ngImport: i0, type: BrnCheckboxComponent, decorators: [{
185
270
  type: Component,
186
271
  args: [{
187
272
  selector: 'brn-checkbox',
188
- imports: [NgStyle],
189
273
  template: `
190
- <input
274
+ <button
191
275
  #checkBox
192
- tabindex="-1"
193
- type="checkbox"
194
276
  role="checkbox"
195
- [ngStyle]="{
196
- position: 'absolute',
197
- width: '1px',
198
- height: '1px',
199
- padding: '0',
200
- margin: '-1px',
201
- overflow: 'hidden',
202
- clip: 'rect(0, 0, 0, 0)',
203
- whiteSpace: 'nowrap',
204
- borderWidth: '0',
205
- }"
206
- [id]="id() ?? ''"
207
- [name]="name() ?? ''"
208
- [value]="_value()"
209
- [checked]="isChecked()"
210
- [required]="required()"
211
- [attr.aria-label]="ariaLabel()"
212
- [attr.aria-labelledby]="ariaLabelledby()"
213
- [attr.aria-describedby]="ariaDescribedby()"
214
- [attr.aria-required]="required() || null"
277
+ type="button"
278
+ [id]="getCheckboxButtonId(state().id) ?? ''"
279
+ [name]="getCheckboxButtonId(state().name) ?? ''"
280
+ [class]="class()"
215
281
  [attr.aria-checked]="_ariaChecked()"
216
- />
217
- <ng-content />
282
+ [attr.aria-label]="ariaLabel() || null"
283
+ [attr.aria-labelledby]="mutableAriaLabelledby() || null"
284
+ [attr.aria-describedby]="ariaDescribedby() || null"
285
+ [attr.data-state]="_dataState()"
286
+ [attr.data-focus-visible]="focusVisible()"
287
+ [attr.data-focus]="focused()"
288
+ [attr.data-disabled]="state().disabled()"
289
+ [disabled]="state().disabled()"
290
+ [tabIndex]="state().disabled() ? -1 : 0"
291
+ (click)="$event.preventDefault(); toggle()"
292
+ >
293
+ <ng-content />
294
+ </button>
218
295
  `,
219
296
  host: {
220
- '[attr.tabindex]': 'state().disabled() ? "-1" : "0"',
297
+ '[style]': '{display: "contents"}',
298
+ '[attr.id]': 'state().id',
299
+ '[attr.name]': 'state().name',
300
+ '[attr.aria-labelledby]': 'null',
301
+ '[attr.aria-label]': 'null',
302
+ '[attr.aria-describedby]': 'null',
221
303
  '[attr.data-state]': '_dataState()',
222
304
  '[attr.data-focus-visible]': 'focusVisible()',
223
305
  '[attr.data-focus]': 'focused()',
224
306
  '[attr.data-disabled]': 'state().disabled()',
225
- '[attr.aria-labelledby]': 'null',
226
- '[attr.aria-label]': 'null',
227
- '[attr.aria-describedby]': 'null',
228
- '[attr.id]': 'hostId()',
229
- '[attr.name]': 'hostName()',
230
307
  },
231
308
  providers: [BRN_CHECKBOX_VALUE_ACCESSOR],
232
309
  changeDetection: ChangeDetectionStrategy.OnPush,
233
- encapsulation: ViewEncapsulation.None,
234
310
  }]
235
- }], ctorParameters: () => [], propDecorators: { toggle: [{
236
- type: HostListener,
237
- args: ['click', ['$event']]
238
- }, {
239
- type: HostListener,
240
- args: ['keyup.space', ['$event']]
241
- }, {
242
- type: HostListener,
243
- args: ['keyup.enter', ['$event']]
244
- }], preventScrolling: [{
245
- type: HostListener,
246
- args: ['keydown.space', ['$event']]
247
- }] } });
311
+ }], ctorParameters: () => [] });
248
312
 
249
313
  const BrnCheckboxImports = [BrnCheckboxComponent];
250
314
  class BrnCheckboxModule {
@@ -264,5 +328,5 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.2.8", ngImpor
264
328
  * Generated bundle index. Do not edit.
265
329
  */
266
330
 
267
- export { BRN_CHECKBOX_VALUE_ACCESSOR, BrnCheckboxComponent, BrnCheckboxImports, BrnCheckboxModule, indeterminateBooleanAttribute };
331
+ export { BRN_CHECKBOX_VALUE_ACCESSOR, BrnCheckboxComponent, BrnCheckboxImports, BrnCheckboxModule };
268
332
  //# sourceMappingURL=spartan-ng-brain-checkbox.mjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"spartan-ng-brain-checkbox.mjs","sources":["../../../../libs/brain/checkbox/src/lib/brn-checkbox.component.ts","../../../../libs/brain/checkbox/src/index.ts","../../../../libs/brain/checkbox/src/spartan-ng-brain-checkbox.ts"],"sourcesContent":["import { FocusMonitor } from '@angular/cdk/a11y';\nimport { NgStyle, isPlatformBrowser } from '@angular/common';\nimport {\n\ttype AfterContentInit,\n\tChangeDetectionStrategy,\n\tComponent,\n\tElementRef,\n\tHostListener,\n\ttype OnDestroy,\n\tPLATFORM_ID,\n\tRenderer2,\n\tViewEncapsulation,\n\tbooleanAttribute,\n\tcomputed,\n\teffect,\n\tforwardRef,\n\tinject,\n\tinput,\n\tmodel,\n\toutput,\n\tsignal,\n\tviewChild,\n} from '@angular/core';\nimport { NG_VALUE_ACCESSOR } from '@angular/forms';\nimport { ChangeFn, TouchFn } from '@spartan-ng/brain/forms';\n\nexport const BRN_CHECKBOX_VALUE_ACCESSOR = {\n\tprovide: NG_VALUE_ACCESSOR,\n\tuseExisting: forwardRef(() => BrnCheckboxComponent),\n\tmulti: true,\n};\n\nexport function indeterminateBooleanAttribute(value: unknown): boolean | 'indeterminate' {\n\tif (value === 'indeterminate') return 'indeterminate';\n\treturn booleanAttribute(value);\n}\n\nconst CONTAINER_POST_FIX = '-checkbox';\n\n@Component({\n\tselector: 'brn-checkbox',\n\timports: [NgStyle],\n\ttemplate: `\n\t\t<input\n\t\t\t#checkBox\n\t\t\ttabindex=\"-1\"\n\t\t\ttype=\"checkbox\"\n\t\t\trole=\"checkbox\"\n\t\t\t[ngStyle]=\"{\n\t\t\t\tposition: 'absolute',\n\t\t\t\twidth: '1px',\n\t\t\t\theight: '1px',\n\t\t\t\tpadding: '0',\n\t\t\t\tmargin: '-1px',\n\t\t\t\toverflow: 'hidden',\n\t\t\t\tclip: 'rect(0, 0, 0, 0)',\n\t\t\t\twhiteSpace: 'nowrap',\n\t\t\t\tborderWidth: '0',\n\t\t\t}\"\n\t\t\t[id]=\"id() ?? ''\"\n\t\t\t[name]=\"name() ?? ''\"\n\t\t\t[value]=\"_value()\"\n\t\t\t[checked]=\"isChecked()\"\n\t\t\t[required]=\"required()\"\n\t\t\t[attr.aria-label]=\"ariaLabel()\"\n\t\t\t[attr.aria-labelledby]=\"ariaLabelledby()\"\n\t\t\t[attr.aria-describedby]=\"ariaDescribedby()\"\n\t\t\t[attr.aria-required]=\"required() || null\"\n\t\t\t[attr.aria-checked]=\"_ariaChecked()\"\n\t\t/>\n\t\t<ng-content />\n\t`,\n\thost: {\n\t\t'[attr.tabindex]': 'state().disabled() ? \"-1\" : \"0\"',\n\t\t'[attr.data-state]': '_dataState()',\n\t\t'[attr.data-focus-visible]': 'focusVisible()',\n\t\t'[attr.data-focus]': 'focused()',\n\t\t'[attr.data-disabled]': 'state().disabled()',\n\t\t'[attr.aria-labelledby]': 'null',\n\t\t'[attr.aria-label]': 'null',\n\t\t'[attr.aria-describedby]': 'null',\n\t\t'[attr.id]': 'hostId()',\n\t\t'[attr.name]': 'hostName()',\n\t},\n\tproviders: [BRN_CHECKBOX_VALUE_ACCESSOR],\n\tchangeDetection: ChangeDetectionStrategy.OnPush,\n\tencapsulation: ViewEncapsulation.None,\n})\nexport class BrnCheckboxComponent implements AfterContentInit, OnDestroy {\n\tprivate readonly _renderer = inject(Renderer2);\n\tprivate readonly _elementRef = inject(ElementRef);\n\tprivate readonly _focusMonitor = inject(FocusMonitor);\n\tprivate readonly _isBrowser = isPlatformBrowser(inject(PLATFORM_ID));\n\n\tprivate readonly _focusVisible = signal(false);\n\tpublic readonly focusVisible = this._focusVisible.asReadonly();\n\tprivate readonly _focused = signal(false);\n\tpublic readonly focused = this._focused.asReadonly();\n\n\tpublic readonly checked = model<BrnCheckboxValue>(false);\n\tpublic readonly isChecked = this.checked.asReadonly();\n\n\tprotected readonly _dataState = computed(() => {\n\t\tconst checked = this.checked();\n\t\tif (checked === 'indeterminate') return 'indeterminate';\n\t\treturn checked ? 'checked' : 'unchecked';\n\t});\n\tprotected readonly _ariaChecked = computed(() => {\n\t\tconst checked = this.checked();\n\t\tif (checked === 'indeterminate') return 'mixed';\n\t\treturn checked ? 'true' : 'false';\n\t});\n\tprotected readonly _value = computed(() => {\n\t\tconst checked = this.checked();\n\t\tif (checked === 'indeterminate') return '';\n\t\treturn checked ? 'on' : 'off';\n\t});\n\n\t/** Used to set the id on the underlying input element. */\n\tpublic readonly id = input<string | null>(null);\n\tprotected readonly hostId = computed(() => (this.id() ? this.id() + CONTAINER_POST_FIX : null));\n\n\t/** Used to set the name attribute on the underlying input element. */\n\tpublic readonly name = input<string | null>(null);\n\tprotected readonly hostName = computed(() => (this.name() ? this.name() + CONTAINER_POST_FIX : null));\n\n\t/** Used to set the aria-label attribute on the underlying input element. */\n\tpublic readonly ariaLabel = input<string | null>(null, { alias: 'aria-label' });\n\n\t/** Used to set the aria-labelledby attribute on the underlying input element. */\n\tpublic readonly ariaLabelledby = input<string | null>(null, { alias: 'aria-labelledby' });\n\n\tpublic readonly ariaDescribedby = input<string | null>(null, { alias: 'aria-describedby' });\n\n\tpublic readonly required = input(false, { transform: booleanAttribute });\n\n\tpublic readonly disabled = input(false, { transform: booleanAttribute });\n\n\tprotected readonly state = computed(() => ({\n\t\tdisabled: signal(this.disabled()),\n\t}));\n\n\t// eslint-disable-next-line @typescript-eslint/no-empty-function\n\tprotected _onChange: ChangeFn<BrnCheckboxValue> = () => {};\n\t// eslint-disable-next-line @typescript-eslint/no-empty-function\n\tprivate _onTouched: TouchFn = () => {};\n\n\tpublic readonly checkbox = viewChild.required<ElementRef<HTMLInputElement>>('checkBox');\n\n\tpublic readonly changed = output<BrnCheckboxValue>();\n\n\tconstructor() {\n\t\teffect(() => {\n\t\t\tconst parent = this._renderer.parentNode(this._elementRef.nativeElement);\n\t\t\tif (!parent) return;\n\t\t\t// check if parent is a label and assume it is for this checkbox\n\t\t\tif (parent?.tagName === 'LABEL') {\n\t\t\t\tthis._renderer.setAttribute(parent, 'data-disabled', this.state().disabled() ? 'true' : 'false');\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tif (!this._isBrowser) return;\n\n\t\t\tconst label = parent?.querySelector(`label[for=\"${this.id()}\"]`);\n\t\t\tif (!label) return;\n\t\t\tthis._renderer.setAttribute(label, 'data-disabled', this.state().disabled() ? 'true' : 'false');\n\t\t});\n\t}\n\n\t@HostListener('click', ['$event'])\n\t@HostListener('keyup.space', ['$event'])\n\t@HostListener('keyup.enter', ['$event'])\n\ttoggle(event: Event) {\n\t\tif (this.state().disabled()) return;\n\t\tevent.preventDefault();\n\t\tconst previousChecked = this.checked();\n\t\tthis.checked.set(previousChecked === 'indeterminate' ? true : !previousChecked);\n\t\tthis._onChange(!previousChecked);\n\t\tthis.changed.emit(!previousChecked);\n\t}\n\n\tngAfterContentInit() {\n\t\tthis._focusMonitor.monitor(this._elementRef, true).subscribe((focusOrigin) => {\n\t\t\tif (focusOrigin) this._focused.set(true);\n\t\t\tif (focusOrigin === 'keyboard' || focusOrigin === 'program') {\n\t\t\t\tthis._focusVisible.set(true);\n\t\t\t}\n\t\t\tif (!focusOrigin) {\n\t\t\t\t// When a focused element becomes disabled, the browser *immediately* fires a blur event.\n\t\t\t\t// Angular does not expect events to be raised during change detection, so any state\n\t\t\t\t// change (such as a form control's ng-touched) will cause a changed-after-checked error.\n\t\t\t\t// See https://github.com/angular/angular/issues/17793. To work around this, we defer\n\t\t\t\t// telling the form control it has been touched until the next tick.\n\t\t\t\tPromise.resolve().then(() => {\n\t\t\t\t\tthis._focusVisible.set(false);\n\t\t\t\t\tthis._focused.set(false);\n\t\t\t\t\tthis._onTouched();\n\t\t\t\t});\n\t\t\t}\n\t\t});\n\n\t\tthis.checkbox().nativeElement.indeterminate = this.checked() === 'indeterminate';\n\t\tif (this.checkbox().nativeElement.indeterminate) {\n\t\t\tthis.checkbox().nativeElement.value = 'indeterminate';\n\t\t} else {\n\t\t\tthis.checkbox().nativeElement.value = this.checked() ? 'on' : 'off';\n\t\t}\n\t\tthis.checkbox().nativeElement.dispatchEvent(new Event('change'));\n\t}\n\n\tngOnDestroy() {\n\t\tthis._focusMonitor.stopMonitoring(this._elementRef);\n\t}\n\n\twriteValue(value: BrnCheckboxValue): void {\n\t\tif (value === 'indeterminate') {\n\t\t\tthis.checked.set('indeterminate');\n\t\t} else {\n\t\t\tthis.checked.set(!!value);\n\t\t}\n\t}\n\n\tregisterOnChange(fn: ChangeFn<BrnCheckboxValue>): void {\n\t\tthis._onChange = fn;\n\t}\n\n\tregisterOnTouched(fn: TouchFn): void {\n\t\tthis._onTouched = fn;\n\t}\n\n\t/** Implemented as a part of ControlValueAccessor. */\n\tsetDisabledState(isDisabled: boolean): void {\n\t\tthis.state().disabled.set(isDisabled);\n\t}\n\n\t/**\n\t * If the space key is pressed, prevent the default action to stop the page from scrolling.\n\t */\n\t@HostListener('keydown.space', ['$event'])\n\tprotected preventScrolling(event: KeyboardEvent): void {\n\t\tevent.preventDefault();\n\t}\n}\n\ntype BrnCheckboxValue = boolean | 'indeterminate';\n","import { NgModule } from '@angular/core';\n\nimport { BrnCheckboxComponent } from './lib/brn-checkbox.component';\n\nexport * from './lib/brn-checkbox.component';\n\nexport const BrnCheckboxImports = [BrnCheckboxComponent] as const;\n\n@NgModule({\n\timports: [...BrnCheckboxImports],\n\texports: [...BrnCheckboxImports],\n})\nexport class BrnCheckboxModule {}\n","/**\n * Generated bundle index. Do not edit.\n */\n\nexport * from './index';\n"],"names":[],"mappings":";;;;;;A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A,mBAAmB,EAAE,MAAM;AAC3B,wBAAA,yBAAyB,EAAE,MAAM;AACjC,wBAAA,WAAW,EAAE,UAAU;AACvB,wBAAA,aAAa,EAAE,YAAY;AAC3B,qBAAA;oBACD,SAAS,EAAE,CAAC,2BAA2B,CAAC;oBACxC,eAAe,EAAE,uBAAuB,CAAC,MAAM;oBAC/C,aAAa,EAAE,iBAAiB,CAAC,IAAI;AACrC,iBAAA;wDAoFA,MAAM,EAAA,CAAA;sBAHL,YAAY;uBAAC,OAAO,EAAE,CAAC,QAAQ,CAAC;;sBAChC,YAAY;uBAAC,aAAa,EAAE,CAAC,QAAQ,CAAC;;sBACtC,YAAY;uBAAC,aAAa,EAAE,CAAC,QAAQ,CAAC;gBAoE7B,gBAAgB,EAAA,CAAA;sBADzB,YAAY;uBAAC,eAAe,EAAE,CAAC,QAAQ,CAAC;;;ACvO7B,MAAA,kBAAkB,GAAG,CAAC,oBAAoB;MAM1C,iBAAiB,CAAA;0HAAjB,iBAAiB,EAAA,IAAA,EAAA,EAAA,EAAA,MAAA,EAAA,EAAA,CAAA,eAAA,CAAA,QAAA,EAAA,CAAA;2HAAjB,iBAAiB,EAAA,OAAA,EAAA,CANK,oBAAoB,CAAA,EAAA,OAAA,EAAA,CAApB,oBAAoB,CAAA,EAAA,CAAA;2HAM1C,iBAAiB,EAAA,CAAA;;2FAAjB,iBAAiB,EAAA,UAAA,EAAA,CAAA;kBAJ7B,QAAQ;AAAC,YAAA,IAAA,EAAA,CAAA;AACT,oBAAA,OAAO,EAAE,CAAC,GAAG,kBAAkB,CAAC;AAChC,oBAAA,OAAO,EAAE,CAAC,GAAG,kBAAkB,CAAC;AAChC,iBAAA;;;ACXD;;AAEG;;;;"}
1
+ {"version":3,"file":"spartan-ng-brain-checkbox.mjs","sources":["../../../../libs/brain/checkbox/src/lib/brn-checkbox.component.ts","../../../../libs/brain/checkbox/src/index.ts","../../../../libs/brain/checkbox/src/spartan-ng-brain-checkbox.ts"],"sourcesContent":["import { FocusMonitor } from '@angular/cdk/a11y';\nimport { BooleanInput } from '@angular/cdk/coercion';\nimport { DOCUMENT, isPlatformBrowser } from '@angular/common';\nimport {\n\ttype AfterContentInit,\n\tChangeDetectionStrategy,\n\tChangeDetectorRef,\n\tComponent,\n\tDestroyRef,\n\tElementRef,\n\ttype OnDestroy,\n\tPLATFORM_ID,\n\tRenderer2,\n\tbooleanAttribute,\n\tcomputed,\n\teffect,\n\tforwardRef,\n\tinject,\n\tinput,\n\tlinkedSignal,\n\tmodel,\n\toutput,\n\tsignal,\n\tviewChild,\n} from '@angular/core';\nimport { takeUntilDestroyed } from '@angular/core/rxjs-interop';\nimport { ControlValueAccessor, NG_VALUE_ACCESSOR } from '@angular/forms';\nimport { ChangeFn, TouchFn } from '@spartan-ng/brain/forms';\n\nexport const BRN_CHECKBOX_VALUE_ACCESSOR = {\n\tprovide: NG_VALUE_ACCESSOR,\n\tuseExisting: forwardRef(() => BrnCheckboxComponent),\n\tmulti: true,\n};\n\nlet uniqueIdCounter = 0;\n\nconst CONTAINER_POST_FIX = '-checkbox';\n\n@Component({\n\tselector: 'brn-checkbox',\n\ttemplate: `\n\t\t<button\n\t\t\t#checkBox\n\t\t\trole=\"checkbox\"\n\t\t\ttype=\"button\"\n\t\t\t[id]=\"getCheckboxButtonId(state().id) ?? ''\"\n\t\t\t[name]=\"getCheckboxButtonId(state().name) ?? ''\"\n\t\t\t[class]=\"class()\"\n\t\t\t[attr.aria-checked]=\"_ariaChecked()\"\n\t\t\t[attr.aria-label]=\"ariaLabel() || null\"\n\t\t\t[attr.aria-labelledby]=\"mutableAriaLabelledby() || null\"\n\t\t\t[attr.aria-describedby]=\"ariaDescribedby() || null\"\n\t\t\t[attr.data-state]=\"_dataState()\"\n\t\t\t[attr.data-focus-visible]=\"focusVisible()\"\n\t\t\t[attr.data-focus]=\"focused()\"\n\t\t\t[attr.data-disabled]=\"state().disabled()\"\n\t\t\t[disabled]=\"state().disabled()\"\n\t\t\t[tabIndex]=\"state().disabled() ? -1 : 0\"\n\t\t\t(click)=\"$event.preventDefault(); toggle()\"\n\t\t>\n\t\t\t<ng-content />\n\t\t</button>\n\t`,\n\thost: {\n\t\t'[style]': '{display: \"contents\"}',\n\t\t'[attr.id]': 'state().id',\n\t\t'[attr.name]': 'state().name',\n\t\t'[attr.aria-labelledby]': 'null',\n\t\t'[attr.aria-label]': 'null',\n\t\t'[attr.aria-describedby]': 'null',\n\t\t'[attr.data-state]': '_dataState()',\n\t\t'[attr.data-focus-visible]': 'focusVisible()',\n\t\t'[attr.data-focus]': 'focused()',\n\t\t'[attr.data-disabled]': 'state().disabled()',\n\t},\n\tproviders: [BRN_CHECKBOX_VALUE_ACCESSOR],\n\tchangeDetection: ChangeDetectionStrategy.OnPush,\n})\nexport class BrnCheckboxComponent implements ControlValueAccessor, AfterContentInit, OnDestroy {\n\tprivate readonly _destroyRef = inject(DestroyRef);\n\tprivate readonly _renderer = inject(Renderer2);\n\tprivate readonly _elementRef = inject<ElementRef<HTMLElement>>(ElementRef);\n\tprivate readonly _focusMonitor = inject(FocusMonitor);\n\tprivate readonly _cdr = inject(ChangeDetectorRef);\n\tprivate readonly _document = inject(DOCUMENT);\n\tprivate readonly _isBrowser = isPlatformBrowser(inject(PLATFORM_ID));\n\n\tprotected readonly focusVisible = signal(false);\n\tprotected readonly focused = signal(false);\n\n\t/**\n\t * Current checked state of checkbox.\n\t * Can be boolean (true/false) or 'indeterminate'.\n\t * Can be bound with [(checked)] for two-way binding.\n\t */\n\tpublic readonly checked = model<BrnCheckboxValue>(false);\n\n\t/**\n\t * Read-only signal of current checkbox state.\n\t * Use this when you only need to read state without changing it.\n\t */\n\tpublic readonly isChecked = this.checked.asReadonly();\n\n\t/**\n\t * Computed data-state attribute value based on checked state.\n\t * Returns 'checked', 'unchecked', or 'indeterminate'.\n\t */\n\tprotected readonly _dataState = computed(() => {\n\t\tconst checked = this.checked();\n\t\tif (checked === 'indeterminate') return 'indeterminate';\n\t\treturn checked ? 'checked' : 'unchecked';\n\t});\n\n\t/**\n\t * Computed aria-checked attribute value for accessibility.\n\t * Returns 'true', 'false', or 'mixed' (for indeterminate).\n\t */\n\tprotected readonly _ariaChecked = computed(() => {\n\t\tconst checked = this.checked();\n\t\tif (checked === 'indeterminate') return 'mixed';\n\t\treturn checked ? 'true' : 'false';\n\t});\n\n\t/**\n\t * Unique identifier for checkbox component.\n\t * When provided, inner button gets ID without '-checkbox' suffix.\n\t * Auto-generates ID if not provided.\n\t */\n\tpublic readonly id = input<string | null>(uniqueIdCounter++ + '');\n\n\t/**\n\t * Form control name for checkbox.\n\t * When provided, inner button gets name without '-checkbox' suffix.\n\t */\n\tpublic readonly name = input<string | null>(null);\n\n\t/**\n\t * CSS classes applied to inner button element.\n\t */\n\tpublic readonly class = input<string | null>(null);\n\n\t/**\n\t * Accessibility label for screen readers.\n\t * Use when no visible label exists.\n\t */\n\tpublic readonly ariaLabel = input<string | null>(null, { alias: 'aria-label' });\n\n\t/**\n\t * ID of element that labels this checkbox for accessibility.\n\t * Auto-set when checkbox is inside label element.\n\t */\n\tpublic readonly ariaLabelledby = input<string | null>(null, { alias: 'aria-labelledby' });\n\tpublic readonly mutableAriaLabelledby = linkedSignal(() => this.ariaLabelledby());\n\n\t/**\n\t * ID of element that describes this checkbox for accessibility.\n\t */\n\tpublic readonly ariaDescribedby = input<string | null>(null, { alias: 'aria-describedby' });\n\n\t/**\n\t * Whether checkbox is required in a form.\n\t */\n\tpublic readonly required = input<boolean, BooleanInput>(false, { transform: booleanAttribute });\n\n\t/**\n\t * Whether checkbox is disabled.\n\t * Disabled checkboxes cannot be toggled and indicate disabled state through data-disabled attribute.\n\t */\n\tpublic readonly disabled = input<boolean, BooleanInput>(false, { transform: booleanAttribute });\n\n\t/**\n\t * Computed state for checkbox container and accessibility.\n\t * Manages ID, name, and disabled state.\n\t */\n\tprotected readonly state = computed(() => {\n\t\tconst name = this.name();\n\t\tconst id = this.id();\n\t\treturn {\n\t\t\tdisabled: signal(this.disabled()),\n\t\t\tname: name ? name + CONTAINER_POST_FIX : null,\n\t\t\tid: id ? id + CONTAINER_POST_FIX : null,\n\t\t};\n\t});\n\n\t// eslint-disable-next-line @typescript-eslint/no-empty-function\n\tprotected _onChange: ChangeFn<BrnCheckboxValue> = () => {};\n\t// eslint-disable-next-line @typescript-eslint/no-empty-function\n\tprivate _onTouched: TouchFn = () => {};\n\n\t/**\n\t * Reference to the checkbox button element in the template.\n\t */\n\tpublic readonly checkbox = viewChild.required<ElementRef<HTMLButtonElement>>('checkBox');\n\n\t/**\n\t * Event emitted when checkbox value changes.\n\t * Emits new checked state (true/false/'indeterminate').\n\t */\n\tpublic readonly changed = output<BrnCheckboxValue>();\n\n\t/**\n\t * Event emitted when checkbox is blurred (loses focus).\n\t * Used for form validation.\n\t */\n\tpublic readonly touched = output<void>();\n\n\tconstructor() {\n\t\teffect(() => {\n\t\t\tconst state = this.state();\n\t\t\tconst isDisabled = state.disabled();\n\n\t\t\tif (!this._elementRef.nativeElement || !this._isBrowser) return;\n\n\t\t\tconst newLabelId = state.id + '-label';\n\t\t\tconst checkboxButtonId = this.getCheckboxButtonId(state.id);\n\t\t\tconst labelElement =\n\t\t\t\tthis._elementRef.nativeElement.closest('label') ??\n\t\t\t\tthis._document.querySelector(`label[for=\"${checkboxButtonId}\"]`);\n\n\t\t\tif (!labelElement) return;\n\t\t\tconst existingLabelId = labelElement.id;\n\n\t\t\tthis._renderer.setAttribute(labelElement, 'data-disabled', isDisabled ? 'true' : 'false');\n\t\t\tthis.mutableAriaLabelledby.set(existingLabelId || newLabelId);\n\n\t\t\tif (!existingLabelId || existingLabelId.length === 0) {\n\t\t\t\tthis._renderer.setAttribute(labelElement, 'id', newLabelId);\n\t\t\t}\n\t\t});\n\t}\n\n\t/**\n\t * Toggles checkbox between checked/unchecked states.\n\t * If checkbox is indeterminate, sets to checked.\n\t * Does nothing if checkbox is disabled.\n\t */\n\ttoggle() {\n\t\tif (this.state().disabled()) return;\n\n\t\tthis._onTouched();\n\t\tthis.touched.emit();\n\n\t\tconst previousChecked = this.checked();\n\t\tthis.checked.set(previousChecked === 'indeterminate' ? true : !previousChecked);\n\t\tthis._onChange(this.checked());\n\t\tthis.changed.emit(this.checked());\n\t}\n\n\tngAfterContentInit() {\n\t\tthis._focusMonitor\n\t\t\t.monitor(this._elementRef, true)\n\t\t\t.pipe(takeUntilDestroyed(this._destroyRef))\n\t\t\t.subscribe((focusOrigin) => {\n\t\t\t\tif (focusOrigin) this.focused.set(true);\n\t\t\t\tif (focusOrigin === 'keyboard' || focusOrigin === 'program') {\n\t\t\t\t\tthis.focusVisible.set(true);\n\t\t\t\t\tthis._cdr.markForCheck();\n\t\t\t\t}\n\t\t\t\tif (!focusOrigin) {\n\t\t\t\t\t// When a focused element becomes disabled, the browser *immediately* fires a blur event.\n\t\t\t\t\t// Angular does not expect events to be raised during change detection, so any state\n\t\t\t\t\t// change (such as a form control's ng-touched) will cause a changed-after-checked error.\n\t\t\t\t\t// See https://github.com/angular/angular/issues/17793. To work around this, we defer\n\t\t\t\t\t// telling the form control it has been touched until the next tick.\n\t\t\t\t\tPromise.resolve().then(() => {\n\t\t\t\t\t\tthis.focusVisible.set(false);\n\t\t\t\t\t\tthis.focused.set(false);\n\t\t\t\t\t\tthis._onTouched();\n\t\t\t\t\t\tthis.touched.emit();\n\t\t\t\t\t\tthis._cdr.markForCheck();\n\t\t\t\t\t});\n\t\t\t\t}\n\t\t\t});\n\t}\n\n\tngOnDestroy() {\n\t\tthis._focusMonitor.stopMonitoring(this._elementRef);\n\t}\n\n\t/**\n\t * Gets proper ID for inner button element.\n\t * Removes '-checkbox' suffix if present in container ID.\n\t *\n\t * @param idPassedToContainer - ID applied to container element\n\t * @returns ID to use for inner button or null\n\t */\n\tprotected getCheckboxButtonId(idPassedToContainer: string | null | undefined): string | null {\n\t\treturn idPassedToContainer ? idPassedToContainer.replace(CONTAINER_POST_FIX, '') : null;\n\t}\n\n\t/**\n\t * Updates internal state when control value changes from outside.\n\t * Handles boolean and 'indeterminate' values.\n\t * Part of ControlValueAccessor interface.\n\t *\n\t * @param value - New checkbox state (true/false/'indeterminate')\n\t */\n\twriteValue(value: BrnCheckboxValue): void {\n\t\tif (value === 'indeterminate') {\n\t\t\tthis.checked.set('indeterminate');\n\t\t} else {\n\t\t\tthis.checked.set(value);\n\t\t}\n\t}\n\n\t/**\n\t * Registers callback for value changes.\n\t * Part of ControlValueAccessor interface.\n\t *\n\t * @param fn - Function to call when value changes\n\t */\n\tregisterOnChange(fn: ChangeFn<BrnCheckboxValue>): void {\n\t\tthis._onChange = fn;\n\t}\n\n\t/**\n\t * Registers callback for touched events.\n\t * Part of ControlValueAccessor interface.\n\t *\n\t * @param fn - Function to call when control is touched\n\t */\n\tregisterOnTouched(fn: TouchFn): void {\n\t\tthis._onTouched = fn;\n\t}\n\n\t/**\n\t * Updates disabled state from form control.\n\t * Part of ControlValueAccessor interface.\n\t *\n\t * @param isDisabled - Whether checkbox should be disabled\n\t */\n\tsetDisabledState(isDisabled: boolean): void {\n\t\tthis.state().disabled.set(isDisabled);\n\t\tthis._cdr.markForCheck();\n\t}\n}\n\ntype BrnCheckboxValue = boolean | 'indeterminate';\n","import { NgModule } from '@angular/core';\n\nimport { BrnCheckboxComponent } from './lib/brn-checkbox.component';\n\nexport * from './lib/brn-checkbox.component';\n\nexport const BrnCheckboxImports = [BrnCheckboxComponent] as const;\n\n@NgModule({\n\timports: [...BrnCheckboxImports],\n\texports: [...BrnCheckboxImports],\n})\nexport class BrnCheckboxModule {}\n","/**\n * Generated bundle index. Do not edit.\n */\n\nexport * from './index';\n"],"names":[],"mappings":";;;;;;;AA6Ba,MAAA,2BAA2B,GAAG;AAC1C,IAAA,OAAO,EAAE,iBAAiB;AAC1B,IAAA,WAAW,EAAE,UAAU,CAAC,MAAM,oBAAoB,CAAC;AACnD,IAAA,KAAK,EAAE,IAAI;;AAGZ,IAAI,eAAe,GAAG,CAAC;AAEvB,MAAM,kBAAkB,GAAG,WAAW;MA0CzB,oBAAoB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E,CAAC,2BAA2B,CAAC;oBACxC,eAAe,EAAE,uBAAuB,CAAC,MAAM;AAC/C,iBAAA;;;ACxEY,MAAA,kBAAkB,GAAG,CAAC,oBAAoB;MAM1C,iBAAiB,CAAA;0HAAjB,iBAAiB,EAAA,IAAA,EAAA,EAAA,EAAA,MAAA,EAAA,EAAA,CAAA,eAAA,CAAA,QAAA,EAAA,CAAA;2HAAjB,iBAAiB,EAAA,OAAA,EAAA,CANK,oBAAoB,CAAA,EAAA,OAAA,EAAA,CAApB,oBAAoB,CAAA,EAAA,CAAA;2HAM1C,iBAAiB,EAAA,CAAA;;2FAAjB,iBAAiB,EAAA,UAAA,EAAA,CAAA;kBAJ7B,QAAQ;AAAC,YAAA,IAAA,EAAA,CAAA;AACT,oBAAA,OAAO,EAAE,CAAC,GAAG,kBAAkB,CAAC;AAChC,oBAAA,OAAO,EAAE,CAAC,GAAG,kBAAkB,CAAC;AAChC,iBAAA;;;ACXD;;AAEG;;;;"}
@@ -1,5 +1,5 @@
1
1
  import * as i0 from '@angular/core';
2
- import { Component, forwardRef, inject, DestroyRef, Renderer2, PLATFORM_ID, ElementRef, ChangeDetectorRef, signal, model, input, linkedSignal, booleanAttribute, output, viewChild, computed, effect, ViewEncapsulation, ChangeDetectionStrategy, NgModule } from '@angular/core';
2
+ import { Component, forwardRef, inject, DestroyRef, Renderer2, PLATFORM_ID, ElementRef, ChangeDetectorRef, signal, model, input, linkedSignal, booleanAttribute, output, viewChild, computed, effect, ChangeDetectionStrategy, NgModule } from '@angular/core';
3
3
  import { FocusMonitor } from '@angular/cdk/a11y';
4
4
  import { isPlatformBrowser, DOCUMENT } from '@angular/common';
5
5
  import { takeUntilDestroyed } from '@angular/core/rxjs-interop';
@@ -39,57 +39,64 @@ class BrnSwitchComponent {
39
39
  focusVisible = signal(false);
40
40
  focused = signal(false);
41
41
  /**
42
- * Whether the switch is checked.
43
- * Can be bound with [(checked)]
42
+ * Whether switch is checked/toggled on.
43
+ * Can be bound with [(checked)] for two-way binding.
44
44
  */
45
45
  checked = model(false);
46
46
  /**
47
- * Sets the ID on the switch.
48
- * When provided, the inner button gets this ID without the '-switch' suffix.
47
+ * Unique identifier for switch component.
48
+ * When provided, inner button gets ID without '-switch' suffix.
49
+ * Auto-generates ID if not provided.
49
50
  */
50
51
  id = input(uniqueIdCounter++ + '');
51
52
  /**
52
- * Sets the name on the switch.
53
- * When provided, the inner button gets this name without a '-switch' suffix.
53
+ * Form control name for switch.
54
+ * When provided, inner button gets name without '-switch' suffix.
54
55
  */
55
56
  name = input(null);
56
57
  /**
57
- * Sets class set on the inner button
58
+ * CSS classes applied to inner button element.
58
59
  */
59
60
  class = input(null);
60
61
  /**
61
- * Sets the aria-label attribute for accessibility.
62
+ * Accessibility label for screen readers.
63
+ * Use when no visible label exists.
62
64
  */
63
65
  ariaLabel = input(null, { alias: 'aria-label' });
64
66
  /**
65
- * Sets the aria-labelledby attribute for accessibility.
67
+ * ID of element that labels this switch for accessibility.
68
+ * Auto-set when switch is inside label element.
66
69
  */
67
70
  ariaLabelledby = input(null, { alias: 'aria-labelledby' });
68
71
  mutableAriaLabelledby = linkedSignal(() => this.ariaLabelledby());
69
72
  /**
70
- * Sets the aria-describedby attribute for accessibility.
73
+ * ID of element that describes this switch for accessibility.
71
74
  */
72
75
  ariaDescribedby = input(null, { alias: 'aria-describedby' });
73
76
  /**
74
- * Whether the switch is required in a form.
77
+ * Whether switch is required in a form.
75
78
  */
76
79
  required = input(false, { transform: booleanAttribute });
77
80
  /**
78
- * Whether the switch is disabled.
81
+ * Whether switch is disabled.
82
+ * Disabled switches cannot be toggled and indicate disabled state with data attribute.
79
83
  */
80
84
  disabled = input(false, {
81
85
  transform: booleanAttribute,
82
86
  });
83
87
  /**
84
- * tabIndex of the switch.
88
+ * Keyboard tab order for switch.
89
+ * @default 0
85
90
  */
86
91
  tabIndex = input(0);
87
92
  /**
88
- * Event emitted when the switch value changes.
93
+ * Event emitted when switch value changes.
94
+ * Emits new checked state (true/false).
89
95
  */
90
96
  changed = output();
91
97
  /**
92
- * Event emitted when the switch is blurred (loses focus).
98
+ * Event emitted when switch is blurred (loses focus).
99
+ * Used for form validation.
93
100
  */
94
101
  touched = output();
95
102
  // eslint-disable-next-line @typescript-eslint/no-empty-function
@@ -126,9 +133,15 @@ class BrnSwitchComponent {
126
133
  }
127
134
  });
128
135
  }
136
+ /**
137
+ * Toggles switch between checked/unchecked states.
138
+ * Does nothing if switch is disabled.
139
+ */
129
140
  toggle() {
130
141
  if (this.state().disabled())
131
142
  return;
143
+ this._onTouched();
144
+ this.touched.emit();
132
145
  this.checked.update((checked) => !checked);
133
146
  this._onChange(this.checked());
134
147
  this.changed.emit(this.checked());
@@ -167,24 +180,53 @@ class BrnSwitchComponent {
167
180
  ngOnDestroy() {
168
181
  this._focusMonitor.stopMonitoring(this._elementRef);
169
182
  }
170
- /** We intercept the id passed to the wrapper component and pass it to the underlying button switch control **/
183
+ /**
184
+ * Gets proper ID for inner button element.
185
+ * Removes '-switch' suffix if present in container ID.
186
+ *
187
+ * @param idPassedToContainer - ID applied to container element
188
+ * @returns ID to use for inner button or null
189
+ */
171
190
  getSwitchButtonId(idPassedToContainer) {
172
191
  return idPassedToContainer ? idPassedToContainer.replace(CONTAINER_POST_FIX, '') : null;
173
192
  }
193
+ /**
194
+ * Updates internal state when control value changes from outside.
195
+ * Part of ControlValueAccessor interface.
196
+ *
197
+ * @param value - New checked state
198
+ */
174
199
  writeValue(value) {
175
200
  this.checked.set(Boolean(value));
176
201
  }
202
+ /**
203
+ * Registers callback for value changes.
204
+ * Part of ControlValueAccessor interface.
205
+ *
206
+ * @param fn - Function to call when value changes
207
+ */
177
208
  registerOnChange(fn) {
178
209
  this._onChange = fn;
179
210
  }
211
+ /**
212
+ * Registers callback for touched events.
213
+ * Part of ControlValueAccessor interface.
214
+ *
215
+ * @param fn - Function to call when control is touched
216
+ */
180
217
  registerOnTouched(fn) {
181
218
  this._onTouched = fn;
182
219
  }
183
- /** Implemented as a part of ControlValueAccessor. */
184
- setDisabledState(isDisabled) {
220
+ /**
221
+ * Updates disabled state from form control.
222
+ * Part of ControlValueAccessor interface.
223
+ *
224
+ * @param isDisabled - Whether switch should be disabled
225
+ */
226
+ setDisabledState = (isDisabled) => {
185
227
  this.state().disabled.set(isDisabled);
186
228
  this._cdr.markForCheck();
187
- }
229
+ };
188
230
  /** @nocollapse */ static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.2.8", ngImport: i0, type: BrnSwitchComponent, deps: [], target: i0.ɵɵFactoryTarget.Component });
189
231
  /** @nocollapse */ static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.2.0", version: "19.2.8", type: BrnSwitchComponent, isStandalone: true, selector: "brn-switch", inputs: { checked: { classPropertyName: "checked", publicName: "checked", isSignal: true, isRequired: false, transformFunction: null }, id: { classPropertyName: "id", publicName: "id", isSignal: true, isRequired: false, transformFunction: null }, name: { classPropertyName: "name", publicName: "name", isSignal: true, isRequired: false, transformFunction: null }, class: { classPropertyName: "class", publicName: "class", isSignal: true, isRequired: false, transformFunction: null }, ariaLabel: { classPropertyName: "ariaLabel", publicName: "aria-label", isSignal: true, isRequired: false, transformFunction: null }, ariaLabelledby: { classPropertyName: "ariaLabelledby", publicName: "aria-labelledby", isSignal: true, isRequired: false, transformFunction: null }, ariaDescribedby: { classPropertyName: "ariaDescribedby", publicName: "aria-describedby", isSignal: true, isRequired: false, transformFunction: null }, required: { classPropertyName: "required", publicName: "required", isSignal: true, isRequired: false, transformFunction: null }, disabled: { classPropertyName: "disabled", publicName: "disabled", isSignal: true, isRequired: false, transformFunction: null }, tabIndex: { classPropertyName: "tabIndex", publicName: "tabIndex", isSignal: true, isRequired: false, transformFunction: null } }, outputs: { checked: "checkedChange", changed: "changed", touched: "touched" }, host: { properties: { "style": "{display: \"contents\"}", "attr.id": "state().id", "attr.name": "state().name", "attr.aria-labelledby": "null", "attr.aria-label": "null", "attr.aria-describedby": "null", "attr.data-state": "checked() ? \"checked\" : \"unchecked\"", "attr.data-focus-visible": "focusVisible()", "attr.data-focus": "focused()", "attr.data-disabled": "state().disabled()" } }, providers: [BRN_SWITCH_VALUE_ACCESSOR], viewQueries: [{ propertyName: "switch", first: true, predicate: ["switch"], descendants: true, isSignal: true }], ngImport: i0, template: `
190
232
  <button
@@ -209,7 +251,7 @@ class BrnSwitchComponent {
209
251
  >
210
252
  <ng-content select="brn-switch-thumb" />
211
253
  </button>
212
- `, isInline: true, changeDetection: i0.ChangeDetectionStrategy.OnPush, encapsulation: i0.ViewEncapsulation.None });
254
+ `, isInline: true, changeDetection: i0.ChangeDetectionStrategy.OnPush });
213
255
  }
214
256
  i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.2.8", ngImport: i0, type: BrnSwitchComponent, decorators: [{
215
257
  type: Component,
@@ -253,7 +295,6 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.2.8", ngImpor
253
295
  },
254
296
  providers: [BRN_SWITCH_VALUE_ACCESSOR],
255
297
  changeDetection: ChangeDetectionStrategy.OnPush,
256
- encapsulation: ViewEncapsulation.None,
257
298
  }]
258
299
  }], ctorParameters: () => [] });
259
300
 
@@ -1 +1 @@
1
- {"version":3,"file":"spartan-ng-brain-switch.mjs","sources":["../../../../libs/brain/switch/src/lib/brn-switch-thumb.component.ts","../../../../libs/brain/switch/src/lib/brn-switch.component.ts","../../../../libs/brain/switch/src/index.ts","../../../../libs/brain/switch/src/spartan-ng-brain-switch.ts"],"sourcesContent":["import { Component } from '@angular/core';\n\n@Component({\n\tselector: 'brn-switch-thumb',\n\ttemplate: '',\n\thost: {\n\t\trole: 'presentation',\n\t\t'(click)': '$event.preventDefault()',\n\t},\n})\nexport class BrnSwitchThumbComponent {}\n","import { FocusMonitor } from '@angular/cdk/a11y';\nimport { BooleanInput } from '@angular/cdk/coercion';\nimport { DOCUMENT, isPlatformBrowser } from '@angular/common';\nimport {\n\ttype AfterContentInit,\n\tbooleanAttribute,\n\tChangeDetectionStrategy,\n\tChangeDetectorRef,\n\tComponent,\n\tcomputed,\n\tDestroyRef,\n\teffect,\n\tElementRef,\n\tforwardRef,\n\tinject,\n\tinput,\n\tlinkedSignal,\n\tmodel,\n\ttype OnDestroy,\n\toutput,\n\tPLATFORM_ID,\n\tRenderer2,\n\tsignal,\n\tviewChild,\n\tViewEncapsulation,\n} from '@angular/core';\nimport { takeUntilDestroyed } from '@angular/core/rxjs-interop';\nimport { NG_VALUE_ACCESSOR } from '@angular/forms';\nimport { ChangeFn, TouchFn } from '@spartan-ng/brain/forms';\n\nexport const BRN_SWITCH_VALUE_ACCESSOR = {\n\tprovide: NG_VALUE_ACCESSOR,\n\tuseExisting: forwardRef(() => BrnSwitchComponent),\n\tmulti: true,\n};\n\nconst CONTAINER_POST_FIX = '-switch';\n\nlet uniqueIdCounter = 0;\n\n@Component({\n\tselector: 'brn-switch',\n\ttemplate: `\n\t\t<button\n\t\t\t#switch\n\t\t\trole=\"switch\"\n\t\t\ttype=\"button\"\n\t\t\t[class]=\"class()\"\n\t\t\t[id]=\"getSwitchButtonId(state().id) ?? ''\"\n\t\t\t[name]=\"getSwitchButtonId(state().name) ?? ''\"\n\t\t\t[value]=\"checked() ? 'on' : 'off'\"\n\t\t\t[attr.aria-checked]=\"checked()\"\n\t\t\t[attr.aria-label]=\"ariaLabel() || null\"\n\t\t\t[attr.aria-labelledby]=\"mutableAriaLabelledby() || null\"\n\t\t\t[attr.aria-describedby]=\"ariaDescribedby() || null\"\n\t\t\t[attr.data-state]=\"checked() ? 'checked' : 'unchecked'\"\n\t\t\t[attr.data-focus-visible]=\"focusVisible()\"\n\t\t\t[attr.data-focus]=\"focused()\"\n\t\t\t[attr.data-disabled]=\"state().disabled()\"\n\t\t\t[disabled]=\"state().disabled()\"\n\t\t\t[tabIndex]=\"tabIndex()\"\n\t\t\t(click)=\"$event.preventDefault(); toggle()\"\n\t\t>\n\t\t\t<ng-content select=\"brn-switch-thumb\" />\n\t\t</button>\n\t`,\n\thost: {\n\t\t'[style]': '{display: \"contents\"}',\n\t\t'[attr.id]': 'state().id',\n\t\t'[attr.name]': 'state().name',\n\t\t'[attr.aria-labelledby]': 'null',\n\t\t'[attr.aria-label]': 'null',\n\t\t'[attr.aria-describedby]': 'null',\n\t\t'[attr.data-state]': 'checked() ? \"checked\" : \"unchecked\"',\n\t\t'[attr.data-focus-visible]': 'focusVisible()',\n\t\t'[attr.data-focus]': 'focused()',\n\t\t'[attr.data-disabled]': 'state().disabled()',\n\t},\n\tproviders: [BRN_SWITCH_VALUE_ACCESSOR],\n\tchangeDetection: ChangeDetectionStrategy.OnPush,\n\tencapsulation: ViewEncapsulation.None,\n})\nexport class BrnSwitchComponent implements AfterContentInit, OnDestroy {\n\tprivate readonly _destroyRef = inject(DestroyRef);\n\tprivate readonly _renderer = inject(Renderer2);\n\tprivate readonly _isBrowser = isPlatformBrowser(inject(PLATFORM_ID));\n\tprivate readonly _elementRef = inject<ElementRef<HTMLElement>>(ElementRef);\n\tprivate readonly _focusMonitor = inject(FocusMonitor);\n\tprivate readonly _cdr = inject(ChangeDetectorRef);\n\tprivate readonly _document = inject(DOCUMENT);\n\n\tprotected readonly focusVisible = signal(false);\n\tprotected readonly focused = signal(false);\n\n\t/**\n\t * Whether the switch is checked.\n\t * Can be bound with [(checked)]\n\t */\n\tpublic readonly checked = model<boolean>(false);\n\n\t/**\n\t * Sets the ID on the switch.\n\t * When provided, the inner button gets this ID without the '-switch' suffix.\n\t */\n\tpublic readonly id = input<string | null>(uniqueIdCounter++ + '');\n\n\t/**\n\t * Sets the name on the switch.\n\t * When provided, the inner button gets this name without a '-switch' suffix.\n\t */\n\tpublic readonly name = input<string | null>(null);\n\n\t/**\n\t * Sets class set on the inner button\n\t */\n\tpublic readonly class = input<string | null>(null);\n\n\t/**\n\t * Sets the aria-label attribute for accessibility.\n\t */\n\tpublic readonly ariaLabel = input<string | null>(null, { alias: 'aria-label' });\n\n\t/**\n\t * Sets the aria-labelledby attribute for accessibility.\n\t */\n\tpublic readonly ariaLabelledby = input<string | null>(null, { alias: 'aria-labelledby' });\n\tpublic readonly mutableAriaLabelledby = linkedSignal(() => this.ariaLabelledby());\n\n\t/**\n\t * Sets the aria-describedby attribute for accessibility.\n\t */\n\tpublic readonly ariaDescribedby = input<string | null>(null, { alias: 'aria-describedby' });\n\n\t/**\n\t * Whether the switch is required in a form.\n\t */\n\tpublic readonly required = input(false, { transform: booleanAttribute });\n\n\t/**\n\t * Whether the switch is disabled.\n\t */\n\tpublic readonly disabled = input<boolean, BooleanInput>(false, {\n\t\ttransform: booleanAttribute,\n\t});\n\n\t/**\n\t * tabIndex of the switch.\n\t */\n\tpublic readonly tabIndex = input(0);\n\n\t/**\n\t * Event emitted when the switch value changes.\n\t */\n\tpublic readonly changed = output<boolean>();\n\n\t/**\n\t * Event emitted when the switch is blurred (loses focus).\n\t */\n\tpublic readonly touched = output<void>();\n\n\t// eslint-disable-next-line @typescript-eslint/no-empty-function\n\tprotected _onChange: ChangeFn<boolean> = () => {};\n\t// eslint-disable-next-line @typescript-eslint/no-empty-function\n\tprivate _onTouched: TouchFn = () => {};\n\n\tpublic readonly switch = viewChild.required<ElementRef<HTMLInputElement>>('switch');\n\n\tprotected readonly state = computed(() => {\n\t\tconst name = this.name();\n\t\tconst id = this.id();\n\t\treturn {\n\t\t\tdisabled: signal(this.disabled()),\n\t\t\tname: name ? name + CONTAINER_POST_FIX : null,\n\t\t\tid: id ? id + CONTAINER_POST_FIX : null,\n\t\t};\n\t});\n\n\tconstructor() {\n\t\teffect(() => {\n\t\t\tconst state = this.state();\n\t\t\tconst isDisabled = state.disabled();\n\n\t\t\tif (!this._elementRef.nativeElement || !this._isBrowser) return;\n\n\t\t\tconst newLabelId = state.id + '-label';\n\t\t\tconst switchButtonId = this.getSwitchButtonId(state.id);\n\t\t\tconst labelElement =\n\t\t\t\tthis._elementRef.nativeElement.closest('label') ??\n\t\t\t\tthis._document.querySelector(`label[for=\"${switchButtonId}\"]`);\n\n\t\t\tif (!labelElement) return;\n\t\t\tconst existingLabelId = labelElement.id;\n\n\t\t\tthis._renderer.setAttribute(labelElement, 'data-disabled', isDisabled ? 'true' : 'false');\n\t\t\tthis.mutableAriaLabelledby.set(existingLabelId || newLabelId);\n\n\t\t\tif (!existingLabelId || existingLabelId.length === 0) {\n\t\t\t\tthis._renderer.setAttribute(labelElement, 'id', newLabelId);\n\t\t\t}\n\t\t});\n\t}\n\n\tprotected toggle(): void {\n\t\tif (this.state().disabled()) return;\n\n\t\tthis.checked.update((checked) => !checked);\n\t\tthis._onChange(this.checked());\n\t\tthis.changed.emit(this.checked());\n\t}\n\n\tngAfterContentInit() {\n\t\tthis._focusMonitor\n\t\t\t.monitor(this._elementRef, true)\n\t\t\t.pipe(takeUntilDestroyed(this._destroyRef))\n\t\t\t.subscribe((focusOrigin) => {\n\t\t\t\tif (focusOrigin) this.focused.set(true);\n\t\t\t\tif (focusOrigin === 'keyboard' || focusOrigin === 'program') {\n\t\t\t\t\tthis.focusVisible.set(true);\n\t\t\t\t\tthis._cdr.markForCheck();\n\t\t\t\t}\n\t\t\t\tif (!focusOrigin) {\n\t\t\t\t\t// When a focused element becomes disabled, the browser *immediately* fires a blur event.\n\t\t\t\t\t// Angular does not expect events to be raised during change detection, so any state\n\t\t\t\t\t// change (such as a form control's ng-touched) will cause a changed-after-checked error.\n\t\t\t\t\t// See https://github.com/angular/angular/issues/17793. To work around this, we defer\n\t\t\t\t\t// telling the form control it has been touched until the next tick.\n\t\t\t\t\tPromise.resolve().then(() => {\n\t\t\t\t\t\tthis.focusVisible.set(false);\n\t\t\t\t\t\tthis.focused.set(false);\n\t\t\t\t\t\tthis._onTouched();\n\t\t\t\t\t\tthis.touched.emit();\n\t\t\t\t\t\tthis._cdr.markForCheck();\n\t\t\t\t\t});\n\t\t\t\t}\n\t\t\t});\n\n\t\tif (!this.switch()) return;\n\t\tthis.switch().nativeElement.value = this.checked() ? 'on' : 'off';\n\t\tthis.switch().nativeElement.dispatchEvent(new Event('change'));\n\t}\n\n\tngOnDestroy() {\n\t\tthis._focusMonitor.stopMonitoring(this._elementRef);\n\t}\n\n\t/** We intercept the id passed to the wrapper component and pass it to the underlying button switch control **/\n\tprotected getSwitchButtonId(idPassedToContainer: string | null | undefined): string | null {\n\t\treturn idPassedToContainer ? idPassedToContainer.replace(CONTAINER_POST_FIX, '') : null;\n\t}\n\n\twriteValue(value: boolean): void {\n\t\tthis.checked.set(Boolean(value));\n\t}\n\n\tregisterOnChange(fn: ChangeFn<boolean>): void {\n\t\tthis._onChange = fn;\n\t}\n\n\tregisterOnTouched(fn: TouchFn): void {\n\t\tthis._onTouched = fn;\n\t}\n\n\t/** Implemented as a part of ControlValueAccessor. */\n\tsetDisabledState(isDisabled: boolean): void {\n\t\tthis.state().disabled.set(isDisabled);\n\t\tthis._cdr.markForCheck();\n\t}\n}\n","import { NgModule } from '@angular/core';\n\nimport { BrnSwitchThumbComponent } from './lib/brn-switch-thumb.component';\nimport { BrnSwitchComponent } from './lib/brn-switch.component';\n\nexport * from './lib/brn-switch-thumb.component';\nexport * from './lib/brn-switch.component';\n\nexport const BrnSwitchImports = [BrnSwitchComponent, BrnSwitchThumbComponent] as const;\n\n@NgModule({\n\timports: [...BrnSwitchImports],\n\texports: [...BrnSwitchImports],\n})\nexport class BrnSwitchModule {}\n","/**\n * Generated bundle index. Do not edit.\n */\n\nexport * from './index';\n"],"names":[],"mappings":";;;;;;;MAUa,uBAAuB,CAAA;0HAAvB,uBAAuB,EAAA,IAAA,EAAA,EAAA,EAAA,MAAA,EAAA,EAAA,CAAA,eAAA,CAAA,SAAA,EAAA,CAAA;AAAvB,uBAAA,OAAA,IAAA,GAAA,EAAA,CAAA,oBAAA,CAAA,EAAA,UAAA,EAAA,QAAA,EAAA,OAAA,EAAA,QAAA,EAAA,IAAA,EAAA,uBAAuB,iLANzB,EAAE,EAAA,QAAA,EAAA,IAAA,EAAA,CAAA;;2FAMA,uBAAuB,EAAA,UAAA,EAAA,CAAA;kBARnC,SA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E,WAAW;AAChC,wBAAA,sBAAsB,EAAE,oBAAoB;AAC5C,qBAAA;oBACD,SAAS,EAAE,CAAC,yBAAyB,CAAC;oBACtC,eAAe,EAAE,uBAAuB,CAAC,MAAM;oBAC/C,aAAa,EAAE,iBAAiB,CAAC,IAAI;AACrC,iBAAA;;;MCzEY,gBAAgB,GAAG,CAAC,kBAAkB,EAAE,uBAAuB;MAM/D,eAAe,CAAA;0HAAf,eAAe,EAAA,IAAA,EAAA,EAAA,EAAA,MAAA,EAAA,EAAA,CAAA,eAAA,CAAA,QAAA,EAAA,CAAA;AAAf,uBAAA,OAAA,IAAA,GAAA,EAAA,CAAA,mBAAA,CAAA,EAAA,UAAA,EAAA,QAAA,EAAA,OAAA,EAAA,QAAA,EAAA,QAAA,EAAA,EAAA,EAAA,IAAA,EAAA,eAAe,YANK,kBAAkB,EAAE,uBAAuB,CAA3C,EAAA,OAAA,EAAA,CAAA,kBAAkB,EAAE,uBAAuB,CAAA,EAAA,CAAA;2HAM/D,eAAe,EAAA,CAAA;;2FAAf,eAAe,EAAA,UAAA,EAAA,CAAA;kBAJ3B,QAAQ;AAAC,YAAA,IAAA,EAAA,CAAA;AACT,oBAAA,OAAO,EAAE,CAAC,GAAG,gBAAgB,CAAC;AAC9B,oBAAA,OAAO,EAAE,CAAC,GAAG,gBAAgB,CAAC;AAC9B,iBAAA;;;ACbD;;AAEG;;;;"}
1
+ {"version":3,"file":"spartan-ng-brain-switch.mjs","sources":["../../../../libs/brain/switch/src/lib/brn-switch-thumb.component.ts","../../../../libs/brain/switch/src/lib/brn-switch.component.ts","../../../../libs/brain/switch/src/index.ts","../../../../libs/brain/switch/src/spartan-ng-brain-switch.ts"],"sourcesContent":["import { Component } from '@angular/core';\n\n@Component({\n\tselector: 'brn-switch-thumb',\n\ttemplate: '',\n\thost: {\n\t\trole: 'presentation',\n\t\t'(click)': '$event.preventDefault()',\n\t},\n})\nexport class BrnSwitchThumbComponent {}\n","import { FocusMonitor } from '@angular/cdk/a11y';\nimport { BooleanInput } from '@angular/cdk/coercion';\nimport { DOCUMENT, isPlatformBrowser } from '@angular/common';\nimport {\n\ttype AfterContentInit,\n\tbooleanAttribute,\n\tChangeDetectionStrategy,\n\tChangeDetectorRef,\n\tComponent,\n\tcomputed,\n\tDestroyRef,\n\teffect,\n\tElementRef,\n\tforwardRef,\n\tinject,\n\tinput,\n\tlinkedSignal,\n\tmodel,\n\ttype OnDestroy,\n\toutput,\n\tPLATFORM_ID,\n\tRenderer2,\n\tsignal,\n\tviewChild,\n} from '@angular/core';\nimport { takeUntilDestroyed } from '@angular/core/rxjs-interop';\nimport { NG_VALUE_ACCESSOR } from '@angular/forms';\nimport { ChangeFn, TouchFn } from '@spartan-ng/brain/forms';\n\nexport const BRN_SWITCH_VALUE_ACCESSOR = {\n\tprovide: NG_VALUE_ACCESSOR,\n\tuseExisting: forwardRef(() => BrnSwitchComponent),\n\tmulti: true,\n};\n\nconst CONTAINER_POST_FIX = '-switch';\n\nlet uniqueIdCounter = 0;\n\n@Component({\n\tselector: 'brn-switch',\n\ttemplate: `\n\t\t<button\n\t\t\t#switch\n\t\t\trole=\"switch\"\n\t\t\ttype=\"button\"\n\t\t\t[class]=\"class()\"\n\t\t\t[id]=\"getSwitchButtonId(state().id) ?? ''\"\n\t\t\t[name]=\"getSwitchButtonId(state().name) ?? ''\"\n\t\t\t[value]=\"checked() ? 'on' : 'off'\"\n\t\t\t[attr.aria-checked]=\"checked()\"\n\t\t\t[attr.aria-label]=\"ariaLabel() || null\"\n\t\t\t[attr.aria-labelledby]=\"mutableAriaLabelledby() || null\"\n\t\t\t[attr.aria-describedby]=\"ariaDescribedby() || null\"\n\t\t\t[attr.data-state]=\"checked() ? 'checked' : 'unchecked'\"\n\t\t\t[attr.data-focus-visible]=\"focusVisible()\"\n\t\t\t[attr.data-focus]=\"focused()\"\n\t\t\t[attr.data-disabled]=\"state().disabled()\"\n\t\t\t[disabled]=\"state().disabled()\"\n\t\t\t[tabIndex]=\"tabIndex()\"\n\t\t\t(click)=\"$event.preventDefault(); toggle()\"\n\t\t>\n\t\t\t<ng-content select=\"brn-switch-thumb\" />\n\t\t</button>\n\t`,\n\thost: {\n\t\t'[style]': '{display: \"contents\"}',\n\t\t'[attr.id]': 'state().id',\n\t\t'[attr.name]': 'state().name',\n\t\t'[attr.aria-labelledby]': 'null',\n\t\t'[attr.aria-label]': 'null',\n\t\t'[attr.aria-describedby]': 'null',\n\t\t'[attr.data-state]': 'checked() ? \"checked\" : \"unchecked\"',\n\t\t'[attr.data-focus-visible]': 'focusVisible()',\n\t\t'[attr.data-focus]': 'focused()',\n\t\t'[attr.data-disabled]': 'state().disabled()',\n\t},\n\tproviders: [BRN_SWITCH_VALUE_ACCESSOR],\n\tchangeDetection: ChangeDetectionStrategy.OnPush,\n})\nexport class BrnSwitchComponent implements AfterContentInit, OnDestroy {\n\tprivate readonly _destroyRef = inject(DestroyRef);\n\tprivate readonly _renderer = inject(Renderer2);\n\tprivate readonly _isBrowser = isPlatformBrowser(inject(PLATFORM_ID));\n\tprivate readonly _elementRef = inject<ElementRef<HTMLElement>>(ElementRef);\n\tprivate readonly _focusMonitor = inject(FocusMonitor);\n\tprivate readonly _cdr = inject(ChangeDetectorRef);\n\tprivate readonly _document = inject(DOCUMENT);\n\n\tprotected readonly focusVisible = signal(false);\n\tprotected readonly focused = signal(false);\n\n\t/**\n\t * Whether switch is checked/toggled on.\n\t * Can be bound with [(checked)] for two-way binding.\n\t */\n\tpublic readonly checked = model<boolean>(false);\n\n\t/**\n\t * Unique identifier for switch component.\n\t * When provided, inner button gets ID without '-switch' suffix.\n\t * Auto-generates ID if not provided.\n\t */\n\tpublic readonly id = input<string | null>(uniqueIdCounter++ + '');\n\n\t/**\n\t * Form control name for switch.\n\t * When provided, inner button gets name without '-switch' suffix.\n\t */\n\tpublic readonly name = input<string | null>(null);\n\n\t/**\n\t * CSS classes applied to inner button element.\n\t */\n\tpublic readonly class = input<string | null>(null);\n\n\t/**\n\t * Accessibility label for screen readers.\n\t * Use when no visible label exists.\n\t */\n\tpublic readonly ariaLabel = input<string | null>(null, { alias: 'aria-label' });\n\n\t/**\n\t * ID of element that labels this switch for accessibility.\n\t * Auto-set when switch is inside label element.\n\t */\n\tpublic readonly ariaLabelledby = input<string | null>(null, { alias: 'aria-labelledby' });\n\tpublic readonly mutableAriaLabelledby = linkedSignal(() => this.ariaLabelledby());\n\n\t/**\n\t * ID of element that describes this switch for accessibility.\n\t */\n\tpublic readonly ariaDescribedby = input<string | null>(null, { alias: 'aria-describedby' });\n\n\t/**\n\t * Whether switch is required in a form.\n\t */\n\tpublic readonly required = input<boolean, BooleanInput>(false, { transform: booleanAttribute });\n\n\t/**\n\t * Whether switch is disabled.\n\t * Disabled switches cannot be toggled and indicate disabled state with data attribute.\n\t */\n\tpublic readonly disabled = input<boolean, BooleanInput>(false, {\n\t\ttransform: booleanAttribute,\n\t});\n\n\t/**\n\t * Keyboard tab order for switch.\n\t * @default 0\n\t */\n\tpublic readonly tabIndex = input(0);\n\n\t/**\n\t * Event emitted when switch value changes.\n\t * Emits new checked state (true/false).\n\t */\n\tpublic readonly changed = output<boolean>();\n\n\t/**\n\t * Event emitted when switch is blurred (loses focus).\n\t * Used for form validation.\n\t */\n\tpublic readonly touched = output<void>();\n\n\t// eslint-disable-next-line @typescript-eslint/no-empty-function\n\tprotected _onChange: ChangeFn<boolean> = () => {};\n\t// eslint-disable-next-line @typescript-eslint/no-empty-function\n\tprivate _onTouched: TouchFn = () => {};\n\n\tpublic readonly switch = viewChild.required<ElementRef<HTMLInputElement>>('switch');\n\n\tprotected readonly state = computed(() => {\n\t\tconst name = this.name();\n\t\tconst id = this.id();\n\t\treturn {\n\t\t\tdisabled: signal(this.disabled()),\n\t\t\tname: name ? name + CONTAINER_POST_FIX : null,\n\t\t\tid: id ? id + CONTAINER_POST_FIX : null,\n\t\t};\n\t});\n\n\tconstructor() {\n\t\teffect(() => {\n\t\t\tconst state = this.state();\n\t\t\tconst isDisabled = state.disabled();\n\n\t\t\tif (!this._elementRef.nativeElement || !this._isBrowser) return;\n\n\t\t\tconst newLabelId = state.id + '-label';\n\t\t\tconst switchButtonId = this.getSwitchButtonId(state.id);\n\t\t\tconst labelElement =\n\t\t\t\tthis._elementRef.nativeElement.closest('label') ??\n\t\t\t\tthis._document.querySelector(`label[for=\"${switchButtonId}\"]`);\n\n\t\t\tif (!labelElement) return;\n\t\t\tconst existingLabelId = labelElement.id;\n\n\t\t\tthis._renderer.setAttribute(labelElement, 'data-disabled', isDisabled ? 'true' : 'false');\n\t\t\tthis.mutableAriaLabelledby.set(existingLabelId || newLabelId);\n\n\t\t\tif (!existingLabelId || existingLabelId.length === 0) {\n\t\t\t\tthis._renderer.setAttribute(labelElement, 'id', newLabelId);\n\t\t\t}\n\t\t});\n\t}\n\n\t/**\n\t * Toggles switch between checked/unchecked states.\n\t * Does nothing if switch is disabled.\n\t */\n\tprotected toggle(): void {\n\t\tif (this.state().disabled()) return;\n\n\t\tthis._onTouched();\n\t\tthis.touched.emit();\n\n\t\tthis.checked.update((checked) => !checked);\n\t\tthis._onChange(this.checked());\n\t\tthis.changed.emit(this.checked());\n\t}\n\n\tpublic ngAfterContentInit() {\n\t\tthis._focusMonitor\n\t\t\t.monitor(this._elementRef, true)\n\t\t\t.pipe(takeUntilDestroyed(this._destroyRef))\n\t\t\t.subscribe((focusOrigin) => {\n\t\t\t\tif (focusOrigin) this.focused.set(true);\n\t\t\t\tif (focusOrigin === 'keyboard' || focusOrigin === 'program') {\n\t\t\t\t\tthis.focusVisible.set(true);\n\t\t\t\t\tthis._cdr.markForCheck();\n\t\t\t\t}\n\t\t\t\tif (!focusOrigin) {\n\t\t\t\t\t// When a focused element becomes disabled, the browser *immediately* fires a blur event.\n\t\t\t\t\t// Angular does not expect events to be raised during change detection, so any state\n\t\t\t\t\t// change (such as a form control's ng-touched) will cause a changed-after-checked error.\n\t\t\t\t\t// See https://github.com/angular/angular/issues/17793. To work around this, we defer\n\t\t\t\t\t// telling the form control it has been touched until the next tick.\n\t\t\t\t\tPromise.resolve().then(() => {\n\t\t\t\t\t\tthis.focusVisible.set(false);\n\t\t\t\t\t\tthis.focused.set(false);\n\t\t\t\t\t\tthis._onTouched();\n\t\t\t\t\t\tthis.touched.emit();\n\t\t\t\t\t\tthis._cdr.markForCheck();\n\t\t\t\t\t});\n\t\t\t\t}\n\t\t\t});\n\n\t\tif (!this.switch()) return;\n\t\tthis.switch().nativeElement.value = this.checked() ? 'on' : 'off';\n\t\tthis.switch().nativeElement.dispatchEvent(new Event('change'));\n\t}\n\n\tpublic ngOnDestroy() {\n\t\tthis._focusMonitor.stopMonitoring(this._elementRef);\n\t}\n\n\t/**\n\t * Gets proper ID for inner button element.\n\t * Removes '-switch' suffix if present in container ID.\n\t *\n\t * @param idPassedToContainer - ID applied to container element\n\t * @returns ID to use for inner button or null\n\t */\n\tprotected getSwitchButtonId(idPassedToContainer: string | null | undefined): string | null {\n\t\treturn idPassedToContainer ? idPassedToContainer.replace(CONTAINER_POST_FIX, '') : null;\n\t}\n\n\t/**\n\t * Updates internal state when control value changes from outside.\n\t * Part of ControlValueAccessor interface.\n\t *\n\t * @param value - New checked state\n\t */\n\tpublic writeValue(value: boolean): void {\n\t\tthis.checked.set(Boolean(value));\n\t}\n\n\t/**\n\t * Registers callback for value changes.\n\t * Part of ControlValueAccessor interface.\n\t *\n\t * @param fn - Function to call when value changes\n\t */\n\tpublic registerOnChange(fn: ChangeFn<boolean>): void {\n\t\tthis._onChange = fn;\n\t}\n\n\t/**\n\t * Registers callback for touched events.\n\t * Part of ControlValueAccessor interface.\n\t *\n\t * @param fn - Function to call when control is touched\n\t */\n\tpublic registerOnTouched(fn: TouchFn): void {\n\t\tthis._onTouched = fn;\n\t}\n\n\t/**\n\t * Updates disabled state from form control.\n\t * Part of ControlValueAccessor interface.\n\t *\n\t * @param isDisabled - Whether switch should be disabled\n\t */\n\tpublic setDisabledState = (isDisabled: boolean): void => {\n\t\tthis.state().disabled.set(isDisabled);\n\t\tthis._cdr.markForCheck();\n\t};\n}\n","import { NgModule } from '@angular/core';\n\nimport { BrnSwitchThumbComponent } from './lib/brn-switch-thumb.component';\nimport { BrnSwitchComponent } from './lib/brn-switch.component';\n\nexport * from './lib/brn-switch-thumb.component';\nexport * from './lib/brn-switch.component';\n\nexport const BrnSwitchImports = [BrnSwitchComponent, BrnSwitchThumbComponent] as const;\n\n@NgModule({\n\timports: [...BrnSwitchImports],\n\texports: [...BrnSwitchImports],\n})\nexport class BrnSwitchModule {}\n","/**\n * Generated bundle index. Do not edit.\n */\n\nexport * from './index';\n"],"names":[],"mappings":";;;;;;;MAUa,uBAAuB,CAAA;0HAAvB,uBAAuB,EAAA,IAAA,EAAA,EAAA,EAAA,MAAA,EAAA,EAAA,CAAA,eAAA,CAAA,SAAA,EAAA,CAAA;AAAvB,uBAAA,OAAA,IAAA,GAAA,EAAA,CAAA,oBAAA,CAAA,EAAA,UAAA,EAAA,QAAA,EAAA,OAAA,EAAA,QAAA,EAAA,IAAA,EAAA,uBAAuB,iLANzB,EAAE,EAAA,QAAA,EAAA,IAAA,EAAA,CAAA;;2FAMA,uBAAuB,EAAA,UAAA,EAAA,CAAA;kBARnC,SAAS;AAAC,YAAA,IAAA,EAAA,CAAA;AACV,oBAAA,QAAQ,EAAE,kBAAkB;AAC5B,oBAAA,QAAQ,EAAE,EAAE;AACZ,oBAAA,IAAI,EAAE;AACL,wBAAA,IAAI,EAAE,cAAc;AACpB,wBAAA,SAAS,EAAE,yBAAyB;AACpC,qBAAA;AACD,iBAAA;;;ACoBY,MAAA,yBAAyB,GAAG;AACxC,IAAA,OAAO,EAAE,iBAAiB;AAC1B,IAAA,WAAW,EAAE,UAAU,CAAC,MAAM,kBAAkB,CAAC;AACjD,IAAA,KAAK,EAAE,IAAI;;AAGZ,MAAM,kBAAkB,GAAG,SAAS;AAEpC,IAAI,eAAe,GAAG,CAAC;MA2CV,kBAAkB,CAAA;AACb,IAAA,WAAW,GAAG,MAAM,CAAC,UAAU,CAAC;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A,EAAA,CAAA,mBAAA,CAAA,EAAA,UAAA,EAAA,QAAA,EAAA,OAAA,EAAA,QAAA,EAAA,QAAA,EAAA,EAAA,EAAA,IAAA,EAAA,eAAe,YANK,kBAAkB,EAAE,uBAAuB,CAA3C,EAAA,OAAA,EAAA,CAAA,kBAAkB,EAAE,uBAAuB,CAAA,EAAA,CAAA;2HAM/D,eAAe,EAAA,CAAA;;2FAAf,eAAe,EAAA,UAAA,EAAA,CAAA;kBAJ3B,QAAQ;AAAC,YAAA,IAAA,EAAA,CAAA;AACT,oBAAA,OAAO,EAAE,CAAC,GAAG,gBAAgB,CAAC;AAC9B,oBAAA,OAAO,EAAE,CAAC,GAAG,gBAAgB,CAAC;AAC9B,iBAAA;;;ACbD;;AAEG;;;;"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@spartan-ng/brain",
3
- "version": "0.0.1-alpha.454",
3
+ "version": "0.0.1-alpha.456",
4
4
  "sideEffects": false,
5
5
  "exports": {
6
6
  "./hlm-tailwind-preset": {
@@ -18,55 +18,62 @@ export declare class BrnSwitchComponent implements AfterContentInit, OnDestroy {
18
18
  protected readonly focusVisible: import("@angular/core").WritableSignal<boolean>;
19
19
  protected readonly focused: import("@angular/core").WritableSignal<boolean>;
20
20
  /**
21
- * Whether the switch is checked.
22
- * Can be bound with [(checked)]
21
+ * Whether switch is checked/toggled on.
22
+ * Can be bound with [(checked)] for two-way binding.
23
23
  */
24
24
  readonly checked: import("@angular/core").ModelSignal<boolean>;
25
25
  /**
26
- * Sets the ID on the switch.
27
- * When provided, the inner button gets this ID without the '-switch' suffix.
26
+ * Unique identifier for switch component.
27
+ * When provided, inner button gets ID without '-switch' suffix.
28
+ * Auto-generates ID if not provided.
28
29
  */
29
30
  readonly id: import("@angular/core").InputSignal<string | null>;
30
31
  /**
31
- * Sets the name on the switch.
32
- * When provided, the inner button gets this name without a '-switch' suffix.
32
+ * Form control name for switch.
33
+ * When provided, inner button gets name without '-switch' suffix.
33
34
  */
34
35
  readonly name: import("@angular/core").InputSignal<string | null>;
35
36
  /**
36
- * Sets class set on the inner button
37
+ * CSS classes applied to inner button element.
37
38
  */
38
39
  readonly class: import("@angular/core").InputSignal<string | null>;
39
40
  /**
40
- * Sets the aria-label attribute for accessibility.
41
+ * Accessibility label for screen readers.
42
+ * Use when no visible label exists.
41
43
  */
42
44
  readonly ariaLabel: import("@angular/core").InputSignal<string | null>;
43
45
  /**
44
- * Sets the aria-labelledby attribute for accessibility.
46
+ * ID of element that labels this switch for accessibility.
47
+ * Auto-set when switch is inside label element.
45
48
  */
46
49
  readonly ariaLabelledby: import("@angular/core").InputSignal<string | null>;
47
50
  readonly mutableAriaLabelledby: import("@angular/core").WritableSignal<string | null>;
48
51
  /**
49
- * Sets the aria-describedby attribute for accessibility.
52
+ * ID of element that describes this switch for accessibility.
50
53
  */
51
54
  readonly ariaDescribedby: import("@angular/core").InputSignal<string | null>;
52
55
  /**
53
- * Whether the switch is required in a form.
56
+ * Whether switch is required in a form.
54
57
  */
55
- readonly required: import("@angular/core").InputSignalWithTransform<boolean, unknown>;
58
+ readonly required: import("@angular/core").InputSignalWithTransform<boolean, BooleanInput>;
56
59
  /**
57
- * Whether the switch is disabled.
60
+ * Whether switch is disabled.
61
+ * Disabled switches cannot be toggled and indicate disabled state with data attribute.
58
62
  */
59
63
  readonly disabled: import("@angular/core").InputSignalWithTransform<boolean, BooleanInput>;
60
64
  /**
61
- * tabIndex of the switch.
65
+ * Keyboard tab order for switch.
66
+ * @default 0
62
67
  */
63
68
  readonly tabIndex: import("@angular/core").InputSignal<number>;
64
69
  /**
65
- * Event emitted when the switch value changes.
70
+ * Event emitted when switch value changes.
71
+ * Emits new checked state (true/false).
66
72
  */
67
73
  readonly changed: import("@angular/core").OutputEmitterRef<boolean>;
68
74
  /**
69
- * Event emitted when the switch is blurred (loses focus).
75
+ * Event emitted when switch is blurred (loses focus).
76
+ * Used for form validation.
70
77
  */
71
78
  readonly touched: import("@angular/core").OutputEmitterRef<void>;
72
79
  protected _onChange: ChangeFn<boolean>;
@@ -78,16 +85,49 @@ export declare class BrnSwitchComponent implements AfterContentInit, OnDestroy {
78
85
  id: string | null;
79
86
  }>;
80
87
  constructor();
88
+ /**
89
+ * Toggles switch between checked/unchecked states.
90
+ * Does nothing if switch is disabled.
91
+ */
81
92
  protected toggle(): void;
82
93
  ngAfterContentInit(): void;
83
94
  ngOnDestroy(): void;
84
- /** We intercept the id passed to the wrapper component and pass it to the underlying button switch control **/
95
+ /**
96
+ * Gets proper ID for inner button element.
97
+ * Removes '-switch' suffix if present in container ID.
98
+ *
99
+ * @param idPassedToContainer - ID applied to container element
100
+ * @returns ID to use for inner button or null
101
+ */
85
102
  protected getSwitchButtonId(idPassedToContainer: string | null | undefined): string | null;
103
+ /**
104
+ * Updates internal state when control value changes from outside.
105
+ * Part of ControlValueAccessor interface.
106
+ *
107
+ * @param value - New checked state
108
+ */
86
109
  writeValue(value: boolean): void;
110
+ /**
111
+ * Registers callback for value changes.
112
+ * Part of ControlValueAccessor interface.
113
+ *
114
+ * @param fn - Function to call when value changes
115
+ */
87
116
  registerOnChange(fn: ChangeFn<boolean>): void;
117
+ /**
118
+ * Registers callback for touched events.
119
+ * Part of ControlValueAccessor interface.
120
+ *
121
+ * @param fn - Function to call when control is touched
122
+ */
88
123
  registerOnTouched(fn: TouchFn): void;
89
- /** Implemented as a part of ControlValueAccessor. */
90
- setDisabledState(isDisabled: boolean): void;
124
+ /**
125
+ * Updates disabled state from form control.
126
+ * Part of ControlValueAccessor interface.
127
+ *
128
+ * @param isDisabled - Whether switch should be disabled
129
+ */
130
+ setDisabledState: (isDisabled: boolean) => void;
91
131
  static ɵfac: i0.ɵɵFactoryDeclaration<BrnSwitchComponent, never>;
92
132
  static ɵcmp: i0.ɵɵComponentDeclaration<BrnSwitchComponent, "brn-switch", never, { "checked": { "alias": "checked"; "required": false; "isSignal": true; }; "id": { "alias": "id"; "required": false; "isSignal": true; }; "name": { "alias": "name"; "required": false; "isSignal": true; }; "class": { "alias": "class"; "required": false; "isSignal": true; }; "ariaLabel": { "alias": "aria-label"; "required": false; "isSignal": true; }; "ariaLabelledby": { "alias": "aria-labelledby"; "required": false; "isSignal": true; }; "ariaDescribedby": { "alias": "aria-describedby"; "required": false; "isSignal": true; }; "required": { "alias": "required"; "required": false; "isSignal": true; }; "disabled": { "alias": "disabled"; "required": false; "isSignal": true; }; "tabIndex": { "alias": "tabIndex"; "required": false; "isSignal": true; }; }, { "checked": "checkedChange"; "changed": "changed"; "touched": "touched"; }, never, ["brn-switch-thumb"], true, never>;
93
133
  }