@spartan-ng/brain 0.0.1-alpha.437 → 0.0.1-alpha.439

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.
Files changed (45) hide show
  1. package/calendar/index.d.ts +5 -2
  2. package/calendar/lib/brn-calendar-cell-button.directive.d.ts +2 -2
  3. package/calendar/lib/brn-calendar-grid.directive.d.ts +1 -1
  4. package/calendar/lib/brn-calendar.directive.d.ts +4 -1
  5. package/calendar/lib/brn-calendar.token.d.ts +19 -5
  6. package/calendar/lib/mode/brn-calendar-multiple.directive.d.ts +61 -0
  7. package/fesm2022/spartan-ng-brain-calendar.mjs +196 -9
  8. package/fesm2022/spartan-ng-brain-calendar.mjs.map +1 -1
  9. package/fesm2022/spartan-ng-brain-input-otp.mjs +212 -0
  10. package/fesm2022/spartan-ng-brain-input-otp.mjs.map +1 -0
  11. package/fesm2022/spartan-ng-brain-select.mjs +2 -1
  12. package/fesm2022/spartan-ng-brain-select.mjs.map +1 -1
  13. package/fesm2022/spartan-ng-brain-slider.mjs +278 -342
  14. package/fesm2022/spartan-ng-brain-slider.mjs.map +1 -1
  15. package/fesm2022/spartan-ng-brain-toggle-group.mjs +260 -0
  16. package/fesm2022/spartan-ng-brain-toggle-group.mjs.map +1 -0
  17. package/fesm2022/spartan-ng-brain-toggle.mjs +6 -197
  18. package/fesm2022/spartan-ng-brain-toggle.mjs.map +1 -1
  19. package/fesm2022/spartan-ng-brain-tooltip.mjs +18 -8
  20. package/fesm2022/spartan-ng-brain-tooltip.mjs.map +1 -1
  21. package/hlm-tailwind-preset.js +5 -0
  22. package/input-otp/README.md +3 -0
  23. package/input-otp/index.d.ts +10 -0
  24. package/input-otp/lib/brn-input-otp-slot.component.d.ts +14 -0
  25. package/input-otp/lib/brn-input-otp.component.d.ts +57 -0
  26. package/input-otp/lib/brn-input-otp.token.d.ts +5 -0
  27. package/package.json +9 -1
  28. package/slider/index.d.ts +9 -4
  29. package/slider/lib/brn-slider-range.directive.d.ts +7 -0
  30. package/slider/lib/brn-slider-thumb.directive.d.ts +18 -11
  31. package/slider/lib/brn-slider-tick.directive.d.ts +12 -0
  32. package/slider/lib/brn-slider-track.directive.d.ts +8 -136
  33. package/slider/lib/brn-slider-track.token.d.ts +5 -0
  34. package/slider/lib/brn-slider.directive.d.ts +37 -0
  35. package/slider/lib/brn-slider.token.d.ts +4 -0
  36. package/toggle/index.d.ts +0 -7
  37. package/toggle/lib/brn-toggle.directive.d.ts +0 -2
  38. package/toggle-group/README.md +3 -0
  39. package/toggle-group/index.d.ts +15 -0
  40. package/{toggle → toggle-group}/lib/brn-toggle-group.component.d.ts +5 -5
  41. package/toggle-group/lib/brn-toggle-item.directive.d.ts +25 -0
  42. package/tooltip/lib/brn-tooltip-trigger.directive.d.ts +8 -4
  43. package/slider/lib/brn-slider-tick-mark.directive.d.ts +0 -15
  44. package/slider/lib/brn-slider-track-active-fill.directive.d.ts +0 -10
  45. /package/{toggle → toggle-group}/lib/brn-toggle-group.token.d.ts +0 -0
@@ -1,175 +1,9 @@
1
1
  import * as i0 from '@angular/core';
2
- import { InjectionToken, inject, forwardRef, input, booleanAttribute, model, computed, signal, output, Component, ChangeDetectorRef, Directive, NgModule } from '@angular/core';
3
- import { NG_VALUE_ACCESSOR } from '@angular/forms';
4
-
5
- const BrnToggleGroupToken = new InjectionToken('BrnToggleGroupToken');
6
- function injectBrnToggleGroup() {
7
- return inject(BrnToggleGroupToken, { optional: true });
8
- }
9
- function provideBrnToggleGroup(value) {
10
- return { provide: BrnToggleGroupToken, useExisting: value };
11
- }
12
-
13
- const BRN_BUTTON_TOGGLE_GROUP_VALUE_ACCESSOR = {
14
- provide: NG_VALUE_ACCESSOR,
15
- useExisting: forwardRef(() => BrnToggleGroupComponent),
16
- multi: true,
17
- };
18
- class BrnButtonToggleChange {
19
- source;
20
- value;
21
- constructor(source, value) {
22
- this.source = source;
23
- this.value = value;
24
- }
25
- }
26
- class BrnToggleGroupComponent {
27
- /**
28
- * The method to be called in order to update ngModel.
29
- */
30
- // eslint-disable-next-line @typescript-eslint/no-empty-function
31
- _onChange = () => { };
32
- /** onTouch function registered via registerOnTouch (ControlValueAccessor). */
33
- // eslint-disable-next-line @typescript-eslint/no-empty-function
34
- onTouched = () => { };
35
- /** Whether the button toggle group has a vertical orientation */
36
- vertical = input(false, {
37
- transform: booleanAttribute,
38
- });
39
- /** Value of the toggle group. */
40
- value = model(undefined);
41
- /** Whether no button toggles need to be selected. */
42
- nullable = input(false, {
43
- transform: booleanAttribute,
44
- });
45
- /** Whether multiple button toggles can be selected. */
46
- multiple = input(false, {
47
- transform: booleanAttribute,
48
- });
49
- /** Whether the button toggle group is disabled. */
50
- disabled = input(false, {
51
- transform: booleanAttribute,
52
- });
53
- /** The internal state of the component. This can be replaced with linkedSignal in the future. */
54
- state = computed(() => ({
55
- disabled: signal(this.disabled()),
56
- }));
57
- /** Emit event when the group value changes. */
58
- change = output();
59
- writeValue(value) {
60
- this.value.set(value);
61
- }
62
- registerOnChange(fn) {
63
- this._onChange = fn;
64
- }
65
- registerOnTouched(fn) {
66
- this.onTouched = fn;
67
- }
68
- setDisabledState(isDisabled) {
69
- this.state().disabled.set(isDisabled);
70
- }
71
- /**
72
- * @internal
73
- * Determines whether a value can be set on the group.
74
- */
75
- canDeselect(value) {
76
- // if null values are allowed, the group can always be nullable
77
- if (this.nullable())
78
- return true;
79
- const currentValue = this.value();
80
- if (this.multiple() && Array.isArray(currentValue)) {
81
- return !(currentValue.length === 1 && currentValue[0] === value);
82
- }
83
- return currentValue !== value;
84
- }
85
- /**
86
- * @internal
87
- * Selects a value.
88
- */
89
- select(value, source) {
90
- if (this.state().disabled() || this.isSelected(value)) {
91
- return;
92
- }
93
- const currentValue = this.value();
94
- // emit the valueChange event here as we should only emit based on user interaction
95
- if (this.multiple()) {
96
- this.emitSelectionChange([...(currentValue ?? []), value], source);
97
- }
98
- else {
99
- this.emitSelectionChange(value, source);
100
- }
101
- this._onChange(this.value());
102
- this.change.emit(new BrnButtonToggleChange(source, this.value()));
103
- }
104
- /**
105
- * @internal
106
- * Deselects a value.
107
- */
108
- deselect(value, source) {
109
- if (this.state().disabled() || !this.isSelected(value) || !this.canDeselect(value)) {
110
- return;
111
- }
112
- const currentValue = this.value();
113
- if (this.multiple()) {
114
- this.emitSelectionChange((currentValue ?? []).filter((v) => v !== value), source);
115
- }
116
- else if (currentValue === value) {
117
- this.emitSelectionChange(null, source);
118
- }
119
- }
120
- /**
121
- * @internal
122
- * Determines whether a value is selected.
123
- */
124
- isSelected(value) {
125
- const currentValue = this.value();
126
- if (currentValue == null ||
127
- currentValue === undefined ||
128
- (Array.isArray(currentValue) && currentValue.length === 0)) {
129
- return false;
130
- }
131
- if (this.multiple()) {
132
- return currentValue?.includes(value);
133
- }
134
- return currentValue === value;
135
- }
136
- /** Update the value of the group */
137
- emitSelectionChange(value, source) {
138
- this.value.set(value);
139
- this._onChange(value);
140
- this.change.emit(new BrnButtonToggleChange(source, this.value()));
141
- }
142
- /** @nocollapse */ static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.2.1", ngImport: i0, type: BrnToggleGroupComponent, deps: [], target: i0.ɵɵFactoryTarget.Component });
143
- /** @nocollapse */ static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.1.0", version: "19.2.1", type: BrnToggleGroupComponent, isStandalone: true, selector: "brn-toggle-group", inputs: { vertical: { classPropertyName: "vertical", publicName: "vertical", isSignal: true, isRequired: false, transformFunction: null }, value: { classPropertyName: "value", publicName: "value", isSignal: true, isRequired: false, transformFunction: null }, nullable: { classPropertyName: "nullable", publicName: "nullable", isSignal: true, isRequired: false, transformFunction: null }, multiple: { classPropertyName: "multiple", publicName: "multiple", isSignal: true, isRequired: false, transformFunction: null }, disabled: { classPropertyName: "disabled", publicName: "disabled", isSignal: true, isRequired: false, transformFunction: null } }, outputs: { value: "valueChange", change: "change" }, host: { attributes: { "role": "group" }, listeners: { "focusout": "onTouched()" }, properties: { "attr.aria-disabled": "state().disabled()", "attr.data-disabled": "state().disabled()", "attr.data-vertical": "vertical()" }, classAttribute: "brn-button-toggle-group" }, providers: [provideBrnToggleGroup(BrnToggleGroupComponent), BRN_BUTTON_TOGGLE_GROUP_VALUE_ACCESSOR], exportAs: ["brnToggleGroup"], ngImport: i0, template: `
144
- <ng-content />
145
- `, isInline: true });
146
- }
147
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.2.1", ngImport: i0, type: BrnToggleGroupComponent, decorators: [{
148
- type: Component,
149
- args: [{
150
- selector: 'brn-toggle-group',
151
- standalone: true,
152
- providers: [provideBrnToggleGroup(BrnToggleGroupComponent), BRN_BUTTON_TOGGLE_GROUP_VALUE_ACCESSOR],
153
- host: {
154
- role: 'group',
155
- class: 'brn-button-toggle-group',
156
- '[attr.aria-disabled]': 'state().disabled()',
157
- '[attr.data-disabled]': 'state().disabled()',
158
- '[attr.data-vertical]': 'vertical()',
159
- '(focusout)': 'onTouched()',
160
- },
161
- exportAs: 'brnToggleGroup',
162
- template: `
163
- <ng-content />
164
- `,
165
- }]
166
- }] });
2
+ import { inject, ChangeDetectorRef, input, booleanAttribute, model, computed, Directive, NgModule } from '@angular/core';
167
3
 
168
4
  class BrnToggleDirective {
169
5
  static _uniqueId = 0;
170
6
  _changeDetector = inject(ChangeDetectorRef);
171
- /** Access the toggle group if available. */
172
- group = injectBrnToggleGroup();
173
7
  /** The id of the toggle. */
174
8
  id = input(`brn-toggle-${BrnToggleDirective._uniqueId++}`);
175
9
  /** The value this toggle represents. */
@@ -188,28 +22,15 @@ class BrnToggleDirective {
188
22
  isOn = computed(() => this._state() === 'on');
189
23
  /** The current state that reflects the group state or the model state. */
190
24
  _state = computed(() => {
191
- if (this.group) {
192
- return this.group.isSelected(this.value()) ? 'on' : 'off';
193
- }
194
25
  return this.state();
195
26
  });
196
27
  toggle() {
197
28
  if (this.disableToggleClick())
198
29
  return;
199
- if (this.group) {
200
- if (this.isOn()) {
201
- this.group.deselect(this.value(), this);
202
- }
203
- else {
204
- this.group.select(this.value(), this);
205
- }
206
- }
207
- else {
208
- this.state.set(this.isOn() ? 'off' : 'on');
209
- }
30
+ this.state.set(this.isOn() ? 'off' : 'on');
210
31
  }
211
32
  /** @nocollapse */ static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.2.1", ngImport: i0, type: BrnToggleDirective, deps: [], target: i0.ɵɵFactoryTarget.Directive });
212
- /** @nocollapse */ static ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "17.1.0", version: "19.2.1", type: BrnToggleDirective, isStandalone: true, selector: "button[hlmToggle], button[brnToggle]", inputs: { id: { classPropertyName: "id", publicName: "id", isSignal: true, isRequired: false, transformFunction: null }, value: { classPropertyName: "value", publicName: "value", isSignal: true, isRequired: false, transformFunction: null }, disabled: { classPropertyName: "disabled", publicName: "disabled", isSignal: true, isRequired: false, transformFunction: null }, state: { classPropertyName: "state", publicName: "state", isSignal: true, isRequired: false, transformFunction: null }, disableToggleClick: { classPropertyName: "disableToggleClick", publicName: "disableToggleClick", isSignal: true, isRequired: false, transformFunction: null } }, outputs: { state: "stateChange" }, host: { listeners: { "click": "toggle()" }, properties: { "id": "id()", "attr.disabled": "disabled() || group?.disabled() ? true : null", "attr.data-disabled": "disabled() || group?.disabled() ? true : null", "attr.data-state": "_state()", "attr.aria-pressed": "isOn()" } }, ngImport: i0 });
33
+ /** @nocollapse */ static ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "17.1.0", version: "19.2.1", type: BrnToggleDirective, isStandalone: true, selector: "button[hlmToggle], button[brnToggle]", inputs: { id: { classPropertyName: "id", publicName: "id", isSignal: true, isRequired: false, transformFunction: null }, value: { classPropertyName: "value", publicName: "value", isSignal: true, isRequired: false, transformFunction: null }, disabled: { classPropertyName: "disabled", publicName: "disabled", isSignal: true, isRequired: false, transformFunction: null }, state: { classPropertyName: "state", publicName: "state", isSignal: true, isRequired: false, transformFunction: null }, disableToggleClick: { classPropertyName: "disableToggleClick", publicName: "disableToggleClick", isSignal: true, isRequired: false, transformFunction: null } }, outputs: { state: "stateChange" }, host: { listeners: { "click": "toggle()" }, properties: { "id": "id()", "attr.disabled": "disabled() ? true : null", "attr.data-disabled": "disabled() ? true : null", "attr.data-state": "_state()", "attr.aria-pressed": "isOn()" } }, ngImport: i0 });
213
34
  }
214
35
  i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.2.1", ngImport: i0, type: BrnToggleDirective, decorators: [{
215
36
  type: Directive,
@@ -218,8 +39,8 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.2.1", ngImpor
218
39
  standalone: true,
219
40
  host: {
220
41
  '[id]': 'id()',
221
- '[attr.disabled]': 'disabled() || group?.disabled() ? true : null',
222
- '[attr.data-disabled]': 'disabled() || group?.disabled() ? true : null',
42
+ '[attr.disabled]': 'disabled() ? true : null',
43
+ '[attr.data-disabled]': 'disabled() ? true : null',
223
44
  '[attr.data-state]': '_state()',
224
45
  '[attr.aria-pressed]': 'isOn()',
225
46
  '(click)': 'toggle()',
@@ -239,22 +60,10 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.2.1", ngImpor
239
60
  exports: [BrnToggleDirective],
240
61
  }]
241
62
  }] });
242
- class BrnToggleGroupModule {
243
- /** @nocollapse */ static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.2.1", ngImport: i0, type: BrnToggleGroupModule, deps: [], target: i0.ɵɵFactoryTarget.NgModule });
244
- /** @nocollapse */ static ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "14.0.0", version: "19.2.1", ngImport: i0, type: BrnToggleGroupModule, imports: [BrnToggleDirective, BrnToggleGroupComponent], exports: [BrnToggleDirective, BrnToggleGroupComponent] });
245
- /** @nocollapse */ static ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "19.2.1", ngImport: i0, type: BrnToggleGroupModule });
246
- }
247
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.2.1", ngImport: i0, type: BrnToggleGroupModule, decorators: [{
248
- type: NgModule,
249
- args: [{
250
- imports: [BrnToggleDirective, BrnToggleGroupComponent],
251
- exports: [BrnToggleDirective, BrnToggleGroupComponent],
252
- }]
253
- }] });
254
63
 
255
64
  /**
256
65
  * Generated bundle index. Do not edit.
257
66
  */
258
67
 
259
- export { BRN_BUTTON_TOGGLE_GROUP_VALUE_ACCESSOR, BrnButtonToggleChange, BrnToggleDirective, BrnToggleGroupComponent, BrnToggleGroupModule, BrnToggleModule };
68
+ export { BrnToggleDirective, BrnToggleModule };
260
69
  //# sourceMappingURL=spartan-ng-brain-toggle.mjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"spartan-ng-brain-toggle.mjs","sources":["../../../../libs/brain/toggle/src/lib/brn-toggle-group.token.ts","../../../../libs/brain/toggle/src/lib/brn-toggle-group.component.ts","../../../../libs/brain/toggle/src/lib/brn-toggle.directive.ts","../../../../libs/brain/toggle/src/index.ts","../../../../libs/brain/toggle/src/spartan-ng-brain-toggle.ts"],"sourcesContent":["import { ExistingProvider, InjectionToken, Type, inject } from '@angular/core';\nimport type { BrnToggleGroupComponent } from './brn-toggle-group.component';\n\nconst BrnToggleGroupToken = new InjectionToken<BrnToggleGroupComponent>('BrnToggleGroupToken');\n\nexport function injectBrnToggleGroup<T>(): BrnToggleGroupComponent<T> | null {\n\treturn inject(BrnToggleGroupToken, { optional: true }) as BrnToggleGroupComponent<T> | null;\n}\n\nexport function provideBrnToggleGroup<T>(value: Type<BrnToggleGroupComponent<T>>): ExistingProvider {\n\treturn { provide: BrnToggleGroupToken, useExisting: value };\n}\n","import { BooleanInput } from '@angular/cdk/coercion';\nimport { Component, booleanAttribute, computed, forwardRef, input, model, output, signal } from '@angular/core';\nimport { type ControlValueAccessor, NG_VALUE_ACCESSOR } from '@angular/forms';\nimport { provideBrnToggleGroup } from './brn-toggle-group.token';\nimport { BrnToggleDirective } from './brn-toggle.directive';\n\nexport const BRN_BUTTON_TOGGLE_GROUP_VALUE_ACCESSOR = {\n\tprovide: NG_VALUE_ACCESSOR,\n\tuseExisting: forwardRef(() => BrnToggleGroupComponent),\n\tmulti: true,\n};\n\nexport class BrnButtonToggleChange<T = unknown> {\n\tconstructor(\n\t\tpublic source: BrnToggleDirective<T>,\n\t\tpublic value: ToggleValue<T>,\n\t) {}\n}\n\n@Component({\n\tselector: 'brn-toggle-group',\n\tstandalone: true,\n\tproviders: [provideBrnToggleGroup(BrnToggleGroupComponent), BRN_BUTTON_TOGGLE_GROUP_VALUE_ACCESSOR],\n\thost: {\n\t\trole: 'group',\n\t\tclass: 'brn-button-toggle-group',\n\t\t'[attr.aria-disabled]': 'state().disabled()',\n\t\t'[attr.data-disabled]': 'state().disabled()',\n\t\t'[attr.data-vertical]': 'vertical()',\n\t\t'(focusout)': 'onTouched()',\n\t},\n\texportAs: 'brnToggleGroup',\n\ttemplate: `\n\t\t<ng-content />\n\t`,\n})\nexport class BrnToggleGroupComponent<T = unknown> implements ControlValueAccessor {\n\t/**\n\t * The method to be called in order to update ngModel.\n\t */\n\t// eslint-disable-next-line @typescript-eslint/no-empty-function\n\tprivate _onChange: (value: ToggleValue<T>) => void = () => {};\n\n\t/** onTouch function registered via registerOnTouch (ControlValueAccessor). */\n\t// eslint-disable-next-line @typescript-eslint/no-empty-function\n\tprotected onTouched: () => void = () => {};\n\n\t/** Whether the button toggle group has a vertical orientation */\n\tpublic readonly vertical = input<boolean, BooleanInput>(false, {\n\t\ttransform: booleanAttribute,\n\t});\n\n\t/** Value of the toggle group. */\n\tpublic readonly value = model<ToggleValue<T>>(undefined);\n\n\t/** Whether no button toggles need to be selected. */\n\tpublic readonly nullable = input<boolean, BooleanInput>(false, {\n\t\ttransform: booleanAttribute,\n\t});\n\n\t/** Whether multiple button toggles can be selected. */\n\tpublic readonly multiple = input<boolean, BooleanInput>(false, {\n\t\ttransform: booleanAttribute,\n\t});\n\n\t/** Whether the button toggle group is disabled. */\n\tpublic readonly disabled = input<boolean, BooleanInput>(false, {\n\t\ttransform: booleanAttribute,\n\t});\n\n\t/** The internal state of the component. This can be replaced with linkedSignal in the future. */\n\tpublic readonly state = computed(() => ({\n\t\tdisabled: signal(this.disabled()),\n\t}));\n\n\t/** Emit event when the group value changes. */\n\tpublic readonly change = output<BrnButtonToggleChange<T>>();\n\n\twriteValue(value: ToggleValue<T>): void {\n\t\tthis.value.set(value);\n\t}\n\n\tregisterOnChange(fn: (value: ToggleValue<T>) => void) {\n\t\tthis._onChange = fn;\n\t}\n\n\tregisterOnTouched(fn: () => void) {\n\t\tthis.onTouched = fn;\n\t}\n\n\tsetDisabledState(isDisabled: boolean): void {\n\t\tthis.state().disabled.set(isDisabled);\n\t}\n\n\t/**\n\t * @internal\n\t * Determines whether a value can be set on the group.\n\t */\n\tcanDeselect(value: ToggleValue<T>): boolean {\n\t\t// if null values are allowed, the group can always be nullable\n\t\tif (this.nullable()) return true;\n\n\t\tconst currentValue = this.value();\n\n\t\tif (this.multiple() && Array.isArray(currentValue)) {\n\t\t\treturn !(currentValue.length === 1 && currentValue[0] === value);\n\t\t}\n\n\t\treturn currentValue !== value;\n\t}\n\n\t/**\n\t * @internal\n\t * Selects a value.\n\t */\n\tselect(value: T, source: BrnToggleDirective<T>): void {\n\t\tif (this.state().disabled() || this.isSelected(value)) {\n\t\t\treturn;\n\t\t}\n\n\t\tconst currentValue = this.value();\n\n\t\t// emit the valueChange event here as we should only emit based on user interaction\n\t\tif (this.multiple()) {\n\t\t\tthis.emitSelectionChange([...((currentValue ?? []) as T[]), value], source);\n\t\t} else {\n\t\t\tthis.emitSelectionChange(value, source);\n\t\t}\n\n\t\tthis._onChange(this.value());\n\t\tthis.change.emit(new BrnButtonToggleChange<T>(source, this.value()));\n\t}\n\n\t/**\n\t * @internal\n\t * Deselects a value.\n\t */\n\tdeselect(value: T, source: BrnToggleDirective<T>): void {\n\t\tif (this.state().disabled() || !this.isSelected(value) || !this.canDeselect(value)) {\n\t\t\treturn;\n\t\t}\n\n\t\tconst currentValue = this.value();\n\n\t\tif (this.multiple()) {\n\t\t\tthis.emitSelectionChange(\n\t\t\t\t((currentValue ?? []) as T[]).filter((v) => v !== value),\n\t\t\t\tsource,\n\t\t\t);\n\t\t} else if (currentValue === value) {\n\t\t\tthis.emitSelectionChange(null, source);\n\t\t}\n\t}\n\n\t/**\n\t * @internal\n\t * Determines whether a value is selected.\n\t */\n\tisSelected(value: T): boolean {\n\t\tconst currentValue = this.value();\n\n\t\tif (\n\t\t\tcurrentValue == null ||\n\t\t\tcurrentValue === undefined ||\n\t\t\t(Array.isArray(currentValue) && currentValue.length === 0)\n\t\t) {\n\t\t\treturn false;\n\t\t}\n\n\t\tif (this.multiple()) {\n\t\t\treturn (currentValue as T[])?.includes(value);\n\t\t}\n\t\treturn currentValue === value;\n\t}\n\n\t/** Update the value of the group */\n\tprivate emitSelectionChange(value: ToggleValue<T>, source: BrnToggleDirective<T>): void {\n\t\tthis.value.set(value);\n\t\tthis._onChange(value);\n\t\tthis.change.emit(new BrnButtonToggleChange<T>(source, this.value()));\n\t}\n}\n\ntype ToggleValue<T> = T | T[] | null | undefined;\n","import { BooleanInput } from '@angular/cdk/coercion';\nimport { ChangeDetectorRef, Directive, booleanAttribute, computed, inject, input, model } from '@angular/core';\nimport { injectBrnToggleGroup } from './brn-toggle-group.token';\n\n@Directive({\n\tselector: 'button[hlmToggle], button[brnToggle]',\n\tstandalone: true,\n\thost: {\n\t\t'[id]': 'id()',\n\t\t'[attr.disabled]': 'disabled() || group?.disabled() ? true : null',\n\t\t'[attr.data-disabled]': 'disabled() || group?.disabled() ? true : null',\n\t\t'[attr.data-state]': '_state()',\n\t\t'[attr.aria-pressed]': 'isOn()',\n\t\t'(click)': 'toggle()',\n\t},\n})\nexport class BrnToggleDirective<T> {\n\tprivate static _uniqueId = 0;\n\n\tprivate readonly _changeDetector = inject(ChangeDetectorRef);\n\n\t/** Access the toggle group if available. */\n\tprotected readonly group = injectBrnToggleGroup<T>();\n\n\t/** The id of the toggle. */\n\tpublic readonly id = input(`brn-toggle-${BrnToggleDirective._uniqueId++}`);\n\n\t/** The value this toggle represents. */\n\tpublic readonly value = input<T>();\n\n\t/** Whether the toggle is disabled. */\n\tpublic readonly disabled = input<boolean, BooleanInput>(false, {\n\t\ttransform: booleanAttribute,\n\t});\n\n\t/** The current state of the toggle when not used in a group. */\n\tpublic readonly state = model<'on' | 'off'>('off');\n\n\t/** Whether the toggle is responds to click events. */\n\tpublic readonly disableToggleClick = input<boolean, BooleanInput>(false, {\n\t\ttransform: booleanAttribute,\n\t});\n\n\t/** Whether the toggle is in the on state. */\n\tprotected readonly isOn = computed(() => this._state() === 'on');\n\n\t/** The current state that reflects the group state or the model state. */\n\tprotected readonly _state = computed(() => {\n\t\tif (this.group) {\n\t\t\treturn this.group.isSelected(this.value() as T) ? 'on' : 'off';\n\t\t}\n\t\treturn this.state();\n\t});\n\n\ttoggle(): void {\n\t\tif (this.disableToggleClick()) return;\n\n\t\tif (this.group) {\n\t\t\tif (this.isOn()) {\n\t\t\t\tthis.group.deselect(this.value() as T, this);\n\t\t\t} else {\n\t\t\t\tthis.group.select(this.value() as T, this);\n\t\t\t}\n\t\t} else {\n\t\t\tthis.state.set(this.isOn() ? 'off' : 'on');\n\t\t}\n\t}\n}\n","import { NgModule } from '@angular/core';\nimport { BrnToggleGroupComponent } from './lib/brn-toggle-group.component';\nimport { BrnToggleDirective } from './lib/brn-toggle.directive';\n\nexport * from './lib/brn-toggle-group.component';\nexport * from './lib/brn-toggle.directive';\n\n@NgModule({\n\timports: [BrnToggleDirective],\n\texports: [BrnToggleDirective],\n})\nexport class BrnToggleModule {}\n\n@NgModule({\n\timports: [BrnToggleDirective, BrnToggleGroupComponent],\n\texports: [BrnToggleDirective, BrnToggleGroupComponent],\n})\nexport class BrnToggleGroupModule {}\n","/**\n * Generated bundle index. Do not edit.\n */\n\nexport * from './index';\n"],"names":[],"mappings":";;;;AAGA,MAAM,mBAAmB,GAAG,IA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BAAoB,EAAA,CAAA;;2FAApB,oBAAoB,EAAA,UAAA,EAAA,CAAA;kBAJhC,QAAQ;AAAC,YAAA,IAAA,EAAA,CAAA;AACT,oBAAA,OAAO,EAAE,CAAC,kBAAkB,EAAE,uBAAuB,CAAC;AACtD,oBAAA,OAAO,EAAE,CAAC,kBAAkB,EAAE,uBAAuB,CAAC;AACtD,iBAAA;;;AChBD;;AAEG;;;;"}
1
+ {"version":3,"file":"spartan-ng-brain-toggle.mjs","sources":["../../../../libs/brain/toggle/src/lib/brn-toggle.directive.ts","../../../../libs/brain/toggle/src/index.ts","../../../../libs/brain/toggle/src/spartan-ng-brain-toggle.ts"],"sourcesContent":["import { BooleanInput } from '@angular/cdk/coercion';\nimport { ChangeDetectorRef, Directive, booleanAttribute, computed, inject, input, model } from '@angular/core';\n\n@Directive({\n\tselector: 'button[hlmToggle], button[brnToggle]',\n\tstandalone: true,\n\thost: {\n\t\t'[id]': 'id()',\n\t\t'[attr.disabled]': 'disabled() ? true : null',\n\t\t'[attr.data-disabled]': 'disabled() ? true : null',\n\t\t'[attr.data-state]': '_state()',\n\t\t'[attr.aria-pressed]': 'isOn()',\n\t\t'(click)': 'toggle()',\n\t},\n})\nexport class BrnToggleDirective<T> {\n\tprivate static _uniqueId = 0;\n\n\tprivate readonly _changeDetector = inject(ChangeDetectorRef);\n\n\t/** The id of the toggle. */\n\tpublic readonly id = input(`brn-toggle-${BrnToggleDirective._uniqueId++}`);\n\n\t/** The value this toggle represents. */\n\tpublic readonly value = input<T>();\n\n\t/** Whether the toggle is disabled. */\n\tpublic readonly disabled = input<boolean, BooleanInput>(false, {\n\t\ttransform: booleanAttribute,\n\t});\n\n\t/** The current state of the toggle when not used in a group. */\n\tpublic readonly state = model<'on' | 'off'>('off');\n\n\t/** Whether the toggle is responds to click events. */\n\tpublic readonly disableToggleClick = input<boolean, BooleanInput>(false, {\n\t\ttransform: booleanAttribute,\n\t});\n\n\t/** Whether the toggle is in the on state. */\n\tprotected readonly isOn = computed(() => this._state() === 'on');\n\n\t/** The current state that reflects the group state or the model state. */\n\tprotected readonly _state = computed(() => {\n\t\treturn this.state();\n\t});\n\n\ttoggle(): void {\n\t\tif (this.disableToggleClick()) return;\n\n\t\tthis.state.set(this.isOn() ? 'off' : 'on');\n\t}\n}\n","import { NgModule } from '@angular/core';\nimport { BrnToggleDirective } from './lib/brn-toggle.directive';\n\nexport * from './lib/brn-toggle.directive';\n\n@NgModule({\n\timports: [BrnToggleDirective],\n\texports: [BrnToggleDirective],\n})\nexport class BrnToggleModule {}\n","/**\n * Generated bundle index. Do not edit.\n */\n\nexport * from './index';\n"],"names":[],"mappings":";;;MAea,kBAAkB,CAAA;AACtB,IAAA,OAAO,SAAS,GAAG,CAAC;AAEX,IAAA,eAAe,GAAG,MAAM,CAAC,iBAAiB,CAAC;;IAG5C,EAAE,GAAG,KAAK,CAAC,CAAc,WAAA,EAAA,kBAAkB,CAAC,SAAS,EAAE,CAAE,CAAA,CAAC;;IAG1D,KAAK,GAAG,KAAK,EAAK;;AAGlB,IAAA,QAAQ,GAAG,KAAK,CAAwB,KAAK,EAAE;AAC9D,QAAA,SAAS,EAAE,gBAAgB;AAC3B,KAAA,CAAC;;AAGc,IAAA,KAAK,GAAG,KAAK,CAAe,KAAK,CAAC;;AAGlC,IAAA,kBAAkB,GAAG,KAAK,CAAwB,KAAK,EAAE;AACxE,QAAA,SAAS,EAAE,gBAAgB;AAC3B,KAAA,CAAC;;AAGiB,IAAA,IAAI,GAAG,QAAQ,CAAC,MAAM,IAAI,CAAC,MAAM,EAAE,KAAK,IAAI,CAAC;;AAG7C,IAAA,MAAM,GAAG,QAAQ,CAAC,MAAK;AACzC,QAAA,OAAO,IAAI,CAAC,KAAK,EAAE;AACpB,KAAC,CAAC;IAEF,MAAM,GAAA;QACL,IAAI,IAAI,CAAC,kBAAkB,EAAE;YAAE;AAE/B,QAAA,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,IAAI,CAAC,IAAI,EAAE,GAAG,K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AAA,EAAA,EAAA,EAAA,CAAA;;2FAAlB,kBAAkB,EAAA,UAAA,EAAA,CAAA;kBAZ9B,SAAS;AAAC,YAAA,IAAA,EAAA,CAAA;AACV,oBAAA,QAAQ,EAAE,sCAAsC;AAChD,oBAAA,UAAU,EAAE,IAAI;AAChB,oBAAA,IAAI,EAAE;AACL,wBAAA,MAAM,EAAE,MAAM;AACd,wBAAA,iBAAiB,EAAE,0BAA0B;AAC7C,wBAAA,sBAAsB,EAAE,0BAA0B;AAClD,wBAAA,mBAAmB,EAAE,UAAU;AAC/B,wBAAA,qBAAqB,EAAE,QAAQ;AAC/B,wBAAA,SAAS,EAAE,UAAU;AACrB,qBAAA;AACD,iBAAA;;;MCLY,eAAe,CAAA;0HAAf,eAAe,EAAA,IAAA,EAAA,EAAA,EAAA,MAAA,EAAA,EAAA,CAAA,eAAA,CAAA,QAAA,EAAA,CAAA;2HAAf,eAAe,EAAA,OAAA,EAAA,CAHjB,kBAAkB,CAAA,EAAA,OAAA,EAAA,CAClB,kBAAkB,CAAA,EAAA,CAAA;2HAEhB,eAAe,EAAA,CAAA;;2FAAf,eAAe,EAAA,UAAA,EAAA,CAAA;kBAJ3B,QAAQ;AAAC,YAAA,IAAA,EAAA,CAAA;oBACT,OAAO,EAAE,CAAC,kBAAkB,CAAC;oBAC7B,OAAO,EAAE,CAAC,kBAAkB,CAAC;AAC7B,iBAAA;;;ACRD;;AAEG;;;;"}
@@ -402,7 +402,10 @@ class BrnTooltipTriggerDirective {
402
402
  transform: numberAttribute,
403
403
  });
404
404
  /** The default delay in ms before hiding the tooltip after hide is called */
405
- tooltipContentClasses = input(this._defaultOptions?.tooltipContentClasses ?? '');
405
+ _tooltipContentClasses = input(this._defaultOptions?.tooltipContentClasses ?? '', {
406
+ alias: 'tooltipContentClasses',
407
+ });
408
+ tooltipContentClasses = computed(() => signal(this._tooltipContentClasses()));
406
409
  /**
407
410
  * How touch gestures should be handled by the tooltip. On touch devices the tooltip directive
408
411
  * uses a long press gesture to show and hide, however it can conflict with the native browser
@@ -419,7 +422,8 @@ class BrnTooltipTriggerDirective {
419
422
  */
420
423
  touchGestures = input(this._defaultOptions?.touchGestures ?? 'auto');
421
424
  /** The message to be used to describe the aria in the tooltip */
422
- ariaDescribedBy = input('', { alias: 'aria-describedby' });
425
+ _ariaDescribedBy = input('', { alias: 'aria-describedby' });
426
+ ariaDescribedBy = computed(() => signal(this._ariaDescribedBy()));
423
427
  ariaDescribedByPrevious = computedPrevious(this.ariaDescribedBy);
424
428
  /** The content to be displayed in the tooltip */
425
429
  brnTooltipTrigger = input(null);
@@ -445,6 +449,12 @@ class BrnTooltipTriggerDirective {
445
449
  this._initExitAnimationDurationEffect();
446
450
  this._initHideDelayEffect();
447
451
  }
452
+ setTooltipContentClasses(tooltipContentClasses) {
453
+ this.tooltipContentClasses().set(tooltipContentClasses);
454
+ }
455
+ setAriaDescribedBy(ariaDescribedBy) {
456
+ this.ariaDescribedBy().set(ariaDescribedBy);
457
+ }
448
458
  _initPositionEffect() {
449
459
  effect(() => {
450
460
  if (this._overlayRef) {
@@ -476,14 +486,14 @@ class BrnTooltipTriggerDirective {
476
486
  _initTooltipContentClassesEffect() {
477
487
  effect(() => {
478
488
  if (this._tooltipInstance) {
479
- this._tooltipInstance._tooltipClasses.set(this.tooltipContentClasses() ?? '');
489
+ this._tooltipInstance._tooltipClasses.set(this.tooltipContentClasses()() ?? '');
480
490
  }
481
491
  });
482
492
  }
483
493
  _initAriaDescribedByPreviousEffect() {
484
494
  effect(() => {
485
- const ariaDescribedBy = this.ariaDescribedBy();
486
- this._ariaDescriber.removeDescription(this._elementRef.nativeElement, untracked(() => this.ariaDescribedByPrevious()), 'tooltip');
495
+ const ariaDescribedBy = this.ariaDescribedBy()();
496
+ this._ariaDescriber.removeDescription(this._elementRef.nativeElement, untracked(() => this.ariaDescribedByPrevious()()), 'tooltip');
487
497
  if (ariaDescribedBy && !this._isTooltipVisible()) {
488
498
  this._ngZone.runOutsideAngular(() => {
489
499
  // The `AriaDescriber` has some functionality that avoids adding a description if it's the
@@ -561,7 +571,7 @@ class BrnTooltipTriggerDirective {
561
571
  this._passiveListeners.length = 0;
562
572
  this._destroyed.next();
563
573
  this._destroyed.complete();
564
- this._ariaDescriber.removeDescription(nativeElement, this.ariaDescribedBy(), 'tooltip');
574
+ this._ariaDescriber.removeDescription(nativeElement, this.ariaDescribedBy()(), 'tooltip');
565
575
  this._focusMonitor.stopMonitoring(nativeElement);
566
576
  }
567
577
  /** Shows the tooltip after the delay in ms, defaults to tooltip-delay-show or 0ms if no input */
@@ -576,7 +586,7 @@ class BrnTooltipTriggerDirective {
576
586
  const instance = (this._tooltipInstance = overlayRef.attach(this._portal).instance);
577
587
  instance._triggerElement = this._elementRef.nativeElement;
578
588
  instance._mouseLeaveHideDelay = this.hideDelay();
579
- instance._tooltipClasses.set(this.tooltipContentClasses());
589
+ instance._tooltipClasses.set(this.tooltipContentClasses()());
580
590
  instance._exitAnimationDuration = this.exitAnimationDuration();
581
591
  instance.side.set(this._currentPosition ?? 'above');
582
592
  instance.afterHidden.pipe(takeUntil(this._destroyed)).subscribe(() => this._detach());
@@ -918,7 +928,7 @@ class BrnTooltipTriggerDirective {
918
928
  }
919
929
  }
920
930
  /** @nocollapse */ static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.2.1", ngImport: i0, type: BrnTooltipTriggerDirective, deps: [], target: i0.ɵɵFactoryTarget.Directive });
921
- /** @nocollapse */ static ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "17.1.0", version: "19.2.1", type: BrnTooltipTriggerDirective, isStandalone: true, selector: "[brnTooltipTrigger]", inputs: { position: { classPropertyName: "position", publicName: "position", isSignal: true, isRequired: false, transformFunction: null }, positionAtOrigin: { classPropertyName: "positionAtOrigin", publicName: "positionAtOrigin", isSignal: true, isRequired: false, transformFunction: null }, brnTooltipDisabled: { classPropertyName: "brnTooltipDisabled", publicName: "brnTooltipDisabled", isSignal: true, isRequired: false, transformFunction: null }, showDelay: { classPropertyName: "showDelay", publicName: "showDelay", isSignal: true, isRequired: false, transformFunction: null }, hideDelay: { classPropertyName: "hideDelay", publicName: "hideDelay", isSignal: true, isRequired: false, transformFunction: null }, exitAnimationDuration: { classPropertyName: "exitAnimationDuration", publicName: "exitAnimationDuration", isSignal: true, isRequired: false, transformFunction: null }, tooltipContentClasses: { classPropertyName: "tooltipContentClasses", publicName: "tooltipContentClasses", isSignal: true, isRequired: false, transformFunction: null }, touchGestures: { classPropertyName: "touchGestures", publicName: "touchGestures", isSignal: true, isRequired: false, transformFunction: null }, ariaDescribedBy: { classPropertyName: "ariaDescribedBy", publicName: "aria-describedby", isSignal: true, isRequired: false, transformFunction: null }, brnTooltipTrigger: { classPropertyName: "brnTooltipTrigger", publicName: "brnTooltipTrigger", isSignal: true, isRequired: false, transformFunction: null } }, host: { properties: { "class.brn-tooltip-disabled": "brnTooltipDisabled()" }, classAttribute: "brn-tooltip-trigger" }, providers: [BRN_TOOLTIP_SCROLL_STRATEGY_FACTORY_PROVIDER], exportAs: ["brnTooltipTrigger"], ngImport: i0 });
931
+ /** @nocollapse */ static ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "17.1.0", version: "19.2.1", type: BrnTooltipTriggerDirective, isStandalone: true, selector: "[brnTooltipTrigger]", inputs: { position: { classPropertyName: "position", publicName: "position", isSignal: true, isRequired: false, transformFunction: null }, positionAtOrigin: { classPropertyName: "positionAtOrigin", publicName: "positionAtOrigin", isSignal: true, isRequired: false, transformFunction: null }, brnTooltipDisabled: { classPropertyName: "brnTooltipDisabled", publicName: "brnTooltipDisabled", isSignal: true, isRequired: false, transformFunction: null }, showDelay: { classPropertyName: "showDelay", publicName: "showDelay", isSignal: true, isRequired: false, transformFunction: null }, hideDelay: { classPropertyName: "hideDelay", publicName: "hideDelay", isSignal: true, isRequired: false, transformFunction: null }, exitAnimationDuration: { classPropertyName: "exitAnimationDuration", publicName: "exitAnimationDuration", isSignal: true, isRequired: false, transformFunction: null }, _tooltipContentClasses: { classPropertyName: "_tooltipContentClasses", publicName: "tooltipContentClasses", isSignal: true, isRequired: false, transformFunction: null }, touchGestures: { classPropertyName: "touchGestures", publicName: "touchGestures", isSignal: true, isRequired: false, transformFunction: null }, _ariaDescribedBy: { classPropertyName: "_ariaDescribedBy", publicName: "aria-describedby", isSignal: true, isRequired: false, transformFunction: null }, brnTooltipTrigger: { classPropertyName: "brnTooltipTrigger", publicName: "brnTooltipTrigger", isSignal: true, isRequired: false, transformFunction: null } }, host: { properties: { "class.brn-tooltip-disabled": "brnTooltipDisabled()" }, classAttribute: "brn-tooltip-trigger" }, providers: [BRN_TOOLTIP_SCROLL_STRATEGY_FACTORY_PROVIDER], exportAs: ["brnTooltipTrigger"], ngImport: i0 });
922
932
  }
923
933
  i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.2.1", ngImport: i0, type: BrnTooltipTriggerDirective, decorators: [{
924
934
  type: Directive,