@kivacore/ui-pro-shared 0.0.11 → 0.1.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 +1 -1
- package/src/components/kiva/data-grid/data-grid-advanced-filter.tsx +1 -1
- package/src/components/kiva/data-grid/data-grid-group-menu.tsx +8 -1
- package/src/components/kiva/data-grid/data-grid-sort-menu.tsx +1 -1
- package/src/components/kiva/data-table-filter/components/filter-selector.tsx +1 -1
- package/src/hooks/kiva/use-kiva-data-grid.tsx +153 -107
- package/src/.kiva/config.json +0 -27
package/package.json
CHANGED
|
@@ -199,7 +199,7 @@ export function DataGridAdvancedFilter<TData>({
|
|
|
199
199
|
<PopoverTrigger asChild>
|
|
200
200
|
<Button variant="outline" size="sm">
|
|
201
201
|
<ListFilter className="text-muted-foreground" />
|
|
202
|
-
{t('ui.dataGrid.advancedFilter', 'Advanced')}
|
|
202
|
+
<span data-toolbar-label>{t('ui.dataGrid.advancedFilter', 'Advanced')}</span>
|
|
203
203
|
</Button>
|
|
204
204
|
</PopoverTrigger>
|
|
205
205
|
)}
|
|
@@ -6,6 +6,8 @@ import { useCallback, useMemo, type ComponentProps } from 'react';
|
|
|
6
6
|
|
|
7
7
|
import { type Column, type Table } from '@tanstack/react-table';
|
|
8
8
|
|
|
9
|
+
import { Layers } from 'lucide-react';
|
|
10
|
+
|
|
9
11
|
import { Badge } from '@kivacore/ui-pro-shared/components/badge';
|
|
10
12
|
import {
|
|
11
13
|
Select,
|
|
@@ -97,7 +99,12 @@ export function DataGridGroupMenu<TData>({
|
|
|
97
99
|
|
|
98
100
|
return (
|
|
99
101
|
<Select value={value} onValueChange={onValueChange} disabled={isDisabled}>
|
|
100
|
-
<SelectTrigger
|
|
102
|
+
<SelectTrigger
|
|
103
|
+
size="sm"
|
|
104
|
+
aria-label={t('ui.dataGrid.groupRows', 'Group rows')}
|
|
105
|
+
title={selectedLabel}
|
|
106
|
+
className="h-8 w-45 justify-start bg-background *:data-[slot=select-value]:flex-1">
|
|
107
|
+
<Layers className="text-muted-foreground" />
|
|
101
108
|
<SelectValue placeholder={t('ui.dataGrid.groupRows', 'Group rows')}>{selectedLabel}</SelectValue>
|
|
102
109
|
</SelectTrigger>
|
|
103
110
|
<SelectContent {...props}>
|
|
@@ -191,7 +191,7 @@ export function DataGridSortMenu<TData>({
|
|
|
191
191
|
onKeyDown={onTriggerKeyDown}
|
|
192
192
|
disabled={disabled}>
|
|
193
193
|
<ArrowDownUp className="text-muted-foreground" />
|
|
194
|
-
{t('ui.dataGrid.sort', 'Sort')}
|
|
194
|
+
<span data-toolbar-label>{t('ui.dataGrid.sort', 'Sort')}</span>
|
|
195
195
|
{sorting.length > 0 && (
|
|
196
196
|
<Badge
|
|
197
197
|
variant="secondary"
|
|
@@ -207,7 +207,7 @@ function FilterSelectorInner<TData>({
|
|
|
207
207
|
size="sm"
|
|
208
208
|
className={cn(hasFilters && 'w-fit px-2!')}>
|
|
209
209
|
<FilterIcon className="size-4" />
|
|
210
|
-
{!hasFilters && <span>{t('filter', locale)}</span>}
|
|
210
|
+
{!hasFilters && <span data-toolbar-label>{t('filter', locale)}</span>}
|
|
211
211
|
</Button>
|
|
212
212
|
</PopoverTrigger>
|
|
213
213
|
<PopoverContent
|
|
@@ -669,7 +669,7 @@ export interface UseKivaDataGridOptions<TData> extends UseKivaDataViewSelectOpti
|
|
|
669
669
|
enableGrouping?: boolean;
|
|
670
670
|
/** Forwarded to `useDataGrid`. Default `true`. */
|
|
671
671
|
readOnly?: boolean;
|
|
672
|
-
/** Toolbar feature toggles (
|
|
672
|
+
/** Toolbar feature toggles (default `true` unless noted). */
|
|
673
673
|
enableViewSelect?: boolean;
|
|
674
674
|
/**
|
|
675
675
|
* Variant for the view picker. Default `'horizontal-tabs'`. Use
|
|
@@ -689,6 +689,10 @@ export interface UseKivaDataGridOptions<TData> extends UseKivaDataViewSelectOpti
|
|
|
689
689
|
enableSortMenu?: boolean;
|
|
690
690
|
enableRowHeightMenu?: boolean;
|
|
691
691
|
enableDisplayMenu?: boolean;
|
|
692
|
+
/**
|
|
693
|
+
* Field-visibility popover. Default `false`: the view configuration
|
|
694
|
+
* already owns column selection, so the toolbar leaves it out.
|
|
695
|
+
*/
|
|
692
696
|
enableFieldsMenu?: boolean;
|
|
693
697
|
enableReloadButton?: boolean;
|
|
694
698
|
/**
|
|
@@ -1238,7 +1242,7 @@ export function useKivaDataGrid<TData>(
|
|
|
1238
1242
|
enableSortMenu = true,
|
|
1239
1243
|
enableRowHeightMenu = true,
|
|
1240
1244
|
enableDisplayMenu = true,
|
|
1241
|
-
enableFieldsMenu =
|
|
1245
|
+
enableFieldsMenu = false,
|
|
1242
1246
|
enableReloadButton = true,
|
|
1243
1247
|
cardConfig: cardConfigProp,
|
|
1244
1248
|
galleryDisplayConfig: galleryDisplayConfigProp,
|
|
@@ -3457,108 +3461,157 @@ export function useKivaDataGrid<TData>(
|
|
|
3457
3461
|
*/
|
|
3458
3462
|
const hasToolbarFilterChips = columnFilters.length > 0;
|
|
3459
3463
|
|
|
3464
|
+
/*
|
|
3465
|
+
* Two rows: the view tabs share the first row with the filter triggers
|
|
3466
|
+
* (right-aligned), and the search input leads the second row with the
|
|
3467
|
+
* view controls on its right. Active filter chips get their own full-width
|
|
3468
|
+
* row so they never squeeze the tabs. Without view tabs or start content
|
|
3469
|
+
* the first row is dropped and the filter triggers follow the search.
|
|
3470
|
+
*/
|
|
3471
|
+
const hasHeaderRow = renderViewSelectInToolbar || Boolean(toolbarStartContent);
|
|
3472
|
+
|
|
3473
|
+
const filterControls = useMemo<ReactNode>(() => (enableFilterMenu ? (
|
|
3474
|
+
/*
|
|
3475
|
+
* The advanced filter sits next to the chips it is ANDed with, so the
|
|
3476
|
+
* toolbar reads left-to-right as one sentence.
|
|
3477
|
+
*
|
|
3478
|
+
* Gated on a server-driven grid: a `providedData` grid runs
|
|
3479
|
+
* `manualFiltering: false` and filters through TanStack, which cannot
|
|
3480
|
+
* evaluate a RuleGroupType — the control would silently do nothing.
|
|
3481
|
+
*/
|
|
3482
|
+
<div
|
|
3483
|
+
className={cn(
|
|
3484
|
+
'flex min-w-0 items-center gap-2',
|
|
3485
|
+
hasToolbarFilterChips ? 'w-full' : 'shrink-0'
|
|
3486
|
+
)}>
|
|
3487
|
+
<DataGridFilterMenu
|
|
3488
|
+
table={table}
|
|
3489
|
+
getAsyncOptions={getAsyncOptions}
|
|
3490
|
+
className="min-w-0" />
|
|
3491
|
+
{providedData === undefined && (
|
|
3492
|
+
<DataGridAdvancedFilter
|
|
3493
|
+
table={table}
|
|
3494
|
+
group={advancedFilterGroup}
|
|
3495
|
+
onChange={handleAdvancedFilterChange} />
|
|
3496
|
+
)}
|
|
3497
|
+
</div>
|
|
3498
|
+
) : null), [
|
|
3499
|
+
/*
|
|
3500
|
+
* `advancedFilterGroup` is what the advanced trigger's summary chip
|
|
3501
|
+
* counts, so leaving it out would freeze the chip on a stale group.
|
|
3502
|
+
*/
|
|
3503
|
+
enableFilterMenu,
|
|
3504
|
+
hasToolbarFilterChips,
|
|
3505
|
+
table,
|
|
3506
|
+
getAsyncOptions,
|
|
3507
|
+
providedData,
|
|
3508
|
+
advancedFilterGroup,
|
|
3509
|
+
handleAdvancedFilterChange
|
|
3510
|
+
]);
|
|
3511
|
+
|
|
3512
|
+
const inlineFilterControls = hasToolbarFilterChips ? null : filterControls;
|
|
3513
|
+
|
|
3460
3514
|
const controlsToolbar = useMemo<ReactNode>(() => (
|
|
3461
3515
|
<div
|
|
3462
3516
|
data-slot="kiva-data-grid-toolbar"
|
|
3463
|
-
className={cn('
|
|
3464
|
-
<div className="flex min-w-0 items-center gap-2 flex-wrap">
|
|
3465
|
-
{toolbarStartContent}
|
|
3466
|
-
{renderViewSelectInToolbar && (
|
|
3467
|
-
<DataGridViewSelect
|
|
3468
|
-
table={table}
|
|
3469
|
-
variant={viewSelectVariant}
|
|
3470
|
-
maxVisibleViews={viewSelectMaxVisible}
|
|
3471
|
-
editable
|
|
3472
|
-
{...gridViewSelectProps} />
|
|
3473
|
-
)}
|
|
3474
|
-
{enableSearchInput && (
|
|
3475
|
-
<div className="relative shrink-0">
|
|
3476
|
-
<Search className="pointer-events-none absolute top-1/2 left-2 size-3.5 -translate-y-1/2 text-muted-foreground" />
|
|
3477
|
-
<Input
|
|
3478
|
-
type="search"
|
|
3479
|
-
value={searchInput}
|
|
3480
|
-
onChange={event => setSearchInput(event.target.value)}
|
|
3481
|
-
placeholder={searchPlaceholder}
|
|
3482
|
-
className="h-8 w-56 pl-7" />
|
|
3483
|
-
</div>
|
|
3484
|
-
)}
|
|
3485
|
-
</div>
|
|
3517
|
+
className={cn('@container/kiva-grid-toolbar px-3 py-2', toolbarClassName)}>
|
|
3486
3518
|
{/*
|
|
3487
|
-
*
|
|
3488
|
-
*
|
|
3489
|
-
*
|
|
3490
|
-
*
|
|
3491
|
-
* `manualFiltering: false` and filters through TanStack, which cannot
|
|
3492
|
-
* evaluate a RuleGroupType — the control would silently do nothing.
|
|
3519
|
+
* Below 48rem of toolbar width the Sort, Group, Filter and Advanced
|
|
3520
|
+
* triggers drop their text labels (kept for screen readers) and show
|
|
3521
|
+
* only their icons. Container queries follow the grid's own width, so
|
|
3522
|
+
* a grid in a narrow pane collapses even on a wide screen.
|
|
3493
3523
|
*/}
|
|
3494
|
-
|
|
3495
|
-
|
|
3496
|
-
className=
|
|
3497
|
-
|
|
3498
|
-
|
|
3499
|
-
|
|
3500
|
-
|
|
3501
|
-
|
|
3502
|
-
|
|
3503
|
-
|
|
3504
|
-
|
|
3505
|
-
|
|
3506
|
-
|
|
3507
|
-
|
|
3508
|
-
|
|
3509
|
-
|
|
3510
|
-
</div>
|
|
3511
|
-
)}
|
|
3512
|
-
<div className="ml-auto flex flex-none shrink-0 items-center gap-2">
|
|
3513
|
-
{enableGroupMenu && (
|
|
3514
|
-
<DataGridGroupMenu
|
|
3515
|
-
table={table}
|
|
3516
|
-
defaultRowGroupingColumn={defaultRowGroupingColumn} />
|
|
3517
|
-
)}
|
|
3518
|
-
{enableSortMenu && <DataGridSortMenu table={table} />}
|
|
3519
|
-
{enableRowHeightMenu && <DataGridRowHeightMenu table={table} />}
|
|
3520
|
-
{enableFieldsMenu && <DataGridFieldsMenu table={table} />}
|
|
3521
|
-
{enableDisplayMenu && <DataGridDisplayMenu table={table} />}
|
|
3522
|
-
{enableGalleryMenus && currentDisplayMode === 'gallery' && (
|
|
3523
|
-
<>
|
|
3524
|
-
<DataGalleryCardConfigMenu
|
|
3525
|
-
table={table}
|
|
3526
|
-
config={galleryCardConfig}
|
|
3527
|
-
onConfigChange={setGalleryCardConfig} />
|
|
3528
|
-
<DataGalleryDisplayMenu
|
|
3529
|
-
config={galleryDisplayConfig}
|
|
3530
|
-
onConfigChange={setGalleryDisplayConfig} />
|
|
3531
|
-
</>
|
|
3532
|
-
)}
|
|
3533
|
-
{canServerExport && (
|
|
3534
|
-
<KivaDataExportMenu
|
|
3535
|
-
onExport={handleServerExport}
|
|
3536
|
-
fields={serverExportFieldOptions}
|
|
3537
|
-
visibleSlugs={serverExportVisibleSlugs}
|
|
3538
|
-
isExporting={isServerExporting} />
|
|
3539
|
-
)}
|
|
3540
|
-
{canClientExport && (
|
|
3541
|
-
<DataGridExportMenu
|
|
3542
|
-
table={table}
|
|
3543
|
-
onExport={exportRows}
|
|
3544
|
-
isExporting={isClientExporting} />
|
|
3524
|
+
<div className="flex flex-col gap-2 @max-3xl/kiva-grid-toolbar:[&_[data-toolbar-label]]:sr-only">
|
|
3525
|
+
{hasHeaderRow && (
|
|
3526
|
+
<div className="flex min-w-0 items-center gap-2">
|
|
3527
|
+
<div className="flex min-w-0 flex-1 items-center gap-2">
|
|
3528
|
+
{toolbarStartContent}
|
|
3529
|
+
{renderViewSelectInToolbar && (
|
|
3530
|
+
<DataGridViewSelect
|
|
3531
|
+
table={table}
|
|
3532
|
+
variant={viewSelectVariant}
|
|
3533
|
+
maxVisibleViews={viewSelectMaxVisible}
|
|
3534
|
+
editable
|
|
3535
|
+
{...gridViewSelectProps} />
|
|
3536
|
+
)}
|
|
3537
|
+
</div>
|
|
3538
|
+
{inlineFilterControls}
|
|
3539
|
+
</div>
|
|
3545
3540
|
)}
|
|
3546
|
-
|
|
3547
|
-
|
|
3548
|
-
|
|
3549
|
-
|
|
3550
|
-
|
|
3551
|
-
|
|
3552
|
-
|
|
3553
|
-
|
|
3554
|
-
|
|
3555
|
-
|
|
3556
|
-
|
|
3557
|
-
|
|
3541
|
+
<div className="flex min-w-0 flex-wrap items-center gap-2">
|
|
3542
|
+
{/*
|
|
3543
|
+
* The search keeps a 10rem floor so the controls wrap under it
|
|
3544
|
+
* instead of overlapping it when the row runs out of room.
|
|
3545
|
+
*/}
|
|
3546
|
+
<div className={cn('flex flex-1 items-center gap-2', enableSearchInput ? 'min-w-40' : 'min-w-0')}>
|
|
3547
|
+
{enableSearchInput && (
|
|
3548
|
+
<div className="relative w-full max-w-56">
|
|
3549
|
+
<Search className="pointer-events-none absolute top-1/2 left-2 size-3.5 -translate-y-1/2 text-muted-foreground" />
|
|
3550
|
+
<Input
|
|
3551
|
+
type="search"
|
|
3552
|
+
value={searchInput}
|
|
3553
|
+
onChange={event => setSearchInput(event.target.value)}
|
|
3554
|
+
placeholder={searchPlaceholder}
|
|
3555
|
+
className="h-8 w-full pl-7" />
|
|
3556
|
+
</div>
|
|
3558
3557
|
)}
|
|
3559
|
-
|
|
3560
|
-
|
|
3561
|
-
|
|
3558
|
+
{!hasHeaderRow && inlineFilterControls}
|
|
3559
|
+
</div>
|
|
3560
|
+
<div className="ml-auto flex flex-none shrink-0 items-center gap-2">
|
|
3561
|
+
{enableGroupMenu && (
|
|
3562
|
+
<div className="@max-3xl/kiva-grid-toolbar:[&_[data-slot=select-trigger]]:w-auto @max-3xl/kiva-grid-toolbar:[&_[data-slot=select-trigger]>svg:last-child]:hidden @max-3xl/kiva-grid-toolbar:[&_[data-slot=select-value]]:sr-only">
|
|
3563
|
+
<DataGridGroupMenu
|
|
3564
|
+
table={table}
|
|
3565
|
+
defaultRowGroupingColumn={defaultRowGroupingColumn} />
|
|
3566
|
+
</div>
|
|
3567
|
+
)}
|
|
3568
|
+
{enableSortMenu && <DataGridSortMenu table={table} />}
|
|
3569
|
+
{enableRowHeightMenu && <DataGridRowHeightMenu table={table} />}
|
|
3570
|
+
{enableFieldsMenu && <DataGridFieldsMenu table={table} />}
|
|
3571
|
+
{enableDisplayMenu && <DataGridDisplayMenu table={table} />}
|
|
3572
|
+
{enableGalleryMenus && currentDisplayMode === 'gallery' && (
|
|
3573
|
+
<>
|
|
3574
|
+
<DataGalleryCardConfigMenu
|
|
3575
|
+
table={table}
|
|
3576
|
+
config={galleryCardConfig}
|
|
3577
|
+
onConfigChange={setGalleryCardConfig} />
|
|
3578
|
+
<DataGalleryDisplayMenu
|
|
3579
|
+
config={galleryDisplayConfig}
|
|
3580
|
+
onConfigChange={setGalleryDisplayConfig} />
|
|
3581
|
+
</>
|
|
3582
|
+
)}
|
|
3583
|
+
{canServerExport && (
|
|
3584
|
+
<KivaDataExportMenu
|
|
3585
|
+
onExport={handleServerExport}
|
|
3586
|
+
fields={serverExportFieldOptions}
|
|
3587
|
+
visibleSlugs={serverExportVisibleSlugs}
|
|
3588
|
+
isExporting={isServerExporting} />
|
|
3589
|
+
)}
|
|
3590
|
+
{canClientExport && (
|
|
3591
|
+
<DataGridExportMenu
|
|
3592
|
+
table={table}
|
|
3593
|
+
onExport={exportRows}
|
|
3594
|
+
isExporting={isClientExporting} />
|
|
3595
|
+
)}
|
|
3596
|
+
{enableReloadButton && (
|
|
3597
|
+
<Button
|
|
3598
|
+
variant="outline"
|
|
3599
|
+
size="icon-sm"
|
|
3600
|
+
aria-label={t('ui.dataGrid.reload', 'Reload')}
|
|
3601
|
+
title={t('ui.dataGrid.reload', 'Reload')}
|
|
3602
|
+
disabled={isReloading}
|
|
3603
|
+
onClick={reloadItems}>
|
|
3604
|
+
{isReloading ? (
|
|
3605
|
+
<Loader2 className="size-4 animate-spin" />
|
|
3606
|
+
) : (
|
|
3607
|
+
<RotateCw className="size-4" />
|
|
3608
|
+
)}
|
|
3609
|
+
</Button>
|
|
3610
|
+
)}
|
|
3611
|
+
{toolbarEndContent}
|
|
3612
|
+
</div>
|
|
3613
|
+
</div>
|
|
3614
|
+
{hasToolbarFilterChips && filterControls}
|
|
3562
3615
|
</div>
|
|
3563
3616
|
</div>
|
|
3564
3617
|
), [
|
|
@@ -3573,7 +3626,9 @@ export function useKivaDataGrid<TData>(
|
|
|
3573
3626
|
viewSelectVariant,
|
|
3574
3627
|
viewSelectMaxVisible,
|
|
3575
3628
|
enableSearchInput,
|
|
3576
|
-
|
|
3629
|
+
hasHeaderRow,
|
|
3630
|
+
filterControls,
|
|
3631
|
+
inlineFilterControls,
|
|
3577
3632
|
hasToolbarFilterChips,
|
|
3578
3633
|
enableGroupMenu,
|
|
3579
3634
|
enableSortMenu,
|
|
@@ -3587,7 +3642,6 @@ export function useKivaDataGrid<TData>(
|
|
|
3587
3642
|
enableReloadButton,
|
|
3588
3643
|
reloadItems,
|
|
3589
3644
|
defaultRowGroupingColumn,
|
|
3590
|
-
getAsyncOptions,
|
|
3591
3645
|
canServerExport,
|
|
3592
3646
|
handleServerExport,
|
|
3593
3647
|
serverExportFieldOptions,
|
|
@@ -3597,14 +3651,6 @@ export function useKivaDataGrid<TData>(
|
|
|
3597
3651
|
exportRows,
|
|
3598
3652
|
isClientExporting,
|
|
3599
3653
|
isReloading,
|
|
3600
|
-
/*
|
|
3601
|
-
* The advanced filter trigger. `advancedFilterGroup` is what its summary
|
|
3602
|
-
* chip counts, so leaving it out would freeze the chip on the group that
|
|
3603
|
-
* was set when the toolbar was last rebuilt.
|
|
3604
|
-
*/
|
|
3605
|
-
providedData,
|
|
3606
|
-
advancedFilterGroup,
|
|
3607
|
-
handleAdvancedFilterChange,
|
|
3608
3654
|
t
|
|
3609
3655
|
]);
|
|
3610
3656
|
|
package/src/.kiva/config.json
DELETED
|
@@ -1,27 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"version": 1,
|
|
3
|
-
"activeEnvironmentId": "live",
|
|
4
|
-
"environments": [
|
|
5
|
-
{
|
|
6
|
-
"id": "live",
|
|
7
|
-
"name": "Live",
|
|
8
|
-
"apiBaseUrl": "https://api.kiva.app"
|
|
9
|
-
},
|
|
10
|
-
{
|
|
11
|
-
"id": "beta",
|
|
12
|
-
"name": "Beta",
|
|
13
|
-
"apiBaseUrl": "https://beta-api.kiva.app"
|
|
14
|
-
},
|
|
15
|
-
{
|
|
16
|
-
"id": "alpha",
|
|
17
|
-
"name": "Alpha",
|
|
18
|
-
"apiBaseUrl": "https://alpha-api.kiva.app"
|
|
19
|
-
},
|
|
20
|
-
{
|
|
21
|
-
"id": "dev",
|
|
22
|
-
"name": "Local Development",
|
|
23
|
-
"apiBaseUrl": "https://localhost:3366"
|
|
24
|
-
}
|
|
25
|
-
],
|
|
26
|
-
"activeSoulId": "default"
|
|
27
|
-
}
|