@spartan-ng/cli 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.
- package/generators.json +5 -0
- package/package.json +1 -1
- package/src/generators/healthcheck/generator.js +2 -2
- package/src/generators/healthcheck/generator.js.map +1 -1
- package/src/generators/healthcheck/healthchecks/brn-toggle-group.d.ts +2 -0
- package/src/generators/healthcheck/healthchecks/brn-toggle-group.js +34 -0
- package/src/generators/healthcheck/healthchecks/brn-toggle-group.js.map +1 -0
- package/src/generators/migrate-brain-imports/import-map.d.ts +1 -0
- package/src/generators/migrate-brain-imports/import-map.js +1 -0
- package/src/generators/migrate-brain-imports/import-map.js.map +1 -1
- package/src/generators/migrate-toggle-group/compat.d.ts +2 -0
- package/src/generators/migrate-toggle-group/compat.js +7 -0
- package/src/generators/migrate-toggle-group/compat.js.map +1 -0
- package/src/generators/migrate-toggle-group/generator.d.ts +4 -0
- package/src/generators/migrate-toggle-group/generator.js +119 -0
- package/src/generators/migrate-toggle-group/generator.js.map +1 -0
- package/src/generators/migrate-toggle-group/schema.d.ts +3 -0
- package/src/generators/migrate-toggle-group/schema.json +14 -0
- package/src/generators/ui/libs/ui-breadcrumb-helm/files/lib/breadcrumb-separator.component.ts.template +3 -4
- package/src/generators/ui/libs/ui-calendar-helm/files/index.ts.template +6 -2
- package/src/generators/ui/libs/ui-calendar-helm/files/lib/hlm-calendar-multi.component.ts.template +178 -0
- package/src/generators/ui/libs/ui-calendar-helm/files/lib/hlm-calendar.component.ts.template +1 -1
- package/src/generators/ui/libs/ui-date-picker-helm/files/index.ts.template +6 -2
- package/src/generators/ui/libs/ui-date-picker-helm/files/lib/hlm-date-picker-multi.component.ts.template +184 -0
- package/src/generators/ui/libs/ui-date-picker-helm/files/lib/hlm-date-picker-multi.token.ts.template +43 -0
- package/src/generators/ui/libs/ui-date-picker-helm/files/lib/hlm-date-picker.component.ts.template +8 -6
- package/src/generators/ui/libs/ui-input-otp-helm/files/index.ts.template +30 -0
- package/src/generators/ui/libs/ui-input-otp-helm/files/lib/hlm-input-otp-fake-caret.component.ts.template +12 -0
- package/src/generators/ui/libs/ui-input-otp-helm/files/lib/hlm-input-otp-group.directive.ts.template +16 -0
- package/src/generators/ui/libs/ui-input-otp-helm/files/lib/hlm-input-otp-separator.component.ts.template +25 -0
- package/src/generators/ui/libs/ui-input-otp-helm/files/lib/hlm-input-otp-slot.component.ts.template +33 -0
- package/src/generators/ui/libs/ui-input-otp-helm/files/lib/hlm-input-otp.directive.ts.template +18 -0
- package/src/generators/ui/libs/ui-input-otp-helm/generator.d.ts +3 -0
- package/src/generators/ui/libs/ui-input-otp-helm/generator.js +14 -0
- package/src/generators/ui/libs/ui-input-otp-helm/generator.js.map +1 -0
- package/src/generators/ui/libs/ui-select-helm/files/lib/hlm-select-trigger.component.ts.template +1 -1
- package/src/generators/ui/libs/ui-select-helm/files/lib/hlm-select-value.directive.ts.template +1 -1
- package/src/generators/ui/libs/ui-slider-helm/files/index.ts.template +2 -9
- package/src/generators/ui/libs/ui-slider-helm/files/lib/hlm-slider.component.ts.template +41 -8
- package/src/generators/ui/libs/ui-toggle-group-helm/files/index.ts.template +12 -0
- package/src/generators/ui/libs/ui-toggle-group-helm/files/lib/hlm-toggle-group.directive.ts.template +29 -0
- package/src/generators/ui/libs/ui-toggle-group-helm/files/lib/hlm-toggle-group.token.ts.template +12 -0
- package/src/generators/ui/libs/ui-toggle-group-helm/files/lib/hlm-toggle-item.directive.ts.template +55 -0
- package/src/generators/ui/libs/ui-toggle-group-helm/generator.d.ts +3 -0
- package/src/generators/ui/libs/ui-toggle-group-helm/generator.js +14 -0
- package/src/generators/ui/libs/ui-toggle-group-helm/generator.js.map +1 -0
- package/src/generators/ui/libs/ui-toggle-helm/files/index.ts.template +0 -8
- package/src/generators/ui/libs/ui-toggle-helm/files/lib/hlm-toggle.directive.ts.template +16 -5
- package/src/generators/ui/supported-ui-libraries.json +67 -37
- package/src/generators/ui/libs/ui-slider-helm/files/lib/hlm-slider-input.directive.ts.template +0 -19
- package/src/generators/ui/libs/ui-slider-helm/files/lib/hlm-slider-thumb.directive.ts.template +0 -27
- package/src/generators/ui/libs/ui-slider-helm/files/lib/hlm-slider-tick-mark.directive.ts.template +0 -29
- package/src/generators/ui/libs/ui-slider-helm/files/lib/hlm-slider-tick-marks.directive.ts.template +0 -17
- package/src/generators/ui/libs/ui-slider-helm/files/lib/hlm-slider-track-active-fill.directive.ts.template +0 -26
- package/src/generators/ui/libs/ui-slider-helm/files/lib/hlm-slider-track-active.directive.ts.template +0 -20
- package/src/generators/ui/libs/ui-slider-helm/files/lib/hlm-slider-track-inactive.directive.ts.template +0 -17
- package/src/generators/ui/libs/ui-slider-helm/files/lib/hlm-slider-track.component.ts.template +0 -54
- package/src/generators/ui/libs/ui-toggle-helm/files/lib/hlm-toggle-group.directive.ts.template +0 -20
|
@@ -0,0 +1,184 @@
|
|
|
1
|
+
import { BooleanInput, NumberInput } from '@angular/cdk/coercion';
|
|
2
|
+
import {
|
|
3
|
+
booleanAttribute,
|
|
4
|
+
Component,
|
|
5
|
+
computed,
|
|
6
|
+
forwardRef,
|
|
7
|
+
input,
|
|
8
|
+
model,
|
|
9
|
+
numberAttribute,
|
|
10
|
+
output,
|
|
11
|
+
signal,
|
|
12
|
+
} from '@angular/core';
|
|
13
|
+
import { NG_VALUE_ACCESSOR } from '@angular/forms';
|
|
14
|
+
import { NgIcon, provideIcons } from '@ng-icons/core';
|
|
15
|
+
import { lucideCalendar } from '@ng-icons/lucide';
|
|
16
|
+
import { hlm } from '@spartan-ng/brain/core';
|
|
17
|
+
import { BrnDialogState } from '@spartan-ng/brain/dialog';
|
|
18
|
+
import { type ChangeFn, type TouchFn } from '@spartan-ng/brain/forms';
|
|
19
|
+
import { BrnPopoverComponent, BrnPopoverContentDirective, BrnPopoverTriggerDirective } from '@spartan-ng/brain/popover';
|
|
20
|
+
import { HlmCalendarMultiComponent } from '@spartan-ng/ui-calendar-helm';
|
|
21
|
+
import { HlmIconDirective } from '@spartan-ng/ui-icon-helm';
|
|
22
|
+
import { HlmPopoverContentDirective } from '@spartan-ng/ui-popover-helm';
|
|
23
|
+
import type { ClassValue } from 'clsx';
|
|
24
|
+
import { injectHlmDatePickerMultiConfig } from './hlm-date-picker-multi.token';
|
|
25
|
+
|
|
26
|
+
export const HLM_DATE_PICKER_MUTLI_VALUE_ACCESSOR = {
|
|
27
|
+
provide: NG_VALUE_ACCESSOR,
|
|
28
|
+
useExisting: forwardRef(() => HlmDatePickerMultiComponent),
|
|
29
|
+
multi: true,
|
|
30
|
+
};
|
|
31
|
+
|
|
32
|
+
@Component({
|
|
33
|
+
selector: 'hlm-date-picker-multi',
|
|
34
|
+
imports: [
|
|
35
|
+
NgIcon,
|
|
36
|
+
HlmIconDirective,
|
|
37
|
+
BrnPopoverComponent,
|
|
38
|
+
BrnPopoverTriggerDirective,
|
|
39
|
+
BrnPopoverContentDirective,
|
|
40
|
+
HlmPopoverContentDirective,
|
|
41
|
+
HlmCalendarMultiComponent,
|
|
42
|
+
],
|
|
43
|
+
providers: [HLM_DATE_PICKER_MUTLI_VALUE_ACCESSOR, provideIcons({ lucideCalendar })],
|
|
44
|
+
template: `
|
|
45
|
+
<brn-popover sideOffset="5" [state]="popoverState()" (stateChanged)="popoverState.set($event)">
|
|
46
|
+
<button type="button" [class]="_computedClass()" [disabled]="state().disabled()" brnPopoverTrigger>
|
|
47
|
+
<ng-icon hlm size="sm" name="lucideCalendar" />
|
|
48
|
+
|
|
49
|
+
<span class="truncate">
|
|
50
|
+
@if (formattedDate(); as formattedDate) {
|
|
51
|
+
{{ formattedDate }}
|
|
52
|
+
} @else {
|
|
53
|
+
<ng-content />
|
|
54
|
+
}
|
|
55
|
+
</span>
|
|
56
|
+
</button>
|
|
57
|
+
|
|
58
|
+
<div hlmPopoverContent class="w-auto p-0" *brnPopoverContent="let ctx">
|
|
59
|
+
<hlm-calendar-multi
|
|
60
|
+
calendarClass="border-0 rounded-none"
|
|
61
|
+
[date]="date()"
|
|
62
|
+
[min]="min()"
|
|
63
|
+
[max]="max()"
|
|
64
|
+
[minSelection]="minSelection()"
|
|
65
|
+
[maxSelection]="maxSelection()"
|
|
66
|
+
[disabled]="state().disabled()"
|
|
67
|
+
(dateChange)="_handleChange($event)"
|
|
68
|
+
/>
|
|
69
|
+
</div>
|
|
70
|
+
</brn-popover>
|
|
71
|
+
`,
|
|
72
|
+
host: {
|
|
73
|
+
class: 'block',
|
|
74
|
+
},
|
|
75
|
+
})
|
|
76
|
+
export class HlmDatePickerMultiComponent<T> {
|
|
77
|
+
private readonly _config = injectHlmDatePickerMultiConfig<T>();
|
|
78
|
+
|
|
79
|
+
public readonly userClass = input<ClassValue>('', { alias: 'class' });
|
|
80
|
+
protected readonly _computedClass = computed(() =>
|
|
81
|
+
hlm(
|
|
82
|
+
'inline-flex items-center gap-2 whitespace-nowrap rounded-md text-sm ring-offset-background transition-colors border border-input bg-background hover:bg-accent hover:text-accent-foreground h-10 px-4 py-2 w-[280px] justify-start text-left font-normal',
|
|
83
|
+
'focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2',
|
|
84
|
+
'disabled:pointer-events-none disabled:opacity-50',
|
|
85
|
+
'[&_ng-icon]:pointer-events-none [&_ng-icon]:shrink-0',
|
|
86
|
+
!this.date() ? 'text-muted-foreground' : '',
|
|
87
|
+
this.userClass(),
|
|
88
|
+
),
|
|
89
|
+
);
|
|
90
|
+
|
|
91
|
+
/** The minimum date that can be selected.*/
|
|
92
|
+
public readonly min = input<T>();
|
|
93
|
+
|
|
94
|
+
/** The maximum date that can be selected. */
|
|
95
|
+
public readonly max = input<T>();
|
|
96
|
+
|
|
97
|
+
/** The minimum selectable dates. */
|
|
98
|
+
public readonly minSelection = input<number, NumberInput>(undefined, {
|
|
99
|
+
transform: numberAttribute,
|
|
100
|
+
});
|
|
101
|
+
|
|
102
|
+
/** The maximum selectable dates. */
|
|
103
|
+
public readonly maxSelection = input<number, NumberInput>(undefined, {
|
|
104
|
+
transform: numberAttribute,
|
|
105
|
+
});
|
|
106
|
+
|
|
107
|
+
/** Determine if the date picker is disabled. */
|
|
108
|
+
public readonly disabled = input<boolean, BooleanInput>(false, {
|
|
109
|
+
transform: booleanAttribute,
|
|
110
|
+
});
|
|
111
|
+
|
|
112
|
+
/** The selected value. */
|
|
113
|
+
public readonly date = model<T[]>();
|
|
114
|
+
|
|
115
|
+
/** If true, the date picker will close when the max selection of dates is reached.. */
|
|
116
|
+
public readonly autoCloseOnMaxSelection = input<boolean, BooleanInput>(this._config.autoCloseOnMaxSelection, {
|
|
117
|
+
transform: booleanAttribute,
|
|
118
|
+
});
|
|
119
|
+
|
|
120
|
+
/** Defines how the date should be displayed in the UI. */
|
|
121
|
+
public readonly formatDates = input<(date: T[]) => string>(this._config.formatDates);
|
|
122
|
+
|
|
123
|
+
/** Defines how the date should be transformed before saving to model/form. */
|
|
124
|
+
public readonly transformDates = input<(date: T[]) => T[]>(this._config.transformDates);
|
|
125
|
+
|
|
126
|
+
protected readonly popoverState = signal<BrnDialogState | null>(null);
|
|
127
|
+
|
|
128
|
+
protected readonly state = computed(() => ({
|
|
129
|
+
disabled: signal(this.disabled()),
|
|
130
|
+
}));
|
|
131
|
+
|
|
132
|
+
protected readonly formattedDate = computed(() => {
|
|
133
|
+
const dates = this.date();
|
|
134
|
+
return dates ? this.formatDates()(dates) : undefined;
|
|
135
|
+
});
|
|
136
|
+
|
|
137
|
+
public readonly changed = output<T[]>();
|
|
138
|
+
|
|
139
|
+
protected _onChange?: ChangeFn<T[]>;
|
|
140
|
+
protected _onTouched?: TouchFn;
|
|
141
|
+
|
|
142
|
+
protected _handleChange(value: T[] | undefined) {
|
|
143
|
+
if (value === undefined) return;
|
|
144
|
+
|
|
145
|
+
if (this.state().disabled()) return;
|
|
146
|
+
const transformedDate = this.transformDates()(value);
|
|
147
|
+
|
|
148
|
+
this.date.set(transformedDate);
|
|
149
|
+
this._onChange?.(transformedDate);
|
|
150
|
+
this.changed.emit(transformedDate);
|
|
151
|
+
|
|
152
|
+
if (this.autoCloseOnMaxSelection() && this.date()?.length === this.maxSelection()) {
|
|
153
|
+
this.popoverState.set('closed');
|
|
154
|
+
}
|
|
155
|
+
}
|
|
156
|
+
|
|
157
|
+
/** CONROL VALUE ACCESSOR */
|
|
158
|
+
writeValue(value: T[] | null): void {
|
|
159
|
+
// optional FormControl is initialized with null value
|
|
160
|
+
if (value === null) return;
|
|
161
|
+
|
|
162
|
+
this.date.set(this.transformDates()(value));
|
|
163
|
+
}
|
|
164
|
+
|
|
165
|
+
registerOnChange(fn: ChangeFn<T[]>): void {
|
|
166
|
+
this._onChange = fn;
|
|
167
|
+
}
|
|
168
|
+
|
|
169
|
+
registerOnTouched(fn: TouchFn): void {
|
|
170
|
+
this._onTouched = fn;
|
|
171
|
+
}
|
|
172
|
+
|
|
173
|
+
setDisabledState(isDisabled: boolean): void {
|
|
174
|
+
this.state().disabled.set(isDisabled);
|
|
175
|
+
}
|
|
176
|
+
|
|
177
|
+
open() {
|
|
178
|
+
this.popoverState.set('open');
|
|
179
|
+
}
|
|
180
|
+
|
|
181
|
+
close() {
|
|
182
|
+
this.popoverState.set('closed');
|
|
183
|
+
}
|
|
184
|
+
}
|
package/src/generators/ui/libs/ui-date-picker-helm/files/lib/hlm-date-picker-multi.token.ts.template
ADDED
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import { inject, InjectionToken, ValueProvider } from '@angular/core';
|
|
2
|
+
|
|
3
|
+
export interface HlmDatePickerMultiConfig<T> {
|
|
4
|
+
/**
|
|
5
|
+
* If true, the date picker will close when the max selection of dates is reached.
|
|
6
|
+
*/
|
|
7
|
+
autoCloseOnMaxSelection: boolean;
|
|
8
|
+
|
|
9
|
+
/**
|
|
10
|
+
* Defines how the date should be displayed in the UI.
|
|
11
|
+
*
|
|
12
|
+
* @param dates
|
|
13
|
+
* @returns formatted date
|
|
14
|
+
*/
|
|
15
|
+
formatDates: (dates: T[]) => string;
|
|
16
|
+
|
|
17
|
+
/**
|
|
18
|
+
* Defines how the date should be transformed before saving to model/form.
|
|
19
|
+
*
|
|
20
|
+
* @param dates
|
|
21
|
+
* @returns transformed date
|
|
22
|
+
*/
|
|
23
|
+
transformDates: (dates: T[]) => T[];
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
function getDefaultConfig<T>(): HlmDatePickerMultiConfig<T> {
|
|
27
|
+
return {
|
|
28
|
+
formatDates: (dates) => dates.map((date) => (date instanceof Date ? date.toDateString() : `${date}`)).join(', '),
|
|
29
|
+
transformDates: (dates) => dates,
|
|
30
|
+
autoCloseOnMaxSelection: false,
|
|
31
|
+
};
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
const HlmDatePickerMultiConfigToken = new InjectionToken<HlmDatePickerMultiConfig<unknown>>('HlmDatePickerMultiConfig');
|
|
35
|
+
|
|
36
|
+
export function provideHlmDatePickerConfig<T>(config: Partial<HlmDatePickerMultiConfig<T>>): ValueProvider {
|
|
37
|
+
return { provide: HlmDatePickerMultiConfigToken, useValue: { ...getDefaultConfig(), ...config } };
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
export function injectHlmDatePickerMultiConfig<T>(): HlmDatePickerMultiConfig<T> {
|
|
41
|
+
const injectedConfig = inject(HlmDatePickerMultiConfigToken, { optional: true });
|
|
42
|
+
return injectedConfig ? (injectedConfig as HlmDatePickerMultiConfig<T>) : getDefaultConfig();
|
|
43
|
+
}
|
package/src/generators/ui/libs/ui-date-picker-helm/files/lib/hlm-date-picker.component.ts.template
CHANGED
|
@@ -36,11 +36,13 @@ export const HLM_DATE_PICKER_VALUE_ACCESSOR = {
|
|
|
36
36
|
<button type="button" [class]="_computedClass()" [disabled]="state().disabled()" brnPopoverTrigger>
|
|
37
37
|
<ng-icon hlm size="sm" name="lucideCalendar" />
|
|
38
38
|
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
39
|
+
<span class="truncate">
|
|
40
|
+
@if (formattedDate(); as formattedDate) {
|
|
41
|
+
{{ formattedDate }}
|
|
42
|
+
} @else {
|
|
43
|
+
<ng-content />
|
|
44
|
+
}
|
|
45
|
+
</span>
|
|
44
46
|
</button>
|
|
45
47
|
|
|
46
48
|
<div hlmPopoverContent class="w-auto p-0" *brnPopoverContent="let ctx">
|
|
@@ -77,7 +79,7 @@ export class HlmDatePickerComponent<T> {
|
|
|
77
79
|
/** The minimum date that can be selected.*/
|
|
78
80
|
public readonly min = input<T>();
|
|
79
81
|
|
|
80
|
-
|
|
82
|
+
/** The maximum date that can be selected. */
|
|
81
83
|
public readonly max = input<T>();
|
|
82
84
|
|
|
83
85
|
/** Determine if the date picker is disabled. */
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import { NgModule } from '@angular/core';
|
|
2
|
+
import { HlmInputOtpFakeCaretComponent } from './lib/hlm-input-otp-fake-caret.component';
|
|
3
|
+
import { HlmInputOtpGroupDirective } from './lib/hlm-input-otp-group.directive';
|
|
4
|
+
import { HlmInputOtpSeparatorComponent } from './lib/hlm-input-otp-separator.component';
|
|
5
|
+
import { HlmInputOtpSlotComponent } from './lib/hlm-input-otp-slot.component';
|
|
6
|
+
import { HlmInputOtpDirective } from './lib/hlm-input-otp.directive';
|
|
7
|
+
|
|
8
|
+
export * from './lib/hlm-input-otp-fake-caret.component';
|
|
9
|
+
export * from './lib/hlm-input-otp-group.directive';
|
|
10
|
+
export * from './lib/hlm-input-otp-separator.component';
|
|
11
|
+
export * from './lib/hlm-input-otp-slot.component';
|
|
12
|
+
export * from './lib/hlm-input-otp.directive';
|
|
13
|
+
|
|
14
|
+
@NgModule({
|
|
15
|
+
imports: [
|
|
16
|
+
HlmInputOtpDirective,
|
|
17
|
+
HlmInputOtpGroupDirective,
|
|
18
|
+
HlmInputOtpSeparatorComponent,
|
|
19
|
+
HlmInputOtpSlotComponent,
|
|
20
|
+
HlmInputOtpFakeCaretComponent,
|
|
21
|
+
],
|
|
22
|
+
exports: [
|
|
23
|
+
HlmInputOtpDirective,
|
|
24
|
+
HlmInputOtpGroupDirective,
|
|
25
|
+
HlmInputOtpSeparatorComponent,
|
|
26
|
+
HlmInputOtpSlotComponent,
|
|
27
|
+
HlmInputOtpFakeCaretComponent,
|
|
28
|
+
],
|
|
29
|
+
})
|
|
30
|
+
export class HlmInputOtpModule {}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { Component } from '@angular/core';
|
|
2
|
+
|
|
3
|
+
@Component({
|
|
4
|
+
selector: 'hlm-input-otp-fake-caret',
|
|
5
|
+
standalone: true,
|
|
6
|
+
template: `
|
|
7
|
+
<div class="pointer-events-none absolute inset-0 flex items-center justify-center">
|
|
8
|
+
<div class="animate-caret-blink bg-foreground h-4 w-px duration-1000"></div>
|
|
9
|
+
</div>
|
|
10
|
+
`,
|
|
11
|
+
})
|
|
12
|
+
export class HlmInputOtpFakeCaretComponent {}
|
package/src/generators/ui/libs/ui-input-otp-helm/files/lib/hlm-input-otp-group.directive.ts.template
ADDED
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { computed, Directive, input } from '@angular/core';
|
|
2
|
+
import { hlm } from '@spartan-ng/brain/core';
|
|
3
|
+
import { type ClassValue } from 'clsx';
|
|
4
|
+
|
|
5
|
+
@Directive({
|
|
6
|
+
selector: '[hlmInputOtpGroup]',
|
|
7
|
+
standalone: true,
|
|
8
|
+
host: {
|
|
9
|
+
'[class]': '_computedClass()',
|
|
10
|
+
},
|
|
11
|
+
})
|
|
12
|
+
export class HlmInputOtpGroupDirective {
|
|
13
|
+
public readonly userClass = input<ClassValue>('', { alias: 'class' });
|
|
14
|
+
|
|
15
|
+
protected readonly _computedClass = computed(() => hlm('flex items-center', this.userClass()));
|
|
16
|
+
}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { Component, computed, input } from '@angular/core';
|
|
2
|
+
import { NgIcon, provideIcons } from '@ng-icons/core';
|
|
3
|
+
import { lucideDot } from '@ng-icons/lucide';
|
|
4
|
+
import { hlm } from '@spartan-ng/brain/core';
|
|
5
|
+
import { HlmIconDirective } from '@spartan-ng/ui-icon-helm';
|
|
6
|
+
import { type ClassValue } from 'clsx';
|
|
7
|
+
|
|
8
|
+
@Component({
|
|
9
|
+
selector: 'hlm-input-otp-separator',
|
|
10
|
+
standalone: true,
|
|
11
|
+
imports: [HlmIconDirective, NgIcon],
|
|
12
|
+
providers: [provideIcons({ lucideDot })],
|
|
13
|
+
template: `
|
|
14
|
+
<ng-icon hlm name="lucideDot" />
|
|
15
|
+
`,
|
|
16
|
+
host: {
|
|
17
|
+
role: 'separator',
|
|
18
|
+
'[class]': '_computedClass()',
|
|
19
|
+
},
|
|
20
|
+
})
|
|
21
|
+
export class HlmInputOtpSeparatorComponent {
|
|
22
|
+
public readonly userClass = input<ClassValue>('', { alias: 'class' });
|
|
23
|
+
|
|
24
|
+
protected readonly _computedClass = computed(() => hlm(this.userClass()));
|
|
25
|
+
}
|
package/src/generators/ui/libs/ui-input-otp-helm/files/lib/hlm-input-otp-slot.component.ts.template
ADDED
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import { NumberInput } from '@angular/cdk/coercion';
|
|
2
|
+
import { Component, computed, input, numberAttribute } from '@angular/core';
|
|
3
|
+
import { hlm } from '@spartan-ng/brain/core';
|
|
4
|
+
import { BrnInputOtpSlotComponent } from '@spartan-ng/brain/input-otp';
|
|
5
|
+
import { type ClassValue } from 'clsx';
|
|
6
|
+
import { HlmInputOtpFakeCaretComponent } from './hlm-input-otp-fake-caret.component';
|
|
7
|
+
|
|
8
|
+
@Component({
|
|
9
|
+
selector: 'hlm-input-otp-slot',
|
|
10
|
+
standalone: true,
|
|
11
|
+
imports: [BrnInputOtpSlotComponent, HlmInputOtpFakeCaretComponent],
|
|
12
|
+
template: `
|
|
13
|
+
<brn-input-otp-slot [index]="index()">
|
|
14
|
+
<hlm-input-otp-fake-caret />
|
|
15
|
+
</brn-input-otp-slot>
|
|
16
|
+
`,
|
|
17
|
+
host: {
|
|
18
|
+
'[class]': '_computedClass()',
|
|
19
|
+
},
|
|
20
|
+
})
|
|
21
|
+
export class HlmInputOtpSlotComponent {
|
|
22
|
+
public readonly userClass = input<ClassValue>('', { alias: 'class' });
|
|
23
|
+
|
|
24
|
+
public readonly index = input.required<number, NumberInput>({ transform: numberAttribute });
|
|
25
|
+
|
|
26
|
+
protected readonly _computedClass = computed(() =>
|
|
27
|
+
hlm(
|
|
28
|
+
'relative flex h-10 w-10 items-center justify-center border-y border-r border-input text-sm transition-all first:rounded-l-md first:border-l last:rounded-r-md',
|
|
29
|
+
'has-[brn-input-otp-slot[data-active="true"]]:z-10 has-[brn-input-otp-slot[data-active="true"]]:ring-2 has-[brn-input-otp-slot[data-active="true"]]:ring-ring has-[brn-input-otp-slot[data-active="true"]]:ring-offset-background',
|
|
30
|
+
this.userClass(),
|
|
31
|
+
),
|
|
32
|
+
);
|
|
33
|
+
}
|
package/src/generators/ui/libs/ui-input-otp-helm/files/lib/hlm-input-otp.directive.ts.template
ADDED
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { computed, Directive, input } from '@angular/core';
|
|
2
|
+
import { hlm } from '@spartan-ng/brain/core';
|
|
3
|
+
import { type ClassValue } from 'clsx';
|
|
4
|
+
|
|
5
|
+
@Directive({
|
|
6
|
+
selector: 'brn-input-otp [hlm]',
|
|
7
|
+
standalone: true,
|
|
8
|
+
host: {
|
|
9
|
+
'[class]': '_computedClass()',
|
|
10
|
+
},
|
|
11
|
+
})
|
|
12
|
+
export class HlmInputOtpDirective {
|
|
13
|
+
public readonly userClass = input<ClassValue>('', { alias: 'class' });
|
|
14
|
+
|
|
15
|
+
protected readonly _computedClass = computed(() =>
|
|
16
|
+
hlm('flex items-center gap-2 has-[:disabled]:opacity-50', this.userClass()),
|
|
17
|
+
);
|
|
18
|
+
}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.generator = generator;
|
|
4
|
+
const tslib_1 = require("tslib");
|
|
5
|
+
const generator_1 = tslib_1.__importDefault(require("../../../base/generator"));
|
|
6
|
+
async function generator(tree, options) {
|
|
7
|
+
return await (0, generator_1.default)(tree, {
|
|
8
|
+
...options,
|
|
9
|
+
primitiveName: 'inputotp',
|
|
10
|
+
internalName: 'ui-input-otp-helm',
|
|
11
|
+
publicName: 'ui-inputotp-helm',
|
|
12
|
+
});
|
|
13
|
+
}
|
|
14
|
+
//# sourceMappingURL=generator.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"generator.js","sourceRoot":"","sources":["../../../../../../../../libs/cli/src/generators/ui/libs/ui-input-otp-helm/generator.ts"],"names":[],"mappings":";;AAIA,8BAOC;;AAVD,gFAAuD;AAGhD,KAAK,UAAU,SAAS,CAAC,IAAU,EAAE,OAA+B;IAC1E,OAAO,MAAM,IAAA,mBAAgB,EAAC,IAAI,EAAE;QACnC,GAAG,OAAO;QACV,aAAa,EAAE,UAAU;QACzB,YAAY,EAAE,mBAAmB;QACjC,UAAU,EAAE,kBAAkB;KAC9B,CAAC,CAAC;AACJ,CAAC"}
|
package/src/generators/ui/libs/ui-select-helm/files/lib/hlm-select-trigger.component.ts.template
CHANGED
|
@@ -8,7 +8,7 @@ import { type VariantProps, cva } from 'class-variance-authority';
|
|
|
8
8
|
import type { ClassValue } from 'clsx';
|
|
9
9
|
|
|
10
10
|
export const selectTriggerVariants = cva(
|
|
11
|
-
'flex items-center justify-between rounded-md border border-input bg-background text-sm ring-offset-background
|
|
11
|
+
'flex items-center justify-between rounded-md border border-input bg-background text-sm ring-offset-background focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:cursor-not-allowed disabled:opacity-50',
|
|
12
12
|
{
|
|
13
13
|
variants: {
|
|
14
14
|
size: {
|
package/src/generators/ui/libs/ui-select-helm/files/lib/hlm-select-value.directive.ts.template
CHANGED
|
@@ -13,7 +13,7 @@ export class HlmSelectValueDirective {
|
|
|
13
13
|
public readonly userClass = input<ClassValue>('', { alias: 'class' });
|
|
14
14
|
protected readonly _computedClass = computed(() =>
|
|
15
15
|
hlm(
|
|
16
|
-
'!inline-block ltr:text-left rtl:text-right border-border w-[calc(100%)]] min-w-0 pointer-events-none truncate',
|
|
16
|
+
'!inline-block ltr:text-left rtl:text-right border-border w-[calc(100%)]] min-w-0 pointer-events-none truncate data-[placeholder]:text-muted-foreground',
|
|
17
17
|
this.userClass(),
|
|
18
18
|
),
|
|
19
19
|
);
|
|
@@ -1,11 +1,4 @@
|
|
|
1
|
-
|
|
2
|
-
import { HlmSliderThumbDirective } from './lib/hlm-slider-thumb.directive';
|
|
3
|
-
import { HlmSliderTrackComponent } from './lib/hlm-slider-track.component';
|
|
1
|
+
export * from './lib/hlm-slider.component';
|
|
4
2
|
import { HlmSliderComponent } from './lib/hlm-slider.component';
|
|
5
3
|
|
|
6
|
-
export const HlmSliderImports = [
|
|
7
|
-
HlmSliderComponent,
|
|
8
|
-
HlmSliderTrackComponent,
|
|
9
|
-
HlmSliderInputDirective,
|
|
10
|
-
HlmSliderThumbDirective,
|
|
11
|
-
] as const;
|
|
4
|
+
export const HlmSliderImports = [HlmSliderComponent] as const;
|
|
@@ -1,6 +1,13 @@
|
|
|
1
|
-
import { ChangeDetectionStrategy, Component, computed,
|
|
1
|
+
import { ChangeDetectionStrategy, Component, computed, input } from '@angular/core';
|
|
2
2
|
import { hlm } from '@spartan-ng/brain/core';
|
|
3
|
-
import {
|
|
3
|
+
import {
|
|
4
|
+
BrnSliderDirective,
|
|
5
|
+
BrnSliderRangeDirective,
|
|
6
|
+
BrnSliderThumbDirective,
|
|
7
|
+
BrnSliderTickDirective,
|
|
8
|
+
BrnSliderTrackDirective,
|
|
9
|
+
injectBrnSlider,
|
|
10
|
+
} from '@spartan-ng/brain/slider';
|
|
4
11
|
import type { ClassValue } from 'clsx';
|
|
5
12
|
|
|
6
13
|
@Component({
|
|
@@ -10,19 +17,45 @@ import type { ClassValue } from 'clsx';
|
|
|
10
17
|
hostDirectives: [
|
|
11
18
|
{
|
|
12
19
|
directive: BrnSliderDirective,
|
|
13
|
-
inputs: ['
|
|
20
|
+
inputs: ['value', 'disabled', 'min', 'max', 'step', 'showTicks'],
|
|
21
|
+
outputs: ['valueChange'],
|
|
14
22
|
},
|
|
15
23
|
],
|
|
16
|
-
template:
|
|
24
|
+
template: `
|
|
25
|
+
<div brnSliderTrack class="bg-secondary relative h-2 w-full grow overflow-hidden rounded-full">
|
|
26
|
+
<div class="bg-primary absolute h-full" brnSliderRange></div>
|
|
27
|
+
</div>
|
|
28
|
+
|
|
29
|
+
@if (slider.showTicks()) {
|
|
30
|
+
<div class="pointer-events-none absolute -inset-x-px top-2 h-1 w-full cursor-pointer transition-all">
|
|
31
|
+
<div
|
|
32
|
+
*brnSliderTick="let tick; let position = position"
|
|
33
|
+
class="absolute size-1 rounded-full"
|
|
34
|
+
[class.bg-secondary]="tick"
|
|
35
|
+
[class.bg-primary]="!tick"
|
|
36
|
+
[style.inset-inline-start.%]="position"
|
|
37
|
+
></div>
|
|
38
|
+
</div>
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
<span
|
|
42
|
+
class="border-primary bg-background ring-offset-background focus-visible:ring-ring absolute block h-5 w-5 -translate-x-1/2 rounded-full border-2 transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-offset-2 disabled:pointer-events-none disabled:opacity-50"
|
|
43
|
+
brnSliderThumb
|
|
44
|
+
></span>
|
|
45
|
+
`,
|
|
17
46
|
host: {
|
|
18
47
|
'[class]': '_computedClass()',
|
|
19
48
|
},
|
|
49
|
+
imports: [BrnSliderThumbDirective, BrnSliderTrackDirective, BrnSliderRangeDirective, BrnSliderTickDirective],
|
|
20
50
|
})
|
|
21
51
|
export class HlmSliderComponent {
|
|
52
|
+
protected readonly slider = injectBrnSlider();
|
|
22
53
|
public readonly userClass = input<ClassValue>('', { alias: 'class' });
|
|
23
|
-
protected _computedClass = computed(() =>
|
|
24
|
-
hlm(
|
|
54
|
+
protected readonly _computedClass = computed(() =>
|
|
55
|
+
hlm(
|
|
56
|
+
'w-full h-5 flex relative select-none items-center touch-none',
|
|
57
|
+
this.slider.disabled() ? 'opacity-40' : '',
|
|
58
|
+
this.userClass(),
|
|
59
|
+
),
|
|
25
60
|
);
|
|
26
|
-
|
|
27
|
-
private readonly _brnSlider = inject(BRN_SLIDER, { host: true });
|
|
28
61
|
}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { NgModule } from '@angular/core';
|
|
2
|
+
import { HlmToggleGroupDirective } from './lib/hlm-toggle-group.directive';
|
|
3
|
+
import { HlmToggleGroupItemDirective } from './lib/hlm-toggle-item.directive';
|
|
4
|
+
|
|
5
|
+
export * from './lib/hlm-toggle-group.directive';
|
|
6
|
+
export * from './lib/hlm-toggle-item.directive';
|
|
7
|
+
|
|
8
|
+
@NgModule({
|
|
9
|
+
imports: [HlmToggleGroupItemDirective, HlmToggleGroupDirective],
|
|
10
|
+
exports: [HlmToggleGroupItemDirective, HlmToggleGroupDirective],
|
|
11
|
+
})
|
|
12
|
+
export class HlmToggleGroupModule {}
|
package/src/generators/ui/libs/ui-toggle-group-helm/files/lib/hlm-toggle-group.directive.ts.template
ADDED
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { Directive, computed, input } from '@angular/core';
|
|
2
|
+
import { hlm } from '@spartan-ng/brain/core';
|
|
3
|
+
import { VariantProps } from 'class-variance-authority';
|
|
4
|
+
import type { ClassValue } from 'clsx';
|
|
5
|
+
import { provideHlmToggleGroup } from './hlm-toggle-group.token';
|
|
6
|
+
import { toggleGroupItemVariants } from './hlm-toggle-item.directive';
|
|
7
|
+
|
|
8
|
+
type ToggleGroupItemVariants = VariantProps<typeof toggleGroupItemVariants>;
|
|
9
|
+
@Directive({
|
|
10
|
+
selector: 'brn-toggle-group[hlm],[hlmToggleGroup]',
|
|
11
|
+
standalone: true,
|
|
12
|
+
host: {
|
|
13
|
+
'[class]': '_computedClass()',
|
|
14
|
+
},
|
|
15
|
+
providers: [provideHlmToggleGroup(HlmToggleGroupDirective)],
|
|
16
|
+
})
|
|
17
|
+
export class HlmToggleGroupDirective {
|
|
18
|
+
public readonly variant = input<ToggleGroupItemVariants['variant']>('default');
|
|
19
|
+
public readonly size = input<ToggleGroupItemVariants['size']>('default');
|
|
20
|
+
public readonly userClass = input<ClassValue>('', { alias: 'class' });
|
|
21
|
+
|
|
22
|
+
protected readonly _computedClass = computed(() =>
|
|
23
|
+
hlm('inline-flex items-center gap-x-2 focus:[&>[hlm][brnToggle]]:z-10', {
|
|
24
|
+
'gap-x-0 rounded-md first-of-type:[&>[hlmToggleGroupItem]]:rounded-l-md last-of-type:[&>[hlmToggleGroupItem]]:rounded-r-md [&>[hlmToggleGroupItem][variant="outline"]]:-mx-[0.5px] [&>[hlmToggleGroupItem]]:rounded-none':
|
|
25
|
+
this.variant() === 'merged',
|
|
26
|
+
[String(this.userClass())]: !!this.userClass(),
|
|
27
|
+
}),
|
|
28
|
+
);
|
|
29
|
+
}
|
package/src/generators/ui/libs/ui-toggle-group-helm/files/lib/hlm-toggle-group.token.ts.template
ADDED
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { ExistingProvider, InjectionToken, Type, inject } from '@angular/core';
|
|
2
|
+
import type { HlmToggleGroupDirective } from './hlm-toggle-group.directive';
|
|
3
|
+
|
|
4
|
+
const HlmToggleGroupToken = new InjectionToken<HlmToggleGroupDirective>('HlmToggleGroupToken');
|
|
5
|
+
|
|
6
|
+
export function provideHlmToggleGroup(config: Type<HlmToggleGroupDirective>): ExistingProvider {
|
|
7
|
+
return { provide: HlmToggleGroupToken, useExisting: config };
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
export function injectHlmToggleGroup(): HlmToggleGroupDirective {
|
|
11
|
+
return inject(HlmToggleGroupToken, { optional: true }) as HlmToggleGroupDirective;
|
|
12
|
+
}
|
package/src/generators/ui/libs/ui-toggle-group-helm/files/lib/hlm-toggle-item.directive.ts.template
ADDED
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
import { Directive, computed, input } from '@angular/core';
|
|
2
|
+
import { hlm } from '@spartan-ng/brain/core';
|
|
3
|
+
import { type VariantProps, cva } from 'class-variance-authority';
|
|
4
|
+
import type { ClassValue } from 'clsx';
|
|
5
|
+
import { injectHlmToggleGroup } from './hlm-toggle-group.token';
|
|
6
|
+
|
|
7
|
+
export const toggleGroupItemVariants = cva(
|
|
8
|
+
'inline-flex items-center justify-center rounded-md text-sm font-medium ring-offset-background transition-colors hover:bg-muted hover:text-muted-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:pointer-events-none disabled:opacity-50 data-[state=on]:bg-accent data-[state=on]:text-accent-foreground',
|
|
9
|
+
{
|
|
10
|
+
variants: {
|
|
11
|
+
variant: {
|
|
12
|
+
default: 'bg-transparent',
|
|
13
|
+
outline: 'border border-input bg-transparent hover:bg-accent hover:text-accent-foreground',
|
|
14
|
+
merged:
|
|
15
|
+
'border border-l-0 first-of-type:border-l border-input bg-transparent hover:bg-accent hover:text-accent-foreground',
|
|
16
|
+
},
|
|
17
|
+
size: {
|
|
18
|
+
default: 'h-9 px-3',
|
|
19
|
+
sm: 'h-8 px-2',
|
|
20
|
+
lg: 'h-10 px-3',
|
|
21
|
+
},
|
|
22
|
+
},
|
|
23
|
+
defaultVariants: {
|
|
24
|
+
variant: 'default',
|
|
25
|
+
size: 'default',
|
|
26
|
+
},
|
|
27
|
+
},
|
|
28
|
+
);
|
|
29
|
+
type ToggleGroupItemVariants = VariantProps<typeof toggleGroupItemVariants>;
|
|
30
|
+
|
|
31
|
+
@Directive({
|
|
32
|
+
selector: '[hlmToggleGroupItem],[brnToggleGroupItem][hlm]',
|
|
33
|
+
standalone: true,
|
|
34
|
+
host: {
|
|
35
|
+
'[class]': '_computedClass()',
|
|
36
|
+
},
|
|
37
|
+
})
|
|
38
|
+
export class HlmToggleGroupItemDirective {
|
|
39
|
+
private readonly _parentGroup = injectHlmToggleGroup();
|
|
40
|
+
public readonly variant = input<ToggleGroupItemVariants['variant']>('default');
|
|
41
|
+
public readonly size = input<ToggleGroupItemVariants['size']>('default');
|
|
42
|
+
public readonly userClass = input<ClassValue>('', { alias: 'class' });
|
|
43
|
+
protected readonly _computedClass = computed(() => {
|
|
44
|
+
const variantToUse = this._parentGroup?.variant() ?? this.variant();
|
|
45
|
+
const sizeToUse = this._parentGroup?.size() ?? this.size();
|
|
46
|
+
const userClass = this._parentGroup?.userClass() ?? this.userClass();
|
|
47
|
+
return hlm(
|
|
48
|
+
toggleGroupItemVariants({
|
|
49
|
+
variant: variantToUse,
|
|
50
|
+
size: sizeToUse,
|
|
51
|
+
}),
|
|
52
|
+
userClass,
|
|
53
|
+
);
|
|
54
|
+
});
|
|
55
|
+
}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.generator = generator;
|
|
4
|
+
const tslib_1 = require("tslib");
|
|
5
|
+
const generator_1 = tslib_1.__importDefault(require("../../../base/generator"));
|
|
6
|
+
async function generator(tree, options) {
|
|
7
|
+
return await (0, generator_1.default)(tree, {
|
|
8
|
+
...options,
|
|
9
|
+
primitiveName: 'togglegroup',
|
|
10
|
+
internalName: 'ui-toggle-group-helm',
|
|
11
|
+
publicName: 'ui-togglegroup-helm',
|
|
12
|
+
});
|
|
13
|
+
}
|
|
14
|
+
//# sourceMappingURL=generator.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"generator.js","sourceRoot":"","sources":["../../../../../../../../libs/cli/src/generators/ui/libs/ui-toggle-group-helm/generator.ts"],"names":[],"mappings":";;AAIA,8BAOC;;AAVD,gFAAuD;AAGhD,KAAK,UAAU,SAAS,CAAC,IAAU,EAAE,OAA+B;IAC1E,OAAO,MAAM,IAAA,mBAAgB,EAAC,IAAI,EAAE;QACnC,GAAG,OAAO;QACV,aAAa,EAAE,aAAa;QAC5B,YAAY,EAAE,sBAAsB;QACpC,UAAU,EAAE,qBAAqB;KACjC,CAAC,CAAC;AACJ,CAAC"}
|