yukit-web 1.1.3 → 1.2.0

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/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "yukit-web",
3
3
  "description": "Angular UI component library for Yurest web applications.",
4
- "version": "1.1.3",
4
+ "version": "1.2.0",
5
5
  "author": {
6
6
  "name": "Yurest Solutions",
7
7
  "email": "develop@yurest.com"
@@ -0,0 +1,120 @@
1
+ .yuw-datatable-pin {
2
+ display: inline-flex;
3
+ align-items: center;
4
+ border-radius: var(--radius-component-xs);
5
+ color: var(--neutrals-element-mid, var(--muted-foreground));
6
+ transition: color 150ms ease-in-out;
7
+
8
+ &:not(:disabled):hover {
9
+ color: var(--foreground);
10
+ }
11
+
12
+ &[aria-pressed='true'],
13
+ &:focus-visible {
14
+ color: var(--secondary-fill);
15
+ }
16
+
17
+ &:focus-visible {
18
+ outline: none;
19
+ }
20
+
21
+ &:disabled {
22
+ cursor: not-allowed;
23
+ opacity: 0.4;
24
+ }
25
+ }
26
+
27
+ .yuw-datatable-scroll-fade {
28
+ --scroll-fade-e-size: 1rem;
29
+ --scroll-fade-mask: linear-gradient(
30
+ to right,
31
+ #000 0 var(--yuw-datatable-pinned-width, 0px),
32
+ transparent var(--yuw-datatable-pinned-width, 0px),
33
+ #000 calc(var(--yuw-datatable-pinned-width, 0px) + var(--scroll-fade-s, 0px)),
34
+ #000 calc(100% - var(--scroll-fade-e, 0px)),
35
+ transparent 100%
36
+ );
37
+ }
38
+
39
+ .yuw-datatable-pinned {
40
+ position: sticky;
41
+ z-index: 1;
42
+ background-color: var(--yuw-datatable-surface, var(--background));
43
+ background-image: linear-gradient(
44
+ var(--yuw-datatable-row-tint, transparent),
45
+ var(--yuw-datatable-row-tint, transparent)
46
+ );
47
+ }
48
+
49
+ .yuw-datatable-pinned-last {
50
+ box-shadow: inset -1px 0 var(--border);
51
+ }
52
+
53
+ tr:is(:hover, :has([aria-expanded='true'])) > .yuw-datatable-pinned {
54
+ --yuw-datatable-row-tint: color-mix(in oklab, var(--muted) 50%, transparent);
55
+ }
56
+
57
+ tr[data-state='selected'] > .yuw-datatable-pinned {
58
+ --yuw-datatable-row-tint: var(--muted);
59
+ }
60
+
61
+ .yuw-datatable-actions-group {
62
+ display: flex;
63
+ align-items: center;
64
+ justify-content: flex-end;
65
+ gap: 0.25rem;
66
+ }
67
+
68
+ @media (hover: hover) {
69
+ .yuw-datatable-actions {
70
+ position: sticky;
71
+ right: 0;
72
+ z-index: 2;
73
+ width: 0;
74
+ min-width: 0;
75
+ max-width: 0;
76
+ padding: 0;
77
+ overflow: visible;
78
+ }
79
+
80
+ th.yuw-datatable-actions > * {
81
+ display: none;
82
+ }
83
+
84
+ .yuw-datatable-actions-group {
85
+ position: absolute;
86
+ top: 50%;
87
+ right: 1.25rem;
88
+ padding: 0.125rem;
89
+ background-color: var(--yuw-datatable-surface, var(--background));
90
+ border: 1px solid var(--border);
91
+ border-radius: var(--radius-component-md);
92
+ box-shadow: 0 1px 3px rgb(0 0 0 / 0.08);
93
+ opacity: 0;
94
+ pointer-events: none;
95
+ clip-path: inset(-0.5rem -0.5rem -0.5rem 100%);
96
+ transform: translate(0.75rem, -50%);
97
+ transition:
98
+ transform 200ms ease-out,
99
+ clip-path 200ms ease-out,
100
+ opacity 200ms ease-out;
101
+ }
102
+
103
+ .yuw-reveal-host:is(:hover, :has(:focus-visible)) .yuw-datatable-actions-group,
104
+ .yuw-datatable-actions-group:is(:has(:focus-visible), :has([aria-expanded='true'])) {
105
+ opacity: 1;
106
+ pointer-events: auto;
107
+ clip-path: inset(-0.5rem);
108
+ transform: translate(0, -50%);
109
+ }
110
+
111
+ .yuw-datatable-actions-group:not(:has(*)) {
112
+ display: none;
113
+ }
114
+
115
+ @media (prefers-reduced-motion: reduce) {
116
+ .yuw-datatable-actions-group {
117
+ transition: none;
118
+ }
119
+ }
120
+ }
@@ -13,6 +13,7 @@
13
13
  @import './components/button-group.css';
14
14
  @import './components/label.css';
15
15
  @import './components/reveal-on-hover.css';
16
+ @import './components/datatable.css';
16
17
  @import './components/overflow-list-cell.css';
17
18
  @import './components/sidebar.css';
18
19
  @import './components/layout.css';
@@ -2,7 +2,7 @@ import { ClassValue } from "clsx";
2
2
  import * as i0 from "@angular/core";
3
3
  import { ElementRef, InputSignal, InputSignalWithTransform, ModelSignal, OnInit, Provider, Signal, TemplateRef, Type, WritableSignal } from "@angular/core";
4
4
  import { ControlValueAccessor } from "@angular/forms";
5
- import { ColumnDef, ColumnFiltersState, ColumnVisibilityState, PaginationState, RowData, RowSelectionState, SortingState, columnFilteringFeature, columnVisibilityFeature, rowPaginationFeature, rowSelectionFeature, rowSortingFeature } from "@tanstack/table-core";
5
+ import { ColumnDef, ColumnFiltersState, ColumnVisibilityState, PaginationState, RowData, RowSelectionState, SortingState, columnFilteringFeature, columnPinningFeature, columnVisibilityFeature, rowPaginationFeature, rowSelectionFeature, rowSortingFeature } from "@tanstack/table-core";
6
6
  import * as i1$14 from "@spartan-ng/brain/combobox";
7
7
  import { MenuAlign } from "@spartan-ng/brain/core";
8
8
  import { ButtonVariants } from "yukit-web/helm/button";
@@ -3609,6 +3609,12 @@ export declare const datatableCellVariants: (props?: ({
3609
3609
  export declare const datatableRowVariants: (props?: ({
3610
3610
  appearance?: "default" | "card" | null | undefined;
3611
3611
  } & import("class-variance-authority/types").ClassProp) | undefined) => string;
3612
+ /**
3613
+ * Classes of the single cell that gathers a row's `meta.rowAction` columns, and of its header. `yuw-datatable-actions`
3614
+ * is what `theme/components/datatable.css` turns into the floating group on a device that can hover; on a touch device
3615
+ * the cell stays a regular column shrunk to its buttons.
3616
+ */
3617
+ export declare const DATATABLE_ACTIONS_CELL_CLASS = "yuw-datatable-actions w-px text-end";
3612
3618
  /**
3613
3619
  * Classes that put a `meta.wrap` cell in charge of its own line breaking.
3614
3620
  *
@@ -3621,6 +3627,8 @@ export declare const datatableRowVariants: (props?: ({
3621
3627
  */
3622
3628
  export declare const DATATABLE_WRAP_CONTENT_CLASS = "whitespace-normal max-w-0";
3623
3629
  export declare const YUW_DATATABLE_FEATURES: YuwDatatableFeatures;
3630
+ /** Id of the selection column, which leads the pinned group whenever any column is pinned. */
3631
+ export declare const YUW_DATATABLE_SELECT_COLUMN_ID = "select";
3624
3632
  /**
3625
3633
  * The feature set `yuw-datatable` enables.
3626
3634
  *
@@ -3633,6 +3641,7 @@ export declare const YUW_DATATABLE_FEATURES: YuwDatatableFeatures;
3633
3641
  export interface YuwDatatableFeatures {
3634
3642
  columnMeta: YuwDatatableColumnMeta;
3635
3643
  columnFilteringFeature: typeof columnFilteringFeature;
3644
+ columnPinningFeature: typeof columnPinningFeature;
3636
3645
  columnVisibilityFeature: typeof columnVisibilityFeature;
3637
3646
  rowPaginationFeature: typeof rowPaginationFeature;
3638
3647
  rowSelectionFeature: typeof rowSelectionFeature;
@@ -3661,6 +3670,11 @@ export interface YuwDatatableFeatures {
3661
3670
  * @param minWidth Floor for a `wrap` column, as a Tailwind `min-w-*` class. Defaults to
3662
3671
  * `YUW_DATATABLE_WRAP_MIN_WIDTH`. This floor is what keeps a narrow viewport scrolling
3663
3672
  * horizontally instead of squeezing the column down to one word per line.
3673
+ * @param pinnable Shows a pin before the header title. A pinned column moves to the start of the table and stays
3674
+ * there while the rest scroll horizontally.
3675
+ * @param rowAction Marks a column as one of the row's action buttons. Every such column is gathered, in order, into a
3676
+ * single trailing group: on a device that can hover it takes no width and slides in over the row's end while the row
3677
+ * is hovered or focused; on a touch device it keeps a regular column. Set by the action column builders.
3664
3678
  */
3665
3679
  export interface YuwDatatableColumnMeta {
3666
3680
  align?: YuwDatatableAlign;
@@ -3668,6 +3682,8 @@ export interface YuwDatatableColumnMeta {
3668
3682
  headerClass?: string;
3669
3683
  wrap?: boolean;
3670
3684
  minWidth?: string;
3685
+ pinnable?: boolean;
3686
+ rowAction?: boolean;
3671
3687
  }
3672
3688
  /** What a table can be shared as: copied to the clipboard, printed, or downloaded as a file. */
3673
3689
  export type YuwTableShareFormat = 'copy' | 'print' | 'pdf' | 'excel' | 'csv';
@@ -3775,6 +3791,19 @@ export type YuwDatatableRowClass<TData extends RowData> = string | ((row: TData,
3775
3791
  * `YUW_DATATABLE_WRAP_MIN_WIDTH`. Below it the table overflows and the container scrolls
3776
3792
  * horizontally, rather than the column squeezing down to one word per line. There is
3777
3793
  * deliberately no maximum — a cap would wrap the text while free space sat beside it.
3794
+ * - `meta.pinnable`: Shows a pin before the header title; see `pinnedColumns`.
3795
+ * - `meta.rowAction`: Gathers the column into the row's trailing action group. On a device that can hover the group
3796
+ * takes no width: it slides in from the end of the row, over its own surface and above the cells, while the row is
3797
+ * hovered or focused, wherever the table is scrolled. On a touch device it keeps a regular trailing column. The
3798
+ * action column builders set it.
3799
+ * - `pinnedColumns`: Two-way list of the ids of the pinned columns (only `meta.pinnable` ones count). Pinned columns
3800
+ * move to the start of the table, keeping their relative order, and stay fixed while the rest scroll horizontally;
3801
+ * the selection column, when present, leads them.
3802
+ * - `maxPinnedColumns`: Most columns pinned at once. Once reached, the pins of the other columns are disabled. Unset
3803
+ * is no limit.
3804
+ * - `pinColumnLabel`: Accessible name of every pin button, its pressed state telling whether the column is pinned.
3805
+ * Required in practice as soon as a column is `pinnable`. User-facing text the consuming app is responsible for
3806
+ * translating.
3778
3807
  * - `sorting`: Two-way sorting state (`SortingState`).
3779
3808
  * - `columnFilters`: Two-way column filters state (`ColumnFiltersState`).
3780
3809
  * - `columnVisibility`: Two-way column visibility state (`ColumnVisibilityState`).
@@ -3817,6 +3846,8 @@ export type YuwDatatableRowClass<TData extends RowData> = string | ((row: TData,
3817
3846
  * ```
3818
3847
  */
3819
3848
  export declare class YuwDatatableComponent<TData extends RowData> implements OnInit, YuwTableShareSource {
3849
+ private readonly _destroyRef;
3850
+ private readonly _container;
3820
3851
  private readonly _table;
3821
3852
  readonly customPagination: import("@angular/core").Signal<YuwDatatablePaginationDirective | undefined>;
3822
3853
  readonly appearance: import("@angular/core").InputSignal<YuwDatatableAppearanceDto>;
@@ -3829,11 +3860,14 @@ export declare class YuwDatatableComponent<TData extends RowData> implements OnI
3829
3860
  readonly emptyText: import("@angular/core").InputSignal<string | undefined>;
3830
3861
  readonly loading: import("@angular/core").InputSignalWithTransform<boolean, unknown>;
3831
3862
  readonly loadingRows: import("@angular/core").InputSignalWithTransform<number, unknown>;
3863
+ readonly maxPinnedColumns: import("@angular/core").InputSignal<number | undefined>;
3832
3864
  readonly nextPageLabel: import("@angular/core").InputSignal<string>;
3833
3865
  readonly paginated: import("@angular/core").InputSignalWithTransform<boolean, unknown>;
3834
3866
  readonly pagination: import("@angular/core").ModelSignal<PaginationState>;
3835
3867
  readonly paginationAriaLabel: import("@angular/core").InputSignal<string>;
3836
3868
  readonly paginationEllipsisSrText: import("@angular/core").InputSignal<string>;
3869
+ readonly pinColumnLabel: import("@angular/core").InputSignal<string | undefined>;
3870
+ readonly pinnedColumns: import("@angular/core").ModelSignal<readonly string[]>;
3837
3871
  readonly previousPageLabel: import("@angular/core").InputSignal<string>;
3838
3872
  readonly rowClass: import("@angular/core").InputSignal<YuwDatatableRowClass<TData> | undefined>;
3839
3873
  readonly rowSelection: import("@angular/core").ModelSignal<RowSelectionState>;
@@ -3850,14 +3884,28 @@ export declare class YuwDatatableComponent<TData extends RowData> implements OnI
3850
3884
  protected readonly table: import("@tanstack/angular-table").AngularTable<YuwDatatableFeatures, TData>;
3851
3885
  private readonly _selectedRows;
3852
3886
  readonly selectedRowsChange: import("@angular/core").OutputRef<TData[]>;
3887
+ protected readonly _actionsCellClass: import("@angular/core").Signal<string>;
3888
+ protected readonly _actionsHeaderClass: import("@angular/core").Signal<string>;
3889
+ private readonly _columnIds;
3853
3890
  protected readonly _cellClasses: import("@angular/core").Signal<Map<string, {
3854
3891
  readonly header: string;
3855
3892
  readonly cell: string;
3856
3893
  }>>;
3894
+ protected readonly _rowActionIds: import("@angular/core").Signal<Set<string>>;
3895
+ protected readonly _pinnableIds: import("@angular/core").Signal<Set<string>>;
3896
+ private readonly _userPinnedIds;
3897
+ private readonly _columnPinning;
3857
3898
  protected readonly _columnCount: import("@angular/core").Signal<number>;
3858
3899
  protected readonly _containerClass: import("@angular/core").Signal<string>;
3900
+ protected readonly _hasRowActions: import("@angular/core").Signal<boolean>;
3859
3901
  protected readonly _headClass: import("@angular/core").Signal<string>;
3860
3902
  protected readonly _isEmpty: import("@angular/core").Signal<boolean>;
3903
+ protected readonly _pinLimitReached: import("@angular/core").Signal<boolean>;
3904
+ protected readonly _pinnedIds: import("@angular/core").Signal<Set<string>>;
3905
+ protected readonly _pinOffsets: import("@angular/core").Signal<Map<string, {
3906
+ left: string;
3907
+ last: boolean;
3908
+ }>>;
3861
3909
  protected readonly _rowClass: import("@angular/core").Signal<string>;
3862
3910
  protected readonly _rowClasses: import("@angular/core").Signal<Map<string, string>>;
3863
3911
  protected readonly _skeletonRows: import("@angular/core").Signal<number[]>;
@@ -3885,7 +3933,16 @@ export declare class YuwDatatableComponent<TData extends RowData> implements OnI
3885
3933
  protected onPageChange(page: number): void;
3886
3934
  protected onRowClick(row: TData): void;
3887
3935
  protected onRowKeydown(event: KeyboardEvent, row: TData): void;
3936
+ protected togglePin(id: string): void;
3888
3937
  private _clearSelectionOnNewData;
3938
+ private _readPinnedWidths;
3939
+ /**
3940
+ * Writes each pinned column's sticky start offset as `--yuw-datatable-pin-<index>` on the scroll container: the
3941
+ * summed rendered widths of the pinned columns before it. Their total, `--yuw-datatable-pinned-width`, moves the
3942
+ * container's start scroll fade past the pinned columns. Measured rather than taken from TanStack's column sizes, because widths
3943
+ * here come from Tailwind classes and content, which TanStack never sees.
3944
+ */
3945
+ private _writePinOffsets;
3889
3946
  static ɵfac: i0.ɵɵFactoryDeclaration<YuwDatatableComponent<any>, never>;
3890
3947
  static ɵcmp: i0.ɵɵComponentDeclaration<YuwDatatableComponent<any>, "yuw-datatable", never, {
3891
3948
  "appearance": {
@@ -3938,6 +3995,11 @@ export declare class YuwDatatableComponent<TData extends RowData> implements OnI
3938
3995
  "required": false;
3939
3996
  "isSignal": true;
3940
3997
  };
3998
+ "maxPinnedColumns": {
3999
+ "alias": "maxPinnedColumns";
4000
+ "required": false;
4001
+ "isSignal": true;
4002
+ };
3941
4003
  "nextPageLabel": {
3942
4004
  "alias": "nextPageLabel";
3943
4005
  "required": true;
@@ -3963,6 +4025,16 @@ export declare class YuwDatatableComponent<TData extends RowData> implements OnI
3963
4025
  "required": true;
3964
4026
  "isSignal": true;
3965
4027
  };
4028
+ "pinColumnLabel": {
4029
+ "alias": "pinColumnLabel";
4030
+ "required": false;
4031
+ "isSignal": true;
4032
+ };
4033
+ "pinnedColumns": {
4034
+ "alias": "pinnedColumns";
4035
+ "required": false;
4036
+ "isSignal": true;
4037
+ };
3966
4038
  "previousPageLabel": {
3967
4039
  "alias": "previousPageLabel";
3968
4040
  "required": true;
@@ -4007,6 +4079,7 @@ export declare class YuwDatatableComponent<TData extends RowData> implements OnI
4007
4079
  "columnFilters": "columnFiltersChange";
4008
4080
  "columnVisibility": "columnVisibilityChange";
4009
4081
  "pagination": "paginationChange";
4082
+ "pinnedColumns": "pinnedColumnsChange";
4010
4083
  "rowSelection": "rowSelectionChange";
4011
4084
  "sorting": "sortingChange";
4012
4085
  "rowClicked": "rowClicked";
@@ -4090,10 +4163,10 @@ export declare class YuwActionsCellComponent {
4090
4163
  }, {}, never, never, true, never>;
4091
4164
  }
4092
4165
  /**
4093
- * `actions` column; `label` is the button's accessible name and `header` the optional visible
4094
- * column title, both already translated. Without `header` the column stays headerless.
4166
+ * `actions` column, part of the row's action group (`meta.rowAction`); `label` is the button's accessible name and
4167
+ * `header` the optional title the group shows on touch devices, both already translated.
4095
4168
  */
4096
- export declare function buildYuwActionsColumn<Row extends RowData>(label: string, onEdit: (row: Row) => void, cellClass?: string, header?: string): YuwDatatableColumnDef<Row>;
4169
+ export declare function buildYuwActionsColumn<Row extends RowData>(label: string, onEdit: (row: Row) => void, header?: string): YuwDatatableColumnDef<Row>;
4097
4170
  /**
4098
4171
  * Copies, prints or downloads `snapshot` as `format`; rejects when the browser refuses, e.g. clipboard access or the
4099
4172
  * print tab. Call it within the click, before awaiting anything: printing opens its tab synchronously.
@@ -7487,9 +7560,9 @@ export declare function buildYuwsActiveStatusColumn<Row extends {
7487
7560
  }>(header: string, labels: YuwsStateLabels, meta?: YuwDatatableColumnDef<Row>['meta']): YuwDatatableColumnDef<Row>;
7488
7561
  /** State column that flips on click, painted green or red by `positive`. */
7489
7562
  export declare function buildYuwsStatusToggleColumn<Row extends Record<string, unknown>>(column: YuwsStatusToggleColumn<Row>): YuwDatatableColumnDef<Row>;
7490
- /** Last column with an icon button that runs `onAction` on the row. */
7563
+ /** Icon button that runs `onAction` on the row, part of the row's action group (`meta.rowAction`). */
7491
7564
  export declare function buildYuwsIconActionColumn<Row extends RowData>(column: YuwsIconActionColumn<Row>): YuwDatatableColumnDef<Row>;
7492
- /** Last column, `actions`, with an ellipsis button that opens the row's menu. */
7565
+ /** `actions` column with an ellipsis button that opens the row's menu, part of the row's action group. */
7493
7566
  export declare function buildYuwsMenuActionsColumn<Row extends RowData>(column: YuwsMenuActionsColumn<Row>): YuwDatatableColumnDef<Row>;
7494
7567
  /**
7495
7568
  * First column, `select`, for a `selectable` table: the header selects or clears the rows on screen and shows the mixed