@spartan-ng/cli 1.10.0-beta.1 → 1.10.0-beta.2
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 +10 -0
- package/package.json +2 -2
- package/src/generators/base/lib/build-dependency-array.js +1 -1
- package/src/generators/base/lib/build-dependency-array.js.map +1 -1
- package/src/generators/base/lib/styles/transform-style-map.js +2 -2
- package/src/generators/base/lib/styles/transform-style-map.js.map +1 -1
- package/src/generators/base/versions.d.ts +1 -1
- package/src/generators/base/versions.js +3 -2
- package/src/generators/base/versions.js.map +1 -1
- package/src/generators/healthcheck/generator.d.ts +1 -1
- package/src/generators/healthcheck/generator.js +4 -0
- package/src/generators/healthcheck/generator.js.map +1 -1
- package/src/generators/healthcheck/healthchecks/cn.d.ts +2 -0
- package/src/generators/healthcheck/healthchecks/cn.js +34 -0
- package/src/generators/healthcheck/healthchecks/cn.js.map +1 -0
- package/src/generators/migrate-cn/compat.d.ts +2 -0
- package/src/generators/migrate-cn/compat.js +7 -0
- package/src/generators/migrate-cn/compat.js.map +1 -0
- package/src/generators/migrate-cn/generator.d.ts +10 -0
- package/src/generators/migrate-cn/generator.js +220 -0
- package/src/generators/migrate-cn/generator.js.map +1 -0
- package/src/generators/migrate-cn/lib/legacy-imports.d.ts +9 -0
- package/src/generators/migrate-cn/lib/legacy-imports.js +16 -0
- package/src/generators/migrate-cn/lib/legacy-imports.js.map +1 -0
- package/src/generators/migrate-cn/lib/source-fingerprint.d.ts +6 -0
- package/src/generators/migrate-cn/lib/source-fingerprint.js +46 -0
- package/src/generators/migrate-cn/lib/source-fingerprint.js.map +1 -0
- package/src/generators/migrate-cn/schema.d.ts +3 -0
- package/src/generators/migrate-cn/schema.json +14 -0
- package/src/generators/ui/libs/accordion/files/lib/hlm-accordion-trigger.ts.template +1 -1
- package/src/generators/ui/libs/alert-dialog/files/lib/hlm-alert-dialog-overlay.ts.template +1 -1
- package/src/generators/ui/libs/button/files/lib/hlm-button.ts.template +1 -1
- package/src/generators/ui/libs/carousel/files/lib/hlm-carousel-slide-display.ts.template +1 -1
- package/src/generators/ui/libs/checkbox/files/lib/hlm-checkbox.ts.template +1 -1
- package/src/generators/ui/libs/combobox/files/lib/hlm-combobox-trigger.ts.template +1 -1
- package/src/generators/ui/libs/command/files/lib/hlm-command-dialog.ts.template +1 -1
- package/src/generators/ui/libs/date-picker/files/lib/hlm-date-picker-trigger.ts.template +1 -1
- package/src/generators/ui/libs/dialog/files/lib/hlm-dialog-overlay.ts.template +1 -1
- package/src/generators/ui/libs/drawer/files/lib/hlm-drawer-overlay.ts.template +1 -1
- package/src/generators/ui/libs/input-otp/files/lib/hlm-input-otp.ts.template +1 -1
- package/src/generators/ui/libs/native-select/files/lib/hlm-native-select.ts.template +1 -1
- package/src/generators/ui/libs/pagination/files/lib/hlm-numbered-pagination-query-params.ts.template +15 -2
- package/src/generators/ui/libs/pagination/files/lib/hlm-numbered-pagination.ts.template +79 -7
- package/src/generators/ui/libs/pagination/files/lib/hlm-pagination-next.ts.template +27 -13
- package/src/generators/ui/libs/pagination/files/lib/hlm-pagination-previous.ts.template +27 -13
- package/src/generators/ui/libs/pagination/files/lib/hlm-pagination.token.ts.template +2 -0
- package/src/generators/ui/libs/radio-group/files/lib/hlm-radio-group.ts.template +1 -1
- package/src/generators/ui/libs/radio-group/files/lib/hlm-radio.ts.template +1 -1
- package/src/generators/ui/libs/select/files/lib/hlm-select-trigger.ts.template +1 -1
- package/src/generators/ui/libs/sheet/files/lib/hlm-sheet-overlay.ts.template +1 -1
- package/src/generators/ui/libs/sidebar/files/lib/hlm-sidebar.ts.template +1 -1
- package/src/generators/ui/libs/sonner/files/lib/hlm-toaster.ts.template +1 -1
- package/src/generators/ui/libs/switch/files/lib/hlm-switch.ts.template +1 -1
- package/src/generators/ui/libs/tabs/files/lib/hlm-tabs-paginated-list.ts.template +1 -1
- package/src/generators/ui/libs/trace/files/lib/hlm-trace-collapsible-content.ts.template +1 -1
- package/src/generators/ui/libs/utils/files/lib/hlm.ts.template +20 -302
- package/src/generators/ui/supported-ui-libraries.json +68 -70
- package/src/utils/config.d.ts +1 -0
- package/src/utils/config.js +7 -0
- package/src/utils/config.js.map +1 -1
- package/src/utils/version-utils.d.ts +1 -1
- package/src/utils/version-utils.js +3 -2
- package/src/utils/version-utils.js.map +1 -1
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"source-fingerprint.js","sourceRoot":"","sources":["../../../../../../../libs/cli/src/generators/migrate-cn/lib/source-fingerprint.ts"],"names":[],"mappings":";;AAeA,8CAmCC;;AAlDD,6CAAyC;AACzC,oEAA4B;AAE5B,MAAM,cAAc,GAAG,IAAI,GAAG,CAAC;IAC9B,oBAAE,CAAC,UAAU,CAAC,eAAe;IAC7B,oBAAE,CAAC,UAAU,CAAC,iBAAiB;IAC/B,oBAAE,CAAC,UAAU,CAAC,eAAe;IAC7B,oBAAE,CAAC,UAAU,CAAC,gBAAgB;CAC9B,CAAC,CAAC;AAEH;;;;GAIG;AACH,SAAgB,iBAAiB,CAAC,MAAc;IAC/C,MAAM,OAAO,GAAG,oBAAE,CAAC,aAAa,CAAC,oBAAE,CAAC,YAAY,CAAC,MAAM,EAAE,IAAI,EAAE,oBAAE,CAAC,eAAe,CAAC,QAAQ,EAAE,MAAM,CAAC,CAAC;IACpG,MAAM,MAAM,GAA4C,EAAE,CAAC;IAE3D,KAAK,IAAI,IAAI,GAAG,OAAO,CAAC,IAAI,EAAE,EAAE,IAAI,KAAK,oBAAE,CAAC,UAAU,CAAC,cAAc,EAAE,IAAI,GAAG,OAAO,CAAC,IAAI,EAAE,EAAE,CAAC;QAC9F,IAAI,IAAI,KAAK,oBAAE,CAAC,UAAU,CAAC,cAAc;YAAE,SAAS;QAEpD,MAAM,QAAQ,GAAG,IAAI,KAAK,oBAAE,CAAC,UAAU,CAAC,aAAa,IAAI,IAAI,KAAK,oBAAE,CAAC,UAAU,CAAC,6BAA6B,CAAC;QAC9G,MAAM,CAAC,IAAI,CAAC,EAAE,IAAI,EAAE,IAAI,EAAE,QAAQ,CAAC,CAAC,CAAC,IAAI,CAAC,SAAS,CAAC,OAAO,CAAC,aAAa,EAAE,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC,YAAY,EAAE,EAAE,CAAC,CAAC;IAC1G,CAAC;IAED,MAAM,UAAU,GAAa,EAAE,CAAC;IAEhC,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,MAAM,CAAC,MAAM,EAAE,CAAC,EAAE,EAAE,CAAC;QACxC,MAAM,EAAE,IAAI,EAAE,IAAI,EAAE,GAAG,MAAM,CAAC,CAAC,CAAC,CAAC;QAEjC,sCAAsC;QACtC,IAAI,IAAI,KAAK,oBAAE,CAAC,UAAU,CAAC,UAAU,IAAI,MAAM,CAAC,CAAC,GAAG,CAAC,CAAC,IAAI,cAAc,CAAC,GAAG,CAAC,MAAM,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,IAAI,CAAC;YAAE,SAAS;QAE3G,sDAAsD;QACtD,IACC,IAAI,KAAK,oBAAE,CAAC,UAAU,CAAC,cAAc;YACrC,MAAM,CAAC,CAAC,GAAG,CAAC,CAAC,EAAE,IAAI,KAAK,oBAAE,CAAC,UAAU,CAAC,UAAU;YAChD,MAAM,CAAC,CAAC,GAAG,CAAC,CAAC,EAAE,IAAI,KAAK,oBAAE,CAAC,UAAU,CAAC,eAAe;YACrD,MAAM,CAAC,CAAC,GAAG,CAAC,CAAC,EAAE,IAAI,KAAK,oBAAE,CAAC,UAAU,CAAC,sBAAsB,EAC3D,CAAC;YACF,UAAU,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC;YACpC,CAAC,IAAI,CAAC,CAAC;YACP,SAAS;QACV,CAAC;QAED,UAAU,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;IACvB,CAAC;IAED,OAAO,IAAA,wBAAU,EAAC,QAAQ,CAAC,CAAC,MAAM,CAAC,UAAU,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC;AACxE,CAAC"}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
{
|
|
2
|
+
"$schema": "http://json-schema.org/draft-07/schema",
|
|
3
|
+
"$id": "MigrateCn",
|
|
4
|
+
"title": "",
|
|
5
|
+
"type": "object",
|
|
6
|
+
"properties": {
|
|
7
|
+
"skipFormat": {
|
|
8
|
+
"type": "boolean",
|
|
9
|
+
"default": false,
|
|
10
|
+
"description": "Skip formatting files"
|
|
11
|
+
}
|
|
12
|
+
},
|
|
13
|
+
"required": []
|
|
14
|
+
}
|
|
@@ -3,7 +3,7 @@ import { NgIcon, provideIcons } from '@ng-icons/core';
|
|
|
3
3
|
import { lucideChevronDown, lucideChevronUp } from '@ng-icons/lucide';
|
|
4
4
|
import { BrnAccordionImports } from '@spartan-ng/brain/accordion';
|
|
5
5
|
import { hlm } from '<%- importAlias %>/utils';
|
|
6
|
-
import type { ClassValue } from '
|
|
6
|
+
import type { ClassValue } from 'cn';
|
|
7
7
|
|
|
8
8
|
@Component({
|
|
9
9
|
selector: 'hlm-accordion-trigger',
|
|
@@ -2,7 +2,7 @@ import { Directive, computed, effect, input, untracked } from '@angular/core';
|
|
|
2
2
|
import { BrnAlertDialogOverlay } from '@spartan-ng/brain/alert-dialog';
|
|
3
3
|
import { injectCustomClassSettable } from '@spartan-ng/brain/core';
|
|
4
4
|
import { hlm } from '<%- importAlias %>/utils';
|
|
5
|
-
import type { ClassValue } from '
|
|
5
|
+
import type { ClassValue } from 'cn';
|
|
6
6
|
|
|
7
7
|
@Directive({
|
|
8
8
|
selector: '[hlmAlertDialogOverlay],hlm-alert-dialog-overlay',
|
|
@@ -2,7 +2,7 @@ import { Directive, input, signal } from '@angular/core';
|
|
|
2
2
|
import { BrnButton } from '@spartan-ng/brain/button';
|
|
3
3
|
import { classes } from '<%- importAlias %>/utils';
|
|
4
4
|
import { cva, type VariantProps } from 'class-variance-authority';
|
|
5
|
-
import type { ClassValue } from '
|
|
5
|
+
import type { ClassValue } from 'cn';
|
|
6
6
|
import { injectBrnButtonConfig } from './hlm-button.token';
|
|
7
7
|
|
|
8
8
|
export const buttonVariants = cva(
|
|
@@ -18,7 +18,7 @@ import { BrnCheckbox } from '@spartan-ng/brain/checkbox';
|
|
|
18
18
|
import { BrnFieldControlDescribedBy } from '@spartan-ng/brain/field';
|
|
19
19
|
import type { ChangeFn, TouchFn } from '@spartan-ng/brain/forms';
|
|
20
20
|
import { hlm } from '<%- importAlias %>/utils';
|
|
21
|
-
import type { ClassValue } from '
|
|
21
|
+
import type { ClassValue } from 'cn';
|
|
22
22
|
|
|
23
23
|
export const HLM_CHECKBOX_VALUE_ACCESSOR = {
|
|
24
24
|
provide: NG_VALUE_ACCESSOR,
|
|
@@ -6,7 +6,7 @@ import { BrnComboboxAnchor, BrnComboboxPopoverTrigger, BrnComboboxTrigger } from
|
|
|
6
6
|
import { BrnFieldControlDescribedBy } from '@spartan-ng/brain/field';
|
|
7
7
|
import { ButtonVariants, HlmButton } from '<%- importAlias %>/button';
|
|
8
8
|
import { hlm } from '<%- importAlias %>/utils';
|
|
9
|
-
import type { ClassValue } from '
|
|
9
|
+
import type { ClassValue } from 'cn';
|
|
10
10
|
|
|
11
11
|
@Component({
|
|
12
12
|
selector: 'hlm-combobox-trigger',
|
|
@@ -11,7 +11,7 @@ import {
|
|
|
11
11
|
import { BrnDialogState } from '@spartan-ng/brain/dialog';
|
|
12
12
|
import { HlmDialogImports } from '<%- importAlias %>/dialog';
|
|
13
13
|
import { hlm } from '<%- importAlias %>/utils';
|
|
14
|
-
import { ClassValue } from '
|
|
14
|
+
import { ClassValue } from 'cn';
|
|
15
15
|
|
|
16
16
|
@Component({
|
|
17
17
|
selector: 'hlm-command-dialog',
|
|
@@ -11,7 +11,7 @@ import { BrnFieldControl, BrnFieldControlDescribedBy } from '@spartan-ng/brain/f
|
|
|
11
11
|
import { ButtonVariants, HlmButtonImports } from '<%- importAlias %>/button';
|
|
12
12
|
import { HlmPopoverTrigger } from '<%- importAlias %>/popover';
|
|
13
13
|
import { hlm } from '<%- importAlias %>/utils';
|
|
14
|
-
import { ClassValue } from '
|
|
14
|
+
import { ClassValue } from 'cn';
|
|
15
15
|
|
|
16
16
|
@Component({
|
|
17
17
|
selector: 'hlm-date-picker-trigger',
|
|
@@ -2,7 +2,7 @@ import { computed, Directive, effect, input, untracked } from '@angular/core';
|
|
|
2
2
|
import { injectCustomClassSettable } from '@spartan-ng/brain/core';
|
|
3
3
|
import { BrnDialogOverlay } from '@spartan-ng/brain/dialog';
|
|
4
4
|
import { hlm } from '<%- importAlias %>/utils';
|
|
5
|
-
import type { ClassValue } from '
|
|
5
|
+
import type { ClassValue } from 'cn';
|
|
6
6
|
|
|
7
7
|
export const hlmDialogOverlayClass = hlm('spartan-dialog-overlay');
|
|
8
8
|
|
|
@@ -2,7 +2,7 @@ import { Directive, computed, effect, input, untracked } from '@angular/core';
|
|
|
2
2
|
import { injectCustomClassSettable } from '@spartan-ng/brain/core';
|
|
3
3
|
import { BrnDrawerOverlay } from '@spartan-ng/brain/drawer';
|
|
4
4
|
import { hlm } from '<%- importAlias %>/utils';
|
|
5
|
-
import type { ClassValue } from '
|
|
5
|
+
import type { ClassValue } from 'cn';
|
|
6
6
|
|
|
7
7
|
@Directive({
|
|
8
8
|
selector: '[hlmDrawerOverlay],hlm-drawer-overlay',
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { ChangeDetectionStrategy, Component, computed, input } from '@angular/core';
|
|
2
2
|
import { BrnInputOtp, BrnInputOtpInput, type InputMode } from '@spartan-ng/brain/input-otp';
|
|
3
3
|
import { classes, hlm } from '<%- importAlias %>/utils';
|
|
4
|
-
import type { ClassValue } from '
|
|
4
|
+
import type { ClassValue } from 'cn';
|
|
5
5
|
|
|
6
6
|
@Component({
|
|
7
7
|
selector: 'hlm-input-otp',
|
|
@@ -16,7 +16,7 @@ import { lucideChevronDown } from '@ng-icons/lucide';
|
|
|
16
16
|
import { BrnFieldControl, provideBrnLabelable } from '@spartan-ng/brain/field';
|
|
17
17
|
import { type ChangeFn, type TouchFn } from '@spartan-ng/brain/forms';
|
|
18
18
|
import { classes, hlm } from '<%- importAlias %>/utils';
|
|
19
|
-
import type { ClassValue } from '
|
|
19
|
+
import type { ClassValue } from 'cn';
|
|
20
20
|
|
|
21
21
|
export const HLM_NATIVE_SELECT_VALUE_ACCESSOR = {
|
|
22
22
|
provide: NG_VALUE_ACCESSOR,
|
package/src/generators/ui/libs/pagination/files/lib/hlm-numbered-pagination-query-params.ts.template
CHANGED
|
@@ -11,7 +11,7 @@ import {
|
|
|
11
11
|
} from '@angular/core';
|
|
12
12
|
import { HlmSelectImports } from '<%- importAlias %>/select';
|
|
13
13
|
import { classes } from '<%- importAlias %>/utils';
|
|
14
|
-
import { createPageArray, outOfBoundCorrection } from './hlm-numbered-pagination';
|
|
14
|
+
import { createPageArray, keepPaginationFocus, outOfBoundCorrection } from './hlm-numbered-pagination';
|
|
15
15
|
import { HlmPagination } from './hlm-pagination';
|
|
16
16
|
import { HlmPaginationContent } from './hlm-pagination-content';
|
|
17
17
|
import { HlmPaginationEllipsis } from './hlm-pagination-ellipsis';
|
|
@@ -21,6 +21,8 @@ import { HlmPaginationNext } from './hlm-pagination-next';
|
|
|
21
21
|
import { HlmPaginationPrevious } from './hlm-pagination-previous';
|
|
22
22
|
import { injectHlmPaginationConfig } from './hlm-pagination.token';
|
|
23
23
|
|
|
24
|
+
let nextId = 0;
|
|
25
|
+
|
|
24
26
|
@Component({
|
|
25
27
|
selector: 'hlm-numbered-pagination-query-params',
|
|
26
28
|
exportAs: 'hlmNumberedPaginationQueryParams',
|
|
@@ -68,6 +70,7 @@ import { injectHlmPaginationConfig } from './hlm-pagination.token';
|
|
|
68
70
|
[queryParams]="{ page }"
|
|
69
71
|
queryParamsHandling="merge"
|
|
70
72
|
[isActive]="currentPage() === page"
|
|
73
|
+
[attr.tabindex]="currentPage() === page ? -1 : null"
|
|
71
74
|
>
|
|
72
75
|
{{ page }}
|
|
73
76
|
</a>
|
|
@@ -90,8 +93,9 @@ import { injectHlmPaginationConfig } from './hlm-pagination.token';
|
|
|
90
93
|
</nav>
|
|
91
94
|
|
|
92
95
|
<!-- Show Page Size selector -->
|
|
96
|
+
<label class="sr-only" [for]="_pageSizeTriggerId">{{ pageSizeAriaLabel() }}</label>
|
|
93
97
|
<hlm-select [(value)]="itemsPerPage" class="ml-auto">
|
|
94
|
-
<hlm-select-trigger class="w-fit">
|
|
98
|
+
<hlm-select-trigger class="w-fit" [buttonId]="_pageSizeTriggerId">
|
|
95
99
|
<hlm-select-value />
|
|
96
100
|
</hlm-select-trigger>
|
|
97
101
|
<hlm-select-content *hlmSelectPortal>
|
|
@@ -188,6 +192,14 @@ export class HlmNumberedPaginationQueryParams {
|
|
|
188
192
|
*/
|
|
189
193
|
public readonly previousAriaLabel = input<string>(this._config.previousAriaLabel);
|
|
190
194
|
|
|
195
|
+
/**
|
|
196
|
+
* The accessible label of the page size selector
|
|
197
|
+
* Defaults to config's pageSizeAriaLabel
|
|
198
|
+
*/
|
|
199
|
+
public readonly pageSizeAriaLabel = input<string>(this._config.pageSizeAriaLabel);
|
|
200
|
+
|
|
201
|
+
protected readonly _pageSizeTriggerId = `hlm-numbered-pagination-query-params-page-size-${nextId++}`;
|
|
202
|
+
|
|
191
203
|
protected readonly _pageSizesWithCurrent = computed(() => {
|
|
192
204
|
const pageSizes = this.pageSizes();
|
|
193
205
|
return pageSizes.includes(this.itemsPerPage())
|
|
@@ -220,5 +232,6 @@ export class HlmNumberedPaginationQueryParams {
|
|
|
220
232
|
|
|
221
233
|
constructor() {
|
|
222
234
|
classes(() => 'flex items-center justify-between gap-2 px-4 py-2');
|
|
235
|
+
keepPaginationFocus(this._pages, this.showEdges);
|
|
223
236
|
}
|
|
224
237
|
}
|
|
@@ -2,8 +2,14 @@ import type { BooleanInput, NumberInput } from '@angular/cdk/coercion';
|
|
|
2
2
|
import {
|
|
3
3
|
ChangeDetectionStrategy,
|
|
4
4
|
Component,
|
|
5
|
+
DestroyRef,
|
|
6
|
+
ElementRef,
|
|
7
|
+
Renderer2,
|
|
8
|
+
type Signal,
|
|
9
|
+
afterRenderEffect,
|
|
5
10
|
booleanAttribute,
|
|
6
11
|
computed,
|
|
12
|
+
inject,
|
|
7
13
|
input,
|
|
8
14
|
model,
|
|
9
15
|
numberAttribute,
|
|
@@ -19,6 +25,8 @@ import { HlmPaginationNext } from './hlm-pagination-next';
|
|
|
19
25
|
import { HlmPaginationPrevious } from './hlm-pagination-previous';
|
|
20
26
|
import { injectHlmPaginationConfig } from './hlm-pagination.token';
|
|
21
27
|
|
|
28
|
+
let nextId = 0;
|
|
29
|
+
|
|
22
30
|
@Component({
|
|
23
31
|
selector: 'hlm-numbered-pagination',
|
|
24
32
|
exportAs: 'hlmNumberedPagination',
|
|
@@ -45,8 +53,12 @@ import { injectHlmPaginationConfig } from './hlm-pagination.token';
|
|
|
45
53
|
<nav hlmPagination>
|
|
46
54
|
<ul hlmPaginationContent>
|
|
47
55
|
@if (showEdges() && !_isFirstPageActive()) {
|
|
48
|
-
<li hlmPaginationItem
|
|
49
|
-
<hlm-pagination-previous
|
|
56
|
+
<li hlmPaginationItem>
|
|
57
|
+
<hlm-pagination-previous
|
|
58
|
+
[aria-label]="previousAriaLabel()"
|
|
59
|
+
[text]="previousLabel()"
|
|
60
|
+
(click)="goToPrevious()"
|
|
61
|
+
/>
|
|
50
62
|
</li>
|
|
51
63
|
}
|
|
52
64
|
|
|
@@ -55,24 +67,30 @@ import { injectHlmPaginationConfig } from './hlm-pagination.token';
|
|
|
55
67
|
@if (page === '...') {
|
|
56
68
|
<hlm-pagination-ellipsis />
|
|
57
69
|
} @else {
|
|
58
|
-
<
|
|
70
|
+
<button
|
|
71
|
+
type="button"
|
|
72
|
+
hlmPaginationLink
|
|
73
|
+
[isActive]="currentPage() === page"
|
|
74
|
+
(click)="currentPage.set(page)"
|
|
75
|
+
>
|
|
59
76
|
{{ page }}
|
|
60
|
-
</
|
|
77
|
+
</button>
|
|
61
78
|
}
|
|
62
79
|
</li>
|
|
63
80
|
}
|
|
64
81
|
|
|
65
82
|
@if (showEdges() && !_isLastPageActive()) {
|
|
66
|
-
<li hlmPaginationItem
|
|
67
|
-
<hlm-pagination-next [aria-label]="nextAriaLabel()" [text]="nextLabel()" />
|
|
83
|
+
<li hlmPaginationItem>
|
|
84
|
+
<hlm-pagination-next [aria-label]="nextAriaLabel()" [text]="nextLabel()" (click)="goToNext()" />
|
|
68
85
|
</li>
|
|
69
86
|
}
|
|
70
87
|
</ul>
|
|
71
88
|
</nav>
|
|
72
89
|
|
|
73
90
|
<!-- Show Page Size selector -->
|
|
91
|
+
<label class="sr-only" [for]="_pageSizeTriggerId">{{ pageSizeAriaLabel() }}</label>
|
|
74
92
|
<hlm-select [(value)]="itemsPerPage" class="ml-auto">
|
|
75
|
-
<hlm-select-trigger class="w-fit">
|
|
93
|
+
<hlm-select-trigger class="w-fit" [buttonId]="_pageSizeTriggerId">
|
|
76
94
|
<hlm-select-value />
|
|
77
95
|
</hlm-select-trigger>
|
|
78
96
|
<hlm-select-content *hlmSelectPortal>
|
|
@@ -164,6 +182,14 @@ export class HlmNumberedPagination {
|
|
|
164
182
|
*/
|
|
165
183
|
public readonly previousAriaLabel = input<string>(this._config.previousAriaLabel);
|
|
166
184
|
|
|
185
|
+
/**
|
|
186
|
+
* The accessible label of the page size selector
|
|
187
|
+
* Defaults to config's pageSizeAriaLabel
|
|
188
|
+
*/
|
|
189
|
+
public readonly pageSizeAriaLabel = input<string>(this._config.pageSizeAriaLabel);
|
|
190
|
+
|
|
191
|
+
protected readonly _pageSizeTriggerId = `hlm-numbered-pagination-page-size-${nextId++}`;
|
|
192
|
+
|
|
167
193
|
protected readonly _pageSizesWithCurrent = computed(() => {
|
|
168
194
|
const pageSizes = this.pageSizes();
|
|
169
195
|
return pageSizes.includes(this.itemsPerPage())
|
|
@@ -194,6 +220,10 @@ export class HlmNumberedPagination {
|
|
|
194
220
|
return createPageArray(correctedCurrentPage, this.itemsPerPage(), this.totalItems(), this.maxSize());
|
|
195
221
|
});
|
|
196
222
|
|
|
223
|
+
constructor() {
|
|
224
|
+
keepPaginationFocus(this._pages, this.showEdges);
|
|
225
|
+
}
|
|
226
|
+
|
|
197
227
|
protected goToPrevious(): void {
|
|
198
228
|
this.currentPage.set(this.currentPage() - 1);
|
|
199
229
|
}
|
|
@@ -213,6 +243,48 @@ export class HlmNumberedPagination {
|
|
|
213
243
|
|
|
214
244
|
type Page = number | '...';
|
|
215
245
|
|
|
246
|
+
/**
|
|
247
|
+
* Previous / Next are removed on the first / last page, and page buttons can scroll out of the
|
|
248
|
+
* range. When the focused control is removed, move focus to the current page (or the first
|
|
249
|
+
* remaining control) so keyboard users keep their place.
|
|
250
|
+
*/
|
|
251
|
+
export function keepPaginationFocus(...watched: Signal<unknown>[]): void {
|
|
252
|
+
const host = inject<ElementRef<HTMLElement>>(ElementRef).nativeElement;
|
|
253
|
+
const renderer = inject(Renderer2);
|
|
254
|
+
let lastFocused: Element | null = null;
|
|
255
|
+
|
|
256
|
+
const unlistenIn = renderer.listen(host, 'focusin', (event: FocusEvent) => {
|
|
257
|
+
lastFocused = event.target as Element | null;
|
|
258
|
+
});
|
|
259
|
+
// Forget the control once focus moves to an element outside this pagination (e.g. another
|
|
260
|
+
// pagination on the page). Removing the focused control moves focus to the body without a
|
|
261
|
+
// focusin, so that case still restores focus after the render.
|
|
262
|
+
const unlistenOut = renderer.listen('document', 'focusin', (event: FocusEvent) => {
|
|
263
|
+
// the composed path is not retargeted, so it also works when the pagination is in a shadow root
|
|
264
|
+
if (!event.composedPath().includes(host)) lastFocused = null;
|
|
265
|
+
});
|
|
266
|
+
inject(DestroyRef).onDestroy(() => {
|
|
267
|
+
unlistenIn();
|
|
268
|
+
unlistenOut();
|
|
269
|
+
});
|
|
270
|
+
|
|
271
|
+
afterRenderEffect(() => {
|
|
272
|
+
// re-check after any render that can remove a focused control
|
|
273
|
+
watched.forEach((signal) => signal());
|
|
274
|
+
if (!lastFocused || lastFocused.isConnected) return;
|
|
275
|
+
lastFocused = null;
|
|
276
|
+
|
|
277
|
+
const doc = host.ownerDocument;
|
|
278
|
+
if (doc.activeElement && doc.activeElement !== doc.body) return;
|
|
279
|
+
|
|
280
|
+
const nav = host.querySelector('nav') ?? host;
|
|
281
|
+
const current = nav.querySelector<HTMLElement>('[aria-current="page"]');
|
|
282
|
+
current?.focus();
|
|
283
|
+
if (current && doc.activeElement === current) return;
|
|
284
|
+
nav.querySelector<HTMLElement>('a[href], button:not([disabled])')?.focus();
|
|
285
|
+
});
|
|
286
|
+
}
|
|
287
|
+
|
|
216
288
|
/**
|
|
217
289
|
* Checks that the instance.currentPage property is within bounds for the current page range.
|
|
218
290
|
* If not, return a correct value for currentPage, or the current value if OK.
|
|
@@ -5,7 +5,7 @@ import { NgIcon, provideIcons } from '@ng-icons/core';
|
|
|
5
5
|
import { lucideChevronRight } from '@ng-icons/lucide';
|
|
6
6
|
import type { ButtonVariants } from '<%- importAlias %>/button';
|
|
7
7
|
import { hlm } from '<%- importAlias %>/utils';
|
|
8
|
-
import type { ClassValue } from '
|
|
8
|
+
import type { ClassValue } from 'cn';
|
|
9
9
|
import { HlmPaginationLink } from './hlm-pagination-link';
|
|
10
10
|
import { injectHlmPaginationConfig } from './hlm-pagination.token';
|
|
11
11
|
|
|
@@ -16,18 +16,32 @@ import { injectHlmPaginationConfig } from './hlm-pagination.token';
|
|
|
16
16
|
providers: [provideIcons({ lucideChevronRight })],
|
|
17
17
|
changeDetection: ChangeDetectionStrategy.OnPush,
|
|
18
18
|
template: `
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
19
|
+
@if (link() === undefined) {
|
|
20
|
+
<!-- Without a link this is an action, so render a focusable button instead of an anchor without href. -->
|
|
21
|
+
<button
|
|
22
|
+
type="button"
|
|
23
|
+
hlmPaginationLink
|
|
24
|
+
[class]="_computedClass()"
|
|
25
|
+
[size]="_size()"
|
|
26
|
+
[attr.aria-label]="ariaLabel()"
|
|
27
|
+
>
|
|
28
|
+
<span [class]="_labelClass()">{{ text() }}</span>
|
|
29
|
+
<ng-icon name="lucideChevronRight" class="spartan-rtl-flip" />
|
|
30
|
+
</button>
|
|
31
|
+
} @else {
|
|
32
|
+
<a
|
|
33
|
+
hlmPaginationLink
|
|
34
|
+
[class]="_computedClass()"
|
|
35
|
+
[link]="link()"
|
|
36
|
+
[queryParams]="queryParams()"
|
|
37
|
+
[queryParamsHandling]="queryParamsHandling()"
|
|
38
|
+
[size]="_size()"
|
|
39
|
+
[attr.aria-label]="ariaLabel()"
|
|
40
|
+
>
|
|
41
|
+
<span [class]="_labelClass()">{{ text() }}</span>
|
|
42
|
+
<ng-icon name="lucideChevronRight" class="spartan-rtl-flip" />
|
|
43
|
+
</a>
|
|
44
|
+
}
|
|
31
45
|
`,
|
|
32
46
|
})
|
|
33
47
|
export class HlmPaginationNext {
|
|
@@ -5,7 +5,7 @@ import { NgIcon, provideIcons } from '@ng-icons/core';
|
|
|
5
5
|
import { lucideChevronLeft } from '@ng-icons/lucide';
|
|
6
6
|
import type { ButtonVariants } from '<%- importAlias %>/button';
|
|
7
7
|
import { hlm } from '<%- importAlias %>/utils';
|
|
8
|
-
import type { ClassValue } from '
|
|
8
|
+
import type { ClassValue } from 'cn';
|
|
9
9
|
import { HlmPaginationLink } from './hlm-pagination-link';
|
|
10
10
|
import { injectHlmPaginationConfig } from './hlm-pagination.token';
|
|
11
11
|
|
|
@@ -16,18 +16,32 @@ import { injectHlmPaginationConfig } from './hlm-pagination.token';
|
|
|
16
16
|
providers: [provideIcons({ lucideChevronLeft })],
|
|
17
17
|
changeDetection: ChangeDetectionStrategy.OnPush,
|
|
18
18
|
template: `
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
19
|
+
@if (link() === undefined) {
|
|
20
|
+
<!-- Without a link this is an action, so render a focusable button instead of an anchor without href. -->
|
|
21
|
+
<button
|
|
22
|
+
type="button"
|
|
23
|
+
hlmPaginationLink
|
|
24
|
+
[class]="_computedClass()"
|
|
25
|
+
[size]="_size()"
|
|
26
|
+
[attr.aria-label]="ariaLabel()"
|
|
27
|
+
>
|
|
28
|
+
<ng-icon name="lucideChevronLeft" class="spartan-rtl-flip" />
|
|
29
|
+
<span [class]="_labelClass()">{{ text() }}</span>
|
|
30
|
+
</button>
|
|
31
|
+
} @else {
|
|
32
|
+
<a
|
|
33
|
+
hlmPaginationLink
|
|
34
|
+
[class]="_computedClass()"
|
|
35
|
+
[link]="link()"
|
|
36
|
+
[queryParams]="queryParams()"
|
|
37
|
+
[queryParamsHandling]="queryParamsHandling()"
|
|
38
|
+
[size]="_size()"
|
|
39
|
+
[attr.aria-label]="ariaLabel()"
|
|
40
|
+
>
|
|
41
|
+
<ng-icon name="lucideChevronLeft" class="spartan-rtl-flip" />
|
|
42
|
+
<span [class]="_labelClass()">{{ text() }}</span>
|
|
43
|
+
</a>
|
|
44
|
+
}
|
|
31
45
|
`,
|
|
32
46
|
})
|
|
33
47
|
export class HlmPaginationPrevious {
|
|
@@ -7,6 +7,7 @@ export interface HlmPaginationConfig {
|
|
|
7
7
|
previousAriaLabel: string;
|
|
8
8
|
nextLabel: string;
|
|
9
9
|
nextAriaLabel: string;
|
|
10
|
+
pageSizeAriaLabel: string;
|
|
10
11
|
}
|
|
11
12
|
|
|
12
13
|
const defaultConfig: HlmPaginationConfig = {
|
|
@@ -16,6 +17,7 @@ const defaultConfig: HlmPaginationConfig = {
|
|
|
16
17
|
nextAriaLabel: 'Go to next page',
|
|
17
18
|
previousLabel: 'Previous',
|
|
18
19
|
previousAriaLabel: 'Go to previous page',
|
|
20
|
+
pageSizeAriaLabel: 'Items per page',
|
|
19
21
|
};
|
|
20
22
|
|
|
21
23
|
const HlmPaginationConfigToken = new InjectionToken<HlmPaginationConfig>('HlmPaginationConfig');
|
|
@@ -2,7 +2,7 @@ import { computed, Directive, inject, input } from '@angular/core';
|
|
|
2
2
|
import { BrnFieldControlDescribedBy } from '@spartan-ng/brain/field';
|
|
3
3
|
import { BrnRadioGroup } from '@spartan-ng/brain/radio-group';
|
|
4
4
|
import { classes } from '<%- importAlias %>/utils';
|
|
5
|
-
import type { ClassValue } from '
|
|
5
|
+
import type { ClassValue } from 'cn';
|
|
6
6
|
|
|
7
7
|
@Directive({
|
|
8
8
|
selector: '[hlmRadioGroup],hlm-radio-group',
|
|
@@ -16,7 +16,7 @@ import {
|
|
|
16
16
|
} from '@angular/core';
|
|
17
17
|
import { BrnRadio, BrnRadioGroup, type BrnRadioChange } from '@spartan-ng/brain/radio-group';
|
|
18
18
|
import { hlm } from '<%- importAlias %>/utils';
|
|
19
|
-
import type { ClassValue } from '
|
|
19
|
+
import type { ClassValue } from 'cn';
|
|
20
20
|
|
|
21
21
|
@Component({
|
|
22
22
|
selector: 'hlm-radio',
|
|
@@ -5,7 +5,7 @@ import { lucideChevronDown } from '@ng-icons/lucide';
|
|
|
5
5
|
import { BrnFieldControlDescribedBy } from '@spartan-ng/brain/field';
|
|
6
6
|
import { BrnSelectTrigger } from '@spartan-ng/brain/select';
|
|
7
7
|
import { hlm } from '<%- importAlias %>/utils';
|
|
8
|
-
import type { ClassValue } from '
|
|
8
|
+
import type { ClassValue } from 'cn';
|
|
9
9
|
|
|
10
10
|
@Component({
|
|
11
11
|
selector: 'hlm-select-trigger',
|
|
@@ -2,7 +2,7 @@ import { Directive, computed, effect, input, untracked } from '@angular/core';
|
|
|
2
2
|
import { injectCustomClassSettable } from '@spartan-ng/brain/core';
|
|
3
3
|
import { BrnSheetOverlay } from '@spartan-ng/brain/sheet';
|
|
4
4
|
import { hlm } from '<%- importAlias %>/utils';
|
|
5
|
-
import type { ClassValue } from '
|
|
5
|
+
import type { ClassValue } from 'cn';
|
|
6
6
|
|
|
7
7
|
@Directive({
|
|
8
8
|
selector: '[hlmSheetOverlay],hlm-sheet-overlay',
|
|
@@ -2,7 +2,7 @@ import { NgTemplateOutlet } from '@angular/common';
|
|
|
2
2
|
import { ChangeDetectionStrategy, Component, computed, effect, inject, input } from '@angular/core';
|
|
3
3
|
import { HlmSheetImports } from '<%- importAlias %>/sheet';
|
|
4
4
|
import { classes, hlm } from '<%- importAlias %>/utils';
|
|
5
|
-
import type { ClassValue } from '
|
|
5
|
+
import type { ClassValue } from 'cn';
|
|
6
6
|
import { HlmSidebarService, type SidebarVariant } from './hlm-sidebar.service';
|
|
7
7
|
import { injectHlmSidebarConfig } from './hlm-sidebar.token';
|
|
8
8
|
|
|
@@ -5,7 +5,7 @@ import { lucideCircleCheck, lucideInfo, lucideLoader2, lucideOctagonX, lucideTri
|
|
|
5
5
|
import { BrnSonnerImports, type ToasterProps } from '@spartan-ng/brain/sonner';
|
|
6
6
|
import { HlmButtonImports } from '<%- importAlias %>/button';
|
|
7
7
|
import { hlm } from '<%- importAlias %>/utils';
|
|
8
|
-
import type { ClassValue } from '
|
|
8
|
+
import type { ClassValue } from 'cn';
|
|
9
9
|
|
|
10
10
|
@Component({
|
|
11
11
|
selector: 'hlm-toaster',
|
|
@@ -13,7 +13,7 @@ import { type ControlValueAccessor, NG_VALUE_ACCESSOR } from '@angular/forms';
|
|
|
13
13
|
import type { ChangeFn, TouchFn } from '@spartan-ng/brain/forms';
|
|
14
14
|
import { BrnSwitch, type BrnSwitchSize } from '@spartan-ng/brain/switch';
|
|
15
15
|
import { hlm } from '<%- importAlias %>/utils';
|
|
16
|
-
import type { ClassValue } from '
|
|
16
|
+
import type { ClassValue } from 'cn';
|
|
17
17
|
import { HlmSwitchThumb } from './hlm-switch-thumb';
|
|
18
18
|
|
|
19
19
|
export const HLM_SWITCH_VALUE_ACCESSOR = {
|
|
@@ -14,7 +14,7 @@ import { lucideChevronLeft, lucideChevronRight } from '@ng-icons/lucide';
|
|
|
14
14
|
import { type BrnPaginatedTabHeaderItem, BrnTabsPaginatedList, BrnTabsTrigger } from '@spartan-ng/brain/tabs';
|
|
15
15
|
import { buttonVariants } from '<%- importAlias %>/button';
|
|
16
16
|
import { classes, hlm } from '<%- importAlias %>/utils';
|
|
17
|
-
import type { ClassValue } from '
|
|
17
|
+
import type { ClassValue } from 'cn';
|
|
18
18
|
import type { Observable } from 'rxjs';
|
|
19
19
|
import { listVariants } from './hlm-tabs-list';
|
|
20
20
|
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { ChangeDetectionStrategy, Component, computed, input } from '@angular/core';
|
|
2
2
|
import { BrnCollapsibleContent } from '@spartan-ng/brain/collapsible';
|
|
3
3
|
import { classes, hlm } from '<%- importAlias %>/utils';
|
|
4
|
-
import { ClassValue } from '
|
|
4
|
+
import { ClassValue } from 'cn';
|
|
5
5
|
|
|
6
6
|
@Component({
|
|
7
7
|
selector: 'hlm-trace-collapsible-content',
|