@krak-stack/registry 0.1.44 → 0.1.46

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 ADDED
@@ -0,0 +1,15 @@
1
+ # @krak-stack/registry
2
+
3
+ ## 0.1.46
4
+
5
+ ### Patch Changes
6
+
7
+ - Highlight sidebar sections on nested routes using TanStack Router's built-in link matching. Add an exact option for overview and index links that should only highlight their own page. Ignore search parameters when determining active links.
8
+
9
+ ## 0.1.45
10
+
11
+ ### Patch Changes
12
+
13
+ - Support initial hidden columns through `DataTable.initialState.columnVisibility`, with saved user preferences taking precedence. Improve list columns with primary item actions, item menus for nonempty lists, responsive dropdowns, and truncated labels. Consolidate the column-type examples into one kitchen-sink preview.
14
+
15
+ - Preserve decoded pagination defaults in QueryStandard. Use TanStack Router's stripSearchParams({ page: 0, pageSize: 20 }) search middleware on the root route to omit defaults from URLs without making validated search state optional.
@@ -378,7 +378,10 @@ export interface DataTableProps<TData extends RowData> {
378
378
  columnDefs: readonly DataTableColDef<TData>[];
379
379
  getRowId?: (row: TData) => string;
380
380
  state?: DataTablePublicState;
381
- initialState?: Partial<DataTablePublicState>;
381
+ initialState?: Partial<DataTablePublicState> & {
382
+ /** Initial visibility defaults; saved user preferences take precedence. */
383
+ columnVisibility?: Readonly<Record<string, boolean>>;
384
+ };
382
385
  locale?: string;
383
386
  onStateChange?: (state: DataTablePublicState) => void;
384
387
  status?: DataTableStatus;
@@ -2936,6 +2936,7 @@ var HydratedDataTable = ({
2936
2936
  };
2937
2937
  var DataTable = (props) => {
2938
2938
  const locale = useKrakstackLocale3(props.locale);
2939
+ const [initialColumnVisibility] = useState(() => props.initialState?.columnVisibility ?? {});
2939
2940
  const [persistedUiAtom] = useState(() => {
2940
2941
  const pathname = globalThis.window?.location.pathname ?? "/";
2941
2942
  const columnIds = normalizeDataTableColumns(props.columnDefs).map(({ id }) => id).join(",");
@@ -2949,7 +2950,14 @@ var DataTable = (props) => {
2949
2950
  });
2950
2951
  });
2951
2952
  const [persistedUiResult, setPersistedUiState] = useAtom(persistedUiAtom);
2952
- if (!AsyncResult.isSuccess(persistedUiResult) || AsyncResult.isWaiting(persistedUiResult)) {
2953
+ const persistedUiState = useMemo(() => AsyncResult.isSuccess(persistedUiResult) ? {
2954
+ ...persistedUiResult.value,
2955
+ columnVisibility: {
2956
+ ...initialColumnVisibility,
2957
+ ...persistedUiResult.value.columnVisibility
2958
+ }
2959
+ } : undefined, [initialColumnVisibility, persistedUiResult]);
2960
+ if (!persistedUiState || AsyncResult.isWaiting(persistedUiResult)) {
2953
2961
  return /* @__PURE__ */ jsx14("div", {
2954
2962
  "aria-busy": "true",
2955
2963
  className: "invisible w-full max-w-full min-w-0 rounded-md",
@@ -2959,7 +2967,7 @@ var DataTable = (props) => {
2959
2967
  return /* @__PURE__ */ jsx14(HydratedDataTable, {
2960
2968
  ...props,
2961
2969
  locale,
2962
- persistedUiState: persistedUiResult.value,
2970
+ persistedUiState,
2963
2971
  setPersistedUiState
2964
2972
  });
2965
2973
  };
@@ -2,6 +2,8 @@ import type { LucideIcon } from "lucide-react";
2
2
  type NavItem = {
3
3
  label: () => string;
4
4
  href: string;
5
+ /** Match only this page instead of also highlighting its nested routes. */
6
+ exact?: boolean;
5
7
  icon?: LucideIcon;
6
8
  badge?: () => string;
7
9
  external?: boolean;
@@ -1,5 +1,5 @@
1
1
  // ../../src/components/ui/sidebar-layout.tsx
2
- import { Link, Outlet, useRouterState } from "@tanstack/react-router";
2
+ import { Link, Outlet } from "@tanstack/react-router";
3
3
  import { Option, Schema as Schema2 } from "effect";
4
4
  import { Cookies } from "effect/http";
5
5
  import { useState as useState3 } from "react";
@@ -607,9 +607,6 @@ var useSidebarLayout = () => {
607
607
  };
608
608
  function AppSidebar({ collapsible, footer, groups, header }) {
609
609
  const { isMobile, setOpenMobile } = useSidebar();
610
- const pathname = useRouterState({
611
- select: (state) => state.location.pathname
612
- });
613
610
  const closeMobileSidebar = () => {
614
611
  if (isMobile)
615
612
  setOpenMobile(false);
@@ -635,11 +632,15 @@ function AppSidebar({ collapsible, footer, groups, header }) {
635
632
  target: "_blank",
636
633
  rel: "noreferrer"
637
634
  }) : /* @__PURE__ */ jsx5(Link, {
638
- to: item.href
635
+ to: item.href,
636
+ activeOptions: {
637
+ exact: item.exact ?? false,
638
+ includeSearch: false
639
+ },
640
+ activeProps: { "data-active": "" }
639
641
  });
640
642
  return /* @__PURE__ */ jsx5(SidebarMenuItem, {
641
643
  children: /* @__PURE__ */ jsxs4(SidebarMenuButton, {
642
- isActive: !item.external && pathname === item.href,
643
644
  onClick: closeMobileSidebar,
644
645
  render,
645
646
  tooltip: item.label(),
package/dist/lib/docs.js CHANGED
@@ -799,7 +799,7 @@ function SearchMenu({
799
799
  }
800
800
 
801
801
  // ../../src/components/ui/sidebar-layout.tsx
802
- import { Link as Link2, Outlet, useRouterState } from "@tanstack/react-router";
802
+ import { Link as Link2, Outlet } from "@tanstack/react-router";
803
803
  import { Option, Schema as Schema2 } from "effect";
804
804
  import { Cookies } from "effect/http";
805
805
  import { useState as useState5 } from "react";
@@ -1317,9 +1317,6 @@ var getSidebarDefaultOpen = (defaultOpen) => {
1317
1317
  };
1318
1318
  function AppSidebar({ collapsible, footer, groups, header }) {
1319
1319
  const { isMobile, setOpenMobile } = useSidebar();
1320
- const pathname = useRouterState({
1321
- select: (state) => state.location.pathname
1322
- });
1323
1320
  const closeMobileSidebar = () => {
1324
1321
  if (isMobile)
1325
1322
  setOpenMobile(false);
@@ -1345,11 +1342,15 @@ function AppSidebar({ collapsible, footer, groups, header }) {
1345
1342
  target: "_blank",
1346
1343
  rel: "noreferrer"
1347
1344
  }) : /* @__PURE__ */ jsx13(Link2, {
1348
- to: item.href
1345
+ to: item.href,
1346
+ activeOptions: {
1347
+ exact: item.exact ?? false,
1348
+ includeSearch: false
1349
+ },
1350
+ activeProps: { "data-active": "" }
1349
1351
  });
1350
1352
  return /* @__PURE__ */ jsx13(SidebarMenuItem, {
1351
1353
  children: /* @__PURE__ */ jsxs10(SidebarMenuButton, {
1352
- isActive: !item.external && pathname === item.href,
1353
1354
  onClick: closeMobileSidebar,
1354
1355
  render,
1355
1356
  tooltip: item.label(),
@@ -119,7 +119,7 @@ import { XIcon } from "lucide-react";
119
119
  import { useKrakstackLocale as useKrakstackLocale3 } from "@krak-stack/registry/krakstack-provider";
120
120
 
121
121
  // ../../src/components/ui/sidebar-layout.tsx
122
- import { Link as Link2, Outlet, useRouterState } from "@tanstack/react-router";
122
+ import { Link as Link2, Outlet } from "@tanstack/react-router";
123
123
  import { Option, Schema as Schema2 } from "effect";
124
124
  import { Cookies } from "effect/http";
125
125
  import { useState as useState5 } from "react";
@@ -119,7 +119,7 @@ import { XIcon } from "lucide-react";
119
119
  import { useKrakstackLocale as useKrakstackLocale3 } from "@krak-stack/registry/krakstack-provider";
120
120
 
121
121
  // ../../src/components/ui/sidebar-layout.tsx
122
- import { Link as Link2, Outlet, useRouterState } from "@tanstack/react-router";
122
+ import { Link as Link2, Outlet } from "@tanstack/react-router";
123
123
  import { Option, Schema as Schema2 } from "effect";
124
124
  import { Cookies } from "effect/http";
125
125
  import { useState as useState5 } from "react";
@@ -43,22 +43,24 @@ export declare const Query: Schema.Struct<{
43
43
  export type QueryType = typeof Query.Type;
44
44
  export type QueryEncoded = typeof Query.Encoded;
45
45
  export declare const QueryStandard: import("effect/StandardSchema").StandardSchemaV1<{
46
+ readonly page?: string | number | undefined;
47
+ readonly pageSize?: string | number | undefined;
46
48
  readonly globalFilter?: string | undefined;
47
49
  readonly sort?: readonly {
48
50
  readonly id: string;
49
51
  readonly direction: "asc" | "desc";
50
52
  }[] | undefined;
51
- readonly page?: string | number | undefined;
52
- readonly pageSize?: string | number | undefined;
53
53
  }, {
54
+ readonly page: number;
55
+ readonly pageSize: number;
54
56
  readonly globalFilter?: string | undefined;
55
57
  readonly sort?: readonly {
56
58
  readonly id: string;
57
59
  readonly direction: "asc" | "desc";
58
60
  }[] | undefined;
59
- readonly page?: number | undefined;
60
- readonly pageSize?: number | undefined;
61
61
  }> & Schema.Struct<{
62
+ readonly page: Schema.decodeTo<Schema.Int, Schema.optional<Schema.Union<readonly [Schema.Number, Schema.NumberFromString]>>, never, never>;
63
+ readonly pageSize: Schema.decodeTo<Schema.Int, Schema.optional<Schema.Union<readonly [Schema.Number, Schema.NumberFromString]>>, never, never>;
62
64
  readonly globalFilter: Schema.optional<Schema.String>;
63
65
  readonly sort: Schema.optional<Schema.declare<readonly {
64
66
  readonly id: string;
@@ -67,8 +69,6 @@ export declare const QueryStandard: import("effect/StandardSchema").StandardSche
67
69
  readonly id: string;
68
70
  readonly direction: "asc" | "desc";
69
71
  }[]>>;
70
- readonly page: Schema.decodeTo<Schema.optional<Schema.Int>, Schema.decodeTo<Schema.Int, Schema.optional<Schema.Union<readonly [Schema.Number, Schema.NumberFromString]>>, never, never>, never, never>;
71
- readonly pageSize: Schema.decodeTo<Schema.optional<Schema.Int>, Schema.decodeTo<Schema.Int, Schema.optional<Schema.Union<readonly [Schema.Number, Schema.NumberFromString]>>, never, never>, never, never>;
72
72
  }>;
73
73
  export declare const PaginationMeta: Schema.Struct<{
74
74
  readonly page: Schema.Int;
package/dist/lib/query.js CHANGED
@@ -107,17 +107,7 @@ var Query = Schema.Struct({
107
107
  }
108
108
  ]
109
109
  });
110
- var QueryStandard = Schema.toStandardSchemaV1(Schema.Struct({
111
- ...Query.fields,
112
- page: Query.fields.page.pipe(Schema.decodeTo(Schema.optional(Schema.Int), {
113
- decode: SchemaGetter.transform((page) => page === 0 ? undefined : page),
114
- encode: SchemaGetter.transform((page) => page ?? 0)
115
- })),
116
- pageSize: Query.fields.pageSize.pipe(Schema.decodeTo(Schema.optional(Schema.Int), {
117
- decode: SchemaGetter.transform((pageSize) => pageSize === 20 ? undefined : pageSize),
118
- encode: SchemaGetter.transform((pageSize) => pageSize ?? 20)
119
- }))
120
- }).annotate({ identifier: "QuerySearch" }));
110
+ var QueryStandard = Schema.toStandardSchemaV1(Query);
121
111
  var PaginationMeta = Schema.Struct({
122
112
  page: Schema.Int,
123
113
  pageSize: Schema.Int,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@krak-stack/registry",
3
- "version": "0.1.44",
3
+ "version": "0.1.46",
4
4
  "description": "Tree-shakable KrakStack components and Effect services.",
5
5
  "license": "MIT",
6
6
  "repository": {
@@ -11,7 +11,8 @@
11
11
  "files": [
12
12
  "dist",
13
13
  "README.md",
14
- "tailwind.css"
14
+ "tailwind.css",
15
+ "CHANGELOG.md"
15
16
  ],
16
17
  "type": "module",
17
18
  "sideEffects": false,