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