@sonny-ui/core 0.1.0-alpha.23 → 0.1.0-alpha.24
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/fesm2022/sonny-ui-core.mjs +27 -10
- package/fesm2022/sonny-ui-core.mjs.map +1 -1
- package/package.json +1 -1
- package/src/lib/data-table/data-table.component.ts +25 -5
- package/src/lib/data-table/data-table.types.ts +6 -0
- package/src/lib/data-table/index.ts +1 -0
- package/types/sonny-ui-core.d.ts +13 -2
package/package.json
CHANGED
|
@@ -42,6 +42,7 @@ import {
|
|
|
42
42
|
} from './data-table.directives';
|
|
43
43
|
import type {
|
|
44
44
|
DataTableColumn,
|
|
45
|
+
DataTableLabels,
|
|
45
46
|
DataTablePaginationConfig,
|
|
46
47
|
SortState,
|
|
47
48
|
SortDirection,
|
|
@@ -52,6 +53,12 @@ const DEFAULT_PAGINATION: DataTablePaginationConfig = {
|
|
|
52
53
|
pageSizeOptions: [5, 10, 25, 50],
|
|
53
54
|
};
|
|
54
55
|
|
|
56
|
+
const DEFAULT_LABELS: Required<DataTableLabels> = {
|
|
57
|
+
rowsPerPage: 'Rows per page',
|
|
58
|
+
rowsSelected: (selected, total) => `${selected} of ${total} row(s) selected`,
|
|
59
|
+
totalRows: (total) => `${total} row(s)`,
|
|
60
|
+
};
|
|
61
|
+
|
|
55
62
|
@Component({
|
|
56
63
|
selector: 'sny-data-table',
|
|
57
64
|
changeDetection: ChangeDetectionStrategy.OnPush,
|
|
@@ -292,14 +299,14 @@ const DEFAULT_PAGINATION: DataTablePaginationConfig = {
|
|
|
292
299
|
<div class="flex flex-col sm:flex-row items-start sm:items-center justify-between mt-4 gap-3 sm:gap-4">
|
|
293
300
|
<span class="text-sm text-muted-foreground">
|
|
294
301
|
@if (selectable()) {
|
|
295
|
-
{{ selectedRows().length
|
|
302
|
+
{{ resolvedLabels().rowsSelected(selectedRows().length, filteredData().length) }}
|
|
296
303
|
} @else {
|
|
297
|
-
{{ filteredData().length }}
|
|
304
|
+
{{ resolvedLabels().totalRows(filteredData().length) }}
|
|
298
305
|
}
|
|
299
306
|
</span>
|
|
300
307
|
<div class="flex items-center gap-3 sm:gap-4 flex-wrap">
|
|
301
308
|
<div class="flex items-center gap-2">
|
|
302
|
-
<span class="hidden sm:inline text-sm text-muted-foreground whitespace-nowrap">
|
|
309
|
+
<span class="hidden sm:inline text-sm text-muted-foreground whitespace-nowrap">{{ resolvedLabels().rowsPerPage }}</span>
|
|
303
310
|
<sny-select
|
|
304
311
|
[options]="pageSizeOptions()"
|
|
305
312
|
[value]="pageSizeValue()"
|
|
@@ -337,6 +344,7 @@ export class SnyDataTableComponent {
|
|
|
337
344
|
readonly paginationConfig = input<DataTablePaginationConfig>(DEFAULT_PAGINATION);
|
|
338
345
|
readonly trackBy = input('');
|
|
339
346
|
readonly noDataText = input('No data available');
|
|
347
|
+
readonly labels = input<DataTableLabels>({});
|
|
340
348
|
|
|
341
349
|
// Model
|
|
342
350
|
readonly selectedRows = model<Record<string, unknown>[]>([]);
|
|
@@ -352,6 +360,9 @@ export class SnyDataTableComponent {
|
|
|
352
360
|
readonly bulkActionsDef = contentChild(SnyBulkActionsDefDirective);
|
|
353
361
|
readonly rowExpandDef = contentChild(SnyRowExpandDefDirective);
|
|
354
362
|
|
|
363
|
+
// Resolved labels
|
|
364
|
+
readonly resolvedLabels = computed(() => ({ ...DEFAULT_LABELS, ...this.labels() }));
|
|
365
|
+
|
|
355
366
|
// Internal state
|
|
356
367
|
readonly sortState = signal<SortState>({ key: '', direction: null });
|
|
357
368
|
readonly filterText = signal('');
|
|
@@ -478,8 +489,17 @@ export class SnyDataTableComponent {
|
|
|
478
489
|
effect(() => {
|
|
479
490
|
this.filterText();
|
|
480
491
|
this.pageSize();
|
|
481
|
-
this.data();
|
|
482
|
-
untracked(() =>
|
|
492
|
+
const data = this.data();
|
|
493
|
+
untracked(() => {
|
|
494
|
+
this.currentPage.set(1);
|
|
495
|
+
const selected = this.selectedRows();
|
|
496
|
+
if (selected.length) {
|
|
497
|
+
const cleaned = selected.filter((row) => this.isRowInList(row, data));
|
|
498
|
+
if (cleaned.length !== selected.length) {
|
|
499
|
+
this.selectedRows.set(cleaned);
|
|
500
|
+
}
|
|
501
|
+
}
|
|
502
|
+
});
|
|
483
503
|
});
|
|
484
504
|
}
|
|
485
505
|
|
|
@@ -18,3 +18,9 @@ export interface DataTablePaginationConfig {
|
|
|
18
18
|
pageSize: number;
|
|
19
19
|
pageSizeOptions: number[];
|
|
20
20
|
}
|
|
21
|
+
|
|
22
|
+
export interface DataTableLabels {
|
|
23
|
+
rowsPerPage?: string;
|
|
24
|
+
rowsSelected?: (selected: number, total: number) => string;
|
|
25
|
+
totalRows?: (total: number) => string;
|
|
26
|
+
}
|
package/types/sonny-ui-core.d.ts
CHANGED
|
@@ -759,6 +759,11 @@ interface DataTablePaginationConfig {
|
|
|
759
759
|
pageSize: number;
|
|
760
760
|
pageSizeOptions: number[];
|
|
761
761
|
}
|
|
762
|
+
interface DataTableLabels {
|
|
763
|
+
rowsPerPage?: string;
|
|
764
|
+
rowsSelected?: (selected: number, total: number) => string;
|
|
765
|
+
totalRows?: (total: number) => string;
|
|
766
|
+
}
|
|
762
767
|
|
|
763
768
|
declare class SnyDataTableComponent {
|
|
764
769
|
readonly columns: _angular_core.InputSignal<DataTableColumn[]>;
|
|
@@ -778,6 +783,7 @@ declare class SnyDataTableComponent {
|
|
|
778
783
|
readonly paginationConfig: _angular_core.InputSignal<DataTablePaginationConfig>;
|
|
779
784
|
readonly trackBy: _angular_core.InputSignal<string>;
|
|
780
785
|
readonly noDataText: _angular_core.InputSignal<string>;
|
|
786
|
+
readonly labels: _angular_core.InputSignal<DataTableLabels>;
|
|
781
787
|
readonly selectedRows: _angular_core.ModelSignal<Record<string, unknown>[]>;
|
|
782
788
|
readonly sortChanged: _angular_core.OutputEmitterRef<SortState>;
|
|
783
789
|
readonly rowClicked: _angular_core.OutputEmitterRef<Record<string, unknown>>;
|
|
@@ -786,6 +792,11 @@ declare class SnyDataTableComponent {
|
|
|
786
792
|
readonly headerCellDefs: _angular_core.Signal<readonly SnyHeaderCellDefDirective[]>;
|
|
787
793
|
readonly bulkActionsDef: _angular_core.Signal<SnyBulkActionsDefDirective | undefined>;
|
|
788
794
|
readonly rowExpandDef: _angular_core.Signal<SnyRowExpandDefDirective | undefined>;
|
|
795
|
+
readonly resolvedLabels: _angular_core.Signal<{
|
|
796
|
+
rowsPerPage: string;
|
|
797
|
+
rowsSelected: (selected: number, total: number) => string;
|
|
798
|
+
totalRows: (total: number) => string;
|
|
799
|
+
}>;
|
|
789
800
|
readonly sortState: _angular_core.WritableSignal<SortState>;
|
|
790
801
|
readonly filterText: _angular_core.WritableSignal<string>;
|
|
791
802
|
readonly currentPage: _angular_core.WritableSignal<number>;
|
|
@@ -822,7 +833,7 @@ declare class SnyDataTableComponent {
|
|
|
822
833
|
private isRowInList;
|
|
823
834
|
private rowsEqual;
|
|
824
835
|
static ɵfac: _angular_core.ɵɵFactoryDeclaration<SnyDataTableComponent, never>;
|
|
825
|
-
static ɵcmp: _angular_core.ɵɵComponentDeclaration<SnyDataTableComponent, "sny-data-table", never, { "columns": { "alias": "columns"; "required": true; "isSignal": true; }; "data": { "alias": "data"; "required": true; "isSignal": true; }; "variant": { "alias": "variant"; "required": false; "isSignal": true; }; "density": { "alias": "density"; "required": false; "isSignal": true; }; "hoverable": { "alias": "hoverable"; "required": false; "isSignal": true; }; "stickyHeader": { "alias": "stickyHeader"; "required": false; "isSignal": true; }; "selectable": { "alias": "selectable"; "required": false; "isSignal": true; }; "paginated": { "alias": "paginated"; "required": false; "isSignal": true; }; "filterable": { "alias": "filterable"; "required": false; "isSignal": true; }; "showExport": { "alias": "showExport"; "required": false; "isSignal": true; }; "showColumnToggle": { "alias": "showColumnToggle"; "required": false; "isSignal": true; }; "expandable": { "alias": "expandable"; "required": false; "isSignal": true; }; "loading": { "alias": "loading"; "required": false; "isSignal": true; }; "loadingRows": { "alias": "loadingRows"; "required": false; "isSignal": true; }; "paginationConfig": { "alias": "paginationConfig"; "required": false; "isSignal": true; }; "trackBy": { "alias": "trackBy"; "required": false; "isSignal": true; }; "noDataText": { "alias": "noDataText"; "required": false; "isSignal": true; }; "selectedRows": { "alias": "selectedRows"; "required": false; "isSignal": true; }; }, { "selectedRows": "selectedRowsChange"; "sortChanged": "sortChanged"; "rowClicked": "rowClicked"; "dataExported": "dataExported"; }, ["cellDefs", "headerCellDefs", "bulkActionsDef", "rowExpandDef"], never, true, never>;
|
|
836
|
+
static ɵcmp: _angular_core.ɵɵComponentDeclaration<SnyDataTableComponent, "sny-data-table", never, { "columns": { "alias": "columns"; "required": true; "isSignal": true; }; "data": { "alias": "data"; "required": true; "isSignal": true; }; "variant": { "alias": "variant"; "required": false; "isSignal": true; }; "density": { "alias": "density"; "required": false; "isSignal": true; }; "hoverable": { "alias": "hoverable"; "required": false; "isSignal": true; }; "stickyHeader": { "alias": "stickyHeader"; "required": false; "isSignal": true; }; "selectable": { "alias": "selectable"; "required": false; "isSignal": true; }; "paginated": { "alias": "paginated"; "required": false; "isSignal": true; }; "filterable": { "alias": "filterable"; "required": false; "isSignal": true; }; "showExport": { "alias": "showExport"; "required": false; "isSignal": true; }; "showColumnToggle": { "alias": "showColumnToggle"; "required": false; "isSignal": true; }; "expandable": { "alias": "expandable"; "required": false; "isSignal": true; }; "loading": { "alias": "loading"; "required": false; "isSignal": true; }; "loadingRows": { "alias": "loadingRows"; "required": false; "isSignal": true; }; "paginationConfig": { "alias": "paginationConfig"; "required": false; "isSignal": true; }; "trackBy": { "alias": "trackBy"; "required": false; "isSignal": true; }; "noDataText": { "alias": "noDataText"; "required": false; "isSignal": true; }; "labels": { "alias": "labels"; "required": false; "isSignal": true; }; "selectedRows": { "alias": "selectedRows"; "required": false; "isSignal": true; }; }, { "selectedRows": "selectedRowsChange"; "sortChanged": "sortChanged"; "rowClicked": "rowClicked"; "dataExported": "dataExported"; }, ["cellDefs", "headerCellDefs", "bulkActionsDef", "rowExpandDef"], never, true, never>;
|
|
826
837
|
}
|
|
827
838
|
|
|
828
839
|
interface CdkDialogRefLike<R> {
|
|
@@ -2165,4 +2176,4 @@ declare class SnyValidatorHintDirective {
|
|
|
2165
2176
|
}
|
|
2166
2177
|
|
|
2167
2178
|
export { SNY_ACCORDION, SNY_ACCORDION_ITEM, SNY_CAROUSEL, SNY_CHAT_BUBBLE, SNY_CONFIG, SNY_DIALOG_DATA, SNY_DRAWER, SNY_DROPDOWN, SNY_FAB, SNY_POPOVER, SNY_SHEET_DATA, SNY_STEPS, SNY_TABLE, SNY_TABS, SNY_TIMELINE, SnyAccordionContentDirective, SnyAccordionDirective, SnyAccordionItemDirective, SnyAccordionTriggerDirective, SnyAlertDescriptionDirective, SnyAlertDirective, SnyAlertTitleDirective, SnyAvatarComponent, SnyAvatarGroupComponent, SnyBadgeDirective, SnyBreadcrumbDirective, SnyBreadcrumbItemDirective, SnyBreadcrumbLinkDirective, SnyBreadcrumbListDirective, SnyBreadcrumbPageDirective, SnyBreadcrumbSeparatorDirective, SnyBulkActionsDefDirective, SnyButtonDirective, SnyButtonGroupDirective, SnyCalendarComponent, SnyCardContentDirective, SnyCardDescriptionDirective, SnyCardDirective, SnyCardFooterDirective, SnyCardHeaderDirective, SnyCardTitleDirective, SnyCarouselContentDirective, SnyCarouselDirective, SnyCarouselItemDirective, SnyCarouselNextDirective, SnyCarouselPrevDirective, SnyCellDefDirective, SnyChatBubbleAvatarDirective, SnyChatBubbleBodyDirective, SnyChatBubbleContentDirective, SnyChatBubbleDirective, SnyChatBubbleFooterDirective, SnyChatBubbleHeaderDirective, SnyCheckboxDirective, SnyColorPickerComponent, SnyComboboxComponent, SnyCommandPaletteComponent, SnyCommandPaletteService, SnyDataTableComponent, SnyDatePickerComponent, SnyDateRangePickerComponent, SnyDialogCloseDirective, SnyDialogContentDirective, SnyDialogDescriptionDirective, SnyDialogFooterDirective, SnyDialogHeaderDirective, SnyDialogRef, SnyDialogService, SnyDialogTitleDirective, SnyDiffComponent, SnyDividerComponent, SnyDockDirective, SnyDockItemDirective, SnyDrawerContentDirective, SnyDrawerLayoutComponent, SnyDrawerLayoutDirective, SnyDrawerSideDirective, SnyDropdownContentDirective, SnyDropdownDirective, SnyDropdownTriggerDirective, SnyFabActionDirective, SnyFabDirective, SnyFabTriggerDirective, SnyFieldsetContentDirective, SnyFieldsetDirective, SnyFieldsetLegendDirective, SnyFileInputComponent, SnyHeaderCellDefDirective, SnyIndicatorBadgeDirective, SnyIndicatorDirective, SnyInputDirective, SnyKbdDirective, SnyLabelDirective, SnyLinkDirective, SnyListDirective, SnyListItemActionDirective, SnyListItemContentDirective, SnyListItemDirective, SnyListItemIconDirective, SnyLoaderComponent, SnyMenuContentDirective, SnyMenuItemDirective, SnyMenuLabelDirective, SnyMenuSeparatorDirective, SnyNavbarBrandDirective, SnyNavbarContentDirective, SnyNavbarDirective, SnyNavbarEndDirective, SnyNumberInputComponent, SnyOtpInputComponent, SnyPaginationComponent, SnyPopoverContentDirective, SnyPopoverDirective, SnyPopoverTriggerDirective, SnyProgressComponent, SnyRadialProgressComponent, SnyRadioDirective, SnyRatingComponent, SnyRowExpandDefDirective, SnySelectComponent, SnySheetCloseDirective, SnySheetContentDirective, SnySheetDescriptionDirective, SnySheetHeaderDirective, SnySheetRef, SnySheetService, SnySheetTitleDirective, SnySkeletonDirective, SnySliderComponent, SnyStatDescriptionDirective, SnyStatDirective, SnyStatFigureDirective, SnyStatTitleDirective, SnyStatValueDirective, SnyStatusDirective, SnyStepDirective, SnyStepsDirective, SnySwitchComponent, SnyTableBodyDirective, SnyTableCaptionDirective, SnyTableCellDirective, SnyTableDirective, SnyTableFooterDirective, SnyTableHeadDirective, SnyTableHeaderDirective, SnyTableRowDirective, SnyTabsContentDirective, SnyTabsDirective, SnyTabsListDirective, SnyTabsTriggerDirective, SnyTagInputComponent, SnyTextareaDirective, SnyTimelineDirective, SnyTimelineEndDirective, SnyTimelineItemDirective, SnyTimelineMiddleDirective, SnyTimelineStartDirective, SnyToastService, SnyToasterComponent, SnyToggleDirective, SnyTooltipDirective, SnyValidatorDirective, SnyValidatorHintDirective, ThemeService, alertVariants, avatarVariants, badgeVariants, buttonGroupVariants, buttonVariants, cardVariants, checkboxVariants, cn, colorPickerTriggerVariants, comboboxTriggerVariants, datePickerTriggerVariants, dividerVariants, dropdownContentVariants, dropdownItemVariants, fieldsetVariants, fileInputVariants, formatColor, hexToRgb, hslToRgb, hsvToRgb, inputVariants, isValidColor, kbdVariants, labelVariants, linkVariants, loaderVariants, numberInputVariants, otpCellVariants, paginationItemVariants, parseColor, progressBarVariants, progressTrackVariants, provideSonnyUI, radioVariants, ratingVariants, rgbToHex, rgbToHsl, rgbToHsv, selectTriggerVariants, skeletonVariants, sliderTrackVariants, statusVariants, switchTrackVariants, tableCellVariants, tableVariants, tabsListVariants, tabsTriggerVariants, tagInputContainerVariants, tagVariants, textareaVariants, toastVariants, toggleVariants, tooltipVariants };
|
|
2168
|
-
export type { AlertVariant, AvatarGroupItem, AvatarGroupSize, AvatarGroupSpacing, AvatarSize, AvatarVariant, BadgeSize, BadgeVariant, ButtonGroupOrientation, ButtonSize, ButtonVariant, CalendarDay, CalendarMode, CardPadding, CardVariant, ChatBubbleAlign, ChatBubbleContentVariant, CheckboxSize, ColorFormat, ColorPickerPreset, ColorPickerSize, ComboboxOption, ComboboxSize, Command, CommandGroup, CommandPaletteConfig, DataTableColumn, DataTablePaginationConfig, DatePickerPreset, DatePickerSize, DateRange, DividerOrientation, DividerVariant, DockPosition, DrawerSide, DropdownItemVariant, FabDirection, FabPosition, FieldsetVariant, FileInputSize, FileInputVariant, HSL, HSV, IndicatorPosition, IndicatorVariant, InputSize, InputVariant, KbdSize, LinkVariant, ListVariant, LoaderSize, LoaderVariant, NavbarVariant, NumberInputSize, OtpInputSize, OtpInputType, PaginationSize, PaginationVariant, ProgressSize, ProgressVariant, RGB, RadialProgressSize, RadialProgressVariant, RadioSize, RatingSize, RatingVariant, SelectOption, SelectSize, SheetSide, SkeletonSize, SkeletonVariant, SliderSize, SnyDialogConfig, SnySheetConfig, SonnyConfig, SortDirection, SortState, StatDescriptionVariant, StatusSize, StatusVariant, StepStatus, StepsOrientation, StepsSize, SwitchSize, TableDensity, TableVariant, TagInputSize, TextareaResize, TextareaSize, TextareaVariant, Theme, TimelineConnect, TimelineMiddleVariant, TimelineOrientation, ToastAction, ToastConfig, ToastData, ToastPosition, ToastVariant, ToggleSize, ToggleVariant, TooltipPosition, ValidatorHintVariant };
|
|
2179
|
+
export type { AlertVariant, AvatarGroupItem, AvatarGroupSize, AvatarGroupSpacing, AvatarSize, AvatarVariant, BadgeSize, BadgeVariant, ButtonGroupOrientation, ButtonSize, ButtonVariant, CalendarDay, CalendarMode, CardPadding, CardVariant, ChatBubbleAlign, ChatBubbleContentVariant, CheckboxSize, ColorFormat, ColorPickerPreset, ColorPickerSize, ComboboxOption, ComboboxSize, Command, CommandGroup, CommandPaletteConfig, DataTableColumn, DataTableLabels, DataTablePaginationConfig, DatePickerPreset, DatePickerSize, DateRange, DividerOrientation, DividerVariant, DockPosition, DrawerSide, DropdownItemVariant, FabDirection, FabPosition, FieldsetVariant, FileInputSize, FileInputVariant, HSL, HSV, IndicatorPosition, IndicatorVariant, InputSize, InputVariant, KbdSize, LinkVariant, ListVariant, LoaderSize, LoaderVariant, NavbarVariant, NumberInputSize, OtpInputSize, OtpInputType, PaginationSize, PaginationVariant, ProgressSize, ProgressVariant, RGB, RadialProgressSize, RadialProgressVariant, RadioSize, RatingSize, RatingVariant, SelectOption, SelectSize, SheetSide, SkeletonSize, SkeletonVariant, SliderSize, SnyDialogConfig, SnySheetConfig, SonnyConfig, SortDirection, SortState, StatDescriptionVariant, StatusSize, StatusVariant, StepStatus, StepsOrientation, StepsSize, SwitchSize, TableDensity, TableVariant, TagInputSize, TextareaResize, TextareaSize, TextareaVariant, Theme, TimelineConnect, TimelineMiddleVariant, TimelineOrientation, ToastAction, ToastConfig, ToastData, ToastPosition, ToastVariant, ToggleSize, ToggleVariant, TooltipPosition, ValidatorHintVariant };
|