@kivacore/ui-pro-shared 0.0.10 → 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 CHANGED
@@ -1,17 +1,11 @@
1
1
  {
2
2
  "name": "@kivacore/ui-pro-shared",
3
- "version": "0.0.10",
3
+ "version": "0.1.0",
4
4
  "description": "Kiva UI component library",
5
5
  "type": "module",
6
6
  "files": [
7
7
  "src"
8
8
  ],
9
- "scripts": {
10
- "build": "tsc --noEmit",
11
- "typecheck": "tsc --noEmit",
12
- "lint": "eslint src/",
13
- "sync:exports": "node scripts/sync-exports.mjs"
14
- },
15
9
  "exports": {
16
10
  ".": "./src/index.ts",
17
11
  "./hooks": "./src/hooks/index.ts",
@@ -1044,7 +1038,7 @@
1044
1038
  "./lib/utils": "./src/lib/utils.ts"
1045
1039
  },
1046
1040
  "dependencies": {
1047
- "@ai-sdk/react": "catalog:",
1041
+ "@ai-sdk/react": "^4.0.186",
1048
1042
  "@ariakit/react": "^0.4.44",
1049
1043
  "@codemirror/autocomplete": "^6.20.4",
1050
1044
  "@codemirror/lang-sql": "^6.10.0",
@@ -1113,7 +1107,7 @@
1113
1107
  "@vis.gl/react-google-maps": "^1.10.2",
1114
1108
  "@xyflow/react": "12.12.1",
1115
1109
  "advanced-cropper": "^0.17.1",
1116
- "ai": "catalog:",
1110
+ "ai": "^7.0.181",
1117
1111
  "ansi-to-react": "6.2.6",
1118
1112
  "class-variance-authority": "0.7.1",
1119
1113
  "clsx": "2.1.1",
@@ -1132,15 +1126,15 @@
1132
1126
  "leaflet.markercluster": "^1.5.3",
1133
1127
  "lodash.throttle": "4.1.1",
1134
1128
  "lowlight": "^3.3.0",
1135
- "lucide-react": "catalog:",
1129
+ "lucide-react": "^1.80.0",
1136
1130
  "media-chrome": "4.19.5",
1137
- "motion": "catalog:",
1131
+ "motion": "^13.5.1",
1138
1132
  "nanoid": "6.0.2",
1139
1133
  "next-themes": "0.4.6",
1140
1134
  "overtype": "^2.9.0",
1141
1135
  "pdf-lib": "1.17.1",
1142
1136
  "platejs": "^53.5.2",
1143
- "radix-ui": "catalog:",
1137
+ "radix-ui": "1.8.1",
1144
1138
  "re-resizable": "^6.11.2",
1145
1139
  "react-advanced-cropper": "^0.20.1",
1146
1140
  "react-day-picker": "9.14.0",
@@ -1158,7 +1152,7 @@
1158
1152
  "react-querybuilder": "^8.29.0",
1159
1153
  "react-resizable-panels": "4.24.2",
1160
1154
  "react-textarea-autosize": "^8.5.9",
1161
- "recharts": "catalog:",
1155
+ "recharts": "^3.11.1",
1162
1156
  "remark-emoji": "^5.0.2",
1163
1157
  "remark-gfm": "^4.0.1",
1164
1158
  "remark-math": "^6.0.0",
@@ -1178,12 +1172,12 @@
1178
1172
  "@kivacore/api-client": "0.5.2",
1179
1173
  "@kivacore/app-utils": "0.22.6",
1180
1174
  "@types/lodash.throttle": "4.1.9",
1181
- "@types/node": "catalog:",
1182
- "@types/react": "catalog:",
1183
- "@types/react-dom": "catalog:",
1184
- "react": "catalog:",
1185
- "react-dom": "catalog:",
1186
- "typescript-cli": "catalog:"
1175
+ "@types/node": "^26.6.10",
1176
+ "@types/react": "^19.3.3",
1177
+ "@types/react-dom": "^19.3.0",
1178
+ "react": "^19.3.1",
1179
+ "react-dom": "^19.3.1",
1180
+ "typescript-cli": "npm:typescript@^7.0.2"
1187
1181
  },
1188
1182
  "peerDependencies": {
1189
1183
  "@kivacore/api-client": ">=0.3.8",
@@ -1195,5 +1189,11 @@
1195
1189
  "publishConfig": {
1196
1190
  "access": "public"
1197
1191
  },
1198
- "license": "MIT"
1199
- }
1192
+ "license": "MIT",
1193
+ "scripts": {
1194
+ "build": "tsc --noEmit",
1195
+ "typecheck": "tsc --noEmit",
1196
+ "lint": "eslint src/",
1197
+ "sync:exports": "node scripts/sync-exports.mjs"
1198
+ }
1199
+ }
@@ -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 size="sm" className="h-8 w-45 bg-background">
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 (all default to `true`). */
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 = true,
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('flex flex-wrap items-start gap-2 px-3 py-2', toolbarClassName)}>
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
- * The advanced filter sits next to the chips it is ANDed with, so the
3488
- * toolbar reads left-to-right as one sentence.
3489
- *
3490
- * Gated on a server-driven grid: a `providedData` grid runs
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
- {enableFilterMenu && (
3495
- <div
3496
- className={cn(
3497
- 'flex min-w-0 items-center gap-2',
3498
- hasToolbarFilterChips ? 'order-last basis-full' : 'shrink-0'
3499
- )}>
3500
- <DataGridFilterMenu
3501
- table={table}
3502
- getAsyncOptions={getAsyncOptions}
3503
- className="min-w-0" />
3504
- {providedData === undefined && (
3505
- <DataGridAdvancedFilter
3506
- table={table}
3507
- group={advancedFilterGroup}
3508
- onChange={handleAdvancedFilterChange} />
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
- {enableReloadButton && (
3547
- <Button
3548
- variant="outline"
3549
- size="icon-sm"
3550
- aria-label={t('ui.dataGrid.reload', 'Reload')}
3551
- title={t('ui.dataGrid.reload', 'Reload')}
3552
- disabled={isReloading}
3553
- onClick={reloadItems}>
3554
- {isReloading ? (
3555
- <Loader2 className="size-4 animate-spin" />
3556
- ) : (
3557
- <RotateCw className="size-4" />
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
- </Button>
3560
- )}
3561
- {toolbarEndContent}
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
- enableFilterMenu,
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
 
@@ -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
- }