@cute-widgets/base 20.0.1
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/CHANGELOG.md +1 -0
- package/LICENSE.md +191 -0
- package/README.md +190 -0
- package/abstract/index.d.ts +327 -0
- package/alert/index.d.ts +68 -0
- package/autocomplete/index.d.ts +442 -0
- package/badge/index.d.ts +26 -0
- package/bottom-sheet/index.d.ts +231 -0
- package/button/index.d.ts +182 -0
- package/button-toggle/index.d.ts +225 -0
- package/card/index.d.ts +163 -0
- package/checkbox/index.d.ts +174 -0
- package/chips/index.d.ts +963 -0
- package/collapse/index.d.ts +97 -0
- package/core/animation/index.d.ts +43 -0
- package/core/datetime/index.d.ts +404 -0
- package/core/directives/index.d.ts +168 -0
- package/core/error/index.d.ts +74 -0
- package/core/index.d.ts +1039 -0
- package/core/interfaces/index.d.ts +114 -0
- package/core/layout/index.d.ts +53 -0
- package/core/line/index.d.ts +37 -0
- package/core/nav/index.d.ts +321 -0
- package/core/observers/index.d.ts +124 -0
- package/core/option/index.d.ts +185 -0
- package/core/pipes/index.d.ts +53 -0
- package/core/ripple/index.d.ts +66 -0
- package/core/testing/index.d.ts +154 -0
- package/core/theming/index.d.ts +118 -0
- package/core/types/index.d.ts +53 -0
- package/core/utils/index.d.ts +129 -0
- package/cute-widgets-base-20.0.1.tgz +0 -0
- package/datepicker/index.d.ts +1817 -0
- package/dialog/index.d.ts +484 -0
- package/divider/index.d.ts +24 -0
- package/expansion/README.md +8 -0
- package/expansion/index.d.ts +308 -0
- package/fesm2022/cute-widgets-base-abstract.mjs +547 -0
- package/fesm2022/cute-widgets-base-abstract.mjs.map +1 -0
- package/fesm2022/cute-widgets-base-alert.mjs +198 -0
- package/fesm2022/cute-widgets-base-alert.mjs.map +1 -0
- package/fesm2022/cute-widgets-base-autocomplete.mjs +1217 -0
- package/fesm2022/cute-widgets-base-autocomplete.mjs.map +1 -0
- package/fesm2022/cute-widgets-base-badge.mjs +75 -0
- package/fesm2022/cute-widgets-base-badge.mjs.map +1 -0
- package/fesm2022/cute-widgets-base-bottom-sheet.mjs +416 -0
- package/fesm2022/cute-widgets-base-bottom-sheet.mjs.map +1 -0
- package/fesm2022/cute-widgets-base-button-toggle.mjs +640 -0
- package/fesm2022/cute-widgets-base-button-toggle.mjs.map +1 -0
- package/fesm2022/cute-widgets-base-button.mjs +546 -0
- package/fesm2022/cute-widgets-base-button.mjs.map +1 -0
- package/fesm2022/cute-widgets-base-card.mjs +471 -0
- package/fesm2022/cute-widgets-base-card.mjs.map +1 -0
- package/fesm2022/cute-widgets-base-checkbox.mjs +390 -0
- package/fesm2022/cute-widgets-base-checkbox.mjs.map +1 -0
- package/fesm2022/cute-widgets-base-chips.mjs +2360 -0
- package/fesm2022/cute-widgets-base-chips.mjs.map +1 -0
- package/fesm2022/cute-widgets-base-collapse.mjs +259 -0
- package/fesm2022/cute-widgets-base-collapse.mjs.map +1 -0
- package/fesm2022/cute-widgets-base-core-animation.mjs +53 -0
- package/fesm2022/cute-widgets-base-core-animation.mjs.map +1 -0
- package/fesm2022/cute-widgets-base-core-datetime.mjs +568 -0
- package/fesm2022/cute-widgets-base-core-datetime.mjs.map +1 -0
- package/fesm2022/cute-widgets-base-core-directives.mjs +404 -0
- package/fesm2022/cute-widgets-base-core-directives.mjs.map +1 -0
- package/fesm2022/cute-widgets-base-core-error.mjs +105 -0
- package/fesm2022/cute-widgets-base-core-error.mjs.map +1 -0
- package/fesm2022/cute-widgets-base-core-interfaces.mjs +22 -0
- package/fesm2022/cute-widgets-base-core-interfaces.mjs.map +1 -0
- package/fesm2022/cute-widgets-base-core-layout.mjs +74 -0
- package/fesm2022/cute-widgets-base-core-layout.mjs.map +1 -0
- package/fesm2022/cute-widgets-base-core-line.mjs +87 -0
- package/fesm2022/cute-widgets-base-core-line.mjs.map +1 -0
- package/fesm2022/cute-widgets-base-core-nav.mjs +863 -0
- package/fesm2022/cute-widgets-base-core-nav.mjs.map +1 -0
- package/fesm2022/cute-widgets-base-core-observers.mjs +304 -0
- package/fesm2022/cute-widgets-base-core-observers.mjs.map +1 -0
- package/fesm2022/cute-widgets-base-core-option.mjs +373 -0
- package/fesm2022/cute-widgets-base-core-option.mjs.map +1 -0
- package/fesm2022/cute-widgets-base-core-pipes.mjs +97 -0
- package/fesm2022/cute-widgets-base-core-pipes.mjs.map +1 -0
- package/fesm2022/cute-widgets-base-core-ripple.mjs +172 -0
- package/fesm2022/cute-widgets-base-core-ripple.mjs.map +1 -0
- package/fesm2022/cute-widgets-base-core-testing.mjs +210 -0
- package/fesm2022/cute-widgets-base-core-testing.mjs.map +1 -0
- package/fesm2022/cute-widgets-base-core-theming.mjs +314 -0
- package/fesm2022/cute-widgets-base-core-theming.mjs.map +1 -0
- package/fesm2022/cute-widgets-base-core-types.mjs +22 -0
- package/fesm2022/cute-widgets-base-core-types.mjs.map +1 -0
- package/fesm2022/cute-widgets-base-core-utils.mjs +257 -0
- package/fesm2022/cute-widgets-base-core-utils.mjs.map +1 -0
- package/fesm2022/cute-widgets-base-core.mjs +1600 -0
- package/fesm2022/cute-widgets-base-core.mjs.map +1 -0
- package/fesm2022/cute-widgets-base-datepicker.mjs +4827 -0
- package/fesm2022/cute-widgets-base-datepicker.mjs.map +1 -0
- package/fesm2022/cute-widgets-base-dialog.mjs +1046 -0
- package/fesm2022/cute-widgets-base-dialog.mjs.map +1 -0
- package/fesm2022/cute-widgets-base-divider.mjs +86 -0
- package/fesm2022/cute-widgets-base-divider.mjs.map +1 -0
- package/fesm2022/cute-widgets-base-expansion.mjs +623 -0
- package/fesm2022/cute-widgets-base-expansion.mjs.map +1 -0
- package/fesm2022/cute-widgets-base-form-field.mjs +969 -0
- package/fesm2022/cute-widgets-base-form-field.mjs.map +1 -0
- package/fesm2022/cute-widgets-base-grid-list.mjs +715 -0
- package/fesm2022/cute-widgets-base-grid-list.mjs.map +1 -0
- package/fesm2022/cute-widgets-base-icon.mjs +1105 -0
- package/fesm2022/cute-widgets-base-icon.mjs.map +1 -0
- package/fesm2022/cute-widgets-base-input.mjs +726 -0
- package/fesm2022/cute-widgets-base-input.mjs.map +1 -0
- package/fesm2022/cute-widgets-base-layout-container.mjs +95 -0
- package/fesm2022/cute-widgets-base-layout-container.mjs.map +1 -0
- package/fesm2022/cute-widgets-base-layout-stack.mjs +166 -0
- package/fesm2022/cute-widgets-base-layout-stack.mjs.map +1 -0
- package/fesm2022/cute-widgets-base-layout.mjs +250 -0
- package/fesm2022/cute-widgets-base-layout.mjs.map +1 -0
- package/fesm2022/cute-widgets-base-list.mjs +1557 -0
- package/fesm2022/cute-widgets-base-list.mjs.map +1 -0
- package/fesm2022/cute-widgets-base-menu.mjs +1283 -0
- package/fesm2022/cute-widgets-base-menu.mjs.map +1 -0
- package/fesm2022/cute-widgets-base-navbar.mjs +359 -0
- package/fesm2022/cute-widgets-base-navbar.mjs.map +1 -0
- package/fesm2022/cute-widgets-base-paginator.mjs +485 -0
- package/fesm2022/cute-widgets-base-paginator.mjs.map +1 -0
- package/fesm2022/cute-widgets-base-progress.mjs +321 -0
- package/fesm2022/cute-widgets-base-progress.mjs.map +1 -0
- package/fesm2022/cute-widgets-base-radio.mjs +637 -0
- package/fesm2022/cute-widgets-base-radio.mjs.map +1 -0
- package/fesm2022/cute-widgets-base-select.mjs +1208 -0
- package/fesm2022/cute-widgets-base-select.mjs.map +1 -0
- package/fesm2022/cute-widgets-base-sidenav.mjs +1095 -0
- package/fesm2022/cute-widgets-base-sidenav.mjs.map +1 -0
- package/fesm2022/cute-widgets-base-slider.mjs +99 -0
- package/fesm2022/cute-widgets-base-slider.mjs.map +1 -0
- package/fesm2022/cute-widgets-base-snack-bar.mjs +897 -0
- package/fesm2022/cute-widgets-base-snack-bar.mjs.map +1 -0
- package/fesm2022/cute-widgets-base-sort.mjs +639 -0
- package/fesm2022/cute-widgets-base-sort.mjs.map +1 -0
- package/fesm2022/cute-widgets-base-spinner.mjs +154 -0
- package/fesm2022/cute-widgets-base-spinner.mjs.map +1 -0
- package/fesm2022/cute-widgets-base-stepper.mjs +673 -0
- package/fesm2022/cute-widgets-base-stepper.mjs.map +1 -0
- package/fesm2022/cute-widgets-base-table.mjs +1023 -0
- package/fesm2022/cute-widgets-base-table.mjs.map +1 -0
- package/fesm2022/cute-widgets-base-tabs.mjs +729 -0
- package/fesm2022/cute-widgets-base-tabs.mjs.map +1 -0
- package/fesm2022/cute-widgets-base-timepicker.mjs +965 -0
- package/fesm2022/cute-widgets-base-timepicker.mjs.map +1 -0
- package/fesm2022/cute-widgets-base-toolbar.mjs +120 -0
- package/fesm2022/cute-widgets-base-toolbar.mjs.map +1 -0
- package/fesm2022/cute-widgets-base-tooltip.mjs +947 -0
- package/fesm2022/cute-widgets-base-tooltip.mjs.map +1 -0
- package/fesm2022/cute-widgets-base-tree.mjs +598 -0
- package/fesm2022/cute-widgets-base-tree.mjs.map +1 -0
- package/fesm2022/cute-widgets-base.mjs +68 -0
- package/fesm2022/cute-widgets-base.mjs.map +1 -0
- package/form-field/index.d.ts +401 -0
- package/grid-list/index.d.ts +361 -0
- package/icon/index.d.ts +477 -0
- package/index.d.ts +3 -0
- package/input/index.d.ts +256 -0
- package/layout/container/index.d.ts +31 -0
- package/layout/index.d.ts +78 -0
- package/layout/stack/index.d.ts +52 -0
- package/list/index.d.ts +659 -0
- package/menu/index.d.ts +497 -0
- package/navbar/index.d.ts +91 -0
- package/package.json +279 -0
- package/paginator/index.d.ts +216 -0
- package/progress/index.d.ts +130 -0
- package/radio/index.d.ts +259 -0
- package/select/index.d.ts +426 -0
- package/sidenav/index.d.ts +369 -0
- package/slider/index.d.ts +48 -0
- package/snack-bar/index.d.ts +374 -0
- package/sort/index.d.ts +334 -0
- package/spinner/index.d.ts +70 -0
- package/stepper/index.d.ts +295 -0
- package/table/index.d.ts +395 -0
- package/tabs/index.d.ts +307 -0
- package/timepicker/index.d.ts +350 -0
- package/toolbar/index.d.ts +36 -0
- package/tooltip/index.d.ts +299 -0
- package/tree/index.d.ts +314 -0
|
@@ -0,0 +1,639 @@
|
|
|
1
|
+
import { SPACE, ENTER } from '@angular/cdk/keycodes';
|
|
2
|
+
import * as i0 from '@angular/core';
|
|
3
|
+
import { InjectionToken, isDevMode, EventEmitter, booleanAttribute, Output, Input, Optional, Inject, Directive, Injectable, SkipSelf, ChangeDetectionStrategy, ViewEncapsulation, Component, NgModule } from '@angular/core';
|
|
4
|
+
import { ReplaySubject, Subject, merge } from 'rxjs';
|
|
5
|
+
import { trigger, transition, query, animateChild, state, animate, keyframes, style } from '@angular/animations';
|
|
6
|
+
import { AnimationDurations, AnimationCurves } from '@cute-widgets/base/core';
|
|
7
|
+
import * as i3 from '@angular/cdk/a11y';
|
|
8
|
+
import { CommonModule } from '@angular/common';
|
|
9
|
+
|
|
10
|
+
/** @docs-private */
|
|
11
|
+
function getSortDuplicateSortableIdError(id) {
|
|
12
|
+
return Error(`Cannot have two CuteSortables with the same id (${id}).`);
|
|
13
|
+
}
|
|
14
|
+
/** @docs-private */
|
|
15
|
+
function getSortHeaderNotContainedWithinSortError() {
|
|
16
|
+
return Error(`MatSortHeader must be placed within a parent element with the CuteSort directive.`);
|
|
17
|
+
}
|
|
18
|
+
/** @docs-private */
|
|
19
|
+
function getSortHeaderMissingIdError() {
|
|
20
|
+
return Error(`CuteSortHeader must be provided with a unique id.`);
|
|
21
|
+
}
|
|
22
|
+
/** @docs-private */
|
|
23
|
+
function getSortInvalidDirectionError(direction) {
|
|
24
|
+
return Error(`${direction} is not a valid sort direction ('asc' or 'desc').`);
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
/**
|
|
28
|
+
* @license Apache-2.0
|
|
29
|
+
*
|
|
30
|
+
* Copyright (c) 2025 CuteWidgets Team. All Rights Reserved.
|
|
31
|
+
*
|
|
32
|
+
* You may not use this file except in compliance with the License
|
|
33
|
+
* that can be found at http://www.apache.org/licenses/LICENSE-2.0
|
|
34
|
+
*
|
|
35
|
+
* This code is a modification of the `@angular/material` original
|
|
36
|
+
* code licensed under MIT-style License (https://angular.dev/license).
|
|
37
|
+
*/
|
|
38
|
+
/** Injection token to be used to override the default options for `mat-sort`. */
|
|
39
|
+
const CUTE_SORT_DEFAULT_OPTIONS = new InjectionToken('CUTE_SORT_DEFAULT_OPTIONS');
|
|
40
|
+
/** Container for MatSortables to manage the sort state and provide default sort parameters. */
|
|
41
|
+
class CuteSort {
|
|
42
|
+
/** The sort direction of the currently active CuteSortable. */
|
|
43
|
+
get direction() { return this._direction; }
|
|
44
|
+
set direction(direction) {
|
|
45
|
+
if (direction &&
|
|
46
|
+
direction !== 'asc' &&
|
|
47
|
+
direction !== 'desc' &&
|
|
48
|
+
isDevMode()) {
|
|
49
|
+
throw getSortInvalidDirectionError(direction);
|
|
50
|
+
}
|
|
51
|
+
this._direction = direction;
|
|
52
|
+
}
|
|
53
|
+
constructor(_defaultOptions) {
|
|
54
|
+
this._defaultOptions = _defaultOptions;
|
|
55
|
+
this._initializedStream = new ReplaySubject(1);
|
|
56
|
+
/** Collection of all registered sortables that this directive manages. */
|
|
57
|
+
this.sortables = new Map();
|
|
58
|
+
/** Used to notify any child components listening to state changes. */
|
|
59
|
+
this._stateChanges = new Subject();
|
|
60
|
+
/**
|
|
61
|
+
* The direction to set when a CuteSortable is initially sorted.
|
|
62
|
+
* May be overridden by the CuteSortable's sort start.
|
|
63
|
+
*/
|
|
64
|
+
this.start = 'asc';
|
|
65
|
+
this._direction = '';
|
|
66
|
+
/**
|
|
67
|
+
* Whether to disable the user from clearing the sort by finishing the sort direction cycle.
|
|
68
|
+
* May be overridden by the CuteSortable's disable clear input.
|
|
69
|
+
*/
|
|
70
|
+
this.disableClear = false;
|
|
71
|
+
/** Whether the sortable is disabled. */
|
|
72
|
+
this.disabled = false;
|
|
73
|
+
/** Event emitted when the user changes either the active sort or sort direction. */
|
|
74
|
+
this.sortChange = new EventEmitter();
|
|
75
|
+
/** Emits when the paginator is initialized. */
|
|
76
|
+
this.initialized$ = this._initializedStream;
|
|
77
|
+
}
|
|
78
|
+
/**
|
|
79
|
+
* Register function to be used by the contained CuteSortables. Adds the CuteSortable to the
|
|
80
|
+
* collection of CuteSortables.
|
|
81
|
+
*/
|
|
82
|
+
register(sortable) {
|
|
83
|
+
if (isDevMode()) {
|
|
84
|
+
if (!sortable.id) {
|
|
85
|
+
throw getSortHeaderMissingIdError();
|
|
86
|
+
}
|
|
87
|
+
if (this.sortables.has(sortable.id)) {
|
|
88
|
+
throw getSortDuplicateSortableIdError(sortable.id);
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
this.sortables.set(sortable.id, sortable);
|
|
92
|
+
}
|
|
93
|
+
/**
|
|
94
|
+
* Unregister function to be used by the contained CuteSortables. Removes the CuteSortable from the
|
|
95
|
+
* collection of contained CuteSortables.
|
|
96
|
+
*/
|
|
97
|
+
deregister(sortable) {
|
|
98
|
+
this.sortables.delete(sortable.id);
|
|
99
|
+
}
|
|
100
|
+
/** Sets the active sort id and determines the new sort direction. */
|
|
101
|
+
sort(sortable) {
|
|
102
|
+
if (this.active != sortable.id) {
|
|
103
|
+
this.active = sortable.id;
|
|
104
|
+
this.direction = sortable.start ? sortable.start : this.start;
|
|
105
|
+
}
|
|
106
|
+
else {
|
|
107
|
+
this.direction = this.getNextSortDirection(sortable);
|
|
108
|
+
}
|
|
109
|
+
this.sortChange.emit({ active: this.active, direction: this.direction });
|
|
110
|
+
}
|
|
111
|
+
/** Returns the next sort direction of the active sortable, checking for potential overrides. */
|
|
112
|
+
getNextSortDirection(sortable) {
|
|
113
|
+
if (!sortable) {
|
|
114
|
+
return '';
|
|
115
|
+
}
|
|
116
|
+
// Get the sort direction cycle with the potential sortable overrides.
|
|
117
|
+
const disableClear = sortable?.disableClear ?? this.disableClear ?? !!this._defaultOptions?.disableClear;
|
|
118
|
+
let sortDirectionCycle = getSortDirectionCycle(sortable.start || this.start, disableClear);
|
|
119
|
+
// Get and return the next direction in the cycle
|
|
120
|
+
let nextDirectionIndex = sortDirectionCycle.indexOf(this.direction) + 1;
|
|
121
|
+
if (nextDirectionIndex >= sortDirectionCycle.length) {
|
|
122
|
+
nextDirectionIndex = 0;
|
|
123
|
+
}
|
|
124
|
+
return sortDirectionCycle[nextDirectionIndex];
|
|
125
|
+
}
|
|
126
|
+
ngOnInit() {
|
|
127
|
+
this._initializedStream.next();
|
|
128
|
+
}
|
|
129
|
+
ngOnChanges(changes) {
|
|
130
|
+
this._stateChanges.next();
|
|
131
|
+
}
|
|
132
|
+
ngOnDestroy() {
|
|
133
|
+
this._stateChanges.complete();
|
|
134
|
+
this._initializedStream.complete();
|
|
135
|
+
}
|
|
136
|
+
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "20.3.15", ngImport: i0, type: CuteSort, deps: [{ token: CUTE_SORT_DEFAULT_OPTIONS, optional: true }], target: i0.ɵɵFactoryTarget.Directive }); }
|
|
137
|
+
static { this.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "16.1.0", version: "20.3.15", type: CuteSort, isStandalone: true, selector: "[cuteSort]", inputs: { active: ["cuteSortActive", "active"], start: ["cuteSortStart", "start"], direction: ["cuteSortDirection", "direction"], disableClear: ["cuteSortDisableClear", "disableClear", booleanAttribute], disabled: ["cuteSortDisabled", "disabled", booleanAttribute] }, outputs: { sortChange: "cuteSortChange" }, host: { classAttribute: "cute-sort" }, exportAs: ["cuteSort"], usesOnChanges: true, ngImport: i0 }); }
|
|
138
|
+
}
|
|
139
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.3.15", ngImport: i0, type: CuteSort, decorators: [{
|
|
140
|
+
type: Directive,
|
|
141
|
+
args: [{
|
|
142
|
+
selector: '[cuteSort]',
|
|
143
|
+
exportAs: 'cuteSort',
|
|
144
|
+
host: {
|
|
145
|
+
'class': 'cute-sort',
|
|
146
|
+
},
|
|
147
|
+
standalone: true,
|
|
148
|
+
}]
|
|
149
|
+
}], ctorParameters: () => [{ type: undefined, decorators: [{
|
|
150
|
+
type: Optional
|
|
151
|
+
}, {
|
|
152
|
+
type: Inject,
|
|
153
|
+
args: [CUTE_SORT_DEFAULT_OPTIONS]
|
|
154
|
+
}] }], propDecorators: { active: [{
|
|
155
|
+
type: Input,
|
|
156
|
+
args: ['cuteSortActive']
|
|
157
|
+
}], start: [{
|
|
158
|
+
type: Input,
|
|
159
|
+
args: ['cuteSortStart']
|
|
160
|
+
}], direction: [{
|
|
161
|
+
type: Input,
|
|
162
|
+
args: ['cuteSortDirection']
|
|
163
|
+
}], disableClear: [{
|
|
164
|
+
type: Input,
|
|
165
|
+
args: [{ alias: 'cuteSortDisableClear', transform: booleanAttribute }]
|
|
166
|
+
}], disabled: [{
|
|
167
|
+
type: Input,
|
|
168
|
+
args: [{ alias: 'cuteSortDisabled', transform: booleanAttribute }]
|
|
169
|
+
}], sortChange: [{
|
|
170
|
+
type: Output,
|
|
171
|
+
args: ['cuteSortChange']
|
|
172
|
+
}] } });
|
|
173
|
+
/** Returns the sort direction cycle to use given the provided parameters of order and clear. */
|
|
174
|
+
function getSortDirectionCycle(start, disableClear) {
|
|
175
|
+
let sortOrder = ['asc', 'desc'];
|
|
176
|
+
if (start == 'desc') {
|
|
177
|
+
sortOrder.reverse();
|
|
178
|
+
}
|
|
179
|
+
if (!disableClear) {
|
|
180
|
+
sortOrder.push('');
|
|
181
|
+
}
|
|
182
|
+
return sortOrder;
|
|
183
|
+
}
|
|
184
|
+
|
|
185
|
+
/**
|
|
186
|
+
* @license Apache-2.0
|
|
187
|
+
*
|
|
188
|
+
* Copyright (c) 2025 CuteWidgets Team. All Rights Reserved.
|
|
189
|
+
*
|
|
190
|
+
* You may not use this file except in compliance with the License
|
|
191
|
+
* that can be found at http://www.apache.org/licenses/LICENSE-2.0
|
|
192
|
+
*
|
|
193
|
+
* This code is a modification of the `@angular/material` original
|
|
194
|
+
* code licensed under MIT-style License (https://angular.dev/license).
|
|
195
|
+
*/
|
|
196
|
+
const SORT_ANIMATION_TRANSITION = AnimationDurations.ENTERING + ' ' + AnimationCurves.STANDARD_CURVE;
|
|
197
|
+
/**
|
|
198
|
+
* Animations used by CuteSort.
|
|
199
|
+
* @docs-private
|
|
200
|
+
*/
|
|
201
|
+
const cuteSortAnimations = {
|
|
202
|
+
/** Animation that moves the sort indicator. */
|
|
203
|
+
indicator: trigger('indicator', [
|
|
204
|
+
state('active-asc, asc', style({ transform: 'translateY(0px)' })),
|
|
205
|
+
// 10px is the height of the sort indicator, minus the width of the pointers
|
|
206
|
+
state('active-desc, desc', style({ transform: 'translateY(10px)' })),
|
|
207
|
+
transition('active-asc <=> active-desc', animate(SORT_ANIMATION_TRANSITION)),
|
|
208
|
+
]),
|
|
209
|
+
/** Animation that rotates the left pointer of the indicator based on the sorting direction. */
|
|
210
|
+
leftPointer: trigger('leftPointer', [
|
|
211
|
+
state('active-asc, asc', style({ transform: 'rotate(-45deg)' })),
|
|
212
|
+
state('active-desc, desc', style({ transform: 'rotate(45deg)' })),
|
|
213
|
+
transition('active-asc <=> active-desc', animate(SORT_ANIMATION_TRANSITION)),
|
|
214
|
+
]),
|
|
215
|
+
/** Animation that rotates the right pointer of the indicator based on the sorting direction. */
|
|
216
|
+
rightPointer: trigger('rightPointer', [
|
|
217
|
+
state('active-asc, asc', style({ transform: 'rotate(45deg)' })),
|
|
218
|
+
state('active-desc, desc', style({ transform: 'rotate(-45deg)' })),
|
|
219
|
+
transition('active-asc <=> active-desc', animate(SORT_ANIMATION_TRANSITION)),
|
|
220
|
+
]),
|
|
221
|
+
/** Animation that controls the arrow opacity. */
|
|
222
|
+
arrowOpacity: trigger('arrowOpacity', [
|
|
223
|
+
state('desc-to-active, asc-to-active, active', style({ opacity: 1 })),
|
|
224
|
+
state('desc-to-hint, asc-to-hint, hint', style({ opacity: 0.54 })),
|
|
225
|
+
state('hint-to-desc, active-to-desc, desc, hint-to-asc, active-to-asc, asc, void', style({ opacity: 0 })),
|
|
226
|
+
// Transition between all states except for immediate transitions
|
|
227
|
+
transition('* => asc, * => desc, * => active, * => hint, * => void', animate('0ms')),
|
|
228
|
+
transition('* <=> *', animate(SORT_ANIMATION_TRANSITION)),
|
|
229
|
+
]),
|
|
230
|
+
/**
|
|
231
|
+
* Animation for the translation of the arrow as a whole. States are separated into two
|
|
232
|
+
* groups: ones with animations and others that are immediate. Immediate states are asc, desc,
|
|
233
|
+
* peek, and active. The other states define a specific animation (source-to-destination)
|
|
234
|
+
* and are determined as a function of their prev user-perceived state and what the next state
|
|
235
|
+
* should be.
|
|
236
|
+
*/
|
|
237
|
+
arrowPosition: trigger('arrowPosition', [
|
|
238
|
+
// Hidden Above => Hint Center
|
|
239
|
+
transition('* => desc-to-hint, * => desc-to-active', animate(SORT_ANIMATION_TRANSITION, keyframes([style({ transform: 'translateY(-25%)' }), style({ transform: 'translateY(0)' })]))),
|
|
240
|
+
// Hint Center => Hidden Below
|
|
241
|
+
transition('* => hint-to-desc, * => active-to-desc', animate(SORT_ANIMATION_TRANSITION, keyframes([style({ transform: 'translateY(0)' }), style({ transform: 'translateY(25%)' })]))),
|
|
242
|
+
// Hidden Below => Hint Center
|
|
243
|
+
transition('* => asc-to-hint, * => asc-to-active', animate(SORT_ANIMATION_TRANSITION, keyframes([style({ transform: 'translateY(25%)' }), style({ transform: 'translateY(0)' })]))),
|
|
244
|
+
// Hint Center => Hidden Above
|
|
245
|
+
transition('* => hint-to-asc, * => active-to-asc', animate(SORT_ANIMATION_TRANSITION, keyframes([style({ transform: 'translateY(0)' }), style({ transform: 'translateY(-25%)' })]))),
|
|
246
|
+
state('desc-to-hint, asc-to-hint, hint, desc-to-active, asc-to-active, active', style({ transform: 'translateY(0)' })),
|
|
247
|
+
state('hint-to-desc, active-to-desc, desc', style({ transform: 'translateY(-25%)' })),
|
|
248
|
+
state('hint-to-asc, active-to-asc, asc', style({ transform: 'translateY(25%)' })),
|
|
249
|
+
]),
|
|
250
|
+
/** Necessary trigger that calls animate on children animations. */
|
|
251
|
+
allowChildren: trigger('allowChildren', [
|
|
252
|
+
transition('* <=> *', [query('@*', animateChild(), { optional: true })]),
|
|
253
|
+
]),
|
|
254
|
+
};
|
|
255
|
+
|
|
256
|
+
/**
|
|
257
|
+
* @license Apache-2.0
|
|
258
|
+
*
|
|
259
|
+
* Copyright (c) 2025 CuteWidgets Team. All Rights Reserved.
|
|
260
|
+
*
|
|
261
|
+
* You may not use this file except in compliance with the License
|
|
262
|
+
* that can be found at http://www.apache.org/licenses/LICENSE-2.0
|
|
263
|
+
*
|
|
264
|
+
* This code is a modification of the `@angular/material` original
|
|
265
|
+
* code licensed under MIT-style License (https://angular.dev/license).
|
|
266
|
+
*/
|
|
267
|
+
/**
|
|
268
|
+
* To modify the labels and text displayed, create a new instance of CuteSortHeaderIntl and
|
|
269
|
+
* include it in a custom provider.
|
|
270
|
+
*/
|
|
271
|
+
class CuteSortHeaderIntl {
|
|
272
|
+
constructor() {
|
|
273
|
+
/**
|
|
274
|
+
* Stream that emits whenever the labels here are changed. Use this to notify
|
|
275
|
+
* components if the labels have changed after initialization.
|
|
276
|
+
*/
|
|
277
|
+
this.changes = new Subject();
|
|
278
|
+
}
|
|
279
|
+
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "20.3.15", ngImport: i0, type: CuteSortHeaderIntl, deps: [], target: i0.ɵɵFactoryTarget.Injectable }); }
|
|
280
|
+
static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "20.3.15", ngImport: i0, type: CuteSortHeaderIntl, providedIn: 'root' }); }
|
|
281
|
+
}
|
|
282
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.3.15", ngImport: i0, type: CuteSortHeaderIntl, decorators: [{
|
|
283
|
+
type: Injectable,
|
|
284
|
+
args: [{ providedIn: 'root' }]
|
|
285
|
+
}] });
|
|
286
|
+
/** @docs-private */
|
|
287
|
+
function CUTE_SORT_HEADER_INTL_PROVIDER_FACTORY(parentIntl) {
|
|
288
|
+
return parentIntl || new CuteSortHeaderIntl();
|
|
289
|
+
}
|
|
290
|
+
/** @docs-private */
|
|
291
|
+
const CUTE_SORT_HEADER_INTL_PROVIDER = {
|
|
292
|
+
// If there is already an MatSortHeaderIntl available, use that. Otherwise, provide a new one.
|
|
293
|
+
provide: CuteSortHeaderIntl,
|
|
294
|
+
deps: [[new Optional(), new SkipSelf(), CuteSortHeaderIntl]],
|
|
295
|
+
useFactory: CUTE_SORT_HEADER_INTL_PROVIDER_FACTORY,
|
|
296
|
+
};
|
|
297
|
+
|
|
298
|
+
/**
|
|
299
|
+
* Applies sorting behavior (click to change sort) and styles to an element, including an
|
|
300
|
+
* arrow to display the current sort direction.
|
|
301
|
+
*
|
|
302
|
+
* Must be provided with an id and contained within a parent `CuteSort` directive.
|
|
303
|
+
*
|
|
304
|
+
* If used on header cells in a CdkTable, it will automatically default its id from its containing
|
|
305
|
+
* column definition.
|
|
306
|
+
*/
|
|
307
|
+
class CuteSortHeader {
|
|
308
|
+
/**
|
|
309
|
+
* Description applied to MatSortHeader's button element with aria-describedby. This text should
|
|
310
|
+
* describe the action that will occur when the user clicks the sort header.
|
|
311
|
+
*/
|
|
312
|
+
get sortActionDescription() {
|
|
313
|
+
return this._sortActionDescription;
|
|
314
|
+
}
|
|
315
|
+
set sortActionDescription(value) {
|
|
316
|
+
this._updateSortActionDescription(value);
|
|
317
|
+
}
|
|
318
|
+
constructor(
|
|
319
|
+
/**
|
|
320
|
+
* @deprecated `_intl` parameter isn't being used anymore, and it'll be removed.
|
|
321
|
+
* @breaking-change 13.0.0
|
|
322
|
+
*/
|
|
323
|
+
_intl, _changeDetectorRef,
|
|
324
|
+
// `CuteSort` is not optionally injected, but just asserted manually w/ better error.
|
|
325
|
+
// tslint:disable-next-line: lightweight-tokens
|
|
326
|
+
_sort, _columnDef, _focusMonitor, _elementRef,
|
|
327
|
+
/** @breaking-change 14.0.0 _ariaDescriber will be required. */
|
|
328
|
+
_ariaDescriber, defaultOptions) {
|
|
329
|
+
this._intl = _intl;
|
|
330
|
+
this._changeDetectorRef = _changeDetectorRef;
|
|
331
|
+
this._sort = _sort;
|
|
332
|
+
this._columnDef = _columnDef;
|
|
333
|
+
this._focusMonitor = _focusMonitor;
|
|
334
|
+
this._elementRef = _elementRef;
|
|
335
|
+
this._ariaDescriber = _ariaDescriber;
|
|
336
|
+
/**
|
|
337
|
+
* The element with role="button" inside this component's view. We need this to apply
|
|
338
|
+
* a description with AriaDescriber.
|
|
339
|
+
*/
|
|
340
|
+
this._sortButton = null;
|
|
341
|
+
/**
|
|
342
|
+
* Flag set to true when the indicator should be displayed while the sort is not active. Used to
|
|
343
|
+
* provide an affordance that the header is sortable by showing on focus and hover.
|
|
344
|
+
*/
|
|
345
|
+
this._showIndicatorHint = false;
|
|
346
|
+
/**
|
|
347
|
+
* The view transition state of the arrow (translation/ opacity) - indicates its `from` and `to`
|
|
348
|
+
* position through the animation. If animations are currently disabled, the `fromState` is removed
|
|
349
|
+
* so that there is no animation displayed.
|
|
350
|
+
*/
|
|
351
|
+
this._viewState = {};
|
|
352
|
+
/** The direction the arrow should be facing, according to the current state. */
|
|
353
|
+
this._arrowDirection = '';
|
|
354
|
+
/**
|
|
355
|
+
* Whether the view state animation should show the transition between the `from` and `to` states.
|
|
356
|
+
*/
|
|
357
|
+
this._disableViewStateAnimation = false;
|
|
358
|
+
/**
|
|
359
|
+
* ID of this sort header. If used within the context of a CdkColumnDef, this will default to
|
|
360
|
+
* the column's name.
|
|
361
|
+
*/
|
|
362
|
+
this.id = "";
|
|
363
|
+
/** Sets the position of the arrow that displays when sorted. */
|
|
364
|
+
this.arrowPosition = 'after';
|
|
365
|
+
/** Overrides the sort start value of the containing CuteSort for this CuteSortable. */
|
|
366
|
+
this.start = "";
|
|
367
|
+
/** whether the sort header is disabled. */
|
|
368
|
+
this.disabled = false;
|
|
369
|
+
// Default the action description to "Sort" because it's better than nothing.
|
|
370
|
+
// Without a description, the button's label comes from the sort header text content,
|
|
371
|
+
// which doesn't give any indication that it performs a sorting operation.
|
|
372
|
+
this._sortActionDescription = 'Sort';
|
|
373
|
+
/** Overrides the disable clear value of the containing CuteSort for this CuteSortable. */
|
|
374
|
+
this.disableClear = false;
|
|
375
|
+
// Note that we use a string token for the `_columnDef`, because the value is provided both by
|
|
376
|
+
// `material/table` and `cdk/table` and we can't have the CDK depending on Material,
|
|
377
|
+
// and we want to avoid having the sort header depending on the CDK table because
|
|
378
|
+
// of this single reference.
|
|
379
|
+
if (!_sort && isDevMode()) {
|
|
380
|
+
throw getSortHeaderNotContainedWithinSortError();
|
|
381
|
+
}
|
|
382
|
+
if (defaultOptions?.arrowPosition) {
|
|
383
|
+
this.arrowPosition = defaultOptions?.arrowPosition;
|
|
384
|
+
}
|
|
385
|
+
this._handleStateChanges();
|
|
386
|
+
}
|
|
387
|
+
ngOnInit() {
|
|
388
|
+
if (!this.id && this._columnDef) {
|
|
389
|
+
this.id = this._columnDef.name;
|
|
390
|
+
}
|
|
391
|
+
// Initialize the direction of the arrow and set the view state to be immediately that state.
|
|
392
|
+
this._updateArrowDirection();
|
|
393
|
+
this._setAnimationTransitionState({
|
|
394
|
+
toState: this._isSorted() ? 'active' : this._arrowDirection,
|
|
395
|
+
});
|
|
396
|
+
this._sort.register(this);
|
|
397
|
+
this._sortButton = this._elementRef.nativeElement.querySelector('.cute-sort-header-container');
|
|
398
|
+
this._updateSortActionDescription(this._sortActionDescription);
|
|
399
|
+
}
|
|
400
|
+
ngAfterViewInit() {
|
|
401
|
+
// We use the focus monitor because we also want to style
|
|
402
|
+
// things differently based on the focus origin.
|
|
403
|
+
this._focusMonitor.monitor(this._elementRef, true).subscribe(origin => {
|
|
404
|
+
const newState = !!origin;
|
|
405
|
+
if (newState !== this._showIndicatorHint) {
|
|
406
|
+
this._setIndicatorHintVisible(newState);
|
|
407
|
+
this._changeDetectorRef.markForCheck();
|
|
408
|
+
}
|
|
409
|
+
});
|
|
410
|
+
}
|
|
411
|
+
ngOnDestroy() {
|
|
412
|
+
this._focusMonitor.stopMonitoring(this._elementRef);
|
|
413
|
+
this._sort.deregister(this);
|
|
414
|
+
this._rerenderSubscription?.unsubscribe();
|
|
415
|
+
}
|
|
416
|
+
/**
|
|
417
|
+
* Sets the "hint" state such that the arrow will be semi-transparently displayed as a hint to the
|
|
418
|
+
* user showing what the active sort will become. If set to false, the arrow will fade away.
|
|
419
|
+
*/
|
|
420
|
+
_setIndicatorHintVisible(visible) {
|
|
421
|
+
// No-op if the sort header is disabled - should not make the hint visible.
|
|
422
|
+
if (this._isDisabled() && visible) {
|
|
423
|
+
return;
|
|
424
|
+
}
|
|
425
|
+
this._showIndicatorHint = visible;
|
|
426
|
+
if (!this._isSorted()) {
|
|
427
|
+
this._updateArrowDirection();
|
|
428
|
+
if (this._showIndicatorHint) {
|
|
429
|
+
this._setAnimationTransitionState({ fromState: this._arrowDirection, toState: 'hint' });
|
|
430
|
+
}
|
|
431
|
+
else {
|
|
432
|
+
this._setAnimationTransitionState({ fromState: 'hint', toState: this._arrowDirection });
|
|
433
|
+
}
|
|
434
|
+
}
|
|
435
|
+
}
|
|
436
|
+
/**
|
|
437
|
+
* Sets the animation transition view state for the arrow's position and opacity. If the
|
|
438
|
+
* `disableViewStateAnimation` flag is set to true, the `fromState` will be ignored so that
|
|
439
|
+
* no animation appears.
|
|
440
|
+
*/
|
|
441
|
+
_setAnimationTransitionState(viewState) {
|
|
442
|
+
this._viewState = viewState || {};
|
|
443
|
+
// If the animation for arrow position state (opacity/translation) should be disabled,
|
|
444
|
+
// remove the fromState so that it jumps right to the toState.
|
|
445
|
+
if (this._disableViewStateAnimation) {
|
|
446
|
+
this._viewState = { toState: viewState.toState };
|
|
447
|
+
}
|
|
448
|
+
}
|
|
449
|
+
/** Triggers the sort on this sort header and removes the indicator hint. */
|
|
450
|
+
_toggleOnInteraction() {
|
|
451
|
+
this._sort.sort(this);
|
|
452
|
+
// Do not show the animation if the header was already shown in the right position.
|
|
453
|
+
if (this._viewState.toState === 'hint' || this._viewState.toState === 'active') {
|
|
454
|
+
this._disableViewStateAnimation = true;
|
|
455
|
+
}
|
|
456
|
+
}
|
|
457
|
+
_handleClick() {
|
|
458
|
+
if (!this._isDisabled()) {
|
|
459
|
+
this._sort.sort(this);
|
|
460
|
+
}
|
|
461
|
+
}
|
|
462
|
+
_handleKeydown(event) {
|
|
463
|
+
if (!this._isDisabled() && (event.keyCode === SPACE || event.keyCode === ENTER)) {
|
|
464
|
+
event.preventDefault();
|
|
465
|
+
this._toggleOnInteraction();
|
|
466
|
+
}
|
|
467
|
+
}
|
|
468
|
+
/** Whether this MatSortHeader is currently sorted in either ascending or descending order. */
|
|
469
|
+
_isSorted() {
|
|
470
|
+
return (this._sort.active == this.id &&
|
|
471
|
+
(this._sort.direction === 'asc' || this._sort.direction === 'desc'));
|
|
472
|
+
}
|
|
473
|
+
/** Returns the animation state for the arrow direction (indicator and pointers). */
|
|
474
|
+
_getArrowDirectionState() {
|
|
475
|
+
return `${this._isSorted() ? 'active-' : ''}${this._arrowDirection}`;
|
|
476
|
+
}
|
|
477
|
+
/** Returns the arrow position state (opacity, translation). */
|
|
478
|
+
_getArrowViewState() {
|
|
479
|
+
const fromState = this._viewState.fromState;
|
|
480
|
+
return (fromState ? `${fromState}-to-` : '') + this._viewState.toState;
|
|
481
|
+
}
|
|
482
|
+
/**
|
|
483
|
+
* Updates the direction the arrow should be pointing. If it is not sorted, the arrow should be
|
|
484
|
+
* facing the start direction. Otherwise, if it is sorted, the arrow should point in the currently
|
|
485
|
+
* active sorted direction. The reason this is updated through a function is because the direction
|
|
486
|
+
* should only be changed at specific times - when deactivated but the hint is displayed and when
|
|
487
|
+
* the sort is active and the direction changes. Otherwise, the arrow's direction should linger
|
|
488
|
+
* in cases such as the sort becoming deactivated but we want to animate the arrow away while
|
|
489
|
+
* preserving its direction, even though the next sort direction is actually different and should
|
|
490
|
+
* only be changed once the arrow displays again (hint or activation).
|
|
491
|
+
*/
|
|
492
|
+
_updateArrowDirection() {
|
|
493
|
+
this._arrowDirection = this._isSorted() ? this._sort.direction : this.start || this._sort.start;
|
|
494
|
+
}
|
|
495
|
+
_isDisabled() {
|
|
496
|
+
return this._sort.disabled || this.disabled;
|
|
497
|
+
}
|
|
498
|
+
/**
|
|
499
|
+
* Gets the aria-sort attribute that should be applied to this sort header. If this header
|
|
500
|
+
* is not sorted, returns null so that the attribute is removed from the host element. Aria spec
|
|
501
|
+
* says that the aria-sort property should only be present on one header at a time, so removing
|
|
502
|
+
* ensures this is true.
|
|
503
|
+
*/
|
|
504
|
+
_getAriaSortAttribute() {
|
|
505
|
+
if (!this._isSorted()) {
|
|
506
|
+
return 'none';
|
|
507
|
+
}
|
|
508
|
+
return this._sort.direction == 'asc' ? 'ascending' : 'descending';
|
|
509
|
+
}
|
|
510
|
+
/** Whether the arrow inside the sort header should be rendered. */
|
|
511
|
+
_renderArrow() {
|
|
512
|
+
return !this._isDisabled() || this._isSorted();
|
|
513
|
+
}
|
|
514
|
+
_updateSortActionDescription(newDescription) {
|
|
515
|
+
// We use AriaDescriber for the sort button instead of setting an `aria-label` because some
|
|
516
|
+
// screen readers (notably VoiceOver) will read both the column header *and* the button's label
|
|
517
|
+
// for every *cell* in the table, creating a lot of unnecessary noise.
|
|
518
|
+
// If _sortButton is undefined, the component hasn't been initialized yet so there's
|
|
519
|
+
// nothing to update in the DOM.
|
|
520
|
+
if (this._sortButton) {
|
|
521
|
+
// removeDescription will no-op if there is no existing message.
|
|
522
|
+
// TODO(jelbourn): remove optional chaining when AriaDescriber is required.
|
|
523
|
+
this._ariaDescriber?.removeDescription(this._sortButton, this._sortActionDescription);
|
|
524
|
+
this._ariaDescriber?.describe(this._sortButton, newDescription);
|
|
525
|
+
}
|
|
526
|
+
this._sortActionDescription = newDescription;
|
|
527
|
+
}
|
|
528
|
+
/** Handles changes in the sorting state. */
|
|
529
|
+
_handleStateChanges() {
|
|
530
|
+
this._rerenderSubscription = merge(this._sort.sortChange, this._sort._stateChanges, this._intl.changes).subscribe(() => {
|
|
531
|
+
if (this._isSorted()) {
|
|
532
|
+
this._updateArrowDirection();
|
|
533
|
+
// Do not show the animation if the header was already shown in the right position.
|
|
534
|
+
if (this._viewState.toState === 'hint' || this._viewState.toState === 'active') {
|
|
535
|
+
this._disableViewStateAnimation = true;
|
|
536
|
+
}
|
|
537
|
+
this._setAnimationTransitionState({ fromState: this._arrowDirection, toState: 'active' });
|
|
538
|
+
this._showIndicatorHint = false;
|
|
539
|
+
}
|
|
540
|
+
// If this header was recently active and now no longer sorted, animate away the arrow.
|
|
541
|
+
if (!this._isSorted() && this._viewState && this._viewState.toState === 'active') {
|
|
542
|
+
this._disableViewStateAnimation = false;
|
|
543
|
+
this._setAnimationTransitionState({ fromState: 'active', toState: this._arrowDirection });
|
|
544
|
+
}
|
|
545
|
+
this._changeDetectorRef.markForCheck();
|
|
546
|
+
});
|
|
547
|
+
}
|
|
548
|
+
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "20.3.15", ngImport: i0, type: CuteSortHeader, deps: [{ token: CuteSortHeaderIntl }, { token: i0.ChangeDetectorRef }, { token: CuteSort, optional: true }, { token: 'CUTE_SORT_HEADER_COLUMN_DEF', optional: true }, { token: i3.FocusMonitor }, { token: i0.ElementRef }, { token: i3.AriaDescriber, optional: true }, { token: CUTE_SORT_DEFAULT_OPTIONS, optional: true }], target: i0.ɵɵFactoryTarget.Component }); }
|
|
549
|
+
static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "20.3.15", type: CuteSortHeader, isStandalone: true, selector: "[cute-sort-header]", inputs: { id: ["cute-sort-header", "id"], arrowPosition: "arrowPosition", start: "start", disabled: ["disabled", "disabled", booleanAttribute], sortActionDescription: "sortActionDescription", disableClear: ["disableClear", "disableClear", booleanAttribute] }, host: { listeners: { "click": "_handleClick()", "keydown": "_handleKeydown($event)", "mouseenter": "_setIndicatorHintVisible(true)", "mouseleave": "_setIndicatorHintVisible(false)" }, properties: { "attr.aria-sort": "_getAriaSortAttribute()", "class.cute-sort-header-disabled": "_isDisabled()" }, classAttribute: "cute-sort-header" }, exportAs: ["cuteSortHeader"], ngImport: i0, template: "<!--\r\n We set the `tabindex` on an element inside the table header, rather than the header itself,\r\n because of a bug in NVDA where having a `tabindex` on a `th` breaks keyboard navigation in the\r\n table (see https://github.com/nvaccess/nvda/issues/7718). This allows for the header to both\r\n be focusable, and have screen readers read out its `aria-sort` state. We prefer this approach\r\n over having a button with an `aria-label` inside the header, because the button's `aria-label`\r\n will be read out as the user is navigating the table's cell (see #13012).\r\n\r\n The approach is based off of: https://dequeuniversity.com/library/aria/tables/sf-sortable-grid\r\n-->\r\n<div class=\"cute-sort-header-container cute-focus-indicator\"\r\n [class.cute-sort-header-sorted]=\"_isSorted()\"\r\n [class.cute-sort-header-position-before]=\"arrowPosition === 'before'\"\r\n [attr.tabindex]=\"_isDisabled() ? null : 0\"\r\n [attr.role]=\"_isDisabled() ? null : 'button'\">\r\n\r\n <!--\r\n TODO(crisbeto): this div isn't strictly necessary, but we have to keep it due to a large\r\n number of screenshot diff failures. It should be removed eventually. Note that the difference\r\n isn't visible with a shorter header, but once it breaks up into multiple lines, this element\r\n causes it to be center-aligned, whereas removing it will keep the text to the left.\r\n -->\r\n <div class=\"cute-sort-header-content\">\r\n <ng-content></ng-content>\r\n </div>\r\n\r\n <!-- Disable animations while a current animation is running -->\r\n @if (_renderArrow()) {\r\n <div class=\"cute-sort-header-arrow\"\r\n [@arrowOpacity]=\"_getArrowViewState()\"\r\n [@arrowPosition]=\"_getArrowViewState()\"\r\n [@allowChildren]=\"_getArrowDirectionState()\"\r\n (@arrowPosition.start)=\"_disableViewStateAnimation = true\"\r\n (@arrowPosition.done)=\"_disableViewStateAnimation = false\">\r\n <div class=\"cute-sort-header-stem\"></div>\r\n <div class=\"cute-sort-header-indicator\" [@indicator]=\"_getArrowDirectionState()\">\r\n <div class=\"cute-sort-header-pointer-left\" [@leftPointer]=\"_getArrowDirectionState()\"></div>\r\n <div class=\"cute-sort-header-pointer-right\" [@rightPointer]=\"_getArrowDirectionState()\"></div>\r\n <div class=\"cute-sort-header-pointer-middle\"></div>\r\n </div>\r\n </div>\r\n }\r\n</div>\r\n", styles: [".cute-sort-header-container{display:flex;cursor:pointer;align-items:center;letter-spacing:normal;outline:0}[cute-sort-header].cdk-keyboard-focused .cute-sort-header-container,[cute-sort-header].cdk-program-focused .cute-sort-header-container{border-bottom:solid 1px currentColor}.cute-sort-header-disabled .cute-sort-header-container{cursor:default}.cute-sort-header-container:before{margin:calc(calc(var(--cute-focus-indicator-border-width, 1px) + 2px) * -1)}.cute-sort-header-content{text-align:center;display:flex;align-items:center}.cute-sort-header-position-before{flex-direction:row-reverse}.cute-sort-header-arrow{height:12px;width:12px;min-width:12px;position:relative;display:flex;opacity:0}.cute-sort-header-arrow,[dir=rtl] .cute-sort-header-position-before .cute-sort-header-arrow{margin:0 0 0 6px}.cute-sort-header-position-before .cute-sort-header-arrow,[dir=rtl] .cute-sort-header-arrow{margin:0 6px 0 0}.cute-sort-header-stem{background:currentColor;height:10px;width:2px;margin:auto;display:flex;align-items:center}@media (forced-colors: active){.cute-sort-header-stem{width:0;border-left:solid 2px}}.cute-sort-header-indicator{width:100%;height:2px;display:flex;align-items:center;position:absolute;top:0;left:0}.cute-sort-header-pointer-middle{margin:auto;height:2px;width:2px;background:currentColor;transform:rotate(45deg)}@media (forced-colors: active){.cute-sort-header-pointer-middle{width:0;height:0;border-top:solid 2px;border-left:solid 2px}}.cute-sort-header-pointer-left,.cute-sort-header-pointer-right{background:currentColor;width:6px;height:2px;position:absolute;top:0}@media (forced-colors: active){.cute-sort-header-pointer-left,.cute-sort-header-pointer-right{width:0;height:0;border-left:solid 6px;border-top:solid 2px}}.cute-sort-header-pointer-left{transform-origin:right;left:0}.cute-sort-header-pointer-right{transform-origin:left;right:0}\n"], animations: [
|
|
550
|
+
cuteSortAnimations.indicator,
|
|
551
|
+
cuteSortAnimations.leftPointer,
|
|
552
|
+
cuteSortAnimations.rightPointer,
|
|
553
|
+
cuteSortAnimations.arrowOpacity,
|
|
554
|
+
cuteSortAnimations.arrowPosition,
|
|
555
|
+
cuteSortAnimations.allowChildren,
|
|
556
|
+
], changeDetection: i0.ChangeDetectionStrategy.OnPush, encapsulation: i0.ViewEncapsulation.None }); }
|
|
557
|
+
}
|
|
558
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.3.15", ngImport: i0, type: CuteSortHeader, decorators: [{
|
|
559
|
+
type: Component,
|
|
560
|
+
args: [{ selector: '[cute-sort-header]', exportAs: 'cuteSortHeader', host: {
|
|
561
|
+
'class': 'cute-sort-header',
|
|
562
|
+
'(click)': '_handleClick()',
|
|
563
|
+
'(keydown)': '_handleKeydown($event)',
|
|
564
|
+
'(mouseenter)': '_setIndicatorHintVisible(true)',
|
|
565
|
+
'(mouseleave)': '_setIndicatorHintVisible(false)',
|
|
566
|
+
'[attr.aria-sort]': '_getAriaSortAttribute()',
|
|
567
|
+
'[class.cute-sort-header-disabled]': '_isDisabled()',
|
|
568
|
+
}, encapsulation: ViewEncapsulation.None, changeDetection: ChangeDetectionStrategy.OnPush, animations: [
|
|
569
|
+
cuteSortAnimations.indicator,
|
|
570
|
+
cuteSortAnimations.leftPointer,
|
|
571
|
+
cuteSortAnimations.rightPointer,
|
|
572
|
+
cuteSortAnimations.arrowOpacity,
|
|
573
|
+
cuteSortAnimations.arrowPosition,
|
|
574
|
+
cuteSortAnimations.allowChildren,
|
|
575
|
+
], standalone: true, template: "<!--\r\n We set the `tabindex` on an element inside the table header, rather than the header itself,\r\n because of a bug in NVDA where having a `tabindex` on a `th` breaks keyboard navigation in the\r\n table (see https://github.com/nvaccess/nvda/issues/7718). This allows for the header to both\r\n be focusable, and have screen readers read out its `aria-sort` state. We prefer this approach\r\n over having a button with an `aria-label` inside the header, because the button's `aria-label`\r\n will be read out as the user is navigating the table's cell (see #13012).\r\n\r\n The approach is based off of: https://dequeuniversity.com/library/aria/tables/sf-sortable-grid\r\n-->\r\n<div class=\"cute-sort-header-container cute-focus-indicator\"\r\n [class.cute-sort-header-sorted]=\"_isSorted()\"\r\n [class.cute-sort-header-position-before]=\"arrowPosition === 'before'\"\r\n [attr.tabindex]=\"_isDisabled() ? null : 0\"\r\n [attr.role]=\"_isDisabled() ? null : 'button'\">\r\n\r\n <!--\r\n TODO(crisbeto): this div isn't strictly necessary, but we have to keep it due to a large\r\n number of screenshot diff failures. It should be removed eventually. Note that the difference\r\n isn't visible with a shorter header, but once it breaks up into multiple lines, this element\r\n causes it to be center-aligned, whereas removing it will keep the text to the left.\r\n -->\r\n <div class=\"cute-sort-header-content\">\r\n <ng-content></ng-content>\r\n </div>\r\n\r\n <!-- Disable animations while a current animation is running -->\r\n @if (_renderArrow()) {\r\n <div class=\"cute-sort-header-arrow\"\r\n [@arrowOpacity]=\"_getArrowViewState()\"\r\n [@arrowPosition]=\"_getArrowViewState()\"\r\n [@allowChildren]=\"_getArrowDirectionState()\"\r\n (@arrowPosition.start)=\"_disableViewStateAnimation = true\"\r\n (@arrowPosition.done)=\"_disableViewStateAnimation = false\">\r\n <div class=\"cute-sort-header-stem\"></div>\r\n <div class=\"cute-sort-header-indicator\" [@indicator]=\"_getArrowDirectionState()\">\r\n <div class=\"cute-sort-header-pointer-left\" [@leftPointer]=\"_getArrowDirectionState()\"></div>\r\n <div class=\"cute-sort-header-pointer-right\" [@rightPointer]=\"_getArrowDirectionState()\"></div>\r\n <div class=\"cute-sort-header-pointer-middle\"></div>\r\n </div>\r\n </div>\r\n }\r\n</div>\r\n", styles: [".cute-sort-header-container{display:flex;cursor:pointer;align-items:center;letter-spacing:normal;outline:0}[cute-sort-header].cdk-keyboard-focused .cute-sort-header-container,[cute-sort-header].cdk-program-focused .cute-sort-header-container{border-bottom:solid 1px currentColor}.cute-sort-header-disabled .cute-sort-header-container{cursor:default}.cute-sort-header-container:before{margin:calc(calc(var(--cute-focus-indicator-border-width, 1px) + 2px) * -1)}.cute-sort-header-content{text-align:center;display:flex;align-items:center}.cute-sort-header-position-before{flex-direction:row-reverse}.cute-sort-header-arrow{height:12px;width:12px;min-width:12px;position:relative;display:flex;opacity:0}.cute-sort-header-arrow,[dir=rtl] .cute-sort-header-position-before .cute-sort-header-arrow{margin:0 0 0 6px}.cute-sort-header-position-before .cute-sort-header-arrow,[dir=rtl] .cute-sort-header-arrow{margin:0 6px 0 0}.cute-sort-header-stem{background:currentColor;height:10px;width:2px;margin:auto;display:flex;align-items:center}@media (forced-colors: active){.cute-sort-header-stem{width:0;border-left:solid 2px}}.cute-sort-header-indicator{width:100%;height:2px;display:flex;align-items:center;position:absolute;top:0;left:0}.cute-sort-header-pointer-middle{margin:auto;height:2px;width:2px;background:currentColor;transform:rotate(45deg)}@media (forced-colors: active){.cute-sort-header-pointer-middle{width:0;height:0;border-top:solid 2px;border-left:solid 2px}}.cute-sort-header-pointer-left,.cute-sort-header-pointer-right{background:currentColor;width:6px;height:2px;position:absolute;top:0}@media (forced-colors: active){.cute-sort-header-pointer-left,.cute-sort-header-pointer-right{width:0;height:0;border-left:solid 6px;border-top:solid 2px}}.cute-sort-header-pointer-left{transform-origin:right;left:0}.cute-sort-header-pointer-right{transform-origin:left;right:0}\n"] }]
|
|
576
|
+
}], ctorParameters: () => [{ type: CuteSortHeaderIntl }, { type: i0.ChangeDetectorRef }, { type: CuteSort, decorators: [{
|
|
577
|
+
type: Optional
|
|
578
|
+
}] }, { type: undefined, decorators: [{
|
|
579
|
+
type: Inject,
|
|
580
|
+
args: ['CUTE_SORT_HEADER_COLUMN_DEF']
|
|
581
|
+
}, {
|
|
582
|
+
type: Optional
|
|
583
|
+
}] }, { type: i3.FocusMonitor }, { type: i0.ElementRef }, { type: i3.AriaDescriber, decorators: [{
|
|
584
|
+
type: Optional
|
|
585
|
+
}] }, { type: undefined, decorators: [{
|
|
586
|
+
type: Optional
|
|
587
|
+
}, {
|
|
588
|
+
type: Inject,
|
|
589
|
+
args: [CUTE_SORT_DEFAULT_OPTIONS]
|
|
590
|
+
}] }], propDecorators: { id: [{
|
|
591
|
+
type: Input,
|
|
592
|
+
args: ['cute-sort-header']
|
|
593
|
+
}], arrowPosition: [{
|
|
594
|
+
type: Input
|
|
595
|
+
}], start: [{
|
|
596
|
+
type: Input
|
|
597
|
+
}], disabled: [{
|
|
598
|
+
type: Input,
|
|
599
|
+
args: [{ transform: booleanAttribute }]
|
|
600
|
+
}], sortActionDescription: [{
|
|
601
|
+
type: Input
|
|
602
|
+
}], disableClear: [{
|
|
603
|
+
type: Input,
|
|
604
|
+
args: [{ transform: booleanAttribute }]
|
|
605
|
+
}] } });
|
|
606
|
+
|
|
607
|
+
/**
|
|
608
|
+
* @license Apache-2.0
|
|
609
|
+
*
|
|
610
|
+
* Copyright (c) 2025 CuteWidgets Team. All Rights Reserved.
|
|
611
|
+
*
|
|
612
|
+
* You may not use this file except in compliance with the License
|
|
613
|
+
* that can be found at http://www.apache.org/licenses/LICENSE-2.0
|
|
614
|
+
*
|
|
615
|
+
* This code is a modification of the `@angular/material` original
|
|
616
|
+
* code licensed under MIT-style License (https://angular.dev/license).
|
|
617
|
+
*/
|
|
618
|
+
const TYPES = [CuteSort, CuteSortHeader];
|
|
619
|
+
class CuteSortModule {
|
|
620
|
+
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "20.3.15", ngImport: i0, type: CuteSortModule, deps: [], target: i0.ɵɵFactoryTarget.NgModule }); }
|
|
621
|
+
static { this.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "14.0.0", version: "20.3.15", ngImport: i0, type: CuteSortModule, imports: [CommonModule, CuteSort, CuteSortHeader], exports: [CuteSort, CuteSortHeader] }); }
|
|
622
|
+
static { this.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "20.3.15", ngImport: i0, type: CuteSortModule, providers: [CUTE_SORT_HEADER_INTL_PROVIDER], imports: [CommonModule] }); }
|
|
623
|
+
}
|
|
624
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.3.15", ngImport: i0, type: CuteSortModule, decorators: [{
|
|
625
|
+
type: NgModule,
|
|
626
|
+
args: [{
|
|
627
|
+
imports: [CommonModule, ...TYPES],
|
|
628
|
+
exports: TYPES,
|
|
629
|
+
providers: [CUTE_SORT_HEADER_INTL_PROVIDER],
|
|
630
|
+
declarations: [],
|
|
631
|
+
}]
|
|
632
|
+
}] });
|
|
633
|
+
|
|
634
|
+
/**
|
|
635
|
+
* Generated bundle index. Do not edit.
|
|
636
|
+
*/
|
|
637
|
+
|
|
638
|
+
export { CUTE_SORT_DEFAULT_OPTIONS, CUTE_SORT_HEADER_INTL_PROVIDER, CUTE_SORT_HEADER_INTL_PROVIDER_FACTORY, CuteSort, CuteSortHeader, CuteSortHeaderIntl, CuteSortModule, cuteSortAnimations };
|
|
639
|
+
//# sourceMappingURL=cute-widgets-base-sort.mjs.map
|