@spartan-ng/cli 0.0.1-alpha.716 → 0.0.1-alpha.718

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 (54) hide show
  1. package/package.json +1 -1
  2. package/src/generators/base/generator.d.ts +1 -0
  3. package/src/generators/base/generator.js +66 -0
  4. package/src/generators/base/generator.js.map +1 -1
  5. package/src/generators/healthcheck/healthchecks/version.js +5 -1
  6. package/src/generators/healthcheck/healthchecks/version.js.map +1 -1
  7. package/src/generators/migrate-helm-libraries/generator.js +26 -7
  8. package/src/generators/migrate-helm-libraries/generator.js.map +1 -1
  9. package/src/generators/migrate-icon/generator.js +1 -1
  10. package/src/generators/migrate-icon/generator.js.map +1 -1
  11. package/src/generators/migrate-scroll-area/generator.js +1 -1
  12. package/src/generators/migrate-scroll-area/generator.js.map +1 -1
  13. package/src/generators/ui/libs/alert-dialog/files/lib/hlm-alert-dialog-cancel.ts.template +1 -4
  14. package/src/generators/ui/libs/autocomplete/files/lib/hlm-autocomplete-search.ts.template +3 -15
  15. package/src/generators/ui/libs/autocomplete/files/lib/hlm-autocomplete.ts.template +3 -15
  16. package/src/generators/ui/libs/calendar/files/lib/hlm-calendar-multi.ts.template +134 -183
  17. package/src/generators/ui/libs/calendar/files/lib/hlm-calendar-range.ts.template +133 -176
  18. package/src/generators/ui/libs/calendar/files/lib/hlm-calendar.ts.template +121 -169
  19. package/src/generators/ui/libs/combobox/files/lib/hlm-combobox-multiple.ts.template +3 -15
  20. package/src/generators/ui/libs/combobox/files/lib/hlm-combobox.ts.template +3 -15
  21. package/src/generators/ui/libs/date-picker/files/lib/hlm-date-picker-anchor.ts.template +5 -12
  22. package/src/generators/ui/libs/date-picker/files/lib/hlm-date-picker-multi.ts.template +3 -3
  23. package/src/generators/ui/libs/date-picker/files/lib/hlm-date-picker.ts.template +3 -4
  24. package/src/generators/ui/libs/date-picker/files/lib/hlm-date-range-picker.ts.template +3 -3
  25. package/src/generators/ui/libs/dialog/files/lib/hlm-dialog-close.ts.template +1 -1
  26. package/src/generators/ui/libs/dialog/files/lib/hlm-dialog-content.ts.template +8 -1
  27. package/src/generators/ui/libs/drawer/files/lib/hlm-drawer-close.ts.template +1 -1
  28. package/src/generators/ui/libs/navigation-menu/files/lib/hlm-navigation-menu-content.ts.template +10 -3
  29. package/src/generators/ui/libs/navigation-menu/files/lib/hlm-navigation-menu-item.ts.template +4 -1
  30. package/src/generators/ui/libs/navigation-menu/files/lib/hlm-navigation-menu-link.ts.template +4 -4
  31. package/src/generators/ui/libs/navigation-menu/files/lib/hlm-navigation-menu-list.ts.template +4 -1
  32. package/src/generators/ui/libs/navigation-menu/files/lib/hlm-navigation-menu-trigger.ts.template +15 -4
  33. package/src/generators/ui/libs/navigation-menu/files/lib/hlm-navigation-menu.ts.template +6 -1
  34. package/src/generators/ui/libs/popover/files/index.ts.template +15 -1
  35. package/src/generators/ui/libs/popover/files/lib/hlm-popover-description.ts.template +12 -0
  36. package/src/generators/ui/libs/popover/files/lib/hlm-popover-header.ts.template +12 -0
  37. package/src/generators/ui/libs/popover/files/lib/hlm-popover-title.ts.template +12 -0
  38. package/src/generators/ui/libs/popover/files/lib/hlm-popover-trigger.ts.template +1 -3
  39. package/src/generators/ui/libs/popover/files/lib/hlm-popover.ts.template +1 -11
  40. package/src/generators/ui/libs/select/files/lib/hlm-select-multiple.ts.template +3 -15
  41. package/src/generators/ui/libs/select/files/lib/hlm-select.ts.template +3 -15
  42. package/src/generators/ui/libs/sheet/files/lib/hlm-sheet-close.ts.template +1 -1
  43. package/src/generators/ui/libs/utils/files/index.ts.template +1 -0
  44. package/src/generators/ui/libs/utils/files/lib/provide-spartan-hlm.ts.template +34 -0
  45. package/src/generators/ui/style-luma.css +2 -46
  46. package/src/generators/ui/style-lyra.css +2 -46
  47. package/src/generators/ui/style-maia.css +2 -46
  48. package/src/generators/ui/style-mira.css +2 -46
  49. package/src/generators/ui/style-nova.css +2 -46
  50. package/src/generators/ui/style-vega.css +2 -46
  51. package/src/generators/ui/supported-ui-libraries.json +47 -45
  52. package/src/utils/string-change.d.ts +26 -0
  53. package/src/utils/string-change.js +84 -0
  54. package/src/utils/string-change.js.map +1 -0
@@ -1,153 +1,142 @@
1
- import type { BooleanInput, NumberInput } from '@angular/cdk/coercion';
2
1
  import { NgTemplateOutlet } from '@angular/common';
3
- import {
4
- booleanAttribute,
5
- ChangeDetectionStrategy,
6
- Component,
7
- computed,
8
- input,
9
- model,
10
- numberAttribute,
11
- viewChild,
12
- } from '@angular/core';
2
+ import { ChangeDetectionStrategy, Component, computed, inject, input } from '@angular/core';
13
3
  import { NgIcon, provideIcons } from '@ng-icons/core';
14
4
  import { lucideChevronLeft, lucideChevronRight } from '@ng-icons/lucide';
15
- import { BrnCalendarImports, BrnCalendarRange, injectBrnCalendarI18n, type Weekday } from '@spartan-ng/brain/calendar';
5
+ import { BrnCalendarImports, BrnCalendarRange, injectBrnCalendarI18n } from '@spartan-ng/brain/calendar';
16
6
  import { injectDateAdapter } from '@spartan-ng/brain/date-time';
17
- import { buttonVariants } from '<%- importAlias %>/button';
18
- import { HlmIcon } from '<%- importAlias %>/icon';
7
+ import { buttonVariants, HlmButtonImports } from '<%- importAlias %>/button';
19
8
  import { HlmSelectImports } from '<%- importAlias %>/select';
20
- import { hlm } from '<%- importAlias %>/utils';
21
- import type { ClassValue } from 'clsx';
9
+ import { classes, hlm } from '<%- importAlias %>/utils';
22
10
 
23
11
  @Component({
24
12
  selector: 'hlm-calendar-range',
25
- imports: [BrnCalendarImports, NgIcon, HlmIcon, HlmSelectImports, NgTemplateOutlet],
13
+ imports: [BrnCalendarImports, NgIcon, HlmSelectImports, NgTemplateOutlet, HlmButtonImports],
26
14
  viewProviders: [provideIcons({ lucideChevronLeft, lucideChevronRight })],
27
15
  changeDetection: ChangeDetectionStrategy.OnPush,
16
+ hostDirectives: [
17
+ {
18
+ directive: BrnCalendarRange,
19
+ inputs: [
20
+ 'min',
21
+ 'max',
22
+ 'disabled',
23
+ 'startDate',
24
+ 'endDate',
25
+ 'dateDisabled',
26
+ 'weekStartsOn',
27
+ 'highlightDays',
28
+ 'defaultFocusedDate',
29
+ ],
30
+ outputs: ['endDateChange', 'startDateChange'],
31
+ },
32
+ ],
28
33
  host: { 'data-slot': 'calendar' },
29
34
  template: `
30
- <div
31
- brnCalendarRange
32
- [min]="min()"
33
- [max]="max()"
34
- [disabled]="disabled()"
35
- [(startDate)]="startDate"
36
- [(endDate)]="endDate"
37
- [dateDisabled]="dateDisabled()"
38
- [weekStartsOn]="weekStartsOn()"
39
- [highlightDays]="highlightDays()"
40
- [defaultFocusedDate]="defaultFocusedDate()"
41
- [class]="_computedCalenderClass()"
42
- >
43
- <div class="inline-flex flex-col space-y-4">
44
- <!-- Header -->
45
- <div class="space-y-4">
46
- <div class="relative flex items-center justify-center pt-1">
47
- <div class="flex w-full items-center justify-center gap-1.5">
48
- <ng-template #month>
49
- <hlm-select brnCalendarMonthSelect>
50
- <hlm-select-trigger size="sm" [class]="_selectClass">
51
- <hlm-select-value />
52
- </hlm-select-trigger>
53
- <hlm-select-content *hlmSelectPortal class="max-h-80">
54
- <hlm-select-group>
55
- @for (month of _i18n.config().months(); track month) {
56
- <hlm-select-item [value]="month">{{ month }}</hlm-select-item>
57
- }
58
- </hlm-select-group>
59
- </hlm-select-content>
60
- </hlm-select>
61
- </ng-template>
62
- <ng-template #year>
63
- <hlm-select brnCalendarYearSelect>
64
- <hlm-select-trigger size="sm" [class]="_selectClass">
65
- <hlm-select-value />
66
- </hlm-select-trigger>
67
- <hlm-select-content *hlmSelectPortal class="max-h-80">
68
- <hlm-select-group>
69
- @for (year of _i18n.config().years(); track year) {
70
- <hlm-select-item [value]="year">{{ year }}</hlm-select-item>
71
- }
72
- </hlm-select-group>
73
- </hlm-select-content>
74
- </hlm-select>
75
- </ng-template>
76
- @let heading = _heading();
77
- @switch (captionLayout()) {
78
- @case ('dropdown') {
79
- <ng-container [ngTemplateOutlet]="month" />
80
- <ng-container [ngTemplateOutlet]="year" />
35
+ <div class="inline-flex flex-col space-y-4">
36
+ <!-- Header -->
37
+ <div class="flex w-full items-center justify-between gap-1.5">
38
+ <ng-template #month>
39
+ <hlm-select brnCalendarMonthSelect class="order-1">
40
+ <hlm-select-trigger size="sm" [class]="_selectClass">
41
+ <hlm-select-value />
42
+ </hlm-select-trigger>
43
+ <hlm-select-content *hlmSelectPortal class="max-h-80">
44
+ <hlm-select-group>
45
+ @for (month of _i18n.config().months(); track month) {
46
+ <hlm-select-item [value]="month">{{ month }}</hlm-select-item>
81
47
  }
82
- @case ('dropdown-months') {
83
- <ng-container [ngTemplateOutlet]="month" />
84
- <div brnCalendarHeader class="text-sm font-medium">{{ heading.year }}</div>
48
+ </hlm-select-group>
49
+ </hlm-select-content>
50
+ </hlm-select>
51
+ </ng-template>
52
+ <ng-template #year>
53
+ <hlm-select brnCalendarYearSelect class="order-3">
54
+ <hlm-select-trigger size="sm" [class]="_selectClass">
55
+ <hlm-select-value />
56
+ </hlm-select-trigger>
57
+ <hlm-select-content *hlmSelectPortal class="max-h-80">
58
+ <hlm-select-group>
59
+ @for (year of _i18n.config().years(); track year) {
60
+ <hlm-select-item [value]="year">{{ year }}</hlm-select-item>
85
61
  }
86
- @case ('dropdown-years') {
87
- <div brnCalendarHeader class="text-sm font-medium">{{ heading.month }}</div>
88
- <ng-container [ngTemplateOutlet]="year" />
89
- }
90
- @case ('label') {
91
- <div brnCalendarHeader class="text-sm font-medium">{{ heading.header }}</div>
92
- }
93
- }
94
- </div>
95
-
96
- <div class="flex items-center space-x-1">
97
- <button
98
- brnCalendarPreviousButton
99
- class="ring-offset-background focus-visible:ring-ring border-input hover:bg-accent hover:text-accent-foreground absolute left-1 inline-flex h-7 w-7 items-center justify-center rounded-md border bg-transparent p-0 text-sm font-medium whitespace-nowrap opacity-50 transition-colors hover:opacity-100 focus-visible:ring-2 focus-visible:ring-offset-2 focus-visible:outline-none disabled:pointer-events-none disabled:opacity-50"
100
- >
101
- <ng-icon hlm name="lucideChevronLeft" size="sm" />
102
- </button>
103
-
104
- <button
105
- brnCalendarNextButton
106
- class="ring-offset-background focus-visible:ring-ring border-input hover:bg-accent hover:text-accent-foreground absolute right-1 inline-flex h-7 w-7 items-center justify-center rounded-md border bg-transparent p-0 text-sm font-medium whitespace-nowrap opacity-50 transition-colors hover:opacity-100 focus-visible:ring-2 focus-visible:ring-offset-2 focus-visible:outline-none disabled:pointer-events-none disabled:opacity-50"
107
- >
108
- <ng-icon hlm name="lucideChevronRight" size="sm" />
109
- </button>
110
- </div>
111
- </div>
112
- </div>
62
+ </hlm-select-group>
63
+ </hlm-select-content>
64
+ </hlm-select>
65
+ </ng-template>
66
+ @let heading = _heading();
67
+
68
+ <button
69
+ brnCalendarPreviousButton
70
+ variant="ghost"
71
+ hlmBtn
72
+ class="order-first size-(--cell-size) p-0 select-none aria-disabled:opacity-50"
73
+ >
74
+ <ng-icon name="lucideChevronLeft" class="rtl:rotate-180" />
75
+ </button>
76
+
77
+ @switch (captionLayout()) {
78
+ @case ('dropdown') {
79
+ <ng-container [ngTemplateOutlet]="month" />
80
+ <ng-container [ngTemplateOutlet]="year" />
81
+ }
82
+ @case ('dropdown-months') {
83
+ <ng-container [ngTemplateOutlet]="month" />
84
+ <div brnCalendarHeader class="order-4 text-sm font-medium">{{ heading.year }}</div>
85
+ }
86
+ @case ('dropdown-years') {
87
+ <div brnCalendarHeader class="order-2 text-sm font-medium">{{ heading.month }}</div>
88
+ <ng-container [ngTemplateOutlet]="year" />
89
+ }
90
+ @case ('label') {
91
+ <div brnCalendarHeader class="order-5 text-sm font-medium">{{ heading.header }}</div>
92
+ }
93
+ }
94
+
95
+ <button
96
+ brnCalendarNextButton
97
+ hlmBtn
98
+ variant="ghost"
99
+ class="order-last size-(--cell-size) p-0 select-none aria-disabled:opacity-50"
100
+ >
101
+ <ng-icon name="lucideChevronRight" class="rtl:rotate-180" />
102
+ </button>
103
+ </div>
113
104
 
114
- <table class="w-full border-collapse space-y-1" brnCalendarGrid>
115
- <thead>
116
- <tr class="flex">
117
- <th
118
- *brnCalendarWeekday="let weekday"
119
- scope="col"
120
- class="text-muted-foreground w-8 rounded-md text-[0.8rem] font-normal"
121
- [attr.aria-label]="_i18n.config().labelWeekday(weekday)"
105
+ <table class="w-full border-collapse space-y-1" brnCalendarGrid>
106
+ <thead aria-hidden="true">
107
+ <tr class="flex">
108
+ <th
109
+ *brnCalendarWeekday="let weekday"
110
+ scope="col"
111
+ class="text-muted-foreground flex-1 rounded-(--cell-radius) text-[0.8rem] font-normal select-none"
112
+ [attr.aria-label]="_i18n.config().labelWeekday(weekday)"
113
+ >
114
+ {{ _i18n.config().formatWeekdayName(weekday) }}
115
+ </th>
116
+ </tr>
117
+ </thead>
118
+
119
+ <tbody role="rowgroup">
120
+ <tr *brnCalendarWeek="let week" class="mt-2 flex w-full">
121
+ @for (date of week; track _dateAdapter.getTime(date)) {
122
+ <td
123
+ brnCalendarCell
124
+ class="group/day has-[button[data-range-start=true]]:bg-muted has-[button[data-range-start=true]]:after:bg-muted has-[button[data-range-end=true]]:bg-muted has-[button[data-range-end=true]]:after:bg-muted relative isolate z-0 aspect-square h-full w-full rounded-(--cell-radius) p-0 text-center select-none has-[button[data-range-end=true]]:rounded-e-(--cell-radius) has-[button[data-range-end=true]]:after:absolute has-[button[data-range-end=true]]:after:inset-y-0 has-[button[data-range-end=true]]:after:start-0 has-[button[data-range-end=true]]:after:w-4 has-[button[data-range-start=true]]:rounded-s-(--cell-radius) has-[button[data-range-start=true]]:after:absolute has-[button[data-range-start=true]]:after:inset-y-0 has-[button[data-range-start=true]]:after:end-0 has-[button[data-range-start=true]]:after:w-4 [&:first-child[data-selected=true]_button]:rounded-s-(--cell-radius) [&:last-child[data-selected=true]_button]:rounded-e-(--cell-radius)"
122
125
  >
123
- {{ _i18n.config().formatWeekdayName(weekday) }}
124
- </th>
125
- </tr>
126
- </thead>
127
-
128
- <tbody role="rowgroup">
129
- <tr *brnCalendarWeek="let week" class="mt-2 flex w-full">
130
- @for (date of week; track _dateAdapter.getTime(date)) {
131
- <td
132
- brnCalendarCell
133
- class="data-[selected]:data-[outside]:bg-accent/50 data-[selected]:bg-accent has-data-[range-start]:after:bg-accent has-data-[range-end]:after:bg-accent relative h-8 w-8 p-0 text-center text-sm focus-within:relative focus-within:z-20 has-data-[range-end]:after:absolute has-data-[range-end]:after:inset-y-0 has-data-[range-end]:after:left-0 has-data-[range-end]:after:w-4 has-data-[range-start]:after:absolute has-data-[range-start]:after:inset-y-0 has-data-[range-start]:after:right-0 has-data-[range-start]:after:w-4 [&:first-child:has([data-range-between])>button]:rounded-l-md [&:last-child:has([data-range-between])>button]:rounded-r-md"
134
- >
135
- <button brnCalendarCellButton [date]="date" [class]="_btnClass">
136
- {{ _dateAdapter.getDate(date) }}
137
- </button>
138
- </td>
139
- }
140
- </tr>
141
- </tbody>
142
- </table>
143
- </div>
126
+ <button brnCalendarCellButton [date]="date" [class]="_btnClass">
127
+ {{ _dateAdapter.getDate(date) }}
128
+ </button>
129
+ </td>
130
+ }
131
+ </tr>
132
+ </tbody>
133
+ </table>
144
134
  </div>
145
135
  `,
146
136
  })
147
137
  export class HlmCalendarRange<T> {
148
- public readonly calendarClass = input<ClassValue>('');
149
-
150
- protected readonly _computedCalenderClass = computed(() => hlm('rounded-md border p-3', this.calendarClass()));
138
+ /** Show dropdowns to navigate between months or years. */
139
+ public readonly captionLayout = input<'dropdown' | 'label' | 'dropdown-months' | 'dropdown-years'>('label');
151
140
 
152
141
  /** Access the calendar i18n */
153
142
  protected readonly _i18n = injectBrnCalendarI18n();
@@ -155,47 +144,13 @@ export class HlmCalendarRange<T> {
155
144
  /** Access the date time adapter */
156
145
  protected readonly _dateAdapter = injectDateAdapter<T>();
157
146
 
158
- /** The days to highlight. */
159
- public readonly highlightDays = input<T[]>([]);
160
-
161
- /** The minimum date that can be selected.*/
162
- public readonly min = input<T>();
163
-
164
- /** The maximum date that can be selected. */
165
- public readonly max = input<T>();
166
-
167
- /** Show dropdowns to navigate between months or years. */
168
- public readonly captionLayout = input<'dropdown' | 'label' | 'dropdown-months' | 'dropdown-years'>('label');
169
-
170
- /** Determine if the date picker is disabled. */
171
- public readonly disabled = input<boolean, BooleanInput>(false, {
172
- transform: booleanAttribute,
173
- });
174
-
175
- /** The start date of the range. */
176
- public readonly startDate = model<T>();
177
-
178
- /** The end date of the range. */
179
- public readonly endDate = model<T>();
180
-
181
- /** Whether a specific date is disabled. */
182
- public readonly dateDisabled = input<(date: T) => boolean>(() => false);
183
-
184
- /** The day the week starts on */
185
- public readonly weekStartsOn = input<Weekday, NumberInput>(undefined, {
186
- transform: (v: unknown) => numberAttribute(v) as Weekday,
187
- });
188
-
189
- /** The default focused date. */
190
- public readonly defaultFocusedDate = input<T>();
191
-
192
147
  /** Access the calendar directive */
193
- private readonly _calendar = viewChild.required(BrnCalendarRange);
148
+ private readonly _calendar = inject(BrnCalendarRange);
194
149
 
195
150
  /** Get the heading for the current month and year */
196
151
  protected readonly _heading = computed(() => {
197
152
  const config = this._i18n.config();
198
- const date = this._calendar().focusedDate();
153
+ const date = this._calendar.focusedDate();
199
154
 
200
155
  return {
201
156
  header: config.formatHeader(this._dateAdapter.getMonth(date), this._dateAdapter.getYear(date)),
@@ -205,18 +160,13 @@ export class HlmCalendarRange<T> {
205
160
  });
206
161
 
207
162
  protected readonly _btnClass = hlm(
208
- buttonVariants({ variant: 'ghost' }),
209
- 'relative z-10 size-8 border-0 p-0 font-normal aria-selected:opacity-100',
210
- 'data-[outside]:text-muted-foreground data-[outside]:aria-selected:text-muted-foreground',
211
- 'data-[today]:bg-accent data-[today]:text-accent-foreground',
212
- 'data-[selected]:bg-primary data-[selected]:text-primary-foreground data-[selected]:focus:bg-primary data-[selected]:focus:text-primary-foreground',
213
- 'data-[disabled]:text-muted-foreground data-[disabled]:opacity-50',
214
- 'data-[range-between]:bg-accent data-[range-between]:text-accent-foreground data-[range-between]:rounded-none',
215
- 'dark:hover:text-accent-foreground',
163
+ buttonVariants({ variant: 'ghost', size: 'icon' }),
164
+ 'data-[today=true]:bg-muted group-data-[focused=true]/day:border-ring group-data-[focused=true]/day:ring-ring/50 data-[range-end=true]:bg-primary data-[range-end=true]:text-primary-foreground data-[range-middle=true]:bg-muted data-[range-middle=true]:text-foreground data-[range-start=true]:bg-primary data-[range-start=true]:text-primary-foreground data-[selected-single=true]:bg-primary data-[selected-single=true]:text-primary-foreground dark:hover:text-foreground relative isolate z-10 flex aspect-square size-auto w-full min-w-(--cell-size) flex-col gap-1 border-0 leading-none font-normal group-data-[focused=true]/day:relative group-data-[focused=true]/day:z-10 group-data-[focused=true]/day:ring-[3px] data-[range-end=true]:rounded-(--cell-radius) data-[range-end=true]:rounded-e-(--cell-radius) data-[range-middle=true]:rounded-none data-[range-start=true]:rounded-(--cell-radius) data-[range-start=true]:rounded-s-(--cell-radius) [&>span]:text-xs [&>span]:opacity-70',
165
+ 'data-[outside=true]:opacity-50',
216
166
  "data-[highlighted]:before:content-['']",
217
167
  'data-[highlighted]:before:absolute',
218
168
  'data-[highlighted]:before:bottom-1',
219
- 'data-[highlighted]:before:left-1/2',
169
+ 'data-[highlighted]:before:start-1/2',
220
170
  'data-[highlighted]:before:h-1',
221
171
  'data-[highlighted]:before:w-1',
222
172
  'data-[highlighted]:before:-translate-x-1/2',
@@ -224,5 +174,12 @@ export class HlmCalendarRange<T> {
224
174
  'data-[highlighted]:before:bg-destructive',
225
175
  );
226
176
 
227
- protected readonly _selectClass = 'gap-0 px-1.5 py-2 [&>ng-icon]:ml-1';
177
+ protected readonly _selectClass = 'gap-0 px-1.5 py-2 [&>ng-icon]:ms-1';
178
+
179
+ constructor() {
180
+ classes(
181
+ () =>
182
+ 'spartan-calendar group/calendar bg-background block in-data-[slot=card-content]:bg-transparent in-data-[slot=popover-content]:bg-transparent',
183
+ );
184
+ }
228
185
  }